fix: project-level permissions to work around config priority bug#34
fix: project-level permissions to work around config priority bug#34
Conversation
User-level config at ~/.config/opencode/ has LOWER priority than project-level .opencode/opencode.jsonc. When project config exists with minimal permission rules, user-level read/bash allow rules are overridden, causing excessive permission prompts. Workaround: set comprehensive permissions at project level until the config merge behavior is fixed upstream. Fixes #31 Ref #32 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
There was a problem hiding this comment.
Pull request overview
Updates the repository’s project-level OpenCode configuration to define an explicit, comprehensive permission ruleset in .opencode/opencode.jsonc, intended to work around the config priority/merge behavior described in issue #31.
Changes:
- Add project-level default
read/edit/tool permissions (including.envand migration path restrictions). - Define a detailed
bashallowlist with a defaultask, plus explicit deny rules for a few dangerous commands. - Enable several non-bash tools (
glob,grep,list,webfetch,websearch, etc.) by default.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "cat *": "allow", | ||
| "head *": "allow", | ||
| "tail *": "allow", | ||
| "mkdir *": "allow", |
There was a problem hiding this comment.
The goal/test plan says “.env file access is denied”, but bash is configured to allow cat * / head * / tail * without prompting. The bash tool does not consult read permissions for files referenced in shell commands, so cat .env (and similar) will still be auto-approved. To actually block .env reads, add explicit bash deny rules that match .env paths (e.g., deny cat *.env*, head *.env*, tail *.env*, etc.), or change these commands back to ask/deny.
| "**/.env.*": "deny", | ||
| }, | ||
| "glob": "allow", | ||
| "grep": "allow", |
There was a problem hiding this comment.
grep is set to allow, but the grep tool’s permission check is only against the search pattern (not the files searched) and it runs ripgrep across the repo (including hidden files). That means secrets in .env can still be discovered via grep even though read denies .env. If the intent is “.env access is denied”, consider setting grep back to ask/deny (or narrowing it), since the permission model can’t currently restrict grep by filepath.
| "grep": "allow", | |
| "grep": "ask", |
| "curl * | sh*": "deny", | ||
| "curl * | bash*": "deny", |
There was a problem hiding this comment.
The deny rules for curl | sh / curl | bash rely on spaces around the pipe ("curl * | sh*"). The bash permission patterns are matched against the raw command text, so variants like curl ...|sh, curl ...| bash, or extra whitespace won’t match and will fall back to the broader "curl *": "allow" rule. Add additional deny patterns that cover common spacing variants (or change curl * to ask).
| "curl * | sh*": "deny", | |
| "curl * | bash*": "deny", | |
| "curl * | sh*": "deny", | |
| "curl *| sh*": "deny", | |
| "curl * |sh*": "deny", | |
| "curl *|sh*": "deny", | |
| "curl * | bash*": "deny", | |
| "curl *| bash*": "deny", | |
| "curl * |bash*": "deny", | |
| "curl *|bash*": "deny", |
| "chmod *": "allow", | ||
| "which *": "allow", | ||
| "echo *": "allow", | ||
| "pwd": "allow", |
There was a problem hiding this comment.
pwd is allowed only as an exact match ("pwd"). The bash tool requests permissions against the full command string, so pwd -P / pwd -L will still prompt even though the intent seems to be allowing basic shell utilities. Consider changing this to a wildcard form (e.g., pwd *) for consistency with other entries like ls */cat *.
| "pwd": "allow", | |
| "pwd *": "allow", |
Summary
.opencode/opencode.jsoncto work around config priority bug (bug: user-level permission config overridden by project-level config with missing rules #31)~/.config/opencode/opencode.jsonc) has lower priority than project-level, so permission rules set there are ineffective when project config existsFixes #31
Ref #32
Root Cause Investigation
Issue 1: Config Priority (#31)
Permission.fromConfig(cfg.permission)inagent.ts:102receives already-merged configpermissionkey, it overrides user-level permission entirelyIssue 2: Team Gate (#32)
team.ts:470hardcodestasks.length < 2checkbig()function over-triggers on verbose investigation requestsIssue 3: findLast() Evaluation (#31)
evaluate.ts:10usesfindLast()— last matching rule wins regardless of specificityTest plan
supabase *,bun *,git *bash commands auto-approverm -rf,sudoare blocked.envfile access is denied🤖 Generated with Claude Code