GeezerVison is showing github.com — fix(core): match file permission rules without case on macOS by knp-sap · Pull Request #64626 · anomalyco/opencode
Conversation
knp-sap
commented
Nov 18, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Closes #64624
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
Wildcard.match ignores case only on Windows. macOS volumes ignore case by default, so .OPENCODE/plugins/x.ts is the same file as .opencode/plugins/x.ts, but it did not match a .opencode/* rule.
Permission.evaluate and the organization tool.use policy hook now match the resources of the file actions (read, edit, and external_directory) without case on macOS. The list of file actions lives in Permission.pathActions, which the agent config also uses. Windows is unchanged. On macOS, shell commands and other resources still match with case. On a case-sensitive APFS volume, file rules now also match other spellings; that makes ask and deny rules stricter, but allow rules broader too.
No feature flag: this is a bug fix.
How did you verify your code works?
- New tests in
packages/core/test/permission.test.ts and packages/core/test/config/policy.test.ts. They fail on macOS without the fix; the new Wildcard.match option is checked on every platform.
- On macOS, in
packages/core: bun run script/test.ts (7562 pass, 0 fail), bun typecheck, and bun run typecheck:tsc.
Screenshots / recordings
Not a UI change.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
macOS volumes ignore case by default, so an edit to .OPENCODE/plugins/x.ts writes into the directory that config discovery loads as .opencode, yet escaped a .opencode/* rule. Match read, edit, and external_directory resources without case on macOS, as Windows already does for every rule; commands and other resources keep their case.
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.
The fix works. With process.platform set to darwin, Permission.evaluate on the base allowed an edit to .OPENCODE/plugins/x.ts and a read of secrets.ENV under .opencode/* ask and *.env deny rules. With this change they are ask and deny, and shell commands still match with case. The permission tests pass and typecheck:tsc is clean. This was simulated on Linux, not run on a real Mac.
Public API: unchanged. Wildcard.match gains an optional third argument, which is internal and backwards compatible.
One gap worth closing in this pull request: organization tool.use deny policies are checked in packages/core/src/config/plugin/policy.ts through a separate Wildcard.match(${event.action}:${resource}, policy.resource) call. That call still matches with case on macOS, so a managed policy like read:*.env deny can still be bypassed with secrets.ENV, the same problem as #64624 in the layer organizations rely on most. It would be worth applying the same case rule there, ideally from one shared helper rather than a second copy of the file-action list. That list already exists as pathActions in config/plugin/agent.ts.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
export type Error = BlockedError | CorrectedError
|
|
|
|
|
|
// macOS volumes ignore case by default, so `.OPENCODE/x` opens `.opencode/x`; rules for file paths must match it too.
|
|
|
const fileActions = new Set(["read", "edit", "external_directory"])
|
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.
This list repeats pathActions in config/plugin/agent.ts (external_directory, read, edit). The managed tool.use policy hook in config/plugin/policy.ts also matches <action>:<path> resources with case on macOS, so organization deny policies can still be bypassed by spelling the path in another case. Could the list live in one place and be used by both checks?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Thanks, done in da78cd8. Permission now exports pathActions and ignoresCase(action), and evaluate, the tool.use hook in config/plugin/policy.ts, and config/plugin/agent.ts all use them, so the list lives in one place. agent.ts still checks it against the tool names.
A new policy test checks that an organization read:*.env deny also blocks secrets.ENV on macOS; it fails without the change. I ran the full core suite on a real Mac.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The tool.use policy hook matched action:path resources with case, so an organization read:*.env deny could still be bypassed on macOS by reading secrets.ENV. Share the file action list and the case rule through Permission, and use them in evaluate, the policy hook, and the agent config.
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.
My earlier point is resolved. The organization tool.use policy hook now matches file actions without case on macOS, and the list of file actions lives only in Permission.pathActions. config/plugin/agent.ts still checks it against the tool names when type-checking. With the platform set to darwin, a read:*.env deny now matches secrets.ENV, and shell policies still match with case. The permission and policy tests pass (146) and typecheck:tsc is clean. This was simulated on Linux, not run on a real Mac.
Public API: unchanged. Permission.pathActions, Permission.ignoresCase and the optional Wildcard.match argument are internal to packages/core.
No further concerns.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
The new commit only changes how config/plugin/agent.ts reads Permission.pathActions, which is still type-checked against the tool names, so behavior is unchanged. The agent config, permission and policy tests pass and typecheck:tsc is clean. My earlier point about one shared list and the organization tool.use policies was addressed in da78cd8. Public API: unchanged. No further concerns.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
vergeal
added a commit
to vergeal/aicraft
that referenced
this pull request
Nov 22, 2026
…co#64626)
Adapted from upstream 79bd2c6. File actions (external_directory, read,
edit) ignore case on darwin, matching macOS volumes; commands keep their case.
This was referenced Nov 25, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|