Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test for dns.rcode #1563

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/dns/dns-rcode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Test the `dns.rcode` sticky buffer.

The PCAP here was a request created with Scapy to include answers in
the request. However the response is from a real DNS server with the
provided request.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a reference to the redmine ticket :)

If you do re-use a pcap from a different test, you can indicate that here, too.

8 changes: 8 additions & 0 deletions tests/dns/dns-rcode/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Should alert in both directions as no flow is provided.
alert dns any any -> any any (dns.rcode; content:"oisf"; sid:1; rev:1;)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it not be something like dns.rcode:12 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and no content

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's an integer keyword ;)


# Should only alert in the request direction.
alert dns any any -> any any (dns.rcode; content:"oisf"; flow:to_server; sid:2; rev:1;)

# Should only alert in the response direction.
alert dns any any -> any any (dns.rcode; content:"oisf"; flow:to_client; sid:3; rev:1;)
43 changes: 43 additions & 0 deletions tests/dns/dns-rcode/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
requires:
min-version: 8

checks:
- filter:
count: 2
match:
alert.signature_id: 1
app_proto: dns
Comment on lines +8 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's important to add a check for the rcode field on the checks, too :)

- filter:
count: 1
match:
alert.signature_id: 1
direction: to_client
app_proto: dns
- filter:
count: 1
match:
alert.signature_id: 1
direction: to_server
app_proto: dns

- filter:
count: 1
match:
alert.signature_id: 2
- filter:
count: 1
match:
alert.signature_id: 2
direction: to_server
app_proto: dns

- filter:
count: 1
match:
alert.signature_id: 3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can have only one filter per signature id, right ?

- filter:
count: 1
match:
alert.signature_id: 3
direction: to_client
app_proto: dns