Documentation
¶
Overview ¶
Package analysis provides canonical types for security analysis findings and shared analysis functions (detection, statistics, rule comparison) used across the audit, compliance, and converter packages.
Index ¶
- Constants
- func ComputeAnalysis(cfg *common.CommonDevice) *common.Analysis
- func ComputeConfigComplexity(stats *common.Statistics) int
- func ComputeSecurityScore(cfg *common.CommonDevice, stats *common.Statistics) int
- func ComputeStatistics(cfg *common.CommonDevice) *common.Statistics
- func ComputeTotalConfigItems(stats *common.Statistics) int
- func DetectConsistency(cfg *common.CommonDevice) []common.ConsistencyFinding
- func DetectDeadRules(cfg *common.CommonDevice) []common.DeadRuleFinding
- func DetectPerformanceIssues(cfg *common.CommonDevice) []common.PerformanceFinding
- func DetectSecurityIssues(cfg *common.CommonDevice) []common.SecurityFinding
- func DetectShadowedRules(cfg *common.CommonDevice) []common.ShadowedRuleFinding
- func DetectUnusedInterfaces(cfg *common.CommonDevice) []common.UnusedInterfaceFinding
- func DetectUnusedObjects(cfg *common.CommonDevice) []common.UnusedObjectFinding
- func FindDHCPScope(scopes []common.DHCPScope, ifaceName string) *common.DHCPScope
- func FindInterface(interfaces []common.Interface, name string) *common.Interface
- func IsAnyAddress(addr string) bool
- func IsAnyEndpoint(ep common.RuleEndpoint) bool
- func IsAnyPort(port string) bool
- func IsAnyProtocol(proto string) bool
- func IsValidConfidence(c Confidence) bool
- func IsValidSeverity(s Severity) bool
- func IsWANInterfaceName(name string) bool
- func IsWideOpenPassRule(rule common.FirewallRule) bool
- func ParsePrefixOrAddr(s string) (netip.Prefix, error)
- func ReachableObjects(objects common.NamedObjects, roots []string) map[string]bool
- func RedactServiceDetails(details []common.ServiceStatistics) ([]common.ServiceStatistics, bool)
- func RulePortPermits(rulePort string, servicePort int) bool
- func RulesEquivalent(a, b common.FirewallRule) bool
- type Confidence
- type Coverage
- type Finding
- type IndexedRule
- type Observation
- type PrecedencePair
- type Reachability
- type Severity
Constants ¶
const ServiceNameSNMP = "SNMP Daemon"
ServiceNameSNMP is the display name for the SNMP service in statistics.
Variables ¶
This section is empty.
Functions ¶
func ComputeAnalysis ¶
func ComputeAnalysis(cfg *common.CommonDevice) *common.Analysis
ComputeAnalysis performs lightweight analysis of the device configuration and returns an Analysis suitable for serialization in JSON/YAML exports. The returned Analysis is derived purely from cfg with no side effects. A nil cfg returns an empty Analysis.
func ComputeConfigComplexity ¶
func ComputeConfigComplexity(stats *common.Statistics) int
ComputeConfigComplexity returns a normalized complexity score for the configuration based on weighted counts of various configuration elements. Returns 0 when stats is nil.
func ComputeSecurityScore ¶
func ComputeSecurityScore(cfg *common.CommonDevice, stats *common.Statistics) int
ComputeSecurityScore returns a security score based on detected security features, firewall rules, HTTPS Web GUI usage, SSH group configuration, and IDS/IPS enablement. The score is capped at MaxSecurityScore. Returns 0 when cfg or stats is nil.
func ComputeStatistics ¶
func ComputeStatistics(cfg *common.CommonDevice) *common.Statistics
ComputeStatistics analyzes a device configuration and returns aggregated statistics using the common.Statistics type suitable for serialization in JSON/YAML exports. A nil cfg returns an initialized but empty Statistics.
func ComputeTotalConfigItems ¶
func ComputeTotalConfigItems(stats *common.Statistics) int
ComputeTotalConfigItems calculates the total number of configuration items by summing interfaces, rules, users, groups, services, gateways, sysctl, DHCP, load balancer, VLANs, bridges, certificates, and CAs.
func DetectConsistency ¶
func DetectConsistency(cfg *common.CommonDevice) []common.ConsistencyFinding
DetectConsistency detects configuration consistency issues. Returns nil when no consistency issues are found.
func DetectDeadRules ¶
func DetectDeadRules(cfg *common.CommonDevice) []common.DeadRuleFinding
DetectDeadRules detects unreachable and duplicate firewall rules. It is a compatibility view *derived* from the shared shadow-detection core (ADR-0004, R16): the unreachable-plus-duplicate subset of DetectShadowedRules, re-projected into the legacy DeadRuleFinding shape and legacy per-interface, raw-list-position ordering. Each finding carries a Kind field ("unreachable" or "duplicate") for structured classification. Returns nil when no dead rules are found.
The shadow core groups rules by (interface, direction) in pf evaluation order and keeps a disabled rule from winning (internal/analysis/precedence.go), but the pre-existing DetectDeadRules output — pinned byte-for-byte by this file's test suite — buckets by interface name only and orders by raw per-interface list position, with no notion of direction, quick, or floating rules, and lets a disabled rule own a finding. normalizeForDeadRuleView collapses the shadow core's grouping back down to that legacy shape before calling DetectShadowedRules; the flatten loop below then re-projects the filtered result using the *original* rules' interface bindings and positions so output ordering is unchanged.
That contract covers what this function does with the rules it is given. RulesEquivalent compares them as converted, so a converter that changes a field it reads, as the pfSense Quick and Direction readings and each vendor's Disabled reading do, changes what counts as a duplicate (GOTCHAS 23.2).
func DetectPerformanceIssues ¶
func DetectPerformanceIssues(cfg *common.CommonDevice) []common.PerformanceFinding
DetectPerformanceIssues detects performance configuration issues. Returns nil when no performance issues are found.
func DetectSecurityIssues ¶
func DetectSecurityIssues(cfg *common.CommonDevice) []common.SecurityFinding
DetectSecurityIssues detects security configuration issues. Returns nil when no security issues are found.
func DetectShadowedRules ¶ added in v1.7.0
func DetectShadowedRules(cfg *common.CommonDevice) []common.ShadowedRuleFinding
DetectShadowedRules reports firewall rules — or subsets of their traffic — that never take effect because a higher-precedence rule under pf evaluation semantics (quick first-match, non-quick last-match, floating rules ahead of interface rules, device-wide when unscoped) already covers them (R5-R7, R9, R12-R15).
DetectShadowedRules is a pure function of cfg: no shared state, mirroring every other Detect* in this package. Returns nil for a nil cfg or fewer than two firewall rules.
func DetectUnusedInterfaces ¶
func DetectUnusedInterfaces(cfg *common.CommonDevice) []common.UnusedInterfaceFinding
DetectUnusedInterfaces detects enabled interfaces not referenced by firewall rules, DHCP scopes, DNS resolvers (Unbound/DNSMasq), OpenVPN instances, WireGuard, or the load balancer. DNS, WireGuard, and load balancer currently assume "lan" binding when enabled — this is a known limitation when these services are bound to non-LAN interfaces. Returns nil when no unused interfaces are found.
func DetectUnusedObjects ¶ added in v1.7.0
func DetectUnusedObjects(cfg *common.CommonDevice) []common.UnusedObjectFinding
DetectUnusedObjects reports named objects (aliases) that are defined in cfg but not referenced by any policy (issue #203). It is framed as graph reachability from policy roots: nodes are cfg.NamedObjects entries, an edge runs from an object to each member that names another object, and roots are every live ObjectRef on a Tracked policy surface (the Surface Audit / KTD-3 root sites). Any object not reachable from a root is unused.
DetectUnusedObjects is a pure function of cfg: no shared state, mirroring every other Detect* in this package. Returns nil for a nil cfg or an empty NamedObjects registry. Output is sorted by object name for deterministic rendering (GOTCHAS §3.1).
func FindDHCPScope ¶
FindDHCPScope returns the DHCP scope for the given interface, or nil if not found.
func FindInterface ¶
FindInterface returns the interface with the given name, or nil if not found.
func IsAnyAddress ¶ added in v1.7.3
IsAnyAddress reports whether an endpoint address matches every host.
Four spellings mean the same thing in a pf ruleset, and all four reach the common model:
- "any", which the converters normalize <any/> and <network>any</network> to
- any casing of it, since the vendor XML is not case-normalized
- the empty string, produced by an omitted or empty <source>/<destination> element; a rule with no source matches every source
- the wildcard CIDRs 0.0.0.0/0 and ::/0
Comparing against the "any" literal alone classifies the other three as a specific host, so a pass rule matching all traffic reads as scoped and the checks that exist to catch exactly that rule report compliant.
This tests an address spelling only. Callers holding a common.RuleEndpoint want IsAnyEndpoint, which also accounts for an inverted match. It is deliberately not used by the overlap engine in overlap.go, which does real CIDR containment: there, treating 0.0.0.0/0 as an unconditional wildcard would make it cover IPv6 targets it cannot match.
func IsAnyEndpoint ¶ added in v1.7.3
func IsAnyEndpoint(ep common.RuleEndpoint) bool
IsAnyEndpoint reports whether an endpoint matches every host.
This is the endpoint-level predicate, and it is the one audit checks want. IsAnyAddress answers only whether an address string is a wildcard spelling; an endpoint additionally carries Negated, and a negated endpoint matches the complement of what its address names. A negated 0.0.0.0/0 or ::/0 therefore matches nothing at all, so classifying it by address alone turns a rule that passes no traffic into a highest-severity wide-open finding.
A negated any still matches every host. Neither firewall inverts any: OPNsense adds "!" only to an address that is set and is not any (Rule.php mapAddressInfo), and pfSense emits a plain any for <any/> (filter.inc filter_generate_address). A negated endpoint with no address counts as any too. OPNsense reads it as any (Rule.php legacyMoveAddressFields), while pfSense skips a rule whose endpoint is empty or names any as a network or address, so any is the conservative reading, as it already is for those endpoints without the flag.
Negated inverts the address only. The vendor schema carries <not> beside the address fields and pfSense presents it as an invert-match toggle on the address, so port and protocol predicates are unaffected by it.
overlap.go and rules.go already account for Negated; routing the checks through this keeps the audit path consistent with them rather than letting the two disagree about what a rule means.
A negated address list counts as any as well. OPNsense negates each entry of a list on its own and matches each result, so the list matches every address outside the entries' overlap, which is every address when they do not overlap (GOTCHAS 3.8). It counts as any here, where reading it too broadly is the safe error; the overlap engine reads Negated and does not rely on it.
func IsAnyPort ¶ added in v1.7.3
IsAnyPort reports whether an endpoint port specification matches every port. An empty port is the common shape; "any" appears in hand-written and API-created rules.
func IsAnyProtocol ¶ added in v1.7.3
IsAnyProtocol reports whether a rule's protocol field matches every layer-4 protocol. An empty protocol is the common shape; "any" appears in hand-written and API-created rules.
func IsValidConfidence ¶ added in v1.7.0
func IsValidConfidence(c Confidence) bool
IsValidConfidence checks whether the given confidence is a recognized value.
func IsValidSeverity ¶
IsValidSeverity checks whether the given severity is a recognized value.
func IsWANInterfaceName ¶ added in v1.7.0
IsWANInterfaceName reports whether name is a WAN-style interface name, using case-insensitive "wan" prefix matching (e.g. "wan", "WAN", "wan2").
This is the single canonical WAN-interface-name predicate in the codebase. internal/plugins/sans, internal/plugins/firewall, and the rest of internal/analysis all route through this function instead of reimplementing the check — see GOTCHAS.md and the reachability consolidation history for why the two previously-divergent exact-match sites in this package were bugs, not just duplication.
Known limitation: detection is name-prefix-only. A secondary internet uplink left with its default logical name (e.g. "opt1") rather than renamed to a "wan"-prefixed name is classified LAN-only, so a service exposed on it can be under-reported. Closing this requires consulting gateway/default-route signals (common.Gateway.Interface) and is tracked as follow-up work, not addressed by this consolidation.
func IsWideOpenPassRule ¶ added in v1.7.3
func IsWideOpenPassRule(rule common.FirewallRule) bool
IsWideOpenPassRule reports whether rule is an enabled pass rule whose source, destination, port and protocol all match everything. Such a rule passes all traffic on the interfaces it applies to.
func ParsePrefixOrAddr ¶ added in v1.9.0
ParsePrefixOrAddr parses s as a CIDR prefix, or — if s has no "/" — as a single host address represented as a maximally-specific prefix (a /32 for IPv4, a /128 for IPv6).
func ReachableObjects ¶ added in v1.9.0
func ReachableObjects(objects common.NamedObjects, roots []string) map[string]bool
ReachableObjects returns the names in objects reachable from roots via member→object edges. A root that names no object contributes nothing.
The edge predicate is deliberately NOT resolveNode's member walk (KTD-2): resolveNode early-returns for isDynamic types (everything but host/network/ port), so mirroring it would drop every edge out of a "networkgroup"-typed group and falsely flag its nested members as unused. Reachability only cares whether a member names another object, never whether the object's members expand into literal addresses — so this walk has no isDynamic gate. It is still correct for genuinely opaque types (url/geoip/external): their members are URLs and country codes, which do not key into the registry and so contribute no edges without needing a type check.
func RedactServiceDetails ¶ added in v1.6.0
func RedactServiceDetails(details []common.ServiceStatistics) ([]common.ServiceStatistics, bool)
RedactServiceDetails returns a copy of details whose sensitive SNMP detail values are replaced with the redaction marker, plus a flag indicating whether any redaction was applied.
The input is never mutated. When at least one SNMP entry carries a non-empty sensitive key the slice is cloned and only the affected per-element Details maps are cloned (clone-on-write); the second return is true. When nothing matches, the input slice is returned unchanged and the second return is false, letting non-mutating callers (e.g. the converter's memoized Statistics) skip allocating a new container.
Every matching SNMP entry is redacted — not just the first — and every key in snmpSensitiveDetailKeys is redacted on each match. analysis.ComputeStatistics emits a single SNMP entry with a single sensitive key today, but a future schema change could surface multiple; leaving any in cleartext would be a security regression.
func RulePortPermits ¶ added in v1.9.0
RulePortPermits reports whether a rule's destination or external port permits traffic to the numeric service port.
An empty or "any" rule port permits every port. Otherwise the rule port is a comma-separated list whose entries are each a numeric port or a numeric "N-M" range, matched exactly or by containment. A token that is neither, a port alias or a malformed range, cannot be resolved here, so it is treated as permitting the port: the over-report direction, since a false negative in a security audit is worse than a false positive (GOTCHAS 8.4).
func RulesEquivalent ¶
func RulesEquivalent(a, b common.FirewallRule) bool
RulesEquivalent checks if two firewall rules are functionally equivalent. Interface order is normalized before comparison so that ["wan","lan"] and ["lan","wan"] are treated as equivalent. Metadata fields (Description, etc.) are intentionally excluded from comparison. A disabled rule is not equivalent to an enabled rule.
Types ¶
type Confidence ¶ added in v1.7.0
type Confidence string
Confidence represents how confident the shared detection engine is that an Observation reflects a real, actionable condition. Confidence never gates whether an observation is surfaced — every match is reported regardless of its confidence label; confidence is presentation metadata only.
const ( // ConfidenceHigh indicates a deterministic, low-false-positive detection. ConfidenceHigh Confidence = "high" // ConfidenceMedium indicates a detection with plausible false positives. ConfidenceMedium Confidence = "medium" // ConfidenceLow indicates a heuristic detection with a higher false-positive rate. ConfidenceLow Confidence = "low" )
Confidence level constants define the three-level confidence scale shared by observations, blue hygiene findings, and red findings.
func ValidConfidences ¶ added in v1.7.0
func ValidConfidences() []Confidence
ValidConfidences returns a fresh copy of all valid confidence values. Returns a new slice each call to prevent callers from mutating shared state.
func (Confidence) String ¶ added in v1.7.0
func (c Confidence) String() string
String returns the string representation of the confidence level.
type Coverage ¶ added in v1.7.0
type Coverage int
Coverage classifies how completely an earlier firewall rule's match set covers a later rule's match set, on a single dimension or for a whole rule pair. See coverage for the combining rules across dimensions.
const ( // CoverNone indicates the earlier rule does not overlap the later rule // at all on this dimension (or, once combined, on the whole rule). CoverNone Coverage = iota // CoverPartial indicates the earlier rule overlaps some, but not all, // of the later rule's match set. CoverPartial // CoverFull indicates the earlier rule's match set fully contains the // later rule's match set. CoverFull // CoverIndeterminate indicates negation makes the overlap relationship // impossible to determine with confidence; callers must not report a // finding for this result (R10). CoverIndeterminate )
Recognized Coverage values.
type Finding ¶
type Finding struct {
// Type categorizes the finding (e.g., "security", "performance", "compliance").
Type string `json:"type"`
// Severity indicates the severity level of the finding.
Severity string `json:"severity,omitempty"`
// Title is a brief description of the finding.
Title string `json:"title"`
// Description provides detailed information about the finding.
Description string `json:"description"`
// Recommendation suggests how to address the finding.
Recommendation string `json:"recommendation"`
// Component identifies the configuration component involved.
Component string `json:"component"`
// Reference provides additional information or documentation links.
Reference string `json:"reference"`
// Generic references and metadata
// References contains related standard or control identifiers.
References []string `json:"references,omitempty"`
// Tags contains classification labels for the finding.
Tags []string `json:"tags,omitempty"`
// Metadata contains arbitrary key-value pairs for additional context.
Metadata map[string]string `json:"metadata,omitempty"`
}
Finding represents a canonical analysis finding that unifies the common fields across audit and compliance findings.
JSON tag note: Recommendation, Component, and Reference intentionally lack omitempty to match compliance.Finding conventions, so downstream JSON consumers must tolerate empty-string values for those three keys.
type IndexedRule ¶
type IndexedRule struct {
// Index is the position of the rule in the original flat rule list.
Index int
// Rule is the firewall rule at this position.
Rule common.FirewallRule
}
IndexedRule pairs a firewall rule with its original index in the flat rule list.
type Observation ¶ added in v1.7.0
type Observation struct {
// Severity is the shared severity scale value (critical..info), aligned
// with the compliance-plugin severity vocabulary.
Severity Severity `json:"severity"`
// Confidence labels how certain the detection is; never used to drop an
// observation.
Confidence Confidence `json:"confidence"`
// Reachability tags where this observation is reachable from: WAN, LAN,
// or local only.
Reachability Reachability `json:"reachability"`
// Component identifies the originating configuration element (e.g.
// "filter.rule[3]", "system.webgui.protocol").
Component string `json:"component"`
// Evidence carries a human-readable pointer to the specific config value
// that triggered the observation.
Evidence string `json:"evidence,omitempty"`
// Title is a brief description of the observation.
Title string `json:"title"`
// Description provides detailed information about the observation.
Description string `json:"description"`
// Recommendation suggests how to address the observation.
Recommendation string `json:"recommendation"`
}
Observation is a neutral, mode-agnostic detection produced by the shared detection engine (ScanObservations). Blue and red audit modes are presentation lenses over the same observations, so detection logic lives here exactly once and the two modes cannot disagree about the underlying facts. See docs/plans/2026-07-17-001-feat-audit-blue-red-analysis-plan.md.
func ScanObservations ¶ added in v1.7.0
func ScanObservations(cfg *common.CommonDevice) []Observation
ScanObservations runs the shared detection engine over cfg and returns a flat, neutral list of Observations: the existing DetectSecurityIssues detections wrapped with reachability and confidence, plus additive framework-free hygiene detectors for categories no compliance plugin owns at per-instance granularity (insecure management protocols, weak crypto defaults, any-to-any rules, disabled logging).
ScanObservations does not modify DetectSecurityIssues or ComputeAnalysis; both remain unchanged for their existing caller in internal/converter (KTD3, R4). Returns nil for a nil cfg.
func (Observation) ToFinding ¶ added in v1.7.0
func (o Observation) ToFinding() Finding
ToFinding maps the observation into the canonical analysis.Finding shape consumed by blue-mode hygiene rendering. analysis.Finding has no dedicated confidence/reachability/evidence fields, so those three axes are carried in Metadata rather than dropped.
type PrecedencePair ¶ added in v1.7.0
type PrecedencePair struct {
// Interface is the interface name the evaluation group was built for.
Interface string
// Direction is the direction bucket the group was evaluated under
// (DirectionIn or DirectionOut; a DirectionAny rule joins both buckets
// and so may appear in a PrecedencePair under either value).
Direction common.FirewallDirection
// Winner is the rule that wins the shared traffic under pf evaluation
// semantics. It is never a disabled rule; see derivePairWinnerLoser.
Winner IndexedRule
// Loser is the rule that is shadowed on the overlap — the rule a shadow
// finding should be reported against. It can be a disabled rule.
Loser IndexedRule
// Extent is how much of Loser's match set Winner covers: CoverFull when
// Loser is shadowed in its entirety, CoverPartial when only the
// overlapping subset is shadowed. Never CoverNone or CoverIndeterminate;
// pairs with those coverage results produce no PrecedencePair.
Extent Coverage
// AliasBlocked mirrors the coverage() aliasBlocked signal computed for
// this pair, so consumers needing the R8 advisory path do not have to
// re-run coverage() themselves.
AliasBlocked bool
}
PrecedencePair describes one resolved overlapping pair of firewall rules within a single (interface, direction) pf evaluation group: which rule wins the shared traffic, which rule is shadowed on it, and how much of the loser's match set the winner covers.
Quick and non-quick are mirror images (ADR-0005, KTD-5). Under quick (first-match) semantics the earlier-positioned rule in the group wins outright when it covers the later rule, so the later rule is the loser. Under non-quick (last-match) semantics the later-positioned rule wins the overlap, so the earlier rule is the loser. Winner and Loser therefore do not correlate with rule-list position in a fixed direction — callers must not assume Loser.Index is greater than Winner.Index.
func ResolvePrecedence ¶ added in v1.7.0
func ResolvePrecedence(cfg *common.CommonDevice) []PrecedencePair
ResolvePrecedence groups cfg's firewall rules into pf evaluation-order groups — by (interface, direction), with floating rules joining the groups they apply to (every group when unscoped) in evaluation order — and resolves every overlapping pair within each group into its effective PrecedencePair per pf quick (first-match) / non-quick (last-match) semantics (ADR-0005, KTD-5). Overlap candidacy is decided by the U4 coverage predicate; pairs whose coverage is CoverNone or CoverIndeterminate produce no result, and neither does a pair a disabled rule would win.
ResolvePrecedence is a pure function of cfg: no shared state, and deterministic output order (sorted interface name, then direction bucket, then group position). Returns nil for a nil cfg or fewer than two firewall rules.
type Reachability ¶ added in v1.7.0
type Reachability string
Reachability describes where a firewall rule, interface, or NAT rule can be reached from: the public internet (WAN), only from local/internal networks (LAN), or nowhere on any network (Local — e.g. a disabled interface, or a NAT rule with no matching enabled pass rule).
const ( // WANReachable indicates the element is reachable from the WAN (internet). WANReachable Reachability = "wan" // LANOnly indicates the element is reachable only from LAN/internal networks. LANOnly Reachability = "lan" // Local indicates the element is not reachable from any network — for // example a disabled interface, or a NAT rule with no matching enabled // pass rule. Local Reachability = "local" )
func InboundNATRuleReachability ¶ added in v1.7.0
func InboundNATRuleReachability( nat common.InboundNATRule, ifaces []common.Interface, passRules []common.FirewallRule, ) Reachability
InboundNATRuleReachability reports whether an inbound (port-forward) NAT rule is WAN-reachable.
A NAT rule is WAN-reachable only when it is enabled, applies to a WAN interface, AND at least one enabled pass rule also applies to a WAN interface. NAT presence alone — with no matching enabled pass rule — is never WAN-reachable: OPNsense and pfSense both require an explicit pass rule (or an auto-added "filter rule association") to actually allow the forwarded traffic through the firewall; a port-forward with no corresponding pass rule is inert.
func InterfaceReachability ¶ added in v1.7.0
func InterfaceReachability(iface common.Interface) Reachability
InterfaceReachability classifies a single interface as WAN-reachable, LAN-only, or local, based on its administrative state and name.
func RuleReachability ¶ added in v1.7.0
func RuleReachability(rule common.FirewallRule, ifaces []common.Interface) Reachability
RuleReachability classifies a firewall rule's reachability using its bound interfaces and IP protocol.
A rule counts as WAN-reachable when it applies to any WAN interface. This includes:
- Interface-scoped floating rules, which — like ordinary rules — are scoped to exactly the interfaces in rule.Interfaces; the Floating flag does not by itself widen a rule's reach beyond its interface list.
- Unscoped floating rules (Floating == true with an empty rule.Interfaces), which apply to every interface and are therefore WAN-reachable whenever any live WAN interface exists on the device.
- IPv6-only WAN interfaces, matched the same way as any other WAN interface: the classification below is purely name-prefix based via IsWANInterfaceName and does not branch on rule.IPProtocol or inspect the interface's IPv6Address, so a wan-prefixed interface serving only IPv6 is matched by its name alone — a misconfigured/unassigned address must not mask a real exposure.
Enabled-state handling is deliberately asymmetric between the two binding styles. The unscoped-floating path resolves against the actual interface list via InterfaceReachability, which treats a disabled interface as Local — a device-wide rule cannot reach a WAN that is administratively down, and nothing in rule.Interfaces tells us which interfaces exist. The interface-scoped path, by contrast, trusts the operator's explicit binding: a rule bound by name to "wan" is classified as governing WAN traffic by intent, independent of the interface's current admin state (a disabled interface merely makes the rule inert, which is a separate concern from where the rule is scoped). It also keeps classification working for rules that reference an interface name not present in the passed-in ifaces slice.
func (Reachability) String ¶ added in v1.7.0
func (r Reachability) String() string
String returns the string representation of the reachability tag.
type Severity ¶
type Severity string
Severity represents the severity levels for findings.
const ( // SeverityCritical indicates a critical severity finding. SeverityCritical Severity = "critical" // SeverityHigh indicates a high severity finding. SeverityHigh Severity = "high" // SeverityMedium indicates a medium severity finding. SeverityMedium Severity = "medium" // SeverityLow indicates a low severity finding. SeverityLow Severity = "low" // SeverityInfo indicates an informational finding. SeverityInfo Severity = "info" )
Severity level constants define the standard severity tiers for security findings.
func ValidSeverities ¶
func ValidSeverities() []Severity
ValidSeverities returns a fresh copy of all valid severity values. Returns a new slice each call to prevent callers from mutating shared state.