Skip to content

Commit

Permalink
dataset/rep: add tests for error conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
inashivb committed Jan 9, 2025
1 parent e48fd36 commit 1cb23c6
Show file tree
Hide file tree
Showing 16 changed files with 173 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/datasets/datarep-bad-datarep-string/datarep.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert dns any any -> any any (dns.query; datarep:dns_string, >, 200, load dns_string.rep, type string; sid:1;)
1 change: 1 addition & 0 deletions tests/datasets/datarep-bad-datarep-string/dns_string.rep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Z29vZ2xlLm;NvbQ==,1
20 changes: 20 additions & 0 deletions tests/datasets/datarep-bad-datarep-string/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
%YAML 1.1
---

# Logging configuration. This is not about logging IDS alerts/events, but
# output about what Suricata is doing, like startup messages, errors, etc.
logging:
default-log-level: notice
outputs:
- console:
enabled: yes
# type: json
- file:
enabled: yes
level: info
filename: suricata.json
type: json
- syslog:
enabled: no
facility: local5
format: "[%i] <%d> -- "
22 changes: 22 additions & 0 deletions tests/datasets/datarep-bad-datarep-string/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
pcap: ../../flowbit-oring/input.pcap

requires:
features:
- HAVE_LIBJANSSON
files:
- src/datasets.c

args:
- -k none

exit-code: 1

checks:
- filter:
min-version: 8
filename: suricata.json
count: 1
match:
log_level: "Error"
event_type: "engine"
engine.message.__find: "bad base64 encoding dns_string"
1 change: 1 addition & 0 deletions tests/datasets/datarep-bad-datarep-value/datarep.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert dns any any -> any any (dns.query; datarep:dns_string, >, 200, load dns_string.rep, type string; sid:1;)
1 change: 1 addition & 0 deletions tests/datasets/datarep-bad-datarep-value/dns_string.rep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Z29vZ2xlLmNvbQ==,-1
20 changes: 20 additions & 0 deletions tests/datasets/datarep-bad-datarep-value/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
%YAML 1.1
---

# Logging configuration. This is not about logging IDS alerts/events, but
# output about what Suricata is doing, like startup messages, errors, etc.
logging:
default-log-level: notice
outputs:
- console:
enabled: yes
# type: json
- file:
enabled: yes
level: info
filename: suricata.json
type: json
- syslog:
enabled: no
facility: local5
format: "[%i] <%d> -- "
22 changes: 22 additions & 0 deletions tests/datasets/datarep-bad-datarep-value/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
pcap: ../../flowbit-oring/input.pcap

requires:
features:
- HAVE_LIBJANSSON
files:
- src/datasets.c

args:
- -k none

exit-code: 1

checks:
- filter:
min-version: 8
filename: suricata.json
count: 1
match:
log_level: "Error"
event_type: "engine"
engine.message.__find: "invalid datarep value dns_string"
2 changes: 2 additions & 0 deletions tests/datasets/datarep-datasets-mix/datasets.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Y3VybC83LjQzLjA=
YmxhaA==,1
20 changes: 20 additions & 0 deletions tests/datasets/datarep-datasets-mix/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
%YAML 1.1
---

# Logging configuration. This is not about logging IDS alerts/events, but
# output about what Suricata is doing, like startup messages, errors, etc.
logging:
default-log-level: notice
outputs:
- console:
enabled: yes
# type: json
- file:
enabled: yes
level: info
filename: suricata.json
type: json
- syslog:
enabled: no
facility: local5
format: "[%i] <%d> -- "
2 changes: 2 additions & 0 deletions tests/datasets/datarep-datasets-mix/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alert http any any -> any any (http.user_agent; dataset:isset,ua-seen,type string,load datasets.csv; sid:1;)
alert http any any -> any any (http.user_agent; dataset:isnotset,ua-seen,type string,load datasets.csv; sid:2;)
19 changes: 19 additions & 0 deletions tests/datasets/datarep-datasets-mix/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pcap: ../../flowbit-oring/input.pcap

requires:
min-version: 8

args:
- -k none

exit-code: 1

checks:
- filter:
min-version: 8
filename: suricata.json
count: 1
match:
log_level: "Error"
event_type: "engine"
engine.message.__find: "Cannot mix dataset and datarep values for set ua-seen"
1 change: 1 addition & 0 deletions tests/datasets/datasets-datarep-mix/datarep.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert dns any any -> any any (dns.query; datarep:dns_string, >, 200, load dns_string.rep, type string; sid:1;)
2 changes: 2 additions & 0 deletions tests/datasets/datasets-datarep-mix/dns_string.rep
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Z29vZ2xlLmNvbQ==,1
YmxhaA==
20 changes: 20 additions & 0 deletions tests/datasets/datasets-datarep-mix/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
%YAML 1.1
---

# Logging configuration. This is not about logging IDS alerts/events, but
# output about what Suricata is doing, like startup messages, errors, etc.
logging:
default-log-level: notice
outputs:
- console:
enabled: yes
# type: json
- file:
enabled: yes
level: info
filename: suricata.json
type: json
- syslog:
enabled: no
facility: local5
format: "[%i] <%d> -- "
19 changes: 19 additions & 0 deletions tests/datasets/datasets-datarep-mix/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pcap: ../../flowbit-oring/input.pcap

requires:
min-version: 8

args:
- -k none

exit-code: 1

checks:
- filter:
min-version: 8
filename: suricata.json
count: 1
match:
log_level: "Error"
event_type: "engine"
engine.message.__find: "Cannot mix dataset and datarep values for set dns_string"

0 comments on commit 1cb23c6

Please sign in to comment.