Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

feat(prompts): validate template syntax on the REST update endpoint

Sergey Kozyrenko72da224033ed
diff --git a/backend/pkg/server/services/prompts.go b/backend/pkg/server/services/prompts.go
index c3d0db39..174a2493 100644
--- a/backend/pkg/server/services/prompts.go
+++ b/backend/pkg/server/services/prompts.go
@@ -10,6 +10,7 @@ import (
"pentagi/pkg/server/rdb"
"pentagi/pkg/server/response"
"pentagi/pkg/templates"
+ "pentagi/pkg/templates/validator"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
@@ -208,6 +209,10 @@ func (s *PromptService) PatchPrompt(c *gin.Context) {
logger.FromContext(c).WithError(err).Errorf("error validating prompt type '%s'", promptType)
response.Error(c, response.ErrPromptsInvalidRequest, err)
return
+ } else if err = validator.ValidatePrompt(templates.PromptType(promptType), prompt.Prompt); err != nil {
+ logger.FromContext(c).WithError(err).Errorf("error validating prompt template '%s'", promptType)
+ response.Error(c, response.ErrPromptsInvalidRequest, err)
+ return
}
privs := c.GetStringSlice("prm")