fix(opencode): enforce read-only bash permissions in plan mode#24110
fix(opencode): enforce read-only bash permissions in plan mode#24110kzekiue wants to merge 2 commits into
Conversation
…24102-plan-mode-bash-allowlist
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, I found a related PR that may be relevant: Related PR:
The other results are related to permissions and bash command handling but appear to be either older historical changes or addressing different aspects (like sandboxing, auto-approval, and subagent restrictions). The most relevant connection is with PR #23985, which is also addressing plan mode tool permissions, though it focuses on allowing specific CLI tools rather than restricting bash commands. |
|
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 #24102
Type of change
What does this PR do?
Plan mode could still run mutating bash commands because it inherited the default broad tool permissions and only denied edit tools.
This PR makes the native plan agent enforce bash as read-only by default. It denies bash commands unless they match a small allowlist of inspection commands such as git status, git log, git diff, git show, git branch, git stash list, ls, cat, grep, rg, find, wc, head, and tail.
It also adds Agent.permissions(...) so plan-mode rules remain authoritative when session-level permissions are merged in. That prevents session/config permissions from re-allowing mutating commands in plan mode while preserving the existing merge behavior for other agents.
How did you verify your code works?
The session tests were run outside the sandbox because their local HTTP test servers could not bind ephemeral ports inside it.
Screenshots / recordings
Not a UI change.
Checklist