-
Notifications
You must be signed in to change notification settings - Fork 0
fix(agents): harden GitHub mutation guards #2207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Shared agent GitHub guardrails | ||
|
|
||
| `block-git-push.sh` and `block-gh-settings.sh` are shared `PreToolUse` hooks for Codex, Claude Code, Cursor, GitHub Copilot, and Grok. They accept the command from each client's supported JSON shape: | ||
|
|
||
| - `.tool.input.command` | ||
| - `.tool_input.command` | ||
| - `.toolArgs.command` | ||
| - `.toolInput.command` | ||
| - `.command` | ||
|
|
||
| Both hooks exit `0` when a command may proceed and exit `2` with a `BLOCKED by ...` diagnostic when it must stop. | ||
|
|
||
| ## Protected operations | ||
|
|
||
| The push hook blocks explicit and implicit updates or deletions of `main`, `master`, and the cached remote default branch. It resolves upstream and push configuration, bulk pushes, force variants, and Git aliases without executing alias bodies. Direct pushes remain allowed for `shunkakinoki/wiki` and `shunkakinoki/gthq`. | ||
|
|
||
| The settings hook blocks repository control-plane mutations through settings-oriented `gh` commands, REST or GraphQL API calls, and common direct HTTP clients. Read-only API calls and ordinary pull request, issue, review, and comment operations remain available. | ||
|
|
||
| ## Security boundary | ||
|
|
||
| These hooks provide fast feedback and prevent common mistakes. They run with the same user permissions as the agent and can be bypassed, disabled, or avoided through an unsupported tool path. Restricted GitHub credentials and server-side branch rulesets are the authoritative controls; do not grant an agent an administrator credential because these hooks are installed. |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Does HTTPie accept a lowercase request method such ashttp delete https://example.com`?`💡 Result:
Yes, HTTPie accepts lowercase request methods such as
http delete https://example.com[1][2]. While HTTPie documentation typically displays methods in uppercase (e.g.,GET,POST,DELETE), the CLI tool is case-insensitive regarding the request method argument and will correctly process lowercase input [1][3].Citations:
🏁 Script executed:
Repository: shunkakinoki/dotfiles
Length of output: 6484
🏁 Script executed:
Repository: shunkakinoki/dotfiles
Length of output: 1326
Uppercase the HTTP method before the final comparison.
The HTTPie/https/xh capture path assigns the raw
sedcapture, so lowercase methods likehttp delete ...,curl --request delete ..., or--request deleteare not matched by the final^(POST|PATCH|PUT|DELETE)$guard. Normalize the method once before that comparison.🛡️ Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents