Skip to content

test: capture env var prefix permission bypass (#16075)#16086

Closed
fazzledev wants to merge 1 commit into
anomalyco:devfrom
fazzledev:fix/env-var-permission-bypass
Closed

test: capture env var prefix permission bypass (#16075)#16086
fazzledev wants to merge 1 commit into
anomalyco:devfrom
fazzledev:fix/env-var-permission-bypass

Conversation

@fazzledev

@fazzledev fazzledev commented Mar 5, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #16075

Note: This PR does not fix the bug — it only adds a test case capturing the current (buggy) behavior. The fix requires a design decision on how to strip variable_assignment AST nodes from commandText without losing redirect info. See the issue for options.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a test case that captures the env var prefix permission bypass bug. Commands like CI=true git commit produce a permission pattern of "CI=true git commit -m \"test\"" instead of "git commit -m \"test\"", so a rule like "git *": "ask" won't match and the command runs without a dialog.

The test currently asserts the buggy behavior with a TODO to flip the assertions once the fix lands.

How did you verify your code works?

Ran bun test test/tool/bash.test.ts test/permission/arity.test.ts test/permission/next.test.ts — 84 pass, 0 fail.

Screenshots / recordings

N/A — no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 5, 2026
@github-actions

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this May 4, 2026
prullanferragut added a commit to prullanferragut/opencode that referenced this pull request May 21, 2026
Commands like 'GITHUB_TOKEN=x git push --force' were matching '*': allow
instead of the intended deny rule because variable_assignment nodes were
included in the pattern string used for permission matching.

Build the permission pattern from parts() tokens (which already exclude
variable_assignment children) rather than from the raw node text, then
re-attach any redirection suffix from the parent redirected_statement so
'echo test > output.txt' still produces the full pattern as before.

Also adds integration tests verifying the corrected behavior.

Based on test groundwork from PR anomalyco#16086.
Fixes issue anomalyco#16075
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Inline env var prefix (e.g. CI=true git commit) bypasses bash permission rules

1 participant