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: more keywords; plus some eve/keyword parity tooling - v6 #12652

Closed
wants to merge 13 commits into from

Conversation

jasonish
Copy link
Member

This PR builds on #12500 and also adds the following keywords:

To provide consistency and better eve parity the following keywords were renamed:

  • dns.query.rrname -> dns.queries.rrname
  • dns.answer.rrname -> dns.answers.rrname

And finally, as using DNS as a test protocol for parity, try some tooling for eve parity.

For example, ./scripts/eve-parity.py mapped-keywords:

dns.rcode -> [dns.rcode]
dns.answer.additionals.rdata -> [dns.response.rrname]
dns.answer.additionals.rrname -> [dns.additionals.rrname, dns.response.rrname]
dns.answer.authorities.rdata -> [dns.response.rrname]
dns.answer.authorities.rrname -> [dns.authorities.rrname, dns.response.rrname]
dns.queries.rrname -> [dns.queries.rrname, dns.query]
dns.queries.rrtype -> [dns.rrtype]
dns.queries.opcode -> [dns.opcode]
dns.additionals.rdata -> [dns.response.rrname]
dns.additionals.rrname -> [dns.additionals.rrname, dns.response.rrname]
dns.authorities.rdata -> [dns.response.rrname]
dns.authorities.rrname -> [dns.authorities.rrname, dns.response.rrname]
dns.answers.rdata -> [dns.response.rrname]
dns.answers.rrname -> [dns.answers.rrname, dns.response.rrname]

and ./scripts/eve-parity.py unmapped-fields | grep dns:

dhcp.dns_servers
dns.aa
dns.additionals.opt.code
dns.additionals.opt.data
dns.additionals.rrtype
dns.additionals.ttl
dns.answer.additionals.opt.code
dns.answer.additionals.opt.data
dns.answer.additionals.rrtype
dns.answer.additionals.ttl
dns.answer.authorities.rdata_truncated
dns.answer.authorities.rrname_truncated
dns.answer.authorities.rrtype
dns.answer.authorities.soa.expire

and new in this version: unmapped-keywords to show known keywords that are
not mapped in the eve.json.

Other changes:

  • remove unit tests, they should have SV coverage now

SV_BRANCH=OISF/suricata-verify#2311

Copy link

codecov bot commented Feb 21, 2025

Codecov Report

Attention: Patch coverage is 94.06528% with 20 lines in your changes missing coverage. Please review.

Project coverage is 80.80%. Comparing base (3bc2a14) to head (762e73e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12652      +/-   ##
==========================================
+ Coverage   80.77%   80.80%   +0.02%     
==========================================
  Files         932      932              
  Lines      259517   259758     +241     
==========================================
+ Hits       209629   209895     +266     
+ Misses      49888    49863      -25     
Flag Coverage Δ
fuzzcorpus 56.92% <19.58%> (-0.07%) ⬇️
livemode 19.35% <19.58%> (-0.03%) ⬇️
pcap 44.19% <19.58%> (+0.03%) ⬆️
suricata-verify 63.57% <94.06%> (+0.06%) ⬆️
unittests 58.28% <19.58%> (-0.04%) ⬇️

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

@jasonish jasonish marked this pull request as draft February 21, 2025 21:31
scrivs86 and others added 13 commits February 21, 2025 16:11
Feature: 7012
Add dns.response sticky buffer to match on dns response fields.
Add rust functions to return dns response packet data.
Unit tests verifying signature matching.
This is a better name as the keyword is looking at all rrname type
fields in the response.
These arrays are manually formatted for readability.
Make the function safe by returning a reference to the DNSName object,
the unsafe C wrapper can do the conversion to pointers.
Split DetectHelperKeywordRegister into 2 functions, one for acquiring
a new keyword ID, and another to perform the registration.

This makes it easier to do the traditional C keyword initialization
with a dynamic ID.
Add keywords dns.additionals.rrname and dns.authorities.rrname. Along
the way, consolidate dns.query.name and dns.answer.name into a single file
and register them altogether since there is a lot of common code.
To some EVE fields and a "suricata" object that contains an array of
keywords. These are the keywords that map directly to this field, or
somehow cover this field.

This is an attempt at tooling to help with EVE and keyword parity.

Related to tickets: OISF#5642, OISF#6463, OISF#4772
Currently this script has two commands: "missing" and "having".

"missing" will show eve fields that do not map to any keywords.

"having" will sohw eve fields along with their keyword mappsings,
while also validating that those keywords really exist.

Related to tickets: OISF#6463, OISF#4772
Should have coverage by S-V now.
@jasonish jasonish force-pushed the ish/dns/feat-7012/v6 branch from b2b35ed to 762e73e Compare February 21, 2025 22:12
@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 24853

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 24856

"type": "integer"
"type": "integer",
"suricata": {
"keywords": false
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it good to have this suricata.keyword that can either be a boolean or an array ?

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'm ok with it, unless its going into something the hardcodes a schema based on whats first seen., so not in eve. Prevents conflict with another field as well..

"keywords": ["one", "two"],
"no-keywords": "true",

SCFree(ptr);
}

static int DetectDnsResponsePrefilterMpmRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need a specific stuff here ?

Do not we get prefilter for all sticky buffers from the generic engine ?

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 not we get prefilter for all sticky buffers from the generic engine ?

Are you asking? If so, I'm not sure.

InspectionBuffer *buffer =
GetBuffer(det_ctx, flags, transforms, txv, &cbdata, engine->sm_list, false);
if (buffer == NULL || buffer->inspect == NULL) {
local_id++;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need local_id++ if we break right after ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Doesn't look like 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.

Nevermind, we're only breaking the inner loop, its still needed by the outer loop.

@jasonish
Copy link
Member Author

Replaced by #12664

@jasonish jasonish closed this Feb 24, 2025
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