-
Notifications
You must be signed in to change notification settings - Fork 355
Add configurable agentic engine driver script support #27453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b8f81ce
9dd9813
0626dca
b23aa7f
a4ac9bc
2c70445
09d19e5
68a27e8
1c59766
5dbdba1
bd460b0
e26ac51
684d9aa
e12d688
c0de1a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,8 @@ import ( | |
| "encoding/json" | ||
| "fmt" | ||
| "os" | ||
| "path/filepath" | ||
| "regexp" | ||
| "strings" | ||
|
|
||
| "github.com/github/gh-aw/pkg/console" | ||
|
|
@@ -45,6 +47,7 @@ import ( | |
| ) | ||
|
|
||
| var engineValidationLog = newValidationLogger("engine") | ||
| var safeDriverScriptPattern = regexp.MustCompile(`^[A-Za-z0-9_][A-Za-z0-9._-]*$`) | ||
|
|
||
| // validateEngineVersion warns (non-strict) or errors (strict) when the workflow | ||
| // explicitly pins the engine CLI to "latest". Unpinned "latest" versions change | ||
|
|
@@ -75,6 +78,35 @@ func (c *Compiler) validateEngineVersion(workflowData *WorkflowData) error { | |
| return nil | ||
| } | ||
|
|
||
| // validateEngineDriverScript validates optional engine.driver configuration. | ||
| // engine.driver must point to a Node.js script. | ||
| func (c *Compiler) validateEngineDriverScript(workflowData *WorkflowData) error { | ||
| if workflowData == nil || workflowData.EngineConfig == nil || workflowData.EngineConfig.DriverScript == "" { | ||
| return nil | ||
| } | ||
|
|
||
| driverScript := workflowData.EngineConfig.DriverScript | ||
| if strings.TrimSpace(driverScript) != driverScript { | ||
| return fmt.Errorf("engine.driver must be a safe basename without leading/trailing whitespace (found: %s).\n\nSee: %s", workflowData.EngineConfig.DriverScript, constants.DocsEnginesURL) | ||
| } | ||
|
|
||
| if filepath.IsAbs(driverScript) || | ||
| strings.Contains(driverScript, "/") || | ||
| strings.Contains(driverScript, `\`) || | ||
| strings.Contains(driverScript, "..") || | ||
| !safeDriverScriptPattern.MatchString(driverScript) { | ||
| return fmt.Errorf("engine.driver must be a safe basename (no path separators, '..', or shell metacharacters) ending with .js, .cjs, or .mjs (found: %s).\n\nSee: %s", workflowData.EngineConfig.DriverScript, constants.DocsEnginesURL) | ||
| } | ||
|
|
||
| ext := strings.ToLower(filepath.Ext(driverScript)) | ||
| switch ext { | ||
| case ".js", ".cjs", ".mjs": | ||
| return nil | ||
| default: | ||
| return fmt.Errorf("engine.driver must be a Node.js script ending with .js, .cjs, or .mjs (found: %s).\n\nSee: %s", workflowData.EngineConfig.DriverScript, constants.DocsEnginesURL) | ||
| } | ||
|
Comment on lines
+81
to
+107
|
||
| } | ||
|
|
||
| // validateEngineInlineDefinition validates an inline engine definition parsed from | ||
| // engine.runtime + optional engine.provider in the workflow frontmatter. | ||
| // Returns an error if: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Schema text says
engine.driver"must end with .js, .cjs, or .mjs", but the schema itself doesn’t enforce that constraint (e.g., viapattern). Adding a regex pattern here (and ideally also restricting to a safe basename) would keep schema validation consistent withvalidateEngineDriverScriptand help catch invalid/unsafe values earlier.