Skip to content

Read Clustered and Cut-Short Push Options, Branch Patterns, List Expansions, and a Hidden --admin in the Write Guard - #3011

Merged
ptr727 merged 5 commits into
developfrom
feature/guard-push-targets
Oct 14, 2026
Merged

ptr727 merged 5 commits into
developfrom
feature/guard-push-targets

Conversation

@ptr727

@ptr727 ptr727 commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #2957
Closes #2998
Refs #2943

The write guard's push check, its --admin check, 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

  • A short-option cluster such as -uf, -fu, or -ud is read as the force or delete it carries. -o still takes the rest of its word as a push option, so -ofd neither forces nor deletes, matching git.
  • A long option cut short, which git accepts where it names one option, is read as that option: --del deletes, --al pushes every branch, and --mirr mirrors. An ambiguous prefix such as --forc or --d is read as the dangerous option it may start, which only over-reads, since git refuses an ambiguous one.
  • A cluster ending in -o, or a value option such as --rep cut 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.
  • A delete with no refspec is now read as the bare push it spells rather than as nothing. Git refuses that command anyway.
  • A cut-short --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

  • A glob refspec: "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 starting refs/ whose stem can still reach refs/heads/, such as refs/*:refs/* and refs/he*:refs/he*. A stem that leaves refs/heads/ behind, such as refs/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 each gh pr merge argv, so a quoted --admin the shell passes as a flag is denied. Once pr and then merge are found, every word is read for it, since gh reads its flags wherever they sit, so a flag before pr or an --admin before merge does 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": each eval argument is read as the command it runs, for the --admin check, 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-tree value, 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 --selftest passes, with new _GIT_CASES rows for every shape above, a control beside each, and one _PUSH_DIR_CASES row for the cut-short --set-upstream. Run against develop's guard, every new deny row allows there, except git 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-upstream row fails once its fix is reverted.
  • Real git 2.47 against a constructed bare remote confirmed -uf, -ud, --del, --al, --mirr, --bra, --branches, refs/*:refs/*, and refs/he*:refs/he* each write what this change reads. -ofd takes fd as a push option, and --forc and --d are refused as ambiguous.
  • A develop-versus-branch differential classified about a thousand commands: the issue shapes, their neighbours, and every command in the guard's case tables. It ran under five rule sets, two current branches, and the primary-checkout check both off and on. It found no deny-to-allow flip. Every flip was allow-to-deny on a shape listed above.
  • The local gate set passed: ruff, ruff format, mypy, the unit tests, build_dist, repo_gate (eol and eol-coverage included), prose_lint, and spec/validate.

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

ptr727 and others added 3 commits October 14, 2026 09:12
…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]>
Copilot AI lite review requested due to automatic review settings October 14, 2026 16:53
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0453c2e2-7dd3-4378-84ca-52bc48262973
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ptr727

ptr727 commented Oct 14, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 7b42d6621ca3b7e078815c6a77c277a22d7021d0, the content this pull request carries at that commit against develop, and it recorded 2 findings.

@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@dbd80de). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #3011   +/-   ##
==========================================
  Coverage           ?   60.92%           
==========================================
  Files              ?       17           
  Lines              ?     8996           
  Branches           ?        0           
==========================================
  Hits               ?     5481           
  Misses             ?     3515           
  Partials           ?        0           
Flag Coverage Δ
python-3.13 60.92% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 --admin arguments.
  • 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.

ptr727 and others added 2 commits October 14, 2026 10:03
… 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]>
@ptr727

ptr727 commented Oct 14, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 3f82f07452fa4efb42f7620cb68f2e0401afa45f, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@ptr727
ptr727 merged commit 7e41574 into develop Oct 14, 2026
13 checks passed
@ptr727
ptr727 deleted the feature/guard-push-targets branch October 14, 2026 17:22
ptr727 added a commit that referenced this pull request Oct 14, 2026
…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)
ptr727 added a commit that referenced this pull request Oct 15, 2026
…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)
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.

2 participants