Skip to content

Comments

fix(permission): resolve path specificity using longest matching rule#14540

Open
ventsislav-georgiev wants to merge 1 commit intoanomalyco:devfrom
ventsislav-georgiev:fix/permission-next-path-specificity
Open

fix(permission): resolve path specificity using longest matching rule#14540
ventsislav-georgiev wants to merge 1 commit intoanomalyco:devfrom
ventsislav-georgiev:fix/permission-next-path-specificity

Conversation

@ventsislav-georgiev
Copy link

@ventsislav-georgiev ventsislav-georgiev commented Feb 21, 2026

Issue for this PR

Closes #13646, #13872, #11272 (maybe others)

Type of change

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

What does this PR do?

PermissionNext.ask now evaluates each requested pattern in two forms: the original input and, when relative, a worktree-resolved absolute path. It then picks the decision from the most specific matched rule (longest matched pattern).

This fixes cases where generic wildcard rules could beat path-scoped rules only because a tool supplied a relative path.

How did you verify your code works?

  • bun test test/permission/next.test.ts
  • bun test test/permission-task.test.ts

Added regression tests in packages/opencode/test/permission/next.test.ts:

  • absolute specific allow beats wildcard deny for relative edit path
  • absolute specific deny beats wildcard allow for relative edit path
  • absolute specific allow beats wildcard deny for bash command
  • specific deny beats wildcard allow for bash command

Screenshots / recordings

Not a UI change.

Checklist

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

If you do not follow this template your PR will be automatically rejected.

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Feb 21, 2026
@github-actions
Copy link
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 added needs:issue and removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Feb 21, 2026
@github-actions
Copy link
Contributor

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

@ventsislav-georgiev ventsislav-georgiev changed the title fix(permission): prefer most-specific path rule in ask fix(permission): resolve path specificity using longest matching rule Feb 21, 2026
@ventsislav-georgiev ventsislav-georgiev force-pushed the fix/permission-next-path-specificity branch 2 times, most recently from 4617db2 to 5ea5848 Compare February 21, 2026 11:58
@ventsislav-georgiev ventsislav-georgiev force-pushed the fix/permission-next-path-specificity branch from 5ea5848 to 27a1e1b Compare February 21, 2026 12:01
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.

Path-based read permissions not enforced; catch-all rules always take precedence

1 participant