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 instance metadata endpoint 169.254.169.254 — multicast, and AWS's reserved prefix for instance metadata over IPv6.
Private RFC1918/ULA space is deliberately NOT rejected. Warehouses reached over AWS PrivateLink resolve to a private address in the customer's VPC, so rejecting private space would break every such connection. Those ranges are customer-chosen and can overlap our own, which means they cannot be told apart from in-cluster addresses by inspecting the IP alone — blocking in-cluster services needs an operator-supplied CIDR list instead, which is tracked separately.
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, multicast and unspecified addresses stay rejected, so this cannot be used to reach cloud metadata.