]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
test: add test for dns.rcode 1687/head 1693/head
authorHadiqa Alamdar Bukhari <hadiqaalamdar@gmail.com>
Tue, 26 Dec 2023 10:00:08 +0000 (15:00 +0500)
committerJuliana Fajardini <jufajardini@oisf.net>
Tue, 5 Mar 2024 15:40:16 +0000 (12:40 -0300)
Feature #6621

tests/dns/dns-rcode/README.md [new file with mode: 0644]
tests/dns/dns-rcode/input.pcap [new file with mode: 0644]
tests/dns/dns-rcode/test.rules [new file with mode: 0644]
tests/dns/dns-rcode/test.yaml [new file with mode: 0644]

diff --git a/tests/dns/dns-rcode/README.md b/tests/dns/dns-rcode/README.md
new file mode 100644 (file)
index 0000000..d472247
--- /dev/null
@@ -0,0 +1,7 @@
+Test the `dns.rcode` header value.
+
+The PCAP here used the pcap from test dns-eve-v2-udp-nxdomain-soa with
+hex editing header flags to have the DNS query have something in the `rcode`
+section.
+
+Redmine ticket: https://redmine.openinfosecfoundation.org/issues/6621
diff --git a/tests/dns/dns-rcode/input.pcap b/tests/dns/dns-rcode/input.pcap
new file mode 100644 (file)
index 0000000..8396d3e
Binary files /dev/null and b/tests/dns/dns-rcode/input.pcap differ
diff --git a/tests/dns/dns-rcode/test.rules b/tests/dns/dns-rcode/test.rules
new file mode 100644 (file)
index 0000000..1ec3f39
--- /dev/null
@@ -0,0 +1,8 @@
+# Should alert in client direction.
+alert dns any any -> any any (dns.rcode:3; flow:to_client; sid:1; rev:1;)
+
+# Should only alert in client direction.
+alert dns any any -> any any (dns.rcode:!2; flow:to_client; sid:2; rev:1;)
+
+# Should only alert in server direction.
+alert dns any any -> any any (dns.rcode:3; flow:to_server; sid:3; rev:1;)
diff --git a/tests/dns/dns-rcode/test.yaml b/tests/dns/dns-rcode/test.yaml
new file mode 100644 (file)
index 0000000..412f042
--- /dev/null
@@ -0,0 +1,35 @@
+requires:
+  min-version: 8
+
+checks:
+  - filter:
+      count: 1
+      match:
+        alert.signature_id: 1
+        dest_ip: 10.16.1.11
+        dest_port: 59465
+        direction: to_client
+        app_proto: dns
+        event_type: alert
+        dns.answer.rcode: NXDOMAIN
+        src_ip: 8.8.4.4
+        src_port: 53
+  - filter:
+      count: 1
+      match:
+        alert.signature_id: 2
+        dest_ip: 10.16.1.11
+        dest_port: 59465
+        direction: to_client
+        app_proto: dns
+        event_type: alert
+        dns.answer.rcode: NXDOMAIN
+        src_ip: 8.8.4.4
+        src_port: 53
+  - filter:
+      count: 1
+      match:
+        alert.signature_id: 3
+        direction: to_server
+        app_proto: dns
+        event_type: alert