Skip to content

Commit 38091d0

Browse files
committed
test/byte-vars: Restrict var usage to single-buffer
Add/modify test cases to use the `rule-strict-keywords` where appropriate. 2 new test cases - bytemath-07 Test 05 for release 8 and later - bytemath-08 Using additional "lol" signature - bytemath-09 Using additional "lol" signature Issue: 1412
1 parent 5aa77b0 commit 38091d0

File tree

9 files changed

+58
-0
lines changed

9 files changed

+58
-0
lines changed

tests/bug-7549-01/test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
requires:
22
min-version: 8
33

4+
args:
5+
- --strict-rule-keywords
6+
47
checks:
58
- shell:
69
args: grep "Unknown byte_extract var seen.*rpkt_len" stderr | wc -l | xargs

tests/detect-bytemath-05/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This test is for Redmine issue https://redmine.openinfosecfoundation.org/issues/1412
2+
3+
Ensure that variable usage is restricted to a single buffer
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
alert tcp any any -> any any (msg:"byte_math varname test sig"; \
2+
ipv4.hdr; byte_extract:1,5,rpkt_len,relative; \
3+
byte_math:bytes rpkt_len, offset 1, oper +, rvalue 102, result result_val; \
4+
tcp.hdr; byte_test: 1, =, result_val, 1, relative; \
5+
sid:1;)

tests/detect-bytemath-07/test.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pcap: ../detect-bytemath-01/input.pcap
2+
3+
requires:
4+
min-version: 8
5+
6+
args:
7+
- --strict-rule-keywords
8+
9+
exit-code: 1
10+
11+
checks:
12+
- shell:
13+
args: grep "Unknown byte_extract var seen in byte_test - result_val" suricata.log | wc -l | xargs
14+
expect: 1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
alert http any any -> any any (msg:"byte_extract Test"; \
2+
flow:established,to_client; \
3+
http.header.raw; content:"Content|2D|Length|3A 20|"; content:!"|0D 0A|"; within:3; \
4+
byte_extract:2,0,content-length,relative,string,dec; content:"|0D 0A|"; distance:0; within:2; \
5+
http.server; content:"Neuro"; byte_test:2,=,content-length,0,relative,little; \
6+
priority:3; sid:1;);

tests/detect-bytemath-08/test.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pcap: ../detect-bytemath-01/input.pcap
2+
3+
requires:
4+
min-version: 8
5+
6+
args:
7+
- --strict-rule-keywords
8+
9+
exit-code: 1
10+
11+
checks:
12+
- shell:
13+
args: grep "Unknown byte_extract var seen in byte_test - content-length" suricata.log | wc -l | xargs
14+
expect: 1
641 Bytes
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
alert http any any -> any any (msg:"byte_extract Test"; flow:established,to_client; content:"Content|2D|Length|3A 20|"; http_raw_header; content:!"|0D 0A|"; within:3; http_raw_header; byte_extract:2,0,content-length,relative,string,dec; content:"|0D 0A|"; distance:0; within:2; http_raw_header; file_data; content:"test"; byte_test:2,=,content-length,0,relative,little; priority:3; sid:44412999;)

tests/detect-bytemath-09/test.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
checks:
3+
- shell:
4+
min-version: 8
5+
args: grep "Warning. detect-byte. Using byte variable from a different buffer may produce indeterminate results; variable. \"content-length\"" suricata.log | wc -l | xargs
6+
expect: 1
7+
8+
- filter:
9+
count: 1
10+
match:
11+
event_type: alert
12+
alert.signature_id: 44412999

0 commit comments

Comments
 (0)