From 4faeacb0c9d23dbfd22b9594988d2d95ee70fc4d Mon Sep 17 00:00:00 2001 From: Lukas Sismis Date: Tue, 1 Dec 2026 21:02:29 +0100 Subject: [PATCH] tests: firewall counters for packets dropped by the engine In firewall mode, a packet dropped by the midstream exception policy or by the stream engine is counted in firewall.accepted and ips.blocked, also when the firewall ruleset accepts none of the traffic. Add two tests with such a ruleset. They expect that the dropped packets are counted neither as accepted by the firewall nor as blocked by IPS rules. --- .../firewall.rules | 3 ++ .../test.yaml | 30 +++++++++++++++++++ .../firewall.rules | 3 ++ .../test.yaml | 30 +++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 tests/firewall/firewall-stats-midstream-policy-no-accept/firewall.rules create mode 100644 tests/firewall/firewall-stats-midstream-policy-no-accept/test.yaml create mode 100644 tests/firewall/firewall-stats-stream-error-no-accept/firewall.rules create mode 100644 tests/firewall/firewall-stats-stream-error-no-accept/test.yaml diff --git a/tests/firewall/firewall-stats-midstream-policy-no-accept/firewall.rules b/tests/firewall/firewall-stats-midstream-policy-no-accept/firewall.rules new file mode 100644 index 00000000..54a87bce --- /dev/null +++ b/tests/firewall/firewall-stats-midstream-policy-no-accept/firewall.rules @@ -0,0 +1,3 @@ +# Matches none of the traffic in the pcap: all of it falls to the default +# packet policy (drop). +accept:packet udp:all any any -> any 9 (sid:1;) diff --git a/tests/firewall/firewall-stats-midstream-policy-no-accept/test.yaml b/tests/firewall/firewall-stats-midstream-policy-no-accept/test.yaml new file mode 100644 index 00000000..b69bf4a5 --- /dev/null +++ b/tests/firewall/firewall-stats-midstream-policy-no-accept/test.yaml @@ -0,0 +1,30 @@ +# The firewall ruleset accepts none of the traffic in the pcap. The midstream +# exception policy drops the flow before the firewall rules are evaluated, so +# its packets are neither accepted by the firewall nor blocked by IPS rules. +requires: + min-version: 8.0.6 + +pcap: ../tcp-session-midstream-policy/input.pcap + +args: + - --simulate-ips + - -k none + - --set stream.midstream-policy=drop-flow + +checks: + # The midstream policy dropped the flow. + - filter: + count: 1 + match: + event_type: stats + stats.exception_policy.tcp.midstream.drop_flow: 1 + - filter: + count: 1 + match: + event_type: stats + stats.firewall.accepted: 0 + - filter: + count: 1 + match: + event_type: stats + stats.ips.blocked: 0 diff --git a/tests/firewall/firewall-stats-stream-error-no-accept/firewall.rules b/tests/firewall/firewall-stats-stream-error-no-accept/firewall.rules new file mode 100644 index 00000000..54a87bce --- /dev/null +++ b/tests/firewall/firewall-stats-stream-error-no-accept/firewall.rules @@ -0,0 +1,3 @@ +# Matches none of the traffic in the pcap: all of it falls to the default +# packet policy (drop). +accept:packet udp:all any any -> any 9 (sid:1;) diff --git a/tests/firewall/firewall-stats-stream-error-no-accept/test.yaml b/tests/firewall/firewall-stats-stream-error-no-accept/test.yaml new file mode 100644 index 00000000..c0212760 --- /dev/null +++ b/tests/firewall/firewall-stats-stream-error-no-accept/test.yaml @@ -0,0 +1,30 @@ +# The firewall ruleset accepts none of the traffic in the pcap. The stream +# engine drops the third packet (wrong sequence number in the 3-way handshake) +# before the firewall rules are evaluated, so this packet is neither accepted +# by the firewall nor blocked by IPS rules. +requires: + min-version: 8.0.6 + +pcap: ../tcp-session-stream-out-of-window/input.pcap + +args: + - --simulate-ips + - -k none + +checks: + # The stream engine dropped one packet. + - filter: + count: 1 + match: + event_type: stats + stats.ips.drop_reason.stream_error: 1 + - filter: + count: 1 + match: + event_type: stats + stats.firewall.accepted: 0 + - filter: + count: 1 + match: + event_type: stats + stats.ips.blocked: 0 -- 2.52.0