httpx

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package httpx is the outbound HTTP layer for everything the scanner fetches: MCP endpoints, package registries, vulnerability data and model providers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndpointSchemes

func EndpointSchemes(allowInsecure bool) []string

EndpointSchemes is https only unless the operator allowed an insecure endpoint. A third-party endpoint receives the API key on every request, so plain http would send it, and the declared MCP surface being inspected, in the clear.

func SameOrigin

func SameOrigin(a, b *url.URL) bool

SameOrigin compares scheme and host, treating a missing port as the scheme's default

func SameOriginRedirect

func SameOriginRedirect(req *http.Request, via []*http.Request) error

SameOriginRedirect refuses a redirect that changes scheme or host

func UnsafeIP

func UnsafeIP(ip net.IP) bool

UnsafeIP reports whether an address is one the scanner refuses by default

Types

type ErrBlocked

type ErrBlocked struct {
	Addr string
	IP   net.IP
}

ErrBlocked is returned by the dial guard

func (*ErrBlocked) Error

func (e *ErrBlocked) Error() string

type Policy

type Policy struct {
	// AllowPrivateNetworks permits loopback, link-local and private-range
	// destinations. Off by default: the scanner is pointed at things the
	// operator does not trust, and the interesting target for a hostile
	// server is the network the scanner runs on.
	AllowPrivateNetworks bool

	// AllowedSchemes defaults to https and http
	AllowedSchemes []string
}

Policy decides which destinations the scanner may reach

func DefaultPolicy

func DefaultPolicy() Policy

DefaultPolicy blocks private destinations and allows only http and https

func (Policy) CheckURL

func (p Policy) CheckURL(raw string) error

CheckURL rejects a URL on its scheme and, when the host is a literal address, on the address itself. It is only a fast preflight check; the dial guard is the SSRF boundary because it checks the address actually selected after DNS resolution.

func (Policy) Client

func (p Policy) Client(timeout time.Duration) *http.Client

Client builds a guarded http.Client.

Redirects are held to the origin the request started from. A server the scanner does not trust has no legitimate reason to bounce it to another host, and following one is how a credential ends up somewhere it was never meant to go.

func (Policy) Dialer

func (p Policy) Dialer(timeout time.Duration) *net.Dialer

Dialer returns a dialer that refuses to connect to a blocked address.

Control runs after the name has been resolved and before the socket connects, on the address the kernel is about to use, so a name that answers differently on a second lookup gains nothing.

func (Policy) Transport

func (p Policy) Transport(timeout time.Duration) *http.Transport

Transport builds a guarded http.Transport

Jump to

Keyboard shortcuts

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