Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect prefilter events 6728 v1 #1992

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/decode-too-small/test.rules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
alert tcp any any -> any any (msg:"TCP packet too small"; decode-event:tcp.pkt_too_small; sid:1;)
alert tcp any any -> any any (msg:"TCP packet too small"; decode-event:tcp.pkt_too_small; prefilter; requires: version >= 8; sid:1; rev: 2;)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sid 2 is already in this file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah no it's sid 1 rev 2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to use this pattern? Might as well have 2 rules side by side, to test both prefilter and non-prefilter path

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to use this pattern?

This way, it works on both suricata 7 and suricata 8

If you have another rule side by side, you need the whole test to have min-version 8 as suricata 7 does not support prefilter on decode-event

And this is also a good example/showcase of the requires keyword : you load the better rule if suricata version allows it

alert udp any any -> any any (msg:"UDP packet too small"; decode-event:udp.hlen_too_small; sid:2;)
alert ip any any -> any any (msg:"GRE packet too small"; decode-event:gre.pkt_too_small; sid:3;)
12 changes: 12 additions & 0 deletions tests/decode-too-small/test.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
requires:
min-version: 7

checks:
# Look for IPv4 TCP too small
- filter:
Expand All @@ -7,6 +10,15 @@ checks:
src_ip: 1.1.1.1
alert.signature_id: 1

- filter:
min-version: 8
count: 1
match:
event_type: alert
src_ip: 1.1.1.1
alert.signature_id: 1
alert.rev: 2

# Look for IPv6 TCP too small
- filter:
count: 1
Expand Down
1 change: 1 addition & 0 deletions tests/stream-depth-reached-event/test.rules
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
alert tcp any any -> any any (msg:"SURICATA STREAM reassembly depth reached"; stream-event:reassembly_depth_reached; classtype:protocol-command-decode; sid:2210062; rev:1;)
alert tcp any any -> any any (msg:"SURICATA STREAM reassembly depth reached"; stream-event:reassembly_depth_reached; prefilter; classtype:protocol-command-decode; requires: version >= 8; sid:2210062; rev:2;)
8 changes: 8 additions & 0 deletions tests/stream-depth-reached-event/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ checks:
match:
event_type: alert
alert.signature_id: 2210062

- filter:
min-version: 8
count: 2
match:
event_type: alert
alert.signature_id: 2210062
alert.rev: 2
Loading