Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateHost ¶
func ValidateHost(hostname string, opts ...HostValidationOption) error
ValidateHost checks that the hostname is resolvable and that none of the addresses it resolves to are ones a warehouse connection should ever reach.
Rejected: unspecified (0.0.0.0, ::), loopback, link-local — which covers the cloud instance metadata endpoint 169.254.169.254 — multicast, and private RFC1918/ULA space, which is how in-cluster services are addressed.
Note this cannot defend against DNS rebinding: the address checked here is not necessarily the address dialled later. It raises the bar for a caller-supplied host without claiming to close that gap.
Types ¶
type HostValidationOption ¶ added in v1.30.0
type HostValidationOption func(*hostValidationOptions)
HostValidationOption customises ValidateHost.
func AllowLoopback ¶ added in v1.30.0
func AllowLoopback(allow bool) HostValidationOption
AllowLoopback permits hosts that resolve to loopback addresses when allow is true, and is a no-op otherwise, so callers can pass a flag through directly.
Intended only for tests that run against a database in a local container. It deliberately relaxes nothing else: link-local, private and unspecified addresses stay rejected, so this cannot be used to reach cloud metadata or in-cluster services.