Skip to content

feat(transports/http): redact Headers, bound shutdown, fix redirect case#74

Merged
theogravity merged 1 commit into
mainfrom
feat/http-shutdown-and-redaction
May 3, 2026
Merged

feat(transports/http): redact Headers, bound shutdown, fix redirect case#74
theogravity merged 1 commit into
mainfrom
feat/http-shutdown-and-redaction

Conversation

@theogravity
Copy link
Copy Markdown
Contributor

Summary

Security audit follow-up. Three independent fixes in transports/http:

  • Config.String() redacts Headers values so an accidental log.Info(cfg) or fmt.Sprintf("%v", cfg) can't leak Authorization / X-API-Key etc. Mirrors the existing transports/datadog redaction pattern. Header keys stay visible for debuggability.
  • defaultCheckRedirect compares hosts case-insensitively (strings.EqualFold) so legitimate same-host redirects with mixed-case URLs aren't refused. Cross-host refusal still fires; ports are still strict.
  • New Config.ShutdownTimeout (default 5s) bounds Close. Outbound requests now use http.NewRequestWithContext; on a wedged endpoint, Close cancels in-flight requests when the timeout elapses instead of waiting up to Client.Timeout (30s) per pending batch. Queued-but-unsent entries surface via OnError as context.Canceled.

Test plan

  • go test -race -count=1 ./... passes for transports/http, transports/datadog, transports/central (every module that imports transports/http)
  • gofmt -l and go vet clean
  • New TestHTTP_CloseBoundedByShutdownTimeout confirms the bound is enforced (~100ms vs the previous 30s worst-case)
  • New TestHTTP_ConfigStringRedactsHeaders and TestDatadog_ConfigHTTPHeadersRedacted cover both the http transport directly and the realistic downstream wrapper credential-leak surface
  • New TestDefaultCheckRedirectCaseInsensitive covers the redirect change (5 subtests: same/different case, with/without port, cross-host, different-port)
  • Lefthook pre-push (foreach-module test-race + tidy) passes

🤖 Generated with Claude Code

Security audit follow-up. Three independent fixes:

- Config.String() redacts Headers values so an accidental log.Info(cfg)
  or fmt.Sprintf("%v", cfg) can't leak Authorization / X-API-Key.
  Mirrors the existing transports/datadog redaction pattern.

- defaultCheckRedirect compares hosts case-insensitively so legitimate
  same-host redirects with mixed-case URLs aren't refused. Cross-host
  refusal still fires; ports are still strict.

- New Config.ShutdownTimeout (default 5s) bounds Close. Outbound
  requests now use http.NewRequestWithContext; on a wedged endpoint
  Close cancels in-flight requests when the timeout elapses instead
  of waiting up to Client.Timeout (30s) per pending batch. Queued-
  but-unsent entries surface via OnError as context.Canceled.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@theogravity theogravity enabled auto-merge (squash) May 3, 2026 03:26
@theogravity theogravity merged commit 76cde21 into main May 3, 2026
13 checks passed
@theogravity theogravity deleted the feat/http-shutdown-and-redaction branch May 3, 2026 03:28
theogravity added a commit that referenced this pull request May 3, 2026
monorel v0.12+ runs `go mod tidy` per sub-module as part of `pr` and
`release` to refresh go.sum entries. Every sub-module's go.mod
requires `go 1.25.0`, but the GitHub runner default is older and the
monorel CI action sets GOTOOLCHAIN=local, so the toolchain doesn't
auto-upgrade. The tidy step then fails with:

  go: go.mod requires go >= 1.25.0 (running go 1.24.13;
      GOTOOLCHAIN=local)

This bit the release-pr workflow when it ran on PR #76's merge commit
because monorel's `latest` tag had moved past v0.11.0 between PR #74's
release (v0.10.x) and PR #76's release (v0.13.0). The action version is
pinned (`@v0.11.0`), but the action invokes the binary under `latest`.

Add an `actions/setup-go@v5` step with `go-version: '1.25'` before the
monorel invocation in both release-pr.yml and release.yml. Mirrors the
setup-go pattern that ci.yml already uses for the regular CI matrix.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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