Skip to content

Commit 547edd4

Browse files
committed
test: tests for requires keyword
Feature: #5972
1 parent 30875de commit 547edd4

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

tests/requires/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test for the "requires" keyword.

tests/requires/test.rules

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Rule for Suricata >= 7 and < 8.
2+
alert http any any -> any any (msg:"TEST Suricata >= 7 and < 8"; content:"uid=0"; requires: version >= 7, version < 8; sid:7; rev:1;)
3+
4+
# Rule for Suricata >= 7.0.3 but less than 8... Or >= 8.0.1
5+
alert http any any -> any any (content:"uid=0"; requires: version >= 7.0.3 < 8 | >= 8.0.1; sid:9; rev:1;)
6+
7+
# Rule for Suricata >= 8.
8+
alert http any any -> any any (msg:"TEST Suricata >= 8"; content:"uid=0"; requires: version >= 8.0.0; sid:8; rev:1;)
9+
10+
# These rules have something invalid about them, but do follow the general rule
11+
# structure, so should be eliminated by the requires statement.
12+
alert vxlan any any -> any any (requires: version >= 10; sid:1;)
13+
alert udp any any -> any any (vxlan_vni:10; requires: version >= 10; sid:2;)
14+
alert http any any => any any (requires: version >= 10; sid:3;)
15+
alert tcp any any -> any any (frame:smtp.not_supported; requires: version >= 10; sid:4;)

tests/requires/test.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
requires:
2+
files:
3+
- rust/src/detect/requires.rs
4+
5+
pcap: ../eve-metadata/testmyids.pcap
6+
7+
checks:
8+
9+
# Check that for Suricata >= 8.0.0 we have one alert and that alert is sid 8.
10+
- filter:
11+
requires:
12+
min-version: 8
13+
count: 1
14+
match:
15+
event_type: alert
16+
- filter:
17+
requires:
18+
min-version: 8
19+
count: 1
20+
match:
21+
alert.signature_id: 8
22+
23+
# Check that for Suricata >= 7.0.0 and < 8 we have one alert and that alert
24+
# is sid 7.
25+
- filter:
26+
requires:
27+
min-version: 7
28+
lt-version: 8
29+
count: 1
30+
match:
31+
event_type: alert
32+
- filter:
33+
requires:
34+
min-version: 7
35+
lt-version: 8
36+
count: 1
37+
match:
38+
alert.signature_id: 7
39+
40+
# Should have nothing for SID 9.
41+
- filter:
42+
count: 0
43+
match:
44+
alert.signature_id: 9

0 commit comments

Comments
 (0)