fix: close flutter-reviewer read-only hook bypasses - #162
Open
HadiHassan22 wants to merge 1 commit into
Open
HadiHassan22 wants to merge 1 commit into
HadiHassan22 wants to merge 1 commit into
Conversation
allow-readonly-git.sh let a mutating command through when it shared a multi-line command with `git status`/`git diff`, since a newline was not treated as a separator and the allow check passed if any line matched. It also allowed `git diff --output` (writes files) and `--ext-diff` (runs the external diff driver). Deny newlines, carriage returns and `$` expansion, and deny `--output` and `--ext-diff` after stripping quotes. Add tests for each case. Fixes VeryGoodOpenSource#161 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
HadiHassan22
force-pushed
the
fix/reviewer-readonly-hook-bypass
branch
from
September 25, 2026 16:09
e763861 to
788c40e
Compare
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.
Description
Fixes #161.
allow-readonly-git.shkeeps theflutter-revieweragent read-only. It let three kinds of command through:;, but it wasn't in the rejected-operator list, and the allow check passes when any line matches. Agit statusline anywhere in the command let the other lines run.git diff --output=<file>/--output <file>, which writes the diff to any path.git diff --ext-diff, which runs the configured external diff driver.What changed
$is denied outright, extending the existing$(rule. Parameter expansion such as${X:-…}can produce option text the other checks never see.--outor--extis denied, after stripping quotes and backslashes so"--output"or--out\putcan't hide the option.--no-ext-diffand--output-indicator-*stay allowed.The reviewer's normal commands (
git status,git diff,git diff --cached,git diff main...HEAD) are unaffected.Left as-is
Like the other hooks, this one still exits 0 when
jqis not installed, which allows every command. I kept that to match the repo convention, but since this hook is the agent's only write guard, you may want it to fail closed instead. Happy to add that here or in a follow-up.Tests
allow-readonly-git_test.shgains 14 blocked cases (multi-line commands, both--outputforms, quoted and escaped spellings,--ext-diff,$expansion) and 4 allowed cases to guard against over-blocking. 36/36 pass on bash 3.2 and 5; the 14 new blocked cases all fail against the current hook.Type of Change
feat)fix)refactor)docs)ci)chore)🤖 Generated with Claude Code