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

dns: log queries as an array - v3 #11283

Closed
wants to merge 4 commits into from

Conversation

jasonish
Copy link
Member

@jasonish jasonish commented Jun 10, 2024

Previous PR: #11238

Changes from previous PR:

  • unify the code for logging DNS request across DNS and alerts, addresses discrepancies reported in bug
  • documentation/upgrade guide

Ticket: https://redmine.openinfosecfoundation.org/issues/6281

SV_BRANCH=OISF/suricata-verify#1907

If multiple queries exist in a DNS request, Suricata would log a
discrete DNS event for each request. However, in an alert on a DNS
request, the DNS object would contain an array of query objects.

This brings the "dns" object into alignment with respect to DNS
requests in alerts and "dns" records.

This introduces a new function for logging DNS messages that is common
for requests and responses which should reduce code, but for this
commit is only used for requests, so doesn't cover responses yet.

As this is a breaking change, rename the "query" array in alerts to
"queries" to be more in alignment with how we log "answers" and
"authorities".

Note that this is a breaking change.

Bug: OISF#6281
By using the same function for logging DNS requests and responses we
can better ensure that the format stays consistent between.

Bug: OISF#6281
@jasonish
Copy link
Member Author

Comment on lines +57 to +62
"queries": [
{
"rrname": "www.suricata.io",
"rrtype": "A"
}
]
Copy link
Member Author

Choose a reason for hiding this comment

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

This format is critical for mDNS as well.

Copy link
Member Author

@jasonish jasonish Jun 10, 2024

Choose a reason for hiding this comment

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

Elasticsearch is pretty good with arrays like this, you can search on dns.queries.rrname. So it means searches/reports, etc will need to change from dns.rrname to dns.queries.rrname.

Copy link

codecov bot commented Jun 10, 2024

Codecov Report

Attention: Patch coverage is 97.80220% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82.47%. Comparing base (f0dbfe8) to head (4459913).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11283      +/-   ##
==========================================
+ Coverage   82.45%   82.47%   +0.01%     
==========================================
  Files         961      961              
  Lines      251710   251662      -48     
==========================================
  Hits       207552   207552              
+ Misses      44158    44110      -48     
Flag Coverage Δ
fuzzcorpus 60.30% <96.70%> (+<0.01%) ⬆️
livemode 18.69% <0.00%> (+<0.01%) ⬆️
pcap 43.85% <96.70%> (+0.05%) ⬆️
suricata-verify 61.21% <97.80%> (+0.02%) ⬆️
unittests 59.96% <6.59%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 21035

@catenacyber
Copy link
Contributor

Looks a nice clean up, thanks for taking on this

@jasonish jasonish mentioned this pull request Jun 12, 2024
4 tasks
"version": 2,
"type": "answer",
"id": 0,
"flags": "8180",
Copy link
Member Author

Choose a reason for hiding this comment

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

Any thoughts on if flags would look better as:

"flags": ["qr", "rd", "ra"],

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks better as ["qr", "rd", "ra"], than 8180 as a string ?

Copy link
Member Author

Choose a reason for hiding this comment

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

We'd probably want to keep the raw value (8180 in this case). The array would replace "rd": true and friends.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok as well

Copy link
Member

Choose a reason for hiding this comment

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

How would that affect things like elastic and splunk wrt querying for them?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently you'd have to do something like:
dns.flags.rd:true dns.flags.z:true
with this change:
dns.flags:rd dns.flags:z

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, thanks

@jasonish jasonish marked this pull request as draft June 13, 2024 20:10
@jasonish jasonish closed this Jun 13, 2024
@jasonish jasonish deleted the dns-request-array/v3 branch August 7, 2024 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants