Skip to content

Commit

Permalink
test: tests for requires keyword
Browse files Browse the repository at this point in the history
Feature: #5972
  • Loading branch information
jasonish committed Dec 5, 2023
1 parent ffd02b7 commit 547296a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/requires/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test for the "requires" keyword.
12 changes: 12 additions & 0 deletions tests/requires/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Rule for Suricata >= 7 and < 8.
alert http any any -> any any (msg:"TEST Suricata >= 7 and < 8"; content:"uid=0"; requires: version >= 7, version < 8; sid:7; rev:1;)

# Rule for Suricata >= 8.
alert http any any -> any any (msg:"TEST Suricata >= 8"; content:"uid=0"; requires: version >= 8.0.0; sid:8; rev:1;)

# These rules have something invalid about them, but do follow the general rule
# structure, so should be eliminated by the requires statement.
alert vxlan any any -> any any (requires: version >= 10; sid:1;)
alert udp any any -> any any (vxlan_vni:10; requires: version >= 10; sid:2;)
alert http any any => any any (requires: version >= 10; sid:3;)
alert tcp any any -> any any (frame:smtp.not_supported; requires: version >= 10; sid:4;)
40 changes: 40 additions & 0 deletions tests/requires/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
requires:
files:
- rust/src/detect/requires.rs

pcap: ../eve-metadata/testmyids.pcap

checks:

# Check that for Suricata >= 8.0.0 we have one alert and that alert is sid 8.
- filter:
requires:
min-version: 8
count: 1
match:
event_type: alert
- filter:
requires:
min-version: 8
count: 1
match:
alert.signature_id: 8

# Check that for Suricata >= 8.0.0 we have one alert and that alert is sid 8.
- filter:
requires:
min-version: 7
lt-version: 8
count: 1
match:
event_type: alert
- filter:
requires:
min-version: 7
lt-version: 8
count: 1
match:
alert.signature_id: 7



0 comments on commit 547296a

Please sign in to comment.