Repository navigation
fix(api): cut the webhook URL and the ref policy op that a refusal quotes - #902
Conversation
…otes Three refusals repeated request text whole, cut only at the 16,384-byte bound of every answer: a 100,000-byte value of `<` made answers of about 196 KB once JSON escaped each byte to six. - POST /webhooks quoted the host of a refused URL, and an IPv6 zone can be any length (`https://[fe80::1%25…]`), or the whole URL when it has no host (`https://:80/…`). - The 403 of a ref policy (a sync create, pull-upstream, push-upstream, completing a pending sync create, PATCH /repo, DELETE /repos/delete) quoted the op of the token. errtext.Quote now quotes one request value for every such answer: a value of more than errtext.MaxQuotedBytes (256) is cut at a character and followed by its length, `"xx…" (100000 bytes)`. It replaces the api helpers quoteValue and the cut of unknownNameText, which did the same, and refPolicyOpDenies builds the six 403 messages. 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: Id2a60a35c0fb612af14b905771b4bff6c293fb7a Signed-off-by: Thomas Kosiewski <tk@coder.com>
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: Ied4ff4cfc72963a1f44b5a5c7583cea54919e420 Signed-off-by: Thomas Kosiewski <tk@coder.com>
handlers_sync.go is covered code: errtext.Quote replaces quoteValue, and refPolicyOpDenies builds the ref policy 403s. 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: I5ef519973d97172f301f048a273ec68f276091b7 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
A ref write (refs and tags), a commit write and a merge refuse a ref policy op that they do not know with a 403 that repeated the op whole (196,556 bytes for an op of 100,000 `<` on a tag create). They now quote it with errtext.Quote, as the other ref policy 403s do. CheckRegistration also cuts the url.Parse error that it adds after the quoted URL, which can repeat part of the URL (an invalid port). Tests pin the refusal of a host that resolves to a denied address, a long resolved host, a URL that does not parse, and a prefix that takes the quote past 256 bytes without cutting it. 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: I2560cee6477552e0975ba0d0f56a38a2ab4be9f4 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Main gained #896 (githttp). The only conflict is the sync commit of the lane-schedule model; the next commit re-records it on the merged tree. 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: I366cda54751e41e91f387d4647f02b1a4dd3e3e1 Signed-off-by: Thomas Kosiewski <tk@coder.com>
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: I08b980735fd8c3695df98c5e72318a685dbc9ac7 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Main gained #896, #901 and #902. #902 dropped the strconv import of handlers_sync.go with quoteValue; this branch's port and IPv4 checks use it, so the merge keeps it. The other conflicts are the lane-schedule fingerprints and sync commit; the next commit re-records them on the merged tree. 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: Ib2c61d6a44b3a74698bce02f2eef91f7fe0568a3 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Three refusals repeated request text whole, cut only at the 16,384-byte bound of every answer. With 100,000 bytes of
<, which JSON escapes to six bytes each, each answered about 196 KB. I measured them with requests against the full API server on main (1922669):POST /webhookswithhttps://[fe80::1%25<100,000 bytes>]/hook(the host's IPv6 zone)POST /webhookswithhttps://:80/<100,000 bytes>(a URL with no host: the whole URL)Now each of these quotes the value with
errtext.Quote: a value of more than 256 bytes is cut at a character and followed by its length in bytes, as #882 cuts an unknown member name and #900 a refused sync value:Changes
errtext.Quote(prefix, v)anderrtext.MaxQuotedBytes(256) (internal/errtext): one helper for every answer that quotes one request value. It replacesquoteValueandmaxQuotedValueBytes(handlers_sync.go) and the cut ofunknownNameTextandmaxUnknownNameBytes(decode_body.go), which did the same.prefixis text of the server (the dotted path of a known field) and is never cut, sounknown field "author.xx…" (1000000 bytes)stays as it is.TargetGuard.CheckRegistration(internal/events/guard.go) quotes the refused host (a literal, or a name that resolves to a denied address), the URL that has no host, and the URL of a parse error. For a parse error it no longer repeatsurl.Error's copy of the URL and cuts the error it adds, which can repeat a part of the URL such as an invalid port;POST /webhooksrefuses such a URL before it gets there. A short host is now quoted too:webhook target "10.0.0.7" denied: private address.refPolicyOpDeniesbuilds the six messages: a sync create, pull-upstream, push-upstream, completing a pending sync create,PATCH /repoandDELETE /repos/delete. A short op reads as before (ref policy op "no-push" denies pull-upstream). The 403 of a ref write (refs and tags), a commit write and a merge for an op that the server does not know quotes it too:unknown policy op "x" for refs/heads/main(it was unquoted in the commit and merge writes,%qin the ref writes; 196,556 bytes for a tag create with an op of 100,000<).CheckHost, the sync twin of the webhook check, is unchanged: since fix(api): refuse sync credentials that the run refuses, and cut quoted sync values #900 a sync host is an IP literal without a zone or a name that resolved, so the hostname it repeats is short.docs/reference/webhooks.md(registration refusals) anddocs/reference/http-api.md(ref policy 403s);internal/errtext/README.md.handlers_sync.gois covered by the lane-schedule model, so its fingerprints are re-recorded.Evidence
TestQuote(internal/errtext): the limit, one byte over, a prefix that is not cut, a cut inside a rune.TestRefusalsQuoteRequestTextBounded(internal/api): the three webhook refusals and the ref policy 403 of a sync create, pull-upstream, push-upstream,PATCH /repoandDELETE /repos/delete, with a long op (the cut answer, at most 8 KiB) and withno-push(unchanged). Completing a pending sync create builds its message with the same helper and has no case of its own (its callers check the same policy first).TestUnknownPolicyOpQuotedBoundedcalls the three unknown-op checks with a long and a short op.TestCheckRegistrationQuotesURLTextBounded(internal/events) pins a resolved host, a long resolved host and a URL that does not parse.guard.go,handlers_sync.go,handlers.goanddecode_body.gooverlaid, every webhook case and every long-op case fails; the short-op cases pass.go test -race -tags=openstorage_viewcheckof./internal/errtext/...(1 s),./internal/events/...(26 s) and./internal/api/...without pg (362 s) pass at 590a0c8. At 78bde2a the api tests of ref policies, ref, commit and merge writes and webhooks (66 s), and./internal/events/...and./internal/errtext/...with-race, pass. PostgreSQL and S3-WAL rely on CI.Reviews
Round 1 (590a0c8): the Codex review and the Codex security review found nothing. A fresh read-only review found one P2: no test pinned the refusal of a host that resolves to a denied address, whose text this PR changes. Its 21 overlay mutants left 5 alive. 78bde2a adds that test and fixes four P3 points: the unknown-op 403s above, a
TestQuotecase where only the prefix takes the text past 256 bytes, the cut of the parse error, and the example inwebhooks.mdnow names its 100,000-byte zone. Left open, older than this PR: other request text that an answer repeats is still cut only at 16,384 bytes (a path filter, a range, a glob,archive.prefix, a notes ref, a strategy, the fork point), and the git hook's ownunknown policy oprefusal goes to git's stderr.Round 2 (78bde2a): the Codex review and the Codex security review found nothing. A fresh read-only review: PASS. It sent the unknown-op requests through the real commit-pack, diff-commit, restore-commit, merge, branch, tag and note routes: each answered a 403 problem body with the exact text, about 3.3 KB for a 100,000-byte op (196,556–196,574 bytes on main). Its 35 overlay mutants left alive only
finishPendingSync's 403, which no request reaches, and three equivalent sites. Two P3 points follow up in the desk's docs PR:internal/errtext/README.mddoes not list the unknown-op callers, and the unit test ofwcCheckRefPolicycould read each route's envelope statuses instead of none.Round 3 (9e9bad3): 6aa76aa merges main (fix(githttp): refuse a ref at an object that no registered pack holds #896); the only conflict was the lane-schedule sync commit, which 9e9bad3 re-records. The Codex review and the Codex security review found nothing, and a fresh read-only review passed: the PR's own diff is unchanged apart from that line, and main's rewrite of
handlers_write_refs.gorefuses an unknown op only through the quotedwrefPolicyCheck.Found by the reviews of #900 (desk follow-up).
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:xhigh