]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
tests: add ipv4 set save test
authorEric Leblond <el@stamus-networks.com>
Sun, 19 Jun 2022 11:03:13 +0000 (13:03 +0200)
committerShivani Bhardwaj <shivani@oisf.net>
Fri, 28 Oct 2022 11:55:28 +0000 (17:25 +0530)
tests/datasets-07-state-ip/expected/state.csv [new file with mode: 0644]
tests/datasets-07-state-ip/input.pcap [new file with mode: 0644]
tests/datasets-07-state-ip/test.rules [new file with mode: 0644]
tests/datasets-07-state-ip/test.yaml [new file with mode: 0644]
tests/datasets-07-state-ip/writepcap.py [new file with mode: 0755]

diff --git a/tests/datasets-07-state-ip/expected/state.csv b/tests/datasets-07-state-ip/expected/state.csv
new file mode 100644 (file)
index 0000000..8172804
--- /dev/null
@@ -0,0 +1 @@
+1.2.3.4
diff --git a/tests/datasets-07-state-ip/input.pcap b/tests/datasets-07-state-ip/input.pcap
new file mode 100644 (file)
index 0000000..790a6a1
Binary files /dev/null and b/tests/datasets-07-state-ip/input.pcap differ
diff --git a/tests/datasets-07-state-ip/test.rules b/tests/datasets-07-state-ip/test.rules
new file mode 100644 (file)
index 0000000..e4107b8
--- /dev/null
@@ -0,0 +1 @@
+alert dns any any -> any any (ip.dst; dataset:set,dns-srv, type ipv4, state state.csv; sid:1;)
diff --git a/tests/datasets-07-state-ip/test.yaml b/tests/datasets-07-state-ip/test.yaml
new file mode 100644 (file)
index 0000000..d368d01
--- /dev/null
@@ -0,0 +1,13 @@
+requires:
+  features:
+    - HAVE_LIBJANSSON
+  files:
+    - src/detect-ipaddr.c
+
+args:
+  - --data-dir=${OUTPUT_DIR}
+
+checks:
+  - file-compare:
+      filename: state.csv
+      expected: expected/state.csv
diff --git a/tests/datasets-07-state-ip/writepcap.py b/tests/datasets-07-state-ip/writepcap.py
new file mode 100755 (executable)
index 0000000..f5a1b7a
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+from scapy.all import *
+
+pkts = []
+
+pkts += Ether(dst='ff:ff:ff:ff:ff:ff', src='00:01:02:03:04:05')/ \
+    Dot1Q(vlan=6)/ \
+    IP(dst='1.2.3.4', src='5.6.7.8')/UDP(dport=53)/DNS(id=1, rd=1, qd=DNSQR(qname='example.com'))
+pkts += Ether(dst='ff:ff:ff:ff:ff:ff', src='00:01:02:03:04:05')/ \
+    Dot1Q(vlan=6)/ \
+    IP(dst='1.2.3.4', src='5.6.7.8')/UDP(dport=53)/DNS(id=2, rd=1, qd=DNSQR(qname='example.com'))
+pkts += Ether(dst='ff:ff:ff:ff:ff:ff', src='00:01:02:03:04:05')/ \
+    Dot1Q(vlan=6)/ \
+    IP(dst='1.2.3.4', src='5.6.7.8')/UDP(dport=53)/DNS(id=3, rd=1, qd=DNSQR(qname='example.com'))
+
+wrpcap('input.pcap', pkts)