]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
tests: add jsonline format test for datajson
authorEric Leblond <el@stamus-networks.com>
Thu, 27 Mar 2025 22:23:50 +0000 (23:23 +0100)
committerEric Leblond <el@stamus-networks.com>
Wed, 11 Jun 2025 12:01:45 +0000 (14:01 +0200)
tests/datajson/datajson-03-jsonline/host.lst [new file with mode: 0644]
tests/datajson/datajson-03-jsonline/src.lst [new file with mode: 0644]
tests/datajson/datajson-03-jsonline/test.rules [new file with mode: 0644]
tests/datajson/datajson-03-jsonline/test.yaml [new file with mode: 0644]

diff --git a/tests/datajson/datajson-03-jsonline/host.lst b/tests/datajson/datajson-03-jsonline/host.lst
new file mode 100644 (file)
index 0000000..2956f38
--- /dev/null
@@ -0,0 +1,2 @@
+{"host": "testmyids.com", "context":"gold old test", "year": 2005}
+{"host": "www.testmyids.com", "context":"gold old test", "year": 2005}
diff --git a/tests/datajson/datajson-03-jsonline/src.lst b/tests/datajson/datajson-03-jsonline/src.lst
new file mode 100644 (file)
index 0000000..d1f55c6
--- /dev/null
@@ -0,0 +1,2 @@
+{"ip": "10.16.1.11", "test": "success", "context":3}
+{"ip": "10.16.1.12", "test": "fail", "context":4}
diff --git a/tests/datajson/datajson-03-jsonline/test.rules b/tests/datajson/datajson-03-jsonline/test.rules
new file mode 100644 (file)
index 0000000..378b6a3
--- /dev/null
@@ -0,0 +1 @@
+alert http any any -> any any (flow:established,to_server; http.host; dataset:isset,badhost,type string,load host.lst,format jsonline,enrichment_key bad_host,value_key host; ip.src; dataset:isset,src_ip,type ip,load src.lst,format jsonline,enrichment_key src_ip,value_key ip; sid:1;)
diff --git a/tests/datajson/datajson-03-jsonline/test.yaml b/tests/datajson/datajson-03-jsonline/test.yaml
new file mode 100644 (file)
index 0000000..9719055
--- /dev/null
@@ -0,0 +1,20 @@
+requires:
+  min-version: 8
+
+pcap: ../datajson-01-ip/input.pcap
+
+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