Skip to content

Make safe HTTP client options composable - #68

Merged
andrew merged 2 commits into
mainfrom
fix-safe-http-options
Aug 17, 2026
Merged

Make safe HTTP client options composable#68
andrew merged 2 commits into
mainfrom
fix-safe-http-options

Conversation

@andrew

@andrew andrew commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Add per-host private-address allowlists to safehttp.Options and use the shared host-aware gate from fetch. Re-export WithSafeHTTP, WithHTTPClient, and WithTransport from the root package.

Closes #28
Closes #67

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes “safe HTTP” configuration composable across the codebase by moving per-host private-network allowlisting into safehttp.Options, having fetch use the shared host-aware gate logic, and re-exporting client option helpers at the registries package root.

Changes:

  • Add AllowPrivateHosts []string and CheckHostIP to safehttp to allow private-network IPs only for explicitly allowlisted hosts.
  • Update fetch.WithAllowPrivateHosts to populate safehttp.Options and gate resolved IPs via safehttp.CheckHostIP.
  • Re-export WithSafeHTTP, WithHTTPClient, and WithTransport from registries root and add coverage for these root options.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
safehttp/safehttp.go Adds per-host private allowlist support, host-aware IP checks, and host normalization.
safehttp/safehttp_test.go Adds tests covering allowlisted private hosts behavior and redirect refusal to unlisted private targets.
fetch/fetcher.go Switches fetcher gating to safehttp.CheckHostIP and stores allowlist in safehttp.Options.
fetch/fetcher_test.go Updates tests to reflect AllowPrivateHosts storage/composition behavior.
registries.go Re-exports WithSafeHTTP, WithHTTPClient, and WithTransport at the package root.
registries_test.go Adds regression tests ensuring root-level option re-exports behave as expected.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread safehttp/safehttp.go Outdated
Comment thread safehttp/safehttp.go
@andrew
andrew merged commit a36822d into main Aug 17, 2026
5 checks passed
@andrew
andrew deleted the fix-safe-http-options branch August 17, 2026 10:36
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.

safehttp: per-host private-address allowlist Re-export WithSafeHTTP, WithHTTPClient, WithTransport at package root

2 participants