Documentation
¶
Overview ¶
Package netguard keeps a service's requests to URLs it was handed — a webhook receiver, a push endpoint, a link to preview — off the installation's own network (SSRF).
client := netguard.Client(netguard.Redirects(5)) res, err := client.Do(req) // errors.Is(err, netguard.ErrForbiddenAddress), ErrForbiddenURL
Every request and every redirect hop is https (Hosts when set), and its connection goes only to a public address: checked on the address dialed, after DNS, so a name that resolves inside — or rebinds to it — is refused. Requests go direct: through a proxy the address dialed would be the proxy's. Redirects are not followed unless Redirects allows them. The client's *url.Error names the whole URL: scrub it before logging when the URL may carry a token.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrForbiddenAddress: the destination resolved to an address that is // not public (Forbidden). ErrForbiddenAddress = errors.New("netguard: destination is not a public address") // ErrForbiddenURL: a request or redirect URL that is not https, or whose // host is not among Hosts. ErrForbiddenURL = errors.New("netguard: url is not allowed") // ErrRedirects: more redirects than Redirects allows. ErrRedirects = errors.New("netguard: too many redirects") )
Errors.
Functions ¶
func Allowed ¶
Allowed reports whether host matches hosts: an exact name or *.suffix; never an IP address, zoned ones included.
func Client ¶
Client is an *http.Client over Transport whose every request and redirect is https to an allowed host, traced (OpenTelemetry). Set its Timeout, or use request contexts, to bound a fetch.