Repository navigation
fix(guard-public-text): let gh api reads through, and close the gaps around writes - #80
Merged
Merged
Conversation
…around writes
The guard blocked every `gh api` read whose endpoint named an owner the
scanner flags: it classed any `gh api` as publishing and scanned the
endpoint itself. A GET of repos/<owner>/<name>/rulesets publishes nothing.
Reads:
- A `gh api` call with no field, no --input, and a GET or HEAD method
passes unscanned. So does a graphql query; a mutation is still scanned.
This follows gh's own rule: fields switch the default method to POST.
- Each publishing verb is detected on its own, so a read chained to a
write (`gh api ... && git commit -m ...`) still has the write checked.
Addresses are not text:
- A `gh api` write takes its repository from a repos/<owner>/<name>
endpoint, so the repository's visibility decides, as it does for -R.
- The endpoint and the -R value are left out of the scan. The body,
fields and files are still scanned.
- A command naming two different repositories is checked as unknown
visibility, so one private repository cannot clear a public one.
Gaps closed around writes:
- `git push <remote>` checks the remote it names, not only origin: a
repository whose origin is elsewhere can push to a GitHub mirror. A word
that is neither a remote nor a URL is checked, not waved through.
- A push checks every local branch the pushed-to remote lacks, not only
HEAD. It also checks annotated tag messages when tags are sent
(--tags, --follow-tags, refs/tags/, push.followTags).
- git's global options before the subcommand (`git -c k=v commit`,
`git --no-pager commit`) no longer hide a commit or push.
- Also checked now:
- gh pr/issue close --comment;
- gh pr merge --subject/--body;
- gh repo/label create/edit --description;
- gh gist edit;
- gh workflow run fields.
Stays bash 3.2 safe: no ${x^^}. 13 new bats tests; the 22 existing ones
pass unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gutyoh
marked this pull request as draft
November 2, 2026 21:48
-ftitle=x and -XPOST are valid gh flags; the read check only knew the spaced forms, so such a write passed unscanned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
guard-public-text.shclassed everygh apicall as publishing and scanned the whole command, endpoint included. So a plain read likegh api repos/<owner>/<name>/rulesetswas blocked whenever the owner matched a scanner needle. That made read-only checks impossible without routing around the guard, which a guard must never encourage.Fixing that exposed some writes the guard missed. They are fixed here too.
What changes
gh apiGET/HEAD with no body, or a graphql querygh apiwith a field,--input, a non-GET method, or a graphql mutationgh api … && git commit -m …)gh api repos/<o>/<n>/…write-Rvaluegit push <remote>git push origin other-branchgit push --tags/--follow-tagsgit -c k=v commit,git --no-pager commitgh pr/issue close --comment,gh pr merge --subject/--body,gh repo/labelcreate/edit,gh gist edit,gh workflow rungh's own manual backs the read rule: the default method is GET, and adding fields switches it to POST;
-X GETsends the fields as a query string instead.Tests
-s bash -S warning) and shfmt (-i 4 -ci -bn) are clean.tr, not${x^^}.setup.sh --minimal completes under stock macOS bash 3.2fails on unmodifiedmaintoo.main.🤖 Generated with Claude Code