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: new keywords: dns.answer.name, dns.query.name - v5 #9813

Closed
wants to merge 12 commits into from

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.

Previous PR: #9795
Changes from last PR:

  • Some doc cleanups
  • Answer names are now inspected in requests (SV test updated)

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.
DNS request and response messages follow the same format so there is
no reason not to use the same data structure for each. While its
unlikely to see fields like answers in a request, the message format
does not disallow them, so it might be interesting data to have the
ability to log.
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
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.
With some other minor cleanups in the DNS keyword section.
@jasonish
Copy link
Member Author

Open question: Should dns.answer.name and dns.query.name be dns.request.query.name, dns.response.query.name, etc? Or is specify a flow direction enough?

Copy link

codecov bot commented Nov 16, 2023

Codecov Report

Merging #9813 (7093d63) into master (2f4027c) will increase coverage by 0.00%.
The diff coverage is 97.68%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9813   +/-   ##
=======================================
  Coverage   82.37%   82.37%           
=======================================
  Files         968      970    +2     
  Lines      273866   273927   +61     
=======================================
+ Hits       225585   225640   +55     
- Misses      48281    48287    +6     
Flag Coverage Δ
fuzzcorpus 64.14% <78.93%> (-0.08%) ⬇️
suricata-verify 60.99% <97.27%> (+0.01%) ⬆️
unittests 62.89% <78.61%> (-0.05%) ⬇️

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 16565

@catenacyber
Copy link
Contributor

Why did you put the doc in a separate commit ?

@catenacyber
Copy link
Contributor

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.

See also #9871 especially commit detect: helper to have pure rust keywords

return DETECT_ENGINE_INSPECT_SIG_NO_MATCH;
}

typedef struct PrefilterMpm {
Copy link
Contributor

Choose a reason for hiding this comment

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

This generic struct is already defined somewhere, is it not ?

Copy link
Member Author

Choose a reason for hiding this comment

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

In many detect, but no where for generic re-use that I can see? Might be good to make it more formal in your helpers?

Copy link
Contributor

Choose a reason for hiding this comment

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

Will you this as part of this PR ?
Otherwise, I can take care of it

Copy link
Member Author

Choose a reason for hiding this comment

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

I think its out of scope for this PR. Make sense in the helper work you are doing tho.

Copy link
Contributor

Choose a reason for hiding this comment

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

@catenacyber
Copy link
Contributor

Open question: Should dns.answer.name and dns.query.name be dns.request.query.name, dns.response.query.name, etc? Or is specify a flow direction enough?

This is the same buffer, but different directions, right ? (we have http.request_header and http.response_header as something to compare with)

@jasonish
Copy link
Member Author

Why did you put the doc in a separate commit ?

Its our standard practice, or at least once was to not mix code and docs commits.

@jasonish
Copy link
Member Author

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.

See also #9871 especially commit detect: helper to have pure rust keywords

Yeah, I'm actually waiting on that before I re-work the templates.

@jasonish
Copy link
Member Author

Open question: Should dns.answer.name and dns.query.name be dns.request.query.name, dns.response.query.name, etc? Or is specify a flow direction enough?

This is the same buffer, but different directions, right ? (we have http.request_header and http.response_header as something to compare with)

I guess I'd asky why? When flow can do the same thing without introducing almost duplicated code for each direction.

@catenacyber
Copy link
Contributor

Why did you put the doc in a separate commit ?

Its our standard practice, or at least once was to not mix code and docs commits.

I did not know it and I squashed them together...

@catenacyber
Copy link
Contributor

This is the same buffer, but different directions, right ? (we have http.request_header and http.response_header as something to compare with)

I guess I'd asky why? When flow can do the same thing without introducing almost duplicated code for each direction.

For HTTP headers, it makes sense for bidirectional rules, you will want to match certain headers in the request part, and some others in the response. Not sure if it would make sense for DNS queries...

@jasonish
Copy link
Member Author

Why did you put the doc in a separate commit ?

Its our standard practice, or at least once was to not mix code and docs commits.

I did not know it and I squashed them together...

Here we go:

Point 5 at https://docs.suricata.io/en/latest/devguide/codebase/contributing/code-submission-process.html

@jasonish
Copy link
Member Author

This is the same buffer, but different directions, right ? (we have http.request_header and http.response_header as something to compare with)

I guess I'd asky why? When flow can do the same thing without introducing almost duplicated code for each direction.

For HTTP headers, it makes sense for bidirectional rules, you will want to match certain headers in the request part, and some others in the response. Not sure if it would make sense for DNS queries...

I don't think it makes sense for DNS as it does for HTTP. DNS has one transaction for the request and one for the response. So you don't have the ability to look at the request and the response in one TX.

@jasonish
Copy link
Member Author

Continued at #9920.

@jasonish jasonish closed this Nov 29, 2023
@jasonish jasonish deleted the dns-keywords/v5 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