Skip to content

fix(cli): redact Location header in webhook redirect refusal - #5282

Merged
mergify[bot] merged 4 commits into
mvanhorn:mainfrom
Bhumika-1432006:fix/5279-webhook-location-token-leak
Oct 30, 2026
Merged

mergify[bot] merged 4 commits into
mvanhorn:mainfrom
Bhumika-1432006:fix/5279-webhook-location-token-leak

Conversation

@Bhumika-1432006

@Bhumika-1432006 Bhumika-1432006 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Closes #5279

The --deliver webhook:<url> redirect refusal printed the raw Location header verbatim, leaking tokens in the target URL path, query, or userinfo to stderr and CI logs.

Approach

In deliver.go.tmpl, parse the Location header and display only scheme://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.go reflects the new Location-scrubbing block and the added net/url import.

Verification

  • Generator/template change: verified generated output, including emitted-code assertions or compiled generated CLI output
  • Generator/template change: covered the affected fallback or variant shape, not only happy-path fixtures
  • Generator/template change: checked emitted definitions and call sites for matching gates

AI / Automation Disclosure

  • No AI or automation was used
  • Human-reviewed: AI or automation was used, and a human reviewed the work for intent, fit, and obvious issues before submission
  • AI-reviewed only: an AI agent reviewed the work, but no human reviewed it before submission
  • Fully automated: generated and submitted without human review for this specific change

Intent

Closes #5279

--deliver webhook:<url> refuses to follow 3xx redirects. The refusal message now shows only scheme://host of 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 the net/url import. The POST uses RoundTrip so a 3xx is returned as-is; Client.Do parses Location before ErrUseLastResponse and 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

  • Generator/template change: verified generated output, including emitted-code assertions or compiled generated CLI output
  • Generator/template change: covered the affected fallback or variant shape, not only happy-path fixtures
  • Generator/template change: checked emitted definitions and call sites for matching gates

AI / Automation Disclosure

  • No AI or automation was used
  • Human-reviewed: AI or automation was used, and a human reviewed the work for intent, fit, and obvious issues before submission
  • AI-reviewed only: an AI agent reviewed the work, but no human reviewed it before submission
  • Fully automated: generated and submitted without human review for this specific change
Open in WebΒ Open in CursorΒ 

…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>
@mergify

mergify Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Merge Protections

🟒 All 2 merge protections satisfied β€” ready to merge.

Show 2 satisfied protections

🟒 require-ready-label-and-ci

  • #changes-requested-reviews-by = 0
  • #review-threads-unresolved = 0
  • check-success = build-and-test
  • check-success = generated-test
  • check-success = go-lint
  • check-success = golden
  • check-success = pr-title
  • check-success = test
  • any of:
    • label = ready-to-merge
    • all of:
      • head = release-please--branches--main
      • title ~= ^chore\(main\): release
  • any of:
    • -files ~= ^(\.github/workflows/|\.github/scripts/|scripts/|\.github/CODEOWNERS$)
    • approved-reviews-by = mvanhorn
    • approved-reviews-by = tmchow
    • author = mvanhorn
    • author = tmchow
  • any of:
    • check-success = Greptile Review
    • label = queued
    • check-neutral = Greptile Review
    • check-skipped = Greptile Review
    • head ~= ^mergify/merge-queue/
    • all of:
      • head = release-please--branches--main
      • title ~= ^chore\(main\): release

🟒 🚦 Auto-queue

When all merge protections are satisfied and these conditions match, this pull request will be queued automatically.

  • label = ready-to-merge

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable issues remain.

Summary

The PR hides sensitive parts of redirect targets while keeping webhook redirects blocked.

  • Webhook redirect errors hide sensitive parts of the target URL.

Reviews (3) Β· Last reviewed commit: "fix(cli): keep URL userinfo on webhook R..." Β· Reviewed by Greptile

cursoragent and others added 2 commits October 30, 2026 08:22
…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>
@tmchow tmchow added the ready-to-merge Queue when Mergify passes; scripts/.github PRs also need Approve from tmchow/mvanhorn. label Oct 30, 2026
@mergify mergify Bot added the queued PR is in the Mergify merge queue label Oct 30, 2026
@mergify
mergify Bot merged commit 42fde00 into mvanhorn:main Oct 30, 2026
41 of 42 checks passed
@mergify

mergify Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

βœ… Merged into main as 42fde00 at 10:00 UTC

13 min in the queue, 12 min of it CI.

So far

Merge conditions: 13 of 13 met

This pull request

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

@mergify mergify Bot removed the queued PR is in the Mergify merge queue label Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Queue when Mergify passes; scripts/.github PRs also need Approve from tmchow/mvanhorn.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generator: --deliver webhook redirect refusal prints the raw Location header, leaking tokens in the target URL

3 participants