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 over http2 5773 v14 #11376

Closed
wants to merge 11 commits into from

Conversation

catenacyber
Copy link
Contributor

Link to redmine ticket:
https://redmine.openinfosecfoundation.org/issues/5773

Describe changes:

  • analyze DNS over HTTP2

SV_BRANCH=OISF/suricata-verify#1734

#11369 with greener CI.
@victorjulien should I squash the 2 last commits in ?
They are are help to help you review your last comments...

Draft because of TODO :

by making tx parsing and creation more easily available,
without needing a dns state.

Dns event NotResponse is now set on the right tx, and not the one
before.

Also debug log for Z-flag on request says "request" instead of
"response"

Also rustfmt dns.rs
Now a flow alproto can be changed by a call to AppLayerParserParse
when HTTP2 forces the flow to turn into DOH2.
Ticket: 5773

Handles both directions the same way for data if content type is
application/dns-message
So as to consume less memory for HTTP2Transaction
@suricata-qa
Copy link

ERROR:

ERROR: QA failed on build_asan.

Pipeline 21273

@victorjulien
Copy link
Member

Passed my QA. Ran this PR with SV PR OISF/suricata-verify#1734. Local pipeline 4966, run 511.

* in the list that are not for us. */
engine = engine->next;
continue;
if (engine->alproto != 0) {
Copy link
Member

Choose a reason for hiding this comment

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

use ALPROTO_UNKNOWN here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok (is written 0 in master)

@@ -124,6 +128,15 @@ pub struct HTTP2Frame {
pub data: HTTP2FrameTypeData,
}

#[derive(Debug, Default)]
pub struct DohHttp2Tx {
Copy link
Member

Choose a reason for hiding this comment

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

can you add field description comments, esp on the index to these 2 fields

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

js.open_array("query")?;
for i in 0..0xFFFF {
let mut jsa = JsonBuilder::try_new_object()?;
if !SCDnsLogJsonQuery(dtx, i, 0xFFFFFFFFFFFFFFFF, &mut jsa) {
Copy link
Member

Choose a reason for hiding this comment

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

can we use a named constant for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wait for stabilization of #11305 to use what will come of it...

@@ -1844,6 +1844,16 @@ bool AppLayerRequestProtocolTLSUpgrade(Flow *f)
return AppLayerRequestProtocolChange(f, 443, ALPROTO_TLS);
}

void AppLayerForceProtocolChange(Flow *f, AppProto new_proto)
Copy link
Member

Choose a reason for hiding this comment

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

can this get a comment explaining the logic of only setting f->alproto to new_proto?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alproto_ts and alproto_tc are also set to new_proto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

adding a comment to the function anyways

@@ -101,6 +109,48 @@ static inline bool AppProtoEquals(AppProto sigproto, AppProto alproto)
return false;
}

// whether a signature AppProto matches a flow (or signature) AppProto
Copy link
Member

Choose a reason for hiding this comment

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

can you add a comment here on the interplay between doh2 and http2 and sigs using either?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

// Get inner transaction for engine
void *DetectGetInnerTx(void *tx_ptr, AppProto alproto, AppProto engine_alproto, uint8_t flow_flags)
{
if (alproto == ALPROTO_DOH2) {
Copy link
Member

Choose a reason for hiding this comment

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

is this expected to be the common case for calls to this function? Or should we put the non-doh2 first to improve branch prediction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic is not the same as there is an else if

Adding unlikely

Copy link
Member

@victorjulien victorjulien left a comment

Choose a reason for hiding this comment

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

Nice work so far. Some comments inline.

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 21346

@catenacyber
Copy link
Contributor Author

Continued in #11428

@catenacyber catenacyber closed this Jul 4, 2024
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