Repository navigation
Refuse protected branch writes through the GitHub API (T41) - #198
Merged
Merged
Conversation
erickb336
marked this pull request as ready for review
October 13, 2026 18:45
This was referenced Oct 13, 2026
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.
Closes #197
Sage task T41
This change addresses GitHub API writes to main and master through REST and GraphQL branch operations. It is the independent API-policy part of #99; its logbook-writer part stays open. Local checks, CI, and two review cycles are complete.
The policy reads request fields separately from display options and filenames. It refuses unknown destination fields and opaque bodies on protected routes. GraphQL checks account for comments and ignored commas. A GraphQL ref id does not prove a task branch, so ref updates and deletions require the reviewed PR path. Bundled flags such as -iX PATCH retain their value ownership.
Limit: the shell reader does not retain whether single quotes protected a dollar sign or question mark. This policy therefore refuses GraphQL query text with dollar signs or backticks, including literal GraphQL variables, and REST writes with query strings in the endpoint. Use a literal query without variables and put REST write parameters in field flags. It also refuses file-supplied GraphQL queries. Ordinary literal read queries and REST GET query strings pass. Bracketed field keys are refused for GraphQL and protected REST write routes because gh interprets them as structured keys.
Source changes are in packages/sage-core/push-policy.mjs. Both plugins receive generated copies. No Claude hook or PR #140 source files changed.
Validation so far:
All test commands use fake ps, pgrep and kill first on PATH. Attack text reaches only the parser or hook handler.
Final head ed4cb8f passed two clean code, security, and QA review cycles. The reviewers checked the complete change after the last repair. All reviewer checks used parser inputs, not live API writes.
All owned local test and review processes finished. Installed automatic Sage and live API writes were not tested.
Not in scope: #99's logbook writers and sandbox protection, #97's program-name and PowerShell gaps, native automatic Codex activation, or live API writes. This PR makes no claim that the sandbox protects logbook paths today. No owner decision is needed.