Skip to content

fix(githttp): cut the unknown ref policy op that a push refusal quotes - #906

Open
ThomasK33 wants to merge 2 commits into
mainfrom
hook-unknown-op-quote
Open

ThomasK33 wants to merge 2 commits into
mainfrom
hook-unknown-op-quote

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

The update hook refused a ref policy op that it does not know with unknown policy op %q for <ref>, which repeated the op whole on git's stderr, and git shows that line to the pusher. The op is text of the pusher's token, so it can be as long as one environment entry allows (the hook gets the refs claim in OPENSTORAGE_GIT_REFS_POLICY). The API's ref, commit and merge writes already quote the same op with errtext.Quote since #902.

The hook now quotes it with errtext.Quote too. A short op reads as before; an op over 256 bytes is cut at a character and followed by its length:

unknown policy op "<<<…" (100000 bytes) for refs/heads/main

This is the server's own refusal text, not a pattern that reads git's stderr (AGENTS.md).

Changes

  • evalRefPolicy (internal/githttp/hook.go): the unknown-op refusal quotes the op with errtext.Quote. Every path that refuses an unknown op runs this check: the pre-receive policy gate (the line a push with a pack shows), the --atomic denial and the update hook.
  • internal/errtext/README.md lists the hook as a caller.
  • hook.go is covered by the lane-schedule model, so its fingerprints are re-recorded.

Evidence

  • Test: TestUnknownPolicyOpRefusalQuotedBounded (internal/githttp) calls evalRefPolicy with a 100,000-byte op, no-fly and no"fly, with full evaluation and the budget-free mode. Each must return a refusal that git shows the pusher (ShownToPusher) with the exact text.
  • Red on main: with main's hook.go, the long-op case fails; the short cases pass unchanged.
  • Lanes: go test -race -tags=openstorage_viewcheck of ./internal/githttp/... (835 s) and ./internal/errtext/... (1 s) passes at e5769b0.
  • lint, gofmt, the docs gate and both fingerprint gates pass.

Reviews

  • Round 1 (e5769b0): the Codex review and the Codex security review found nothing. A fresh read-only review: PASS. It pushed with real git and a 60,000-byte op: the pre-receive policy gate printed 684 bytes (60,411 on main), the --atomic denial 706 (60,433) and the update hook 586 (60,313), each still a refusal. A short op prints byte for byte as before. No code parses this text. Its mutants (a 4,096-byte cap, no Refuse, quoting in one evaluation mode only, no length suffix) all failed the test. Left open (P3):
    • The test's header comment says the reservation classifier gives the same refusal; it is evalRefPolicy with fullEval off that does, and the classifier turns it into a reservation denial.
    • update: parse ops claim %q repeats the whole ops claim, but no push reaches it: the server writes that claim with json.Marshal, which always parses back.

Found by the reviews of #902 (desk follow-up).


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh

The update hook refused a ref policy op that it does not know with
`unknown policy op %q for <ref>`, which repeats the op whole on git's
stderr, and git shows that line to the pusher. The op is text of the
pusher's token and can be as long as an environment entry allows. The
ref, commit and merge writes of the API already quote the same op with
errtext.Quote (#902).

The hook now quotes it with errtext.Quote too: an op over 256 bytes is
cut and followed by its length. This is the server's own refusal text,
not a pattern that reads git's stderr.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_

Change-Id: I67245cd17be12a5aaad3b4cf130c2f80326f8c8b
Signed-off-by: Thomas Kosiewski <tk@coder.com>
hook.go is covered code: evalRefPolicy quotes an unknown op with
errtext.Quote.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_

Change-Id: I720e36ba852e4a43db4cc3be6ea393253143f485
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T01:50:28.207443Z e5769b0 Manual request
🔒 Security Review ✅ Completed 2026-11-17T01:52:23.318708Z e5769b0 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: e5769b0fe4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: e5769b0fe4

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

This branch has not been deployed

No deployments
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.

1 participant