Repository navigation
feat(core): add portable shell permission scanner - #42351
Merged
Merged
Conversation
kitlangton
force-pushed
the
shell-permission-scan
branch
from
August 13, 2026 18:19
6e68545 to
71c0971
Compare
kitlangton
force-pushed
the
shell-permission-scan
branch
from
August 13, 2026 20:56
7485dc7 to
982357b
Compare
kitlangton
enabled auto-merge (squash)
August 13, 2026 21:35
3 tasks done
kitlangton
added a commit
that referenced
this pull request
Aug 14, 2026
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replace Core's tree-sitter Bash and PowerShell permission parsing with a dependency-free, fail-closed scanner.
This removes the tree-sitter runtime, grammar packages, WASM assets, asset staging, and parser environment variables used by Core shell-permission parsing. The private scanner is bundled into published Core artifacts.
Before / After
Before: shell permission analysis initialized tree-sitter at runtime and depended on staged WASM assets. Unsupported syntax could not carry an explicit opaque permission boundary through every API and UI surface.
After: supported Bash, zsh, and PowerShell command positions produce reusable command resources. Unsupported, dynamic, or uncertain syntax produces one opaque request, never a reusable save, preserves configured asks and denies, and conservatively requires external-directory authorization because it may conceal a directory change.
Validation
How
packages/shell-scanimplements bounded Bash/zsh and PowerShell scanners with recursive command-substitution handling and explicit opaque reasons.packages/core/src/shell/parse.tsadapts scanner output into command resources, reusable prefixes, and directory authorization boundaries.packages/core/src/permission.tsevaluates opaque requests only against safe blanket rules while preserving scoped configured asks and denies.packages/core/src/tool/plugin/shell.tsforwards opaque state, removes reusable saves, and asserts wildcard external-directory access for uncertain directories.dist, so published Core has no scanner runtime dependency.flowchart TD A[Shell tool input] --> B{Portable scanner} B -->|Supported syntax| C[Command resources and known directories] B -->|Dynamic or uncertain| D[Opaque command resource] C --> E[Normal permission evaluation] D --> F[No reusable save] D --> G[Scoped deny and ask preservation] D --> H[Wildcard external-directory check] E --> I[Execute after authorization] F --> I G --> I H --> IScope
The scanner identifies shell-language command positions for supported Bash, zsh, and PowerShell syntax. Behavior delegated to an allowed external program, including package scripts, plugins, makefiles, interpreter files, and remote commands, remains that program's permission boundary.
Unsupported or uncertain syntax intentionally fails closed as opaque. This PR does not replace the TUI's tree-sitter grammar used for syntax highlighting.
Testing
packages/shell-scan: 583 tests, 873 assertions; typecheck passed.packages/core: 54 focused shell parser, permission, and shell tool tests; typecheck and production build passed.packages/cli: 10 focused ACP and node-asset tests; typecheck passed.@opencode-ai/shell-scanruntime dependency.