summaryrefslogtreecommitdiff
path: root/internal/task/validator.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/task/validator.go')
-rw-r--r--internal/task/validator.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/task/validator.go b/internal/task/validator.go
index 09f4b34..03d3921 100644
--- a/internal/task/validator.go
+++ b/internal/task/validator.go
@@ -2,9 +2,16 @@ package task
import (
"fmt"
+ "regexp"
"strings"
)
+// modelPattern restricts Agent.Model to characters safe to concatenate into
+// the `sh -c` command executor.ContainerRunner.buildInnerCmd builds for the
+// claude CLI's --model flag. Real model names (e.g. "sonnet", "opus",
+// "claude-sonnet-4-6") only ever use this character set.
+var modelPattern = regexp.MustCompile(`^[A-Za-z0-9._-]+$`)
+
// ValidationError collects multiple validation failures.
type ValidationError struct {
Errors []string
@@ -55,6 +62,10 @@ func Validate(t *Task) error {
}
}
+ if t.Agent.Model != "" && !modelPattern.MatchString(t.Agent.Model) {
+ ve.Add(fmt.Sprintf("invalid model %q; must match %s", t.Agent.Model, modelPattern.String()))
+ }
+
if t.Agent.PermissionMode != "" {
validModes := map[string]bool{
"default": true, "acceptEdits": true, "bypassPermissions": true,