Skip to content
Open
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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ checks:
# Check if a string is contained within a JSON list.
# Eg. "ftp":{"reply":["Opening BINARY mode data connection for temp.txt (1164 bytes).","Transfer complete."], }
ftp.reply.__contains: 'Transfer complete.'

- filter:
# Check line number of an entry
count: 1
match:
__lineno: 5
alert.signature_id: 15
- shell:
# A simple shell check. If the command exits with a non-0 exit code the
# check will fail. The script is run in the output directory of the
Expand Down
3 changes: 3 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,11 @@ def run(self):

count = 0
with open(json_filename, "r", encoding="utf-8") as fileobj:
lineno = 1
for line in fileobj:
event = json.loads(line)
event["__lineno"] = lineno
lineno = lineno + 1
if self.match(event):
count += 1
if count == self.config["count"]:
Expand Down
4 changes: 4 additions & 0 deletions tests/bug-7638-flowbits-sigorder-01/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alert http any any -> any any (http.uri; content:"down"; flowbits:set,uritest; sid:11;)
alert http any any -> any any (http.user_agent; content:"Mozilla"; flowbits:isset, headtest; flowbits:set,moz; sid:10;)
alert http any any -> any any (http.method; content:"GET"; flowbits:isset,uritest; flowbits:set,headtest; sid:12;)
alert http any any -> any any (http.host; content:"ether"; flowbits:isset,moz; sid:14;)
33 changes: 33 additions & 0 deletions tests/bug-7638-flowbits-sigorder-01/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
requires:
min-version: 8.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

now 9 ?


pcap: false

args:
- --engine-analysis

checks:
- filter:
filename: rules.json
count: 1
match:
__lineno: 1
id: 11
- filter:
filename: rules.json
count: 1
match:
__lineno: 2
id: 12
- filter:
filename: rules.json
count: 1
match:
__lineno: 3
id: 10
- filter:
filename: rules.json
count: 1
match:
__lineno: 4
id: 14
12 changes: 12 additions & 0 deletions tests/flowbits-invalid-01/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%YAML 1.1
---

engine-analysis:
rules: yes

logging:
outputs:
- file:
enabled: yes
filename: eve.json
type: json
1 change: 1 addition & 0 deletions tests/flowbits-invalid-01/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert http any any -> any any (msg: "Illegal flowbit set + isset combination"; http.method; content:"GET"; flowbits:set,fb1; flowbits:isset,fb1; sid:111;)
16 changes: 16 additions & 0 deletions tests/flowbits-invalid-01/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
requires:
min-version: 8

pcap: false

exit-code: 1

args:
- --engine-analysis

checks:
- filter:
count: 1
match:
log_level: Error
engine.message: "invalid flowbit command combination in the same signature: set and isset"
12 changes: 12 additions & 0 deletions tests/flowbits-invalid-02/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%YAML 1.1
---

engine-analysis:
rules: yes

logging:
outputs:
- file:
enabled: yes
filename: eve.json
type: json
1 change: 1 addition & 0 deletions tests/flowbits-invalid-02/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert http any any -> any any (msg: "Illegal flowbit unset + isnotset combination"; http.method; content:"GET"; flowbits:unset,fb1; flowbits:isnotset,fb1; sid:111;)
16 changes: 16 additions & 0 deletions tests/flowbits-invalid-02/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
requires:
min-version: 8

pcap: false

exit-code: 1

args:
- --engine-analysis

checks:
- filter:
count: 1
match:
log_level: Error
engine.message: "invalid flowbit command combination in the same signature: unset and isnotset"
12 changes: 12 additions & 0 deletions tests/flowbits-invalid-03/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%YAML 1.1
---

engine-analysis:
rules: yes

logging:
outputs:
- file:
enabled: yes
filename: eve.json
type: json
1 change: 1 addition & 0 deletions tests/flowbits-invalid-03/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert http any any -> any any (msg: "Illegal flowbit set + toggle combination"; http.method; content:"GET"; flowbits:set,fb1; flowbits:toggle,fb1; sid:111;)
16 changes: 16 additions & 0 deletions tests/flowbits-invalid-03/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
requires:
min-version: 8

pcap: false

exit-code: 1

args:
- --engine-analysis

checks:
- filter:
count: 1
match:
log_level: Error
engine.message: "invalid flowbit command combination in the same signature: set and toggle"
12 changes: 12 additions & 0 deletions tests/flowbits-invalid-04/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%YAML 1.1
---

engine-analysis:
rules: yes

logging:
outputs:
- file:
enabled: yes
filename: eve.json
type: json
1 change: 1 addition & 0 deletions tests/flowbits-invalid-04/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert http any any -> any any (msg: "Illegal flowbit isset + isnot combination"; http.method; content:"GET"; flowbits:isset,fb1; flowbits:isnotset,fb1; sid:111;)
16 changes: 16 additions & 0 deletions tests/flowbits-invalid-04/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
requires:
min-version: 8

pcap: false

exit-code: 1

args:
- --engine-analysis

checks:
- filter:
count: 1
match:
log_level: Error
engine.message: "invalid flowbit command combination in the same signature: isset and isnotset"
12 changes: 12 additions & 0 deletions tests/flowbits-invalid-05/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%YAML 1.1
---

engine-analysis:
rules: yes

logging:
outputs:
- file:
enabled: yes
filename: eve.json
type: json
1 change: 1 addition & 0 deletions tests/flowbits-invalid-05/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert http any any -> any any (msg: "Illegal flowbit set + unset combination"; http.method; content:"GET"; flowbits:set,fb1; flowbits:unset,fb1; sid:111;)
16 changes: 16 additions & 0 deletions tests/flowbits-invalid-05/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
requires:
min-version: 8

pcap: false

exit-code: 1

args:
- --engine-analysis

checks:
- filter:
count: 1
match:
log_level: Error
engine.message: "invalid flowbit command combination in the same signature: set and unset"
Loading