Skip to content

Commit 3452005

Browse files
committed
optimized logging of unsupported netfilter-rules
1 parent a08a12d commit 3452005

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/firewall_test/plugins/system/firewall_netfilter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def matches(self, packet: (PacketIP, PacketTCPUDP, PacketICMP), rule: Rule) -> R
9797
log_warn('Firewall Plugin', ' > Matches: Found not matches we could process - skipping rule')
9898

9999
else:
100-
log_debug('Firewall Plugin', f' > Matches: {nf_rule.get_match_types()} | Result: {results}')
100+
log_debug('Firewall Plugin', f' > Match Results: {nf_rule.get_match_types()} => {results}')
101101

102102
return RuleMatchResult(
103103
matched=all(results),

src/firewall_test/plugins/translate/netfilter/elements.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ def __repr__(self) -> str:
341341
class NftRule(NftBase):
342342
def __init__(self, table: NftTable, chain: NftChain, raw: dict, seq: int, sets: list[NftSet]):
343343
NftBase.__init__(self=self, raw=raw, table=table)
344+
self.raw = raw
344345
self.chain = chain
345346
self.seq = seq
346347

src/firewall_test/plugins/translate/netfilter/parse.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ def _parse_rules(self):
8383
sets=self.sets,
8484
)
8585
if rule.invalid_matches:
86-
log_warn('Firewall Plugin', 'Got rule with unparsable matches - skipping')
86+
log_warn(
87+
'Firewall Plugin',
88+
v1=f'Unsupported rule: Table {rule.table.name}, Chain {rule.chain.name}, Rule {rule.seq}',
89+
v4=f' | {rule.raw}'
90+
)
8791

8892
else:
8993
self.rules.append(rule)

0 commit comments

Comments
 (0)