Repository navigation
fix(core): match absolute permission rules for relative paths - #53365
Shalin-Shah-2002 wants to merge 1 commit into
Conversation
File tools pass Location-relative resources for paths inside the project, so absolute read/edit rules (such as the Plan agent's allow for the Plan directory) never matched and Plan writes were denied. Also match absolute rules against the resolved path; relative rules and last-match-wins order are unchanged. Fixes anomalyco#50241 Fixes anomalyco#46358 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Gev7ZaFyjYyAVymwC5cKkq
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Adding a v2.2.1 observation for the absolute-path case in this PR. On macOS, in the native standalone TUI, I configured absolute I then changed only the three canary resource strings to project-relative spelling, kept the same binary, model and project, and restarted the isolated TUI. The native read and edit of the denied fixture both returned policy errors without an approval prompt: The denied fixture's SHA-256 remained unchanged. The working resource string for both deny rules is: Sanitized excerpt from the agent configuration, with the project root replaced by a placeholder: {
"agents": {
"build": {
"permissions": [
{
"action": "read",
"resource": "/absolute/path/to/project/.tmp/native-v2-self-cutover/synthetic/denied.txt",
"effect": "deny"
},
{
"action": "edit",
"resource": "/absolute/path/to/project/.tmp/native-v2-self-cutover/synthetic/denied.txt",
"effect": "deny"
}
]
}
}
}Separate headless The v2.2.1 sources appear to explain the result:
The relative spelling works in this configuration. I am reporting this as a v2.2.1 confirmation of the absolute-path case covered by this PR, rather than a TUI-specific permission bypass. Limits: both variants retained project configuration and plugins, including the cmux OpenCode integration and a local shell guard. This is not a plugin-free minimal reproduction. Neither control used the shell guard to produce the native file-tool denials. No secret file was used, and I am not attaching raw configuration or credential captures. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #50241
Closes #46358
Type of change
What does this PR do?
The Plan agent can't write to
~/.opencode/plan/when that directory is inside the project. File tools pass paths inside the project as relative resources (.opencode/plan/work.md), but the Plan agent's allow rule is absolute (<home>/.opencode/plan/*). The absolute rule never matches, so the earlieredit *deny wins.Fix is in
packages/core/src/permission.ts: forread/edit, absolute rules are also matched against the resolved absolute path. Relative rules and last-match-wins order are unchanged, andPermission.evaluatekeeps its signature. This is the same approach as the earlier PR #46495, which was closed by the cleanup bot without review.I did not change the Plan guard message in
plugin/plan.ts; it still rewrites any blocked edit to "outside the Plan directory".How did you verify your code works?
test/permission.test.tsfail without the fix.test/plan-write.test.tsuses the real Plan rules, Permission, FileAccess and write tool: writes to the Plan dir succeed (relative/absolute, inside/outside the project); other paths,plan-eviland..traversals stay blocked.origin/v2.Screenshots / recordings
N/A, not a UI change.
Checklist
🤖 Generated with Claude Code