Skip to content

dns: new keywords: dns.answer.name, dns.query.name#9795

Closed
jasonish wants to merge 9 commits intoOISF:masterfrom
jasonish:dns-response/v3
Closed

dns: new keywords: dns.answer.name, dns.query.name#9795
jasonish wants to merge 9 commits intoOISF:masterfrom
jasonish:dns-response/v3

Conversation

@jasonish
Copy link
Member

Introduce two new DNS keywords, dns.query.name and dns.answer.name.

Tickets:

SV_BRANCH=OISF/suricata-verify#1464

While this introduces 2 new keywords, I'm also trying to create a good example
of a sticky buffer keyword, and then migrate that into the template, so please
consider the full structure of the files implementing the sticky buffers.

I probably should have left out the "cleanups", can do in a subsequent PR.

The old DetectAppLayerMpmRegister has not been around since 4.1.x.
Rename the v2 of this function to a versionless function as there is no
documentation referring to what the 2 means.
…ngine

Rename DetectAppLayerInspectEngine2 to DetectAppLayerInspectEngine as
there is no other variant of this function, and the versioning with
lack of supporting documentation can lead to confusion.
This sticky buffer will allow content matching on the answer names.
While ansers typically only occur in DNS responses, we allow the buffer
to be used in request context as well as the request message format
allows it.

Feature: OISF#6496
This buffer is much like dns.query_name but allows for detection in both
directions.

Feature: OISF#6497
With some other minor cleanups in the DNS keyword section.
SCDnsTxGetQueryName was introduced to allow for getting the query name
in responses as well as requests, so covers the functionality of
rs_dns_tx_get_query_name.
Comment on lines +97 to +100
if (!SCDnsTxGetAnswerName(txv, index, &data, &data_len)) {
InspectionBufferSetupMultiEmpty(buffer);
return NULL;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Missing the direction here as we currently don't parse answers, etc in DNS requests. But the message structure fully allows for it, so I'm thinking we should parse it if its there.

Copy link
Member

@victorjulien victorjulien Nov 16, 2023

Choose a reason for hiding this comment

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

you mean answers in the request? Lets at a minimum get a test case + event for it.

wonder if we should make the keywords include directionality in the name, e.g. dns.request.query. I would be confused if answers would match on a request packet, even if from the dns record pov it would be correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is the path I first went down, dns.request.query.name, dns.response.query.name, etc. But don't we have the flow keyword to express the directionality?

Copy link
Member Author

Choose a reason for hiding this comment

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

you mean answers in the request? Lets at a minimum get a test case + event for it.

Converting this to draft as I mostly did complete support for answers in requests yesterday with an SV test, so worth getting that in to avoid some confusing comments.

@codecov
Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Merging #9795 (f1d2319) into master (6bb882c) will decrease coverage by 0.11%.
The diff coverage is 97.70%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9795      +/-   ##
==========================================
- Coverage   82.43%   82.32%   -0.11%     
==========================================
  Files         968      970       +2     
  Lines      273866   273944      +78     
==========================================
- Hits       225758   225529     -229     
- Misses      48108    48415     +307     
Flag Coverage Δ
fuzzcorpus 64.03% <78.23%> (-0.38%) ⬇️
suricata-verify 60.99% <97.38%> (-0.02%) ⬇️
unittests 62.90% <77.90%> (-0.04%) ⬇️

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 16541

@victorjulien victorjulien added this to the 8.0 milestone Nov 16, 2023

/// Get the DNS query name at index i.
#[no_mangle]
pub unsafe extern "C" fn SCDnsTxGetQueryName(
Copy link
Member

Choose a reason for hiding this comment

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

why do we break the rust style here (and previously below)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean the off by one on the indent? Not sure how that happened, I rust formatted the new code, but didn't take in some new formatting.

keyword works a bit different from the normal content modifiers. When
used in a rule all contents following it are affected by it. Example:
With **dns.query** the DNS request query names are inspected. The
dns.query keyword works a bit different from the normal content
Copy link
Member

@victorjulien victorjulien Nov 16, 2023

Choose a reason for hiding this comment

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

"this works a bit different"-bit could be removed. It's just about sticky buffer vs content modifier

Copy link
Member Author

Choose a reason for hiding this comment

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

Given we're at 8 maybe we should clean this up. Just refer to it as a sticky buffer and not much more?


``dns.query.name`` is a sticky buffer that is used to look at the name
field in DNS query (question) resource records. It is nearly identical
to ``dns.query`` but supports both DNS requests and responses.
Copy link
Member

Choose a reason for hiding this comment

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

Guess this makes things clear enough.

@jasonish
Copy link
Member Author

Replaced by #9813.

@jasonish jasonish closed this Nov 16, 2023
@jasonish jasonish deleted the dns-response/v3 branch December 14, 2023 16:27
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