Documentation
¶
Overview ¶
Package netguard makes outbound HTTP requests to user-supplied URLs (outgoing webhooks, the audit stream) safe from server-side request forgery: the address is checked after DNS resolution, at connect time, so a hostname can't point at loopback, private, link-local or metadata addresses, and redirects are never followed. Private networks can be allowed explicitly for self-hosted setups (webhooks.allow_private_networks).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBlocked = errors.New("address not allowed")
ErrBlocked is returned when a URL resolves to a forbidden address.
Functions ¶
func SameAddress ¶
SameAddress reports whether two addresses people typed, URLs or host names, are the same place: letter case, surrounding spaces and a final slash or dot don't count. Forms that keep a saved secret when its field is left blank keep it only for the address it was entered for.
Types ¶
type Policy ¶
type Policy struct {
// AllowPrivate allows loopback and RFC 1918 addresses (self-hosted receivers).
AllowPrivate bool
}
Policy decides which addresses may be dialed.
func (Policy) Client ¶
Client returns an HTTP client that refuses forbidden addresses at connect time and never follows redirects.