httputil

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package httputil provides security-hardened HTTP utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NoRedirectClient

func NoRedirectClient(timeout time.Duration) *http.Client

NoRedirectClient returns an *http.Client that:

  • never follows redirects (prevents token/credential leakage to redirect targets)
  • enforces SSRF protection at DIAL time: every TCP connection's resolved IP is re-checked against the private/internal blocklist, closing the DNS-rebinding / TOCTOU window between URL validation and the actual request
  • has the supplied timeout (default 15s)

Use for outbound requests where the destination is partially or fully operator/user-controlled (callbacks, SIEM exports, secrets backends).

func ValidatePublicURL

func ValidatePublicURL(rawURL string, requireHTTPS bool) error

ValidatePublicURL checks that rawURL:

  1. Parses successfully
  2. Uses http or https scheme
  3. Has a non-empty host
  4. Does not resolve to a loopback, link-local (169.254.x.x / fe80::/10), or private (RFC 1918 / RFC 4193) address — blocks SSRF to IMDS, Redis, Vault, etc.

Pass requireHTTPS=true to additionally reject plain http:// URLs.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL