Documentation
¶
Overview ¶
Package networkmatch provides wildcard-aware matchers for the NetworkNeighbor.IPAddresses and NetworkNeighbor.DNSNames profile fields.
It is the runtime counterpart to spec sections §5.7 (IP) and §5.8 (DNS) of the BoB specification (v0.0.2).
See README.md for the wildcard token vocabulary, public API, and performance contract.
Index ¶
Constants ¶
const ( // DNSDynamicLabel is U+22EF — matches exactly one DNS label in // the middle of a pattern (mirror of dynamicpathdetector.DynamicIdentifier). DNSDynamicLabel = "⋯" // DNSWildcardLabel is "*" — matches exactly one label when it's the // LEADING label (RFC 4592), or one or more labels when it's the // TRAILING label (project extension, spec §5.8 row 3). DNSWildcardLabel = "*" )
DNS wildcard tokens. These mirror the path/argv tokens in dynamicpathdetector but apply with DNS-label semantics.
const AnyIPSentinel = "*"
AnyIPSentinel is the profile entry that matches any valid IP address. Equivalent to the union of 0.0.0.0/0 and ::/0. Spec §5.7.
Variables ¶
This section is empty.
Functions ¶
func MatchDNS ¶
MatchDNS is the convenience wrapper. Hot paths SHOULD reuse a compiled *DNSMatcher built once via CompileDNS.
func MatchIP ¶
MatchIP is the convenience wrapper that compiles + matches in one call. Use this only on cold paths; hot paths SHOULD reuse a cached *IPMatcher constructed via CompileIP.
Empty profile or empty observation returns false.
func ValidateDNSEntry ¶
ValidateDNSEntry returns an error describing why entry is not a valid member of a DNSNames[] list, or nil if it is valid.
Valid forms (spec §5.8):
- literal name (with or without trailing dot)
- leading "*" (only as the first label, RFC 4592)
- trailing "*" (only as the last label)
- mid "⋯" (DynamicLabel, anywhere)
Rejected:
- "**" anywhere (recursive — reserved)
- empty inner labels (e.g. "foo..bar")
- "*" in any position other than first or last
- lone "*" with no fixed anchor (degenerate single-label pattern)
func ValidateIPEntry ¶
ValidateIPEntry returns an error describing why entry is not a valid member of an IPAddresses[] list, or nil if it is valid.
Valid forms:
- literal IP (parsed by net.ParseIP)
- CIDR (parsed by net.ParseCIDR)
- the AnyIPSentinel ("*")
This is the admission-time defence; runtime MatchIP also tolerates malformed entries (silently skips them) so a bad write doesn't kill the whole match.
Types ¶
type DNSMatcher ¶
type DNSMatcher struct {
// contains filtered or unexported fields
}
DNSMatcher is the compiled form of a DNS profile. Each entry compiles into one dnsPattern struct.
func CompileDNS ¶
func CompileDNS(profileEntries []string) *DNSMatcher
CompileDNS builds a DNSMatcher from profile entries. Malformed entries (empty, "**", empty inner labels) are silently skipped.
func (*DNSMatcher) Match ¶
func (m *DNSMatcher) Match(observed string) bool
Match reports whether the observed DNS name is admitted by this matcher.
type IPMatcher ¶
type IPMatcher struct {
// contains filtered or unexported fields
}
IPMatcher is the compiled form of an IP profile. Callers in the hot path (CEL functions, runtime rules) build one per profile and reuse it across every observed event for that profile.