rule_hit_and_shadow_analysis
Analyze firewall rules to flag enabled rules that never hit, are shadowed by earlier rules, or duplicate prior rules. Identify dead, shadowed, and redundant rules to optimize rule order and security.
Instructions
[READ] Flag never-hit enabled rules and shadowed/redundant rules.
Finds enabled rules with zero evaluations (dead or misordered), rules fully covered by an earlier terminating rule (shadowed), and rules identical to an earlier one (redundant). Rules are compared in list order, top-down, exactly as pf evaluates them; every finding names the offending/covering rule uuid. Pass 'rules' for pure analysis, or a target to pull live.
Args: rules: Injected rows {uuid, sequence, enabled, action, interface, protocol, source, destination, destinationPort, evaluations}. interface: Optional interface filter when pulling live. target: Firewall target name from config; omit for the default.
Returns dict: {rulesEvaluated, unusedCount, shadowedCount, redundantCount, unusedRules, shadowedRules, redundantRules, note}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rules | No | ||
| target | No | ||
| interface | No |