Add --add-dir for Copilot plugin discovery in sandbox mode#14296
Add --add-dir for Copilot plugin discovery in sandbox mode#14296
Conversation
Co-authored-by: patrickcarnahan <17889693+patrickcarnahan@users.noreply.github.com>
Co-authored-by: patrickcarnahan <17889693+patrickcarnahan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes GitHub Copilot CLI plugin discovery when workflows run in sandboxed modes (AWF firewall or SRT). Since plugins installed via copilot plugin install live under ~/.copilot/, the Copilot CLI needs that directory explicitly allowlisted via --add-dir in sandbox mode.
Changes:
- Add
--add-dir /home/runner/.copilot/to Copilot CLI arguments when sandbox mode is enabled andworkflowData.Pluginsis non-empty. - Add unit tests covering flag presence/absence across firewall/non-firewall and SRT scenarios, including ordering after the workspace
--add-dir.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/workflow/copilot_engine_execution.go | Adds sandbox-mode --add-dir for /home/runner/.copilot/ when plugins are declared so Copilot can discover installed plugins. |
| pkg/workflow/copilot_engine_test.go | Adds tests validating the new --add-dir behavior for AWF (firewall) and SRT sandboxes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🛡️ Security Posture AnalysisThis PR contains changes that may affect the security posture. Please review the following concerns: 🟠 Network/Sandbox Boundary Expansion: Mounting Copilot config dirLocation: Change Detected: @@
- copilotArgs = append(copilotArgs, "--add-dir", "\"${GITHUB_WORKSPACE}\"")
- copilotExecLog.Print("Added workspace directory to --add-dir")
+ copilotArgs = append(copilotArgs, "--add-dir", "\"${GITHUB_WORKSPACE}\"")
+ copilotExecLog.Print("Added workspace directory to --add-dir")
+
+ // Add Copilot config directory when plugins are declared so the CLI can discover installed plugins
+ if len(workflowData.Plugins) > 0 {
+ copilotArgs = append(copilotArgs, "--add-dir", "/home/runner/.copilot/")
+ copilotExecLog.Printf("Added Copilot config directory to --add-dir for plugin discovery (%d plugins)", len(workflowData.Plugins))
+ }Security Impact: Recommendation: Avoid mounting the full Copilot config directory into the sandbox. Instead, expose only the minimal plugin metadata files (e.g., the plugin index) through a controlled copy or pass Summary
Note: This is an automated analysis. Please verify these findings and determine if the changes are intentional and justified.
|
Plugins installed via
copilot plugin installare stored at~/.copilot/plugins/, but the Copilot CLI cannot discover them in sandbox mode because~/.copilot/is not included in the--add-dirarguments that control directory access permissions.Changes
pkg/workflow/copilot_engine_execution.go--add-dir /home/runner/.copilot/whenworkflowData.Pluginsis non-empty and sandbox mode (AWF or SRT) is enabledpkg/workflow/copilot_engine_test.goTestCopilotEnginePluginDiscoveryInSandboxMode: validates flag presence/absence across 4 scenarios (plugins with/without firewall, with/without sandbox)TestCopilotEnginePluginDiscoveryWithSRT: validates SRT-specific behaviorExample
When a workflow declares plugins with firewall enabled:
The compiled workflow now includes:
copilot --add-dir /tmp/gh-aw/ --add-dir "${GITHUB_WORKSPACE}" --add-dir /home/runner/.copilot/ ...Why
/home/runner/.copilot/vs/home/runner/.copilot/plugins/The CLI requires access to the parent directory to read
plugin-index.jsonfor plugin discovery. The directory also containsmcp-config.jsonalready referenced by the installer script.Original prompt
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.