httpguard

package
v0.8.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigMapKeyDenyCIDRs is the ConfigMap data key for CIDR/IP denylist lines.
	ConfigMapKeyDenyCIDRs = "denyCIDRs"
	// ConfigMapKeyDenyHosts is the ConfigMap data key for hostname denylist lines.
	ConfigMapKeyDenyHosts = "denyHosts"
)
View Source
const (
	// ConfigTemplateLabel identifies the ConfigTemplate that produced a config.
	ConfigTemplateLabel = "config.oam.dev/type"
	// WorkflowHTTPDenyConfigTemplate is the vela-workflow chart ConfigTemplate
	// name and discovery label value (config.oam.dev/type). vela-core uses its
	// own prefixed default (vela-core-http-deny) so dual install has no shared
	// Helm-owned ConfigTemplate.
	WorkflowHTTPDenyConfigTemplate = "vela-workflow-http-deny"
)

Variables

This section is empty.

Functions

func LoadConfigMaps

func LoadConfigMaps(ctx context.Context, c client.Reader, templateName, namespace string) error

LoadConfigMaps discovers ConfigMaps produced by templateName and atomically installs the union of all deny entries on top of BuiltinDeny. Zero discovered labeled ConfigMaps is allowed and leaves only the builtin floor in effect.

func SecureTransport

func SecureTransport(base *http.Transport, policy Policy) *http.Transport

SecureTransport returns a copy of base with dial-time SSRF validation applied. Every connection, including redirect follows, re-enters the dial hook.

func SetDenyFragment

func SetDenyFragment(fragment Policy)

SetDenyFragment atomically replaces the denylist overlay.

func SetEnhancer

func SetEnhancer(fn PolicyEnhancer)

SetEnhancer registers a hook applied on every Current() call.

func SetupWatcher

func SetupWatcher(mgr manager.Manager, templateName, namespace string) error

SetupWatcher registers a cache-backed ConfigMap watch in the controller namespace. After startup, reload failures keep the last good aggregate.

Types

type Policy

type Policy struct {
	// BlockPrivate denies RFC-1918 and RFC-4193 ULA ranges. Off by default
	// because workflow HTTP steps legitimately call in-cluster ClusterIP services.
	BlockPrivate bool
	// BlockLoopback denies 127.0.0.0/8 and ::1. Off by default.
	BlockLoopback bool
	// DenyCIDRs blocks any destination IP contained in these networks.
	DenyCIDRs []*net.IPNet
	ExactIPs  []net.IP
	// ExactHosts are lower-case hostnames that must be rejected.
	ExactHosts map[string]struct{}
	// WildcardSuffixes are lower-case DNS suffixes without the leading "*."
	// (for example "corp.internal" from "*.corp.internal").
	WildcardSuffixes []string
}

Policy controls which destination hosts and IPs outbound HTTP clients may connect to. Host checks run on the URL before dial; IP checks run at dial time on the resolved address.

func BuiltinDeny

func BuiltinDeny() Policy

BuiltinDeny returns a copy of the immutable denylist floor shipped with the binary. Cluster ConfigMaps can only add denies; they cannot remove these entries. Callers must not rely on mutating the returned Policy.

func Current

func Current() Policy

Current returns DefaultPolicy, then enhancer, then the immutable builtin denylist floor, then any discovered ConfigMap deny overlay.

func DefaultPolicy

func DefaultPolicy() Policy

DefaultPolicy returns the base outbound HTTP policy. Destination deny rules are supplied by discovered workflow HTTP deny ConfigMaps.

func ParseConfigMap

func ParseConfigMap(cm *corev1.ConfigMap) (Policy, error)

ParseConfigMap builds a denylist Policy fragment from a ConfigMap.

func ParseDenyList

func ParseDenyList(cidrsText, hostsText string) (Policy, error)

ParseDenyList parses denyCIDRs and denyHosts text blobs into a Policy fragment that only carries denylist fields. Blank lines and # comments are ignored.

func (Policy) Blocked

func (p Policy) Blocked(ip net.IP) bool

Blocked reports whether ip must be rejected under policy.

func (Policy) BlockedAddress

func (p Policy) BlockedAddress(address string) error

BlockedAddress parses host:port from a dial address and reports whether it is blocked. Non-IP hosts are allowed through; host denylist must be checked separately via BlockedHost before dial.

func (Policy) BlockedHost

func (p Policy) BlockedHost(host string) error

BlockedHost reports whether hostname must be rejected under the denylist. Host may include a port; IP literals are checked against ExactIPs/DenyCIDRs.

func (Policy) MergeDeny

func (p Policy) MergeDeny(other Policy) Policy

MergeDeny overlays denylist CIDRs/hosts from other onto p.

type PolicyEnhancer

type PolicyEnhancer func(Policy) Policy

PolicyEnhancer optionally mutates base policy (for example enabling BlockPrivate from a feature gate) before denylist merge.

Jump to

Keyboard shortcuts

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