-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Detect tcp noupdatetotx 6299 v8 #10127
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,13 +152,24 @@ static void DetectRun(ThreadVars *th_v, | |
| DetectRunFrames(th_v, de_ctx, det_ctx, p, pflow, &scratch); | ||
| // PACKET_PROFILING_DETECT_END(p, PROF_DETECT_TX); | ||
| } | ||
| // no update to transactions | ||
| if (!PKT_IS_PSEUDOPKT(p) && p->app_update_direction == 0 && | ||
| ((PKT_IS_TOSERVER(p) && (p->flow->flags & FLOW_TS_APP_UPDATED) == 0) || | ||
| (PKT_IS_TOCLIENT(p) && (p->flow->flags & FLOW_TC_APP_UPDATED) == 0))) { | ||
| goto end; | ||
| } | ||
| } else if (p->proto == IPPROTO_UDP) { | ||
| DetectRunFrames(th_v, de_ctx, det_ctx, p, pflow, &scratch); | ||
| } | ||
|
|
||
| PACKET_PROFILING_DETECT_START(p, PROF_DETECT_TX); | ||
| DetectRunTx(th_v, de_ctx, det_ctx, p, pflow, &scratch); | ||
| PACKET_PROFILING_DETECT_END(p, PROF_DETECT_TX); | ||
| /* see if we need to increment the inspect_id and reset the de_state */ | ||
| PACKET_PROFILING_DETECT_START(p, PROF_DETECT_TX_UPDATE); | ||
| AppLayerParserSetTransactionInspectId( | ||
| pflow, pflow->alparser, pflow->alstate, scratch.flow_flags, (scratch.sgh == NULL)); | ||
| PACKET_PROFILING_DETECT_END(p, PROF_DETECT_TX_UPDATE); | ||
| } | ||
|
|
||
| end: | ||
|
|
@@ -919,14 +930,6 @@ static inline void DetectRunPostRules( | |
| Flow * const pflow, | ||
| DetectRunScratchpad *scratch) | ||
| { | ||
| /* see if we need to increment the inspect_id and reset the de_state */ | ||
| if (pflow && pflow->alstate) { | ||
| PACKET_PROFILING_DETECT_START(p, PROF_DETECT_TX_UPDATE); | ||
| AppLayerParserSetTransactionInspectId(pflow, pflow->alparser, pflow->alstate, | ||
| scratch->flow_flags, (scratch->sgh == NULL)); | ||
| PACKET_PROFILING_DETECT_END(p, PROF_DETECT_TX_UPDATE); | ||
| } | ||
|
|
||
| /* so now let's iterate the alerts and remove the ones after a pass rule | ||
| * matched (if any). This is done inside PacketAlertFinalize() */ | ||
| /* PR: installed "tag" keywords are handled after the threshold inspection */ | ||
|
|
@@ -1223,7 +1226,7 @@ static bool DetectRunTxInspectRule(ThreadVars *tv, | |
| } else if ((inspect_flags & DE_STATE_FLAG_FULL_INSPECT) == 0 && mpm_in_progress) { | ||
| TRACE_SID_TXS(s->id, tx, "no need to store no-match sig, " | ||
| "mpm will revisit it"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. commit message not explaining why/how and problem this solves |
||
| } else { | ||
| } else if (inspect_flags != 0) { | ||
| TRACE_SID_TXS(s->id, tx, "storing state: flags %08x", inspect_flags); | ||
| DetectRunStoreStateTx(scratch->sgh, f, tx->tx_ptr, tx->tx_id, s, | ||
| inspect_flags, flow_flags, file_no_match); | ||
|
|
@@ -1375,21 +1378,50 @@ static void DetectRunTx(ThreadVars *tv, | |
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. commit message should explain why & how |
||
| /* merge 'state' rules from the regular prefilter */ | ||
| uint32_t x = array_idx; | ||
| uint32_t j = x; | ||
| for (uint32_t i = 0; i < det_ctx->match_array_cnt; i++) { | ||
| const Signature *s = det_ctx->match_array[i]; | ||
| if (s->app_inspect != NULL) { | ||
| const SigIntId id = s->num; | ||
| det_ctx->tx_candidates[array_idx].s = s; | ||
| det_ctx->tx_candidates[array_idx].id = id; | ||
| det_ctx->tx_candidates[array_idx].flags = NULL; | ||
| det_ctx->tx_candidates[array_idx].stream_reset = 0; | ||
| array_idx++; | ||
|
|
||
| SCLogDebug("%p/%"PRIu64" rule %u (%u) added from 'match' list", | ||
| tx.tx_ptr, tx.tx_id, s->id, id); | ||
| } | ||
| } | ||
| do_sort = (array_idx > x); // sort if match added anything | ||
| uint32_t k = array_idx; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you move this into a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| for (uint32_t i = det_ctx->match_array_cnt; i > 0;) { | ||
| const Signature *s = det_ctx->match_array[i - 1]; | ||
| if (s->app_inspect != NULL) { | ||
| const SigIntId id = s->num; | ||
| if (j > 0) { | ||
| const RuleMatchCandidateTx *s0 = &det_ctx->tx_candidates[j - 1]; | ||
| if (s->id > s0->id) { | ||
| det_ctx->tx_candidates[k - 1].s = s; | ||
| det_ctx->tx_candidates[k - 1].id = id; | ||
| det_ctx->tx_candidates[k - 1].flags = NULL; | ||
| det_ctx->tx_candidates[k - 1].stream_reset = 0; | ||
| i--; | ||
| } else { | ||
| // progress in the sorted list | ||
| det_ctx->tx_candidates[k - 1].s = det_ctx->tx_candidates[j - 1].s; | ||
| det_ctx->tx_candidates[k - 1].id = det_ctx->tx_candidates[j - 1].id; | ||
| det_ctx->tx_candidates[k - 1].flags = det_ctx->tx_candidates[j - 1].flags; | ||
| det_ctx->tx_candidates[k - 1].stream_reset = | ||
| det_ctx->tx_candidates[j - 1].stream_reset; | ||
| j--; | ||
| } | ||
| } else { | ||
| // simply append the end of sorted list | ||
| det_ctx->tx_candidates[k - 1].s = s; | ||
| det_ctx->tx_candidates[k - 1].id = id; | ||
| det_ctx->tx_candidates[k - 1].flags = NULL; | ||
| det_ctx->tx_candidates[k - 1].stream_reset = 0; | ||
| i--; | ||
| SCLogDebug("%p/%" PRIu64 " rule %u (%u) added from 'match' list", tx.tx_ptr, | ||
| tx.tx_id, s->id, id); | ||
| } | ||
| k--; | ||
| } else { | ||
| i--; | ||
| } | ||
| } | ||
| SCLogDebug("%p/%" PRIu64 " rules added from 'match' list: %u", tx.tx_ptr, tx.tx_id, | ||
| array_idx - x); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit message is very unclear, not understanding what we're doing and why