Repository navigation
fix(cli): redact Location header in webhook redirect refusal - #5282
Merged
mergify[bot] merged 4 commits intoOct 30, 2026
Merged
mergify[bot] merged 4 commits into
mergify[bot] merged 4 commits into
Conversation
β¦n#5279) The redirect refusal in deliver.go.tmpl printed the raw Location header, leaking tokens in the target URL to stderr and CI logs. Now display only scheme://host of the target. Use (redacted) when the value is relative or unparsable, and keep empty-string output for an absent Location header. The refusal behaviour is unchanged. Signed-off-by: Bhumika-1432006 <guravbhumika808@gmail.com>
Contributor
Merge Protectionsπ’ All 2 merge protections satisfied β ready to merge. Show 2 satisfied protectionsπ’ require-ready-label-and-ci
π’ π¦ Auto-queueWhen all merge protections are satisfied and these conditions match, this pull request will be queued automatically.
|
Contributor
[Low impact] The PR appears safe to merge; no actionable issues remain. SummaryThe PR hides sensitive parts of redirect targets while keeping webhook redirects blocked.
Reviews (3) Β· Last reviewed commit: "fix(cli): keep URL userinfo on webhook R..." Β· Reviewed by Greptile |
β¦tion-token-leak Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
deliverWebhook named its parameter url, which hid net/url and broke every generated build. Rename it, return the 3xx from RoundTrip so an unparsable Location is not copied into the client error, and show scheme://host or (redacted). The emitted tests cover userinfo, path, query, relative, and malformed values, and an empty Location still prints "". Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
Client.Do copies URL userinfo into Authorization before the transport runs. RoundTrip does not, so copy it with SetBasicAuth first and cover that header in the emitted webhook test. Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
Closed
56 of 96 tasks
Contributor
β
Merged into
|
| Condition | Required by | |
|---|---|---|
| β | github-review-approved |
GitHub branch protection |
| β | #changes-requested-reviews-by = 0 |
Merge Protections rule require-ready-label-and-ci |
| β | #review-threads-unresolved = 0 |
Merge Protections rule require-ready-label-and-ci |
| β | any of: label = ready-to-merge, (all of: head = release-please--branches--main, title ~= ^chore\(main\): release) |
Merge Protections rule require-ready-label-and-ci |
The batch, tested on draft #5293
| Condition | Required by | |
|---|---|---|
| β | check-success = build-and-test |
Merge Protections rule require-ready-label-and-ci |
| β | check-success = generated-test |
Merge Protections rule require-ready-label-and-ci |
| β | check-success = go-lint |
Merge Protections rule require-ready-label-and-ci |
| β | check-success = golden |
Merge Protections rule require-ready-label-and-ci |
| β | check-success = test |
Merge Protections rule require-ready-label-and-ci |
| β | check-success = pr-title |
Merge Protections rule require-ready-label-and-ci |
| β | any of: -files ~= ^(\.github/workflows/|\.github/scripts/|scripts/|\.github/CODEOWNERS$), approved-reviews-by = mvanhorn, approved-reviews-by = tmchow, author = mvanhorn, author = tmchow |
Merge Protections rule require-ready-label-and-ci |
| β | any of: label = queued, check-neutral = Greptile Review, check-skipped = Greptile Review, check-success = Greptile Review, head ~= ^mergify/merge-queue/, (all of: head = release-please--branches--main, title ~= ^chore\(main\): release) |
Merge Protections rule require-ready-label-and-ci |
| β | any of: check-neutral = Mergify Merge Protections, check-skipped = Mergify Merge Protections, check-success = Mergify Merge Protections |
GitHub branch protection |
Times in UTC Β· dashboard Β· how the merge queue works
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.
Intent
Closes #5279
The
--deliver webhook:<url>redirect refusal printed the rawLocationheader verbatim, leaking tokens in the target URL path, query, or userinfo to stderr and CI logs.Approach
In
deliver.go.tmpl, parse theLocationheader and display onlyscheme://host. Use"(redacted)"for relative or unparsable values, and""for an absent header. The refusal behaviour (refusing to follow the redirect) is unchanged. Updated the matching golden fixture.Scope
Primary area: generator template (
deliver.go.tmpl)Why this belongs in this repo: the line is emitted into every printed CLI, so the fix must be in the template.
Risk
Low. The only change is the text of the redirect-refusal error message. Redirect responses are refused in all cases β the code path and exit behaviour are unchanged.
Output Contract
Golden fixture updated:
testdata/golden/expected/generate-golden-api/printing-press-golden/internal/cli/deliver.goreflects the new Location-scrubbing block and the addednet/urlimport.Verification
AI / Automation Disclosure
Intent
Closes #5279
--deliver webhook:<url>refuses to follow 3xx redirects. The refusal message now shows onlyscheme://hostof the redirect target,(redacted)for relative or unparsable values, and""when the Location header is empty. The refusal itself is unchanged.Approach
In
deliver.go.tmpl, parse the Location header and format that display string. The webhook helper's parameter was renamed so it does not hide thenet/urlimport. The POST usesRoundTripso a 3xx is returned as-is;Client.Doparses Location beforeErrUseLastResponseand includes the raw header in that error. Emitted tests cover userinfo, path, query, relative, scheme-relative, and malformed values, and the empty-header case still expects"".Scope
Primary area: generator template (
deliver.go.tmpl)Why this belongs in this repo: the line is emitted into every printed CLI, so the fix must be in the template.
Risk
Low. Redirect responses are still refused. The change is the text of the refusal and the single-request transport used to read that response.
Output Contract
Golden fixture updated:
testdata/golden/expected/generate-golden-api/printing-press-golden/internal/cli/deliver.go.Verification
AI / Automation Disclosure