safehttp

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package safehttp provides an HTTP client hardened against SSRF, for fetching attacker-influenced URLs (CIMD documents, JWKS, MCP upstreams). It refuses to connect to loopback, private, link-local, or unspecified addresses — checked on the *resolved* IP and pinned for the dial, which defeats DNS-rebinding — allows only https, and bounds redirects, time, and response size.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(allowLoopback bool) *http.Client

Client builds an SSRF-hardened http.Client. allowLoopback permits connections to loopback addresses (for tests / local dev only).

func GetJSON

func GetJSON(ctx context.Context, client *http.Client, url string, v any, maxBytes int64) error

GetJSON fetches url with the hardened client and decodes the JSON body into v. Only https URLs are accepted, and the body is capped at maxBytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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