Skip to content

Refuse protected branch writes through the GitHub API (T41) - #198

Merged
erickb336 merged 12 commits into
mainfrom
codex/t41-github-main-api
Oct 13, 2026
Merged

erickb336 merged 12 commits into
mainfrom
codex/t41-github-main-api

Conversation

@erickb336

@erickb336 erickb336 commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

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:

  • npm run build: passed.
  • npm run check: all checks pass (3 timing bounds carry a timing-ok annotation).
  • node --test --test-name-pattern='T41|shared merge and push extraction' scripts/providers.test.mjs: 4 passed, 0 failed. These checks cover both bundles, hook decisions, and existing merge and push behavior.
  • Detached main at 5e324e7 with the new test: 0 passed, 1 failed. The real behavioral failure is that a PATCH to heads/main returns no refusal.

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.

@erickb336
erickb336 marked this pull request as ready for review October 13, 2026 18:45
@erickb336
erickb336 merged commit 29af916 into main Oct 13, 2026
1 check passed
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.

Refuse GitHub API writes to protected branches in shared policy (T41)

1 participant