]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
tests: duplicate value handling in datajson
authorEric Leblond <el@stamus-networks.com>
Sun, 13 Oct 2024 19:49:02 +0000 (21:49 +0200)
committerEric Leblond <el@stamus-networks.com>
Wed, 11 Jun 2025 12:01:45 +0000 (14:01 +0200)
tests/datajson/datajson-05-duplicate/host.lst [new file with mode: 0644]
tests/datajson/datajson-05-duplicate/input.pcap [new file with mode: 0644]
tests/datajson/datajson-05-duplicate/src.lst [new file with mode: 0644]
tests/datajson/datajson-05-duplicate/test.rules [new file with mode: 0644]
tests/datajson/datajson-05-duplicate/test.yaml [new file with mode: 0644]

diff --git a/tests/datajson/datajson-05-duplicate/host.lst b/tests/datajson/datajson-05-duplicate/host.lst
new file mode 100644 (file)
index 0000000..d852cad
--- /dev/null
@@ -0,0 +1,2 @@
+d3d3LnRlc3RteWlkcy5jb20=,{"context":"good old test", "year": 2005}
+d3d3LnRlc3RteWlkcy5jb20=,{"context":"gold old test", "year": 2006}
diff --git a/tests/datajson/datajson-05-duplicate/input.pcap b/tests/datajson/datajson-05-duplicate/input.pcap
new file mode 100644 (file)
index 0000000..8fb6832
Binary files /dev/null and b/tests/datajson/datajson-05-duplicate/input.pcap differ
diff --git a/tests/datajson/datajson-05-duplicate/src.lst b/tests/datajson/datajson-05-duplicate/src.lst
new file mode 100644 (file)
index 0000000..4993bc6
--- /dev/null
@@ -0,0 +1,2 @@
+10.16.1.11,{"test": "success","context":1}
+10.16.1.11,{"test": "fail","context":2}
diff --git a/tests/datajson/datajson-05-duplicate/test.rules b/tests/datajson/datajson-05-duplicate/test.rules
new file mode 100644 (file)
index 0000000..acbf304
--- /dev/null
@@ -0,0 +1 @@
+alert http any any -> any any (flow:established,to_server; http.host; datajson:isset,badhost,type string,load host.lst,key bad_host; ip.src; datajson:isset,src_ip,type ip,load src.lst,key src_ip; sid:1;)
diff --git a/tests/datajson/datajson-05-duplicate/test.yaml b/tests/datajson/datajson-05-duplicate/test.yaml
new file mode 100644 (file)
index 0000000..bad24cf
--- /dev/null
@@ -0,0 +1,21 @@
+requires:
+  features:
+    - HAVE_LIBJANSSON
+  files:
+    - src/datasets.c
+
+args:
+ - -k none --set datasets.enabled=yes
+
+checks:
+  - filter:
+      count: 1
+      match:
+        event_type: alert
+  - filter:
+      count: 1
+      match:
+        event_type: alert
+        alert.signature_id: 1
+        alert.extra.src_ip.test: success
+        alert.extra.bad_host.year: 2005