Repository navigation
feat(permissions): map crush bash pattern rules to safe_commands and blocked_commands - #3818
Merged
Merged
Conversation
…blocked_commands Crush v0.100.0 added permissions.safe_commands (exact command lines that skip the prompt) and permissions.blocked_commands (commands added to the dangerous list, still prompted for in normal mode). Map canonical bash rules onto them where the semantics match: an allow on a literal command line becomes a safe command unless any deny/ask covers a command Crush would approve through it (including the `--` and wrapper spellings Crush resolves), and an ask on `<name>` / `<name> *` becomes a blocked command. A pattern deny stays skipped with a warning, since blocked_commands would still prompt. Import maps both lists back to bash rules. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7
…ush-command-permissions # Conflicts: # src/generated/docs-content.ts
Crush enforces blocked_commands at exec time on the paths it does not prompt for (its read-only commands and safe_commands), so a blocked name refuses those forms. Writing a canonical ask there turned it into a deny for `git status`-style commands. Map a whole-command deny to blocked_commands instead (reported as not a full deny), skip asks, never block the command of a written safe line, keep every existing blocked entry, import blocked entries as denies, and compare wrapper spellings with an absolute path or another case in the safe-line overlap check. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7
Compare safe lines' wrapper spellings against restrictions whose command word is normalized the way Crush normalizes a wrapper name (any directory, case, Windows suffix), skip denies on wrappers and the `time` keyword (Crush resolves them before matching blocked_commands), and warn when a kept blocked entry would refuse a written safe line. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7
…wrapper name A `*` in a restriction's command word can cross a directory and land inside a wrapper's name (`/u*v` globs `/usr/bin/env`), so fold the word whenever the text after its last `*` is a tail of a wrapper name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7
…ush-command-permissions # Conflicts: # src/generated/docs-content.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Crush v0.100.0 (stable, 2026-11-05) added
permissions.safe_commandsandpermissions.blocked_commands. Until now rulesync skipped every canonicalbashpattern rule for Crush. This PR maps those rules onto the two new keys, on generate and import, but only where the semantics match. No deny/ask is ever widened.How Crush v0.100.0 behaves (checked in
config.go,tools/bash.go,tools/safe.go,shell/{shell,wrappers}.go):safe_commands: Crush skips the prompt only for the exact tokens of an entry, with no extra arguments and no flags. It resolves wrappers first (env,nohup,nice,timeout; wrapper names are normalized, andtimeis judged by what it wraps). A trailing--still matches. Compositions of safe lines are approved too.blocked_commands: adds normalized names to the dangerous list.bashinallowed_tools.safe_commands) the block list is enforced at exec time, so those forms are refused. Indirect invocations are refused too.allowed_commands: only drops names from the dangerous list. Those commands still prompt, so it is not an allow.Changes
allowon a literal command line →safe_commands. The line can have no wildcards, quoting or shell syntax, no leading wrapper, and its command name must be in normalized form. The line is withheld, with a warning, when any canonicaldeny/ask(frombashor*) overlaps a command Crush would approve through it:--…time, including a wrapper spelled with an absolute path or in another case (/usr/bin/env,NICE)denyon<name>/<name> *→blocked_commands. This is the strictest Crush can express, but it is not a full deny, so it comes with a warning. It is withheld, with a warning, when<name>is the command of a written safe line, because Crush would refuse that line.askis skipped with a warning. Writing it toblocked_commandswould refusegit status-style read-only forms instead of prompting for them.allowrules and other patterns are skipped, as before.blocked_commandsentries are kept, because rulesync can't tell its own entries from hand-written ones.safe_commandsentry is dropped (with a warning) when a canonical restriction covers it, or when it can't be read exactly and the config restricts anything.allowed_commandsis never touched.safe_commandsentry →bashallowfor the exact line. The command name is normalized; entries with wildcards, shell syntax or wrappers are skipped with a warning.blocked_commandsentry →denyfor<name>and<name> *. This round-trips the generate mapping, andaskwould read looser than Crush's refusal.bashinallowed_toolsplus blocked names no longer writesbashtoallowed_tools. That is the fail-closed direction, and it is documented.docs/reference/file-formats.md, including the composition caveat, and regenerateddocs-content.ts.json.Unmarshal, so they ignore the new keys.Verification
--, wrapper, path/case wrapper spellings, catch-all ask, all-tools denypnpm cicheckpasses: 16834 tests, plus the content checks.Refs #3672
🤖 Generated with Claude Code
https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7