Repository navigation
Read Clustered and Cut-Short Push Options, Branch Patterns, List Expansions, and a Hidden --admin in the Write Guard - #3011
Conversation
…and a Quoted or Eval'd --admin in the Write Guard The push check now reads a short-option cluster such as -uf or -ud as the force or delete it carries, while -o still takes the rest of its word as a push option. A long option cut short, such as --del, --al, or --mirr, is read as the option it starts, and --branches is read as --all. A cluster ending in -o, or a value option cut short, is read both ways, with and without taking the next word, so neither reading drops a branch. A refspec pattern whose destination stem can still reach refs/heads/, such as refs/*:refs/* or refs/he*:refs/he*, is read as matching every branch, the way a lone colon already is. The --admin check reads each gh pr merge argv, so a quoted "--admin" the shell still passes as a flag is caught, and it reads each eval argument as the command it runs, under the push check's eval budget. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tion Readings
A double-quoted list expansion such as "$@" or "${a[@]}" gives one word
per element, so it no longer counts as a split-free word, whether it is a
-C, --git-dir, or --work-tree value or a commit argument. The directory
value refusal now says so beside its existing workaround.
The second push reading is built in one pass from the left, so an option
that is another's value takes no value of its own. A word starting
--force-with-lease is still read as a force, as develop read it. The
--admin check reads a repo flag between pr and merge. Docstrings now say
only what the code does.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… pr in the Write Guard
A list expansion inside a quoted $(...) leaves the substitution's output
one word, so it no longer fails a commit message or a directory value
closed. A double-quoted $* and a parameter transformation such as ${W@Q}
each give one word and pass. An indirect ${!name} may name every element
of an array, so it fails closed.
The --admin check reads a repo flag before pr as well as between pr and
merge, and reads text past the eval budget as an argv too.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
A recorded local strict-review pass covers head |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3011 +/- ##
==========================================
Coverage ? 60.92%
==========================================
Files ? 17
Lines ? 8996
Branches ? 0
==========================================
Hits ? 5481
Misses ? 3515
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Three moderate findings remain unresolved, including hostname handling, nested list expansions, and line-length compliance.
3 open findings
What changed in this PR
This pull request hardens the write guard against additional Git push forms, gh pr merge --admin variants, and shell list expansions.
Changes:
- Expands push-option and refspec parsing.
- Detects quoted and evaluated
--adminarguments. - Rejects potentially splitting quoted list expansions.
| File | Description |
|---|---|
host-setup/agent-safety/claude/gh-write-guard.py |
Implements parsing hardening and expanded self-tests. |
🧠 Review effort: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… in the Write Guard
A double-quoted "$@" inside a literal brace, such as {"$@"}, still gives
one word per element, so it fails closed again. Only a quote inside a
substitution is now passed over. The --admin check finds pr and then
merge among any words, so a flag such as --hostname before pr cannot hide
it. A _push_readings docstring line is rewrapped under 100 characters.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
gh reads its flags wherever they sit, so an --admin written before merge, as in gh pr --admin=true merge 5, is still merge's flag. Once pr and then merge are found, every word is read for it, skipping only the values of merge's text options. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
A recorded local strict-review pass covers head |
…spec, Hidden --admin, and List Expansion Readings to Main (#3012) - #3011 makes `gh-write-guard` read a clustered short push option (`-uf`, `-ud`) as the force or delete it carries, read a long push option cut short (`--del`, `--al`, `--mirr`, `--bra`) as the option git takes it for, with an ambiguous prefix read as the dangerous option it may start, and read a push whose cluster or cut-short value option takes the next word as its value both ways. It reads a `refs/` glob refspec whose stem can still reach `refs/heads/` as the everything-matches class, `--branches` as `--all`, a quoted `--admin` anywhere in a `gh pr merge` argv and inside an `eval` argument, and fails closed on a double-quoted list expansion (`"$@"`, `"${a[@]}"`, `"${!name}"`) as a `-C`, `--git-dir`, or `--work-tree` value and among a commit's arguments. A differential against the previous guard found no deny-to-allow flip. Only the #2943 shapes listed in that pull request landed, so #2943 stays open After this merges, the host-safety installer payload changes, so the maintainer runs the installer after promotion. Closes #2957 Closes #2998 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…ng, and backlog-burndown Re-Dispatch Rules to Main (#3030) - #2997 adds an updater that keeps the coding-agent tools already installed on a host current, without installing a tool the maintainer has not chosen - #3017 brings the agent-safety READMEs up to the write guard's #3011 readings: `--admin` read inside a quoted `eval` argument, clustered and cut-short push options, `--branches` as `--all`, `refs/` pattern destinations, and a double-quoted list expansion as a directory or commit value failing closed - #3022 pairs a Copilot overview-table or `Review findings:` entry with a review thread by the file it names, replacing word overlap, compares the headline count against everything the round and the pull request account for, and makes `pr_review.py cleanup` read every page of the head pull requests, counting only this repository's own - #3018 has `backlog-burndown` name a new branch when an issue is dispatched again, name the open pull request a pushed branch still heads when cleanup reports it, and splits the long cleanup sentence - #3028 keeps an abandoned group's issue out of the `backlog-burndown` ranking while that group is stopped for the maintainer, and records the release on the claim comment - #3023 makes `gh-write-guard` read a `heads/` push destination as the branch git completes it to, read `--prune` beside a pattern, `:`, `--all`, or bare push as a delete of each branch matched, read `--mirror` as a force and a delete, and read the `@{push}` target against the configured remote names. A differential against the previous guard found no deny-to-allow flip - #3032 subtracts every thread id an open entry links, back-references included, from the earlier threads `pr_review.py`'s headline shortfall counts, so a back-referenced thread is no longer counted twice - #3035 covers the bootstrap upgrade handoff on Linux and Windows, the root and elevated skips included, and has `bootstrap.ps1` say when the agent tools report fails - #3037 makes `gh-write-guard` fail closed when a push target resolves but the remote names cannot be read After this merges, the host-safety installer payload changes, so the maintainer runs the installer after promotion. Fixes #3009 Fixes #2985 Fixes #3003 Fixes #2993 Fixes #3016 Fixes #3005 Fixes #3007 Fixes #2973 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Summary
Closes #2957
Closes #2998
Refs #2943
The write guard's push check, its
--admincheck, and its split-free directory value reading each missed a shape git or the shell still reads as a write. This change reads each one, failing closed where the reading is uncertain, and adds no allow carve-out. The README text it owes is #3009, since another lane was editing the agent-safety READMEs at the same time.Push options, #2957
-uf,-fu, or-udis read as the force or delete it carries.-ostill takes the rest of its word as a push option, so-ofdneither forces nor deletes, matching git.--deldeletes,--alpushes every branch, and--mirrmirrors. An ambiguous prefix such as--forcor--dis read as the dangerous option it may start, which only over-reads, since git refuses an ambiguous one.-o, or a value option such as--repcut short, takes the next word as its value in git. The guard reads such a push twice, once as develop's guard read it and once as git does, built in one pass from the left. Either reading may deny.--set-upstream, such as--set-up, before a bare push now counts as changing that push's upstream, as the whole word already did.Shapes covered from #2943
"refs/heads/*:refs/heads/*"and"*:*"were already read as the everything-matches class by Close the Write Guard's Push Gaps Found Fixing the #2950 Findings #2951. This change extends that to a pattern startingrefs/whose stem can still reachrefs/heads/, such asrefs/*:refs/*andrefs/he*:refs/he*. A stem that leavesrefs/heads/behind, such asrefs/t*, still writes no branch.git push --branches(and a prefix such as--bra) is read as--all.gh pr merge 5 "--admin": the check now reads eachgh pr mergeargv, so a quoted--adminthe shell passes as a flag is denied. Onceprand thenmergeare found, every word is read for it, since gh reads its flags wherever they sit, so a flag beforepror an--adminbeforemergedoes not hide it. The value of--body,--subject, and the other value options stays text, so--body "--admin"passes.eval "gh pr merge 5 --admin": eachevalargument is read as the command it runs, for the--admincheck, under a reading budget the size of the push check's. Past that budget the remaining text is searched whole, which fails closed.Every other #2943 shape is untouched here, and a comment on #2943 lists them.
Double-quoted list expansions, #2998
A double-quoted
"$@","${@:2}", or"${a[@]}"gives one word per element, and an indirect"${!name}"may name an array's every element. Each now fails closed as a-C,--git-dir, or--work-treevalue, and among a commit's arguments, with the existing workaround of writing the directory out. The refusal text now names the case."$W","${W}","$1","${W%/*}","${W@Q}", and"$*"each give one word and still pass, and so does a list expansion inside a quoted$(...), such as a heredoc commit message naming"$@". A list expansion inside a literal brace, such as{"$@"}, still fails closed."$*"is deliberately left allowed: inside double quotes it joins every parameter into one word, so it cannot split.Verification
gh-write-guard.py --selftestpasses, with new_GIT_CASESrows for every shape above, a control beside each, and one_PUSH_DIR_CASESrow for the cut-short--set-upstream. Run against develop's guard, every new deny row allows there, exceptgit push -ud origin,--rep example develop, and a word starting--force-with-lease. Those three pin develop's readings so the new ones cannot drop them. The--set-upstreamrow fails once its fix is reverted.-uf,-ud,--del,--al,--mirr,--bra,--branches,refs/*:refs/*, andrefs/he*:refs/he*each write what this change reads.-ofdtakesfdas a push option, and--forcand--dare refused as ambiguous.Filed From the Local Review
Pre-existing gaps the local review found, each allowed by develop's guard too: #3004, #3005, #3006, #3007, and #3008 (consolidating helper sites), plus a comment on #2978 for a clustered commit
-n.🤖 Generated with Claude Code