Skip to content

fix(permissions): close the remaining all-tools withholding gaps (#3822) - #3987

Merged
dyoshikawa merged 8 commits into
mainfrom
resolve-issue-3822-permission-gaps
Nov 26, 2026
Merged

dyoshikawa merged 8 commits into
mainfrom
resolve-issue-3822-permission-gaps

Conversation

@dyoshikawa

@dyoshikawa dyoshikawa commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes the remaining items of #3822 (permission-withholding gaps left after #3802). Every behaviour change here only adds a restriction or withholds more. No allow is added or widened.

Changes

Tests and cleanups (triage plan)

  • shadowed-allows.test.ts: a truth table for hasDoubleSlashWithoutScheme. Overlap cases from the fix(permissions): treat pathless host allows as any path and keep the host of host//path #3831 review: https://example.com, example.com:8080 and example.com/docs/* overlap *.pdf, while the path allows example.com/a.html and example.com/docs/ are not widened.
  • copilot-permissions.test.ts: the edits map still gets "Evil.com//Admin": false from a * deny.
  • honorAllToolsRestrictions now looks up allToolsRules[pattern] ?? "deny" once and reuses it for bash and the other categories. last-match-restate.ts builds each left-side glob test once per pattern instead of once per pair. Neither change alters behaviour.

Item 5: restate into an absent read category. CodeBuddy, Qoder, Command Code, Letta Code and Qwen Code now also write a * path deny/ask as a Read(...) rule when the config has no read key. So {"*":{".env":"deny"},"bash":{"ls":"allow"}} now writes Read(.env). This uses the new restateIntoAbsentCategories option (RESTATED_ABSENT_CATEGORIES = ["read"]).

Item 6 (rest): integer-like keys in OpenCode / OpenCode V1 / MiMo Code / Kilo. A JSON object always lists an integer-like key such as 8080 first. That holds both when rulesync writes the file and when the tool parses it, so the key cannot be reordered. If a looser rule later in the same key overlaps such a deny/ask, the pattern is now written as 8080* at the end of the key, with a warning. A respelled ask is placed before any deny it overlaps, the same tail order that restated * rules already use. This also covers an integer-like * restriction restated into another key.

Item 7: Codex .git carve-out. The default ".git/**" = "write" is now skipped, with a warning, when a * path deny (or an ask there other than the catch-all) reaches inside .git. That means either its first path segment, after stripping ./, / or **/, matches .git (for example .git/hooks, .git/modules/**, .g*/x, **/.git/**, *, **), or it matches a concrete path git writes under the all-tools glob rules (* crosses /): index, HEAD, config, objects, refs, hooks, logs, submodule and worktree files. Both checks ignore case. Before this change, even {"*":{".git/**":"deny"}} produced ".git/**" = "write".

Item 8: Vibe under a catch-all * restriction. Each stated category without a * rule of its own now gets the catch-all restriction. So {"*":{"*":"deny"},"read":{"src/**":"allow"}} writes read_file with permission = "never" instead of leaving Vibe's default. This happens through downgradeWithheldCatchAll, which only Vibe uses.

Docs: docs/reference/file-formats.md and docs/faq.md are updated, and src/generated/docs-content.ts is regenerated.

Review round 1 follow-ups

  • OpenCode V2 writes the ordered permissions array, so an integer-like deny/ask is now moved to the end of its key's rules as written (no 8080*, no warning). The 8080* respelling applies only to the object-form maps (OpenCode V1, MiMo Code, Kilo). Both paths share orderIntegerLikeRestrictionsLast.
  • Codex .git check, refined in rounds 2 and 3: a hybrid of a first-segment test and a list of concrete git-written paths. Every spelling inside .git drops the carve-out, including .git/hooks, .git/hooks/, .git/modules/sub/hooks/**, .git/worktrees/**, .git/info, .git/packed-refs, .git/FETCH_HEAD, .git/refs, .git/objects, .git/lfs/**, .git/rr-cache/** and .GIT/hooks/**. Broad patterns (*.env, *.log, **/*.pem, *secret*, .github/**, .gitignore) keep it, so git commit keeps working. Both lists are tested exhaustively.
  • Vibe also restates into an absent read category, including the catch-all: {"*":{"*":"deny"},"bash":{"ls":"allow"}} now writes read_file with permission = "never".
  • The CodeBuddy, Qoder and Letta warnings no longer say a pattern-specific * rule is "skipped"; they say how it is honored instead. Added item-5 adapter tests for all five tools (restated Read(.env), hand-written entries kept).

Design decisions

  • 5: only read, and the category stays unmanaged. The issue names reads as the input those tools may auto-approve. Edit, write and webfetch prompt by default, so restating there would only add noise. The adapters do not add a category to managedCategories when it was only restated from *. Otherwise its existing hand-written Read(...) entries would be dropped, and dropping a hand-written deny would loosen the file. Trade-off: if the * deny is later removed, the restated Read(...) entry stays as a stale but stricter entry. Qwen already computed managed tools from the config keys, so it needed no adapter change.
  • 6, integer-like keys: respell rather than withhold. Withholding an OpenCode allow does nothing, because an unlisted input falls back to OpenCode's default, which is mostly allow. Downgrading the later rule (*: allow to ask, *: ask to deny) would change far more inputs. 8080* covers 8080 plus the inputs that start with it: the restriction gets wider and no allow does. A key is rewritten only when a later looser rule actually overlaps it.
  • 6, catch-all {"*":{"*":"deny"}}: not restated, declined. In OpenCode a * catch-all followed by per-tool rules is the documented way to set a default, and {"*":{"*":"ask"},"read":{"*":"allow"}} is a deliberate, common config. Restating the catch-all would override every per-tool rule. That matches how the tools that write a * catch-all natively are handled (writesAllToolsCatchAll). The behaviour is now documented.
  • 7: first segment or concrete git path (refined in rounds 2 and 3). A * path deny/ask drops the carve-out when its first segment, after stripping ./, / or **/, can be .git, or when it matches a path git writes, since such a restriction may reach nowhere else in the Codex profile. A plain overlap test would also drop it for broad patterns like *.env and break git commit in Codex. A pattern whose first segment is a pure wildcard (*/x) also counts, because it can name .git/x; that is conservative. Command patterns and a catch-all * ask are ignored. If the carve-out is dropped, it can be restored with explicit read/edit .git/** allows, or the warning silenced with codexcli.git_write_rules: false.
  • 8: Vibe only. Only Vibe sets downgradeWithheldCatchAll. The catch-all is written only when it is stricter than the category's own * rule.

Skipped items and why

Verification

  • Ran rulesync generate -f permissions on probe configs for each changed target (output checked by hand), including a second generate over existing settings that hold hand-written Read(...) entries: they are kept, with no duplicates.
  • pnpm check, pnpm test and pnpm cicheck:content pass. Under heavy machine load, two time-budget tests (glob.test.ts, shell-command-categories.test.ts) and one real-Bun hook test timed out during the full run; the two budget files passed when rerun on their own. Neither file is touched by this PR.

Closes #3822

🤖 Generated with Claude Code

https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4

dyoshikawa and others added 8 commits November 26, 2026 16:49
- Restate '*' path restrictions as Read rules even without a read
  category in CodeBuddy, Qoder, Command Code, Letta Code and Qwen Code,
  keeping existing entries of that category.
- Respell integer-like deny/ask keys a later looser rule overlaps as
  '<n>*' at the key's end for OpenCode-family last-match-wins tools.
- Skip Codex's default .git carve-out when a '*' deny covers .git.
- Write the '*' catch-all restriction into Vibe categories.
- Add the tests from the #3831 review and compute the restriction
  actions and left-side glob tests once.

Closes #3822

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
- OpenCode V2 moves integer-like restrictions to the end of the ordered
  permissions array as written; only object-form outputs respell them.
- Codex drops the .git carve-out when any '*' path deny/ask names a path
  in .git, compared with all-tools glob semantics.
- Vibe restates the '*' restrictions into an absent read category too.
- Reword the CodeBuddy, Qoder and Letta '*' warnings and add item-5
  adapter tests for every restating tool.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…rmission-gaps

# Conflicts:
#	src/generated/docs-content.ts
Drop the default carve-out only when a '*' deny/ask matches a concrete
path git writes (case-insensitively), so common patterns such as *.env,
*.log or **/*.pem no longer break git commit in Codex while .git/hooks/**,
.g* and **/.git/** still drop it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…rmission-gaps

# Conflicts:
#	src/generated/docs-content.ts
… Codex

Drop the default .git carve-out when a '*' deny/ask's first path segment
(after ./, / or **/) matches .git, or when it matches a concrete path git
writes (now including submodule, worktree, info and ref files), so
.git/hooks, .git/modules/**, .git/info and the like are no longer
reopened while *.env, *.log and **/*.pem keep the carve-out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…rmission-gaps

# Conflicts:
#	src/generated/docs-content.ts
…rmission-gaps

# Conflicts:
#	src/generated/docs-content.ts
@dyoshikawa
dyoshikawa merged commit 42f3d61 into main Nov 26, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3822-permission-gaps branch November 26, 2026 09:10
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.

Remaining permission-withholding gaps after #3802

1 participant