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 rust keywords 7529 v3 #12535

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

catenacyber
Copy link
Contributor

Link to ticket: https://redmine.openinfosecfoundation.org/issues/
https://redmine.openinfosecfoundation.org/issues/7529
https://redmine.openinfosecfoundation.org/issues/3725

Describe changes:

  • dns: move keywords to rust
  • on the way, move unit tests to SV for dns.query keyword
  • extend some dns keywords so that they can use string enumerations
  • improves UTHBuildPacketReal to produce more real packets

#11932 next protocol
#12496 with SV test replacing the unit tests

SV_BRANCH=OISF/suricata-verify#2275

Ticket: 7529
Ticket: 3725

Adds url for dns.opcode on the way

Move dns.query unit tests to SV on the way
So that its contents can be reused when translating unit tests
to SV tests
@catenacyber catenacyber force-pushed the dns-rust-keywords-7529-v3 branch from b350c6d to 4011693 Compare February 6, 2025 13:12
Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 96.63212% with 13 lines in your changes missing coverage. Please review.

Project coverage is 80.70%. Comparing base (d4330ef) to head (4011693).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12535      +/-   ##
==========================================
+ Coverage   80.68%   80.70%   +0.01%     
==========================================
  Files         925      919       -6     
  Lines      258914   258458     -456     
==========================================
- Hits       208914   208581     -333     
+ Misses      50000    49877     -123     
Flag Coverage Δ
fuzzcorpus 56.90% <73.29%> (+0.08%) ⬆️
livemode 19.43% <35.60%> (+0.02%) ⬆️
pcap 44.23% <54.30%> (+0.03%) ⬆️
suricata-verify 63.44% <92.87%> (+0.05%) ⬆️
unittests 58.32% <49.22%> (-0.06%) ⬇️

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 24655

Comment on lines +405 to +414
let kw = SCSigTableElmt {
name: b"dns.query.name\0".as_ptr() as *const libc::c_char,
desc: b"DNS query name sticky buffer\0".as_ptr() as *const libc::c_char,
url: b"/rules/dns-keywords.html#dns-query-name\0".as_ptr() as *const libc::c_char,
Setup: dns_detect_query_name_setup,
flags: SIGMATCH_NOOPT | SIGMATCH_INFO_STICKY_BUFFER,
AppLayerTxMatch: None,
Free: None,
};
let _g_dns_query_name_kw_id = DetectHelperKeywordRegister(&kw);
Copy link
Member

Choose a reason for hiding this comment

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

Have you looked at making registering keywords more of a Rust experience? Rather than this C like code from Rust? By that I mean registration functions where you can use Rust strings, and hide the as_ptr() and stuff away.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, will do

Comment on lines +415 to +424
G_DNS_QUERY_NAME_BUFFER_ID = DetectHelperMultiBufferMpmRegister(
b"dns.query.name\0".as_ptr() as *const libc::c_char,
b"dns query name\0".as_ptr() as *const libc::c_char,
ALPROTO_DNS,
true,
/* Register in both directions as the query is usually echoed back
in the response. */
true,
dns_query_name_get_data_wrapper,
);
Copy link
Member

Choose a reason for hiding this comment

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

This results in:

        DetectAppLayerMultiRegister(name, alproto, SIG_FLAG_TOSERVER, 0, GetData, 2, 0);

However, on the C side:

    DetectAppLayerMultiRegister(keyword, ALPROTO_DNS, SIG_FLAG_TOSERVER, 0, GetBuffer, 2, 1);

I haven't looked into it, but is min-progress not needed? Is 1 equivalent to 0? Is 2 equivalent to 1?

Its not a 1:1 conversion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but is min-progress not needed?

Not really for DNS : you get your unidirectional transaction as soon as you parse it.
So every DNS transaction always has progress 1, so it is like the whole concept of progress is irrelevant for DNS transactions.

But this may be indeed a pitfall in other cases...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is 1 equivalent to 0?

yes here

2 is some default priority...

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.

3 participants