From 1972a5aee4e980ac2c07ed887716c399f733f396 Mon Sep 17 00:00:00 2001 From: Hadiqa Alamdar Bukhari Date: Tue, 26 Dec 2023 15:00:08 +0500 Subject: [PATCH] test: add test for dns.rcode Feature #6621 --- tests/dns/dns-rcode/README.md | 7 +++++++ tests/dns/dns-rcode/input.pcap | Bin 0 -> 315 bytes tests/dns/dns-rcode/test.rules | 8 ++++++++ tests/dns/dns-rcode/test.yaml | 35 +++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 tests/dns/dns-rcode/README.md create mode 100644 tests/dns/dns-rcode/input.pcap create mode 100644 tests/dns/dns-rcode/test.rules create mode 100644 tests/dns/dns-rcode/test.yaml diff --git a/tests/dns/dns-rcode/README.md b/tests/dns/dns-rcode/README.md new file mode 100644 index 000000000..d4722474f --- /dev/null +++ b/tests/dns/dns-rcode/README.md @@ -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 index 0000000000000000000000000000000000000000..8396d3ee6f1a4a5846102099a5a70ece71789c03 GIT binary patch literal 315 zc-p&ic+)~A1{MYcU}0bcl5Y9k5nmfQ8RCI#5M~e+=VkkT<8;^Cg>D=St_%!;iTMl+ z4uVYVTmp>T92_hxFFYAc8EkiLZ<@-e3^sy+fsr{SFO?-fvp9`8FSP{72Z?J6KQuP;+O;%$U2QnTntNq5+Dq*2x2MNx@k8%85k@DCoBh91+tRC6lh^n)~Tkc zjm==|7_nJ*K!AY_B+J~);L4U)tZQg!z?oQHoC0DRGbiWgG6+Js8TrK}xrxOksYPsw gxrtTzc?Yb)hBC+~0JXO;2$cePfek?SGeH9i08 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 index 000000000..412f042e3 --- /dev/null +++ b/tests/dns/dns-rcode/test.yaml @@ -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 -- 2.47.2