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
34 changes: 11 additions & 23 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ def rule_is_version_compatible(rulefile, suri_version):
class FileCompareCheck:

def __init__(self, config, directory, cwd):
for key in config:
if key not in ["requires", "filename", "expected"]:
raise Exception("Unexpected key in file-compare check: {}".format(key))
self.config = config
self.directory = directory
self.cwd = cwd
Expand All @@ -483,26 +486,20 @@ def run(self):
class ShellCheck:

def __init__(self, config, env, suricata_config, output_dir, test_dir):
for key in config:
if key not in ["requires", "args", "expect"]:
raise Exception("Unexpected key in shell check: {}".format(key))
self.config = config
self.env = env
self.suricata_config = suricata_config
self.cwd = output_dir
self.script_cwd = test_dir

def run(self):
shell_args = {}
if not self.config or "args" not in self.config:
raise TestError("shell check missing args")
req_version = self.config.get("version")
min_version = self.config.get("min-version")
lt_version = self.config.get("lt-version")
if req_version is not None:
shell_args["version"] = req_version
if min_version is not None:
shell_args["min-version"] = min_version
if lt_version is not None:
shell_args["lt-version"] = lt_version
check_requires(shell_args, self.suricata_config, self.script_cwd)
requires = self.config.get("requires", {})
check_requires(requires, self.suricata_config, self.script_cwd)

try:
if WIN32:
Expand Down Expand Up @@ -539,6 +536,9 @@ def run(self):
class FilterCheck:

def __init__(self, config, outdir, suricata_config, test_version, script_cwd=None):
for key in config:
if key not in ["count", "match", "filename", "requires"]:
raise Exception("Unexpected key in filter check: {}".format(key))
self.config = config
self.outdir = outdir
self.suricata_config = suricata_config
Expand All @@ -548,19 +548,7 @@ def __init__(self, config, outdir, suricata_config, test_version, script_cwd=Non

def run(self):
requires = self.config.get("requires", {})
req_version = self.config.get("version")
min_version = self.config.get("min-version")
lt_version = self.config.get("lt-version")
if req_version is not None:
requires["version"] = req_version
if min_version is not None:
requires["min-version"] = min_version
if lt_version is not None:
requires["lt-version"] = lt_version
check_filter_test_version_compat(requires, self.test_version)
feature = self.config.get("feature")
if feature is not None:
requires["features"] = [feature]
check_requires(requires, self.suricata_config, self.script_cwd)

if "filename" in self.config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ pcap: ../alert-max-append-higher-priority/input.pcap
checks:
# Sub-test 1
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
Copy link
Member Author

Choose a reason for hiding this comment

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

This looks like an impossible condition, however not new with this PR.

count: 1
match:
event_type: alert
Expand All @@ -20,8 +21,9 @@ checks:
verdict.action: drop
# Sub-test 2
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 1
match:
event_type: alert
Expand All @@ -31,10 +33,11 @@ checks:
verdict.action: drop
# Sub-test 3
- filter:
# suricata 7 doesn't show this alert.
# if we don't drop the flow, it matches against the stream
# (pkt_srt: stream (flow timeout))
min-version: 8.0.4
requires:
# suricata 7 doesn't show this alert.
# if we don't drop the flow, it matches against the stream
# (pkt_srt: stream (flow timeout))
min-version: 8.0.4
count: 1
match:
event_type: alert
Expand All @@ -44,18 +47,20 @@ checks:
verdict.action: drop
# Sub-test 4
- filter:
# suricata 8 doesn't show this alert
lt-version: 8.0
requires:
# suricata 8 doesn't show this alert
lt-version: 8.0
count: 1
match:
event_type: alert
alert.signature_id: 4
# Sub-test 5
- filter:
# suricata 7 doesn't show this alert.
# if we don't drop the flow, it matches against the stream
# (pkt_srt: stream (flow timeout))
lt-version: 8.0
requires:
# suricata 7 doesn't show this alert.
# if we don't drop the flow, it matches against the stream
# (pkt_srt: stream (flow timeout))
lt-version: 8.0
count: 0
match:
event_type: alert
Expand All @@ -65,7 +70,8 @@ checks:
verdict.action: drop
# Sub-test 6
- filter:
min-version: 8.0.4
requires:
min-version: 8.0.4
count: 0
match:
event_type: alert
Expand All @@ -78,8 +84,9 @@ checks:
alert.signature_id: 5
# Sub-test 8
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 1
match:
event_type: drop
Expand All @@ -94,9 +101,10 @@ checks:
flow.action: drop
# Sub-test 10
- filter:
# as suricata 7 won't have a match for sid 3,
# the overflow check fails for 7
min-version: 8.0.4
requires:
# as suricata 7 won't have a match for sid 3,
# the overflow check fails for 7
min-version: 8.0.4
count: 1
match:
event_type: stats
Expand All @@ -108,7 +116,8 @@ checks:
stats.ips.drop_reason.rules: 1
# Sub-test 11
- filter:
lt-version: 8.0
requires:
lt-version: 8.0
count: 1
match:
event_type: stats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ args:
checks:
# Subtest 1
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 0
match:
event_type: alert
alert.signature_id: 1
# Subtest 2
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 1
match:
event_type: alert
Expand All @@ -26,8 +28,9 @@ checks:
verdict.action: drop
# Subtest 3
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 1
match:
event_type: alert
Expand All @@ -38,16 +41,18 @@ checks:
# Subtest 4
# Matches, but not enough space in packet alert queue
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 0
match:
event_type: alert
alert.signature_id: 4
# Subtest 5
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 1
match:
event_type: alert
Expand All @@ -58,42 +63,47 @@ checks:
# Subtest 6
# Matches, but not enough space in packet alert queue
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 0
match:
event_type: alert
alert.signature_id: 6
# Subtest 7
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 1
match:
event_type: drop
pcap_cnt: 1
drop.reason: rules
# Subtest 8
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 1
match:
event_type: drop
pcap_cnt: 2
drop.reason: "flow drop"
# Subtest 9
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 1
match:
event_type: flow
flow.action: "drop"
# Subtest 10
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 1
match:
event_type: stats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ args:
checks:
# Sub-test 1
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 1
match:
event_type: alert
Expand All @@ -17,8 +18,9 @@ checks:
verdict.action: drop
# Sub-test 2
- filter:
lt-version: 8.0.4
gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
count: 1
match:
event_type: alert
Expand All @@ -27,8 +29,9 @@ checks:
verdict.action: drop
# Sub-test 3
- filter:
# as with drop-5180-01 test, 7.0.x doesn't show this alert
min-version: 8.0.4
requires:
# as with drop-5180-01 test, 7.0.x doesn't show this alert
min-version: 8.0.4
count: 1
match:
event_type: alert
Expand All @@ -37,8 +40,9 @@ checks:
verdict.action: drop
# Sub-test 4
- filter:
# as with drop-5180-01 test, 7.0.x shows this alert
lt-version: 8.0
requires:
# as with drop-5180-01 test, 7.0.x shows this alert
lt-version: 8.0
count: 1
match:
event_type: alert
Expand All @@ -51,9 +55,10 @@ checks:
alert.signature_id: 5
# Sub-test 6
- filter:
min-version: 8.0.4
lt-version: 8.0.4
gt-version: 8.0.4
requires:
min-version: 8.0.4
lt-version: 8.0.4
gt-version: 8.0.4
count: 1
match:
event_type: drop
Expand All @@ -66,7 +71,8 @@ checks:
flow.action: drop
# Sub-test 8
- filter:
min-version: 8.0.4
requires:
min-version: 8.0.4
count: 1
match:
event_type: stats
Expand All @@ -78,7 +84,8 @@ checks:
stats.ips.drop_reason.rules: 1
# Sub-test 9
- filter:
lt-version: 8.0
requires:
lt-version: 8.0
count: 1
match:
event_type: stats
Expand Down
3 changes: 2 additions & 1 deletion tests/app-layer-template/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ args:

checks:
- filter:
min-version: 7
requires:
min-version: 7
count: 1
match:
dest_ip: 10.16.1.10
Expand Down
Loading
Loading