89 static inline uint8_t DetectRulePacketRules(
ThreadVars *
const tv,
124 DetectRunInspectIPOnly(
th_v,
de_ctx, det_ctx, pflow,
p);
127 DetectRunGetRuleGroup(
de_ctx,
p, pflow, &scratch);
130 if (scratch.
sgh == NULL) {
132 SCLogDebug(
"no sgh for this packet, nothing to match against");
136 "packet %" PRIu64
": no sgh, need to apply default policies",
PcapPacketCntGet(
p));
139 DetectRunPrefilterPkt(
th_v,
de_ctx, det_ctx,
p, &scratch);
143 const uint8_t pkt_policy = DetectRulePacketRules(
th_v,
de_ctx, det_ctx,
p, pflow, &scratch);
161 if (
p->
proto == IPPROTO_TCP) {
165 SCLogDebug(
"default accept: no PKT_STREAM_EST");
166 DetectRunAppendDefaultAccept(det_ctx,
p);
179 DetectRunFrames(
th_v,
de_ctx, det_ctx,
p, pflow, &scratch);
189 DetectRunAppendDefaultAccept(det_ctx,
p);
193 }
else if (
p->
proto == IPPROTO_UDP) {
194 DetectRunFrames(
th_v,
de_ctx, det_ctx,
p, pflow, &scratch);
198 DetectRunTx(
th_v,
de_ctx, det_ctx,
p, pflow, &scratch);
209 DetectRunAppendDefaultAccept(det_ctx,
p);
214 DetectRunPostRules(
th_v,
de_ctx, det_ctx,
p, pflow, &scratch);
216 DetectRunCleanup(det_ctx,
p, pflow);
241 if (scratch.
sgh == NULL) {
242 SCLogDebug(
"no sgh for this packet, nothing to match against");
247 DetectRunPrefilterPkt(
th_v,
de_ctx, det_ctx,
p, &scratch);
251 const uint8_t pkt_policy = DetectRulePacketRules(
th_v,
de_ctx, det_ctx,
p, pflow, &scratch);
258 DetectRunPostRules(
th_v,
de_ctx, det_ctx,
p, pflow, &scratch);
260 DetectRunCleanup(det_ctx,
p, pflow);
273 SCLogDebug(
"running match functions, sm %p", smd);
310 }
else if (
p->
proto == 0) {
311 if (!(PacketIsIPv4(
p) || PacketIsIPv6(
p))) {
320 int proto = PacketGetIPProto(
p);
321 if (
proto == IPPROTO_TCP) {
325 const uint16_t port = dir ?
p->
dp :
p->
sp;
330 SCLogDebug(
"TCP list %p, port %u, direction %s, sghport %p, sgh %p", list, port,
331 dir ?
"toserver" :
"toclient", sghport, sgh);
332 }
else if (
proto == IPPROTO_UDP) {
334 uint16_t port = dir ?
p->
dp :
p->
sp;
338 SCLogDebug(
"UDP list %p, port %u, direction %s, sghport %p, sgh %p", list, port,
339 dir ?
"toserver" :
"toclient", sghport, sgh);
347 static inline void DetectPrefilterCopyDeDup(
355 while (final_cnt-- > 0) {
360 if (
likely(
id != previous_id)) {
377 DetectPostInspectFileFlagsUpdate(
Flow *f,
const SigGroupHead *sgh, uint8_t direction)
382 SCLogDebug(
"requesting disabling all file features for flow");
386 SCLogDebug(
"requesting disabling filestore for flow");
387 flow_file_flags |= (FLOWFILE_NO_STORE_TS|FLOWFILE_NO_STORE_TC);
390 if (!(sgh->
flags & SIG_GROUP_HEAD_HAVEFILEMAGIC)) {
391 SCLogDebug(
"requesting disabling magic for flow");
396 SCLogDebug(
"requesting disabling md5 for flow");
400 SCLogDebug(
"requesting disabling sha1 for flow");
404 SCLogDebug(
"requesting disabling sha256 for flow");
408 if (flow_file_flags != 0) {
424 SCLogDebug(
"STREAMTCP_STREAM_FLAG_DISABLE_RAW ssn.client");
429 DetectPostInspectFileFlagsUpdate(pflow,
439 SCLogDebug(
"STREAMTCP_STREAM_FLAG_DISABLE_RAW ssn.server");
444 DetectPostInspectFileFlagsUpdate(pflow,
449 static inline void DetectRunGetRuleGroup(
457 bool use_flow_sgh =
false;
460 if (PacketGetIPProto(
p) == pflow->
proto) {
464 SCLogDebug(
"sgh = pflow->sgh_toserver; => %p", sgh);
468 SCLogDebug(
"sgh = pflow->sgh_toclient; => %p", sgh);
474 if (!(use_flow_sgh)) {
487 DetectRunPostGetFirstRuleGroup(
p, pflow, sgh);
507 SCLogDebug(
"testing against \"ip-only\" signatures");
526 static inline bool DetectRunInspectRuleHeader(
536 const bool fv = f->
flowvar != NULL;
538 SCLogDebug(
"skipping sig as the flow has no flowvars and sig "
539 "has SIG_FLAG_REQUIRE_FLOWVAR flag set.");
544 if (!(s->
proto == NULL)) {
545 const uint8_t s_proto_flags = s->
proto->
flags;
557 if (PacketIsEthernet(
p) &&
591 SCLogDebug(
"port-less protocol and sig needs ports");
597 if (PacketIsIPv4(
p)) {
600 }
else if (PacketIsIPv6(
p)) {
607 if (PacketIsIPv4(
p)) {
610 }
else if (PacketIsIPv6(
p)) {
638 DetectPrefilterCopyDeDup(
de_ctx, det_ctx);
653 static bool IsOnlyTxInDirection(
Flow *f, uint64_t txid, uint8_t dir)
656 if (tx_cnt == txid + 1) {
660 if (tx_cnt == txid + 2) {
666 if ((dir == STREAM_TOSERVER && (txd->
flags & APP_LAYER_TX_SKIP_INSPECT_TS)) ||
667 (dir == STREAM_TOCLIENT && (txd->
flags & APP_LAYER_TX_SKIP_INSPECT_TC))) {
675 static int SortHelper(
const void *a,
const void *b)
681 return sa->
iid > sb->
iid ? 1 : -1;
684 static inline bool SkipFwRules(
const Packet *
p)
686 if (
p->
flow != NULL) {
711 SCLogDebug(
"packet %" PRIu64
": drop PKT_DROP_REASON_FW_DEFAULT_PACKET_POLICY",
723 SCLogDebug(
"packet %" PRIu64
": accept scope hook upgraded to packet",
747 static inline uint8_t DetectRulePacketRules(
ThreadVars *
const tv,
752 bool fw_verdict =
false;
772 bool skip_fw = SkipFwRules(
p);
773 uint32_t sflags, next_sflags = 0;
775 next_s = *match_array++;
776 next_sflags = next_s->
flags;
778 while (match_cnt--) {
780 bool break_out_of_packet_filter =
false;
781 uint8_t alert_flags = 0;
786 sflags = next_sflags;
788 next_s = *match_array++;
789 next_sflags = next_s->
flags;
801 }
else if (have_fw_rules) {
808 break_out_of_packet_filter =
true;
831 if (SigDsizePrefilter(
p, s, sflags))
842 if (DetectRunInspectRuleHeader(
p, pflow, s, sflags) ==
false) {
853 DetectRunPostMatch(
tv, det_ctx,
p, s);
871 if (pflow->
proto != IPPROTO_UDP) {
887 SCLogDebug(
"sig_array_len %u det_ctx->pmq.rule_id_array_cnt %u",
890 for (uint32_t x = 0; x < match_cnt; x++) {
891 *r++ = match_array[x];
892 SCLogDebug(
"appended %u", match_array[x]->
id);
899 if (
ts->app_inspect == NULL) {
911 uint32_t skipped = 0;
912 for (uint32_t x = 0; x < match_cnt; x++) {
914 if (last_sig == *
m) {
921 match_cnt -= skipped;
923 next_s = *match_array++;
924 next_sflags = next_s->
flags;
971 break_out_of_packet_filter =
true;
975 DetectVarProcessList(det_ctx, pflow,
p);
976 DetectReplaceFree(det_ctx);
980 if (break_out_of_packet_filter)
990 if (skip_fw || fw_verdict) {
1010 uint8_t flow_flags = 0;
1011 bool app_decoder_events =
false;
1034 det_ctx->pkt_stream_add_cnt++;
1043 flow_flags = STREAM_TOSERVER;
1046 flow_flags = STREAM_TOCLIENT;
1052 flow_flags |= STREAM_EOF;
1083 (
p->
proto == IPPROTO_UDP) ||
1095 SCLogDebug(
"packet doesn't have established flag set (proto %d)",
p->
proto);
1138 SCLogDebug(
"packet %" PRIu64
": default action as no verdict set %02x (pkt %s)",
1151 if (pflow != NULL) {
1174 FatalError(
"failed to allocate %" PRIu64
" bytes",
1178 SCLogDebug(
"array initialized to %u elements (%"PRIu64
" bytes)",
1190 const uint32_t need)
1201 uint32_t new_size = needed;
1204 FatalError(
"failed to expand to %" PRIu64
" bytes",
1210 SCLogDebug(
"array expanded from %u to %u elements (%"PRIu64
" bytes -> %"PRIu64
" bytes)",
1223 DetectRunTxSortHelper(
const void *a,
const void *b)
1227 if (s1->
id == s0->
id) {
1234 return s0->
id > s1->
id ? 1 : -1;
1238 #define TRACE_SID_TXS(sid,txs,...) \
1240 char _trace_buf[2048]; \
1241 snprintf(_trace_buf, sizeof(_trace_buf), __VA_ARGS__); \
1242 SCLogNotice("%p/%"PRIu64"/%u: %s", txs->tx_ptr, txs->tx_id, sid, _trace_buf); \
1245 #define TRACE_SID_TXS(sid,txs,...)
1254 tx_ptr = SCDoH2GetDnsTx(tx_ptr, flow_flags);
1259 }
else if (engine_alproto != alproto && engine_alproto !=
ALPROTO_UNKNOWN) {
1282 const uint8_t in_flow_flags,
1286 const uint8_t flow_flags = in_flow_flags;
1287 const int direction = (flow_flags & STREAM_TOSERVER) ? 0 : 1;
1288 uint32_t inspect_flags = stored_flags ? *stored_flags : 0;
1289 int total_matches = 0;
1290 uint16_t file_no_match = 0;
1291 bool mpm_before_progress =
false;
1292 bool mpm_in_progress =
false;
1294 TRACE_SID_TXS(s->
id, tx,
"starting %s", direction ?
"toclient" :
"toserver");
1297 if (
likely(stored_flags == NULL)) {
1299 if (DetectRunInspectRuleHeader(
p, f, s, s->
flags) ==
false) {
1313 TRACE_SID_TXS(s->
id, tx,
"continue, inspect_flags %x", inspect_flags);
1318 TRACE_SID_TXS(s->
id, tx,
"engine %p inspect_flags %x", engine, inspect_flags);
1321 if (!(inspect_flags &
BIT_U32(engine->
id)) &&
1325 if (tx_ptr == NULL) {
1329 engine = engine->
next;
1339 SCLogDebug(
"tx progress %d < engine progress %d",
1346 "engine->mpm: t->tx_progress %u > engine->progress %u, so set "
1347 "mpm_before_progress",
1349 mpm_before_progress =
true;
1352 "engine->mpm: t->tx_progress %u == engine->progress %u, so set "
1356 mpm_in_progress =
true;
1361 uint8_t engine_flags = flow_flags;
1362 if (direction != engine->
dir) {
1363 engine_flags = flow_flags ^ (STREAM_TOCLIENT | STREAM_TOSERVER);
1369 TRACE_SID_TXS(s->
id, tx,
"stream skipped, stored result %d used instead", match);
1374 mpm_before_progress =
true;
1389 de_ctx, det_ctx, engine, s, f, engine_flags, alstate, tx_ptr, tx->
tx_id);
1394 TRACE_SID_TXS(s->
id, tx,
"stream ran, store result %d for next tx (if any)", match);
1399 engine = engine->
next;
1406 engine = engine->
next;
1418 if (engine->
mpm && mpm_before_progress) {
1424 direction != engine->
dir) {
1428 if (direction == 0 && engine->
next == NULL) {
1432 engine = engine->
next;
1436 engine = engine->
next;
1437 }
while (engine != NULL);
1438 TRACE_SID_TXS(s->
id, tx,
"inspect_flags %x, total_matches %u, engine %p",
1439 inspect_flags, total_matches, engine);
1441 bool full_match =
false;
1442 if (engine == NULL && total_matches) {
1449 *stored_flags = inspect_flags;
1450 TRACE_SID_TXS(s->
id, tx,
"continue inspect flags %08x", inspect_flags);
1457 if (file_no_match) {
1468 inspect_flags, flow_flags, file_no_match);
1472 "mpm won't trigger for it anymore");
1476 "we may have to revisit anyway");
1478 inspect_flags, flow_flags, file_no_match);
1482 "mpm will revisit it");
1484 }
else if (inspect_flags != 0 || file_no_match != 0) {
1487 inspect_flags, flow_flags, file_no_match);
1489 if (inspect_flags == 0) {
1490 TRACE_SID_TXS(s->
id, tx,
"no match: inspect_flags %08x", inspect_flags);
1508 NULL, 0, NULL, NULL, 0, 0, 0, 0, false, \
1516 const uint64_t tx_id,
void *tx_ptr,
const int tx_end_state,
const uint8_t flow_flags)
1525 if (!updated && tx_progress < tx_end_state && ((flow_flags & STREAM_EOF) == 0)) {
1529 const uint8_t inspected_flag =
1532 SCLogDebug(
"%" PRIu64
" tx already fully inspected for %s. Flags %02x", tx_id,
1533 flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient", txd->
flags);
1537 const uint8_t skip_flag = (flow_flags & STREAM_TOSERVER) ? APP_LAYER_TX_SKIP_INSPECT_TS
1538 : APP_LAYER_TX_SKIP_INSPECT_TC;
1540 SCLogDebug(
"%" PRIu64
" tx should not be inspected in direction %s. Flags %02x", tx_id,
1541 flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient", txd->
flags);
1546 const uint8_t detect_progress =
1549 const int dir_int = (flow_flags & STREAM_TOSERVER) ? 0 : 1;
1552 tx_de_state ? &tx_de_state->
dir_state[dir_int] : NULL;
1558 .detect_progress = detect_progress,
1559 .detect_progress_orig = detect_progress,
1560 .tx_progress = (uint8_t)tx_progress,
1561 .tx_end_state = (uint8_t)tx_end_state,
1567 static inline void StoreDetectProgress(
1571 if (flow_flags & STREAM_TOSERVER) {
1580 static inline void RuleMatchCandidateMergeStateRules(
1598 uint32_t j = *array_idx;
1607 uint32_t k = *array_idx;
1629 if (s->
iid <= s0->
id) {
1663 const bool apply_to_packet,
const int direction,
const uint64_t tx_id,
1664 const AppProto alproto,
const uint8_t hook)
1688 const uint8_t progress)
1691 if (direction & STREAM_TOSERVER) {
1692 policy = &policies[alproto].
ts[progress];
1693 SCLogDebug(
"packet %" PRIu64
", hook:%u, toserver, policy: action %02x scope %u",
1696 policy = &policies[alproto].
tc[progress];
1697 SCLogDebug(
"packet %" PRIu64
", hook:%u, toclient, policy: action %02x scope %u",
1702 SCLogDebug(
"dropping packet PKT_DROP_REASON_FW_DEFAULT_APP_POLICY");
1710 DetectRunAppendDefaultAppPolicyAlert(
1711 det_ctx,
p,
true, direction, tx->
tx_id, alproto, progress);
1719 const bool last_hook = progress == tx->
tx_progress;
1720 bool apply_to_packet =
false;
1725 apply_to_packet =
true;
1729 apply_to_packet = tx->
is_last;
1732 apply_to_packet = tx->
is_last && last_hook;
1739 SCLogDebug(
"packet %" PRIu64
" hook %u default policy ACCEPT, apply_to_packet:%s",
1744 DetectRunAppendDefaultAppPolicyAlert(
1745 det_ctx,
p, apply_to_packet, direction, tx->
tx_id, alproto, progress);
1746 }
else if (apply_to_packet) {
1748 DetectRunAppendDefaultAccept(det_ctx,
p);
1772 const uint8_t start_hook,
const uint8_t end_hook)
1776 const bool need_verdict =
1778 SCLogDebug(
"need_verdict:%s is_last:%s end_hook:%u tx->tx_end_state:%u tx->progress: %u",
1782 for (uint8_t hook = start_hook; hook <= end_hook; hook++) {
1783 const bool apply_to_packet =
1786 SCLogDebug(
"%" PRIu64
": %s default policy for hook %u, apply_to_packet %s",
1787 PcapPacketCntGet(
p), direction & STREAM_TOSERVER ?
"toserver" :
"toclient", hook,
1792 SCLogDebug(
"fw: hook:%u policy:%02x apply_to_packet:%s", hook, policy->
action,
1812 if (apply_to_packet) {
1827 SCLogDebug(
"default accept: last tx and progress at end_hook %u", end_hook);
1828 DetectRunAppendDefaultAccept(det_ctx,
p);
1867 SCLogDebug(
"default accept due to flow accept");
1868 DetectRunAppendDefaultAccept(det_ctx,
p);
1879 const bool accept_tx_applies_to_packet = tx->
is_last;
1880 if (accept_tx_applies_to_packet) {
1881 SCLogDebug(
"accept:tx: should be applied to the packet");
1882 DetectRunAppendDefaultAccept(det_ctx,
p);
1886 SCLogDebug(
"APP_LAYER_TX_ACCEPT, so skip rule");
1902 SCLogDebug(
"missing fw rules at list start: sid %u, progress %u (%u:%u)", s->
id,
1941 if (can_idx + 1 < can_size) {
1947 SCLogDebug(
"peek: next sid progress %u != current progress %u, so current "
1948 "is last for progress",
1953 SCLogDebug(
"peek: missing progress, so we'll drop that unless we get a "
1954 "sweeping accept first");
1959 SCLogDebug(
"peek: next sid not a fw rule, so current is last for progress");
1964 SCLogDebug(
"peek: no peek beyond last rule");
1966 SCLogDebug(
"peek: there are no rules to allow the state after this rule");
2057 SCLogDebug(
"fw fw_skip_app_filter:%s skip_fw_hook:%s "
2058 "skip_before_progress:%u fw_last_for_progress:%s fw_next_progress_missing:%s",
2080 SCLogDebug(
"accept:tx applied, skip_fw_hook, skip_before_progress %u",
2085 SCLogDebug(
"sid %u: ACTION_ACCEPT with ACTION_SCOPE_FLOW", s->
id);
2106 if (rule_cnt == 0) {
2109 DetectRunAppendDefaultAccept(det_ctx,
p);
2116 DetectRunAppendDefaultAccept(det_ctx,
p);
2133 tx,
p, alproto, flow_flags & (STREAM_TOSERVER | STREAM_TOCLIENT),
2157 const uint8_t flow_flags)
2164 const bool fw_accept_to_packet = ApplyAcceptToPacket(tx, s);
2165 if (fw_accept_to_packet) {
2167 SCLogDebug(
"accept:(tx|hook): should be applied to the packet");
2176 DetectRunTxFirewallApplyAccept(det_ctx,
p, flow_flags, s, tx, fw_state);
2178 SCLogDebug(
"drop packet because of rule with drop action");
2181 SCLogDebug(
"drop flow because of rule with drop action");
2204 static int DetectRunTxFirewallRulePartialMatch(
2211 SCLogDebug(
"need to apply accept to packet");
2212 DetectRunAppendDefaultAccept(det_ctx,
p);
2215 SCLogDebug(
"only applying accept:flow on full match, downgrading to "
2236 const uint8_t flow_flags)
2264 Packet *
p,
const uint8_t flow_flags)
2270 const bool fw_accept_to_packet = ApplyAcceptToPacket(tx, s);
2271 DetectRunTxFirewallApplyAccept(det_ctx,
p, flow_flags, s, tx, fw_state);
2272 if (fw_accept_to_packet) {
2274 DetectRunAppendDefaultAccept(det_ctx,
p);
2286 const uint8_t flow_flags = scratch->
flow_flags;
2288 void *
const alstate = f->
alstate;
2289 const uint8_t ipproto = f->
proto;
2299 uint32_t tx_inspected = 0;
2307 if (ires.
tx_ptr == NULL) {
2308 SCLogDebug(
"%p/%" PRIu64
" no transaction to inspect", ires.
tx_ptr, tx_id_min);
2313 GetDetectTx(ipproto, alproto, ires.
tx_id, ires.
tx_ptr, tx_end_state, flow_flags);
2315 SCLogDebug(
"%p/%"PRIu64
" no transaction to inspect",
2322 tx_id_min = tx.
tx_id + 1;
2331 bool do_sort =
false;
2332 uint32_t array_idx = 0;
2342 SCLogDebug(
"%p/%"PRIu64
" rules added from prefilter: %u candidates",
2346 if (!(RuleMatchCandidateTxArrayHasSpace(det_ctx, total_rules))) {
2347 RuleMatchCandidateTxArrayExpand(det_ctx, total_rules);
2361 if (!(RuleMatchCandidateTxArrayHasSpace(det_ctx, total_rules))) {
2362 RuleMatchCandidateTxArrayExpand(det_ctx, total_rules);
2368 uint32_t x = array_idx;
2370 RuleMatchCandidateMergeStateRules(det_ctx, &array_idx);
2374 const uint32_t old = array_idx;
2379 if (have_new_file) {
2380 SCLogDebug(
"%p/%"PRIu64
" destate: need to consider new file",
2387 for (; tx_store != NULL; tx_store = tx_store->
next) {
2393 store_cnt++, state_cnt++)
2410 do_sort |= (old && old != array_idx);
2416 DetectRunTxSortHelper);
2425 for (uint32_t i = 0; i < array_idx; i++) {
2441 SCLogDebug(
"%s: tx_progress %u tx %p have_fw_rules %s array_idx %u detect_progress_orig %u "
2442 "cur detect_progress %u",
2443 flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient", tx.
tx_progress,
2447 if (have_fw_rules) {
2450 const int r = DetectTxFirewallNoRulesApplyPolicies(
2451 det_ctx,
p, f, &tx, alproto, flow_flags, array_idx);
2455 }
else if (r == 2) {
2461 for (uint32_t i = 0; i < array_idx; i++) {
2467 flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient", tx.
tx_progress,
2470 if (have_fw_rules) {
2472 DetectRunTxPreCheckFirewallPolicy(det_ctx,
p, &tx,
2473 flow_flags & (STREAM_TOSERVER | STREAM_TOCLIENT), s, i, &fw_state);
2474 SCLogDebug(
"fw fw_skip_app_filter:%s skip_fw_hook:%s "
2475 "skip_before_progress:%u fw_last_for_progress:%s "
2476 "fw_next_progress_missing:%s",
2495 while ((i + 1) < array_idx &&
2497 SCLogDebug(
"%p/%" PRIu64
" inspecting SKIP NEXT: sid %u (%u), flags %08x",
2503 s->
id, s->
iid, inspect_flags ? *inspect_flags : 0);
2505 if (inspect_flags) {
2508 " inspecting: sid %u (%u), flags %08x DE_STATE_FLAG_FULL_INSPECT",
2513 if (have_fw_rules) {
2514 DetectRunTxFirewallRuleStatefulReApplyMatch(
2515 det_ctx, s, &tx, &fw_state,
p, flow_flags);
2521 " inspecting: sid %u (%u), flags %08x DE_STATE_FLAG_SIG_CANT_MATCH",
2533 if (have_fw_rules) {
2536 DetectRunTxCheckRuleState(det_ctx,
p, f, &tx, s, i, array_idx, &fw_state);
2537 SCLogDebug(
"fw fw_skip_app_filter:%s skip_fw_hook:%s "
2538 "skip_before_progress:%u fw_last_for_progress:%s "
2539 "fw_next_progress_missing:%s",
2551 const int r = DetectRunTxInspectRule(
tv,
de_ctx, det_ctx,
p, f, flow_flags,
2552 alstate, &tx, s, inspect_flags, can, scratch);
2556 DetectRunPostMatch(
tv, det_ctx,
p, s);
2565 DetectRunTxFirewallRuleFullMatch(det_ctx, s, &tx, &fw_state, f,
p, flow_flags);
2567 }
else if (r == 0) {
2569 if (DetectRunTxFirewallRulePartialMatch(det_ctx, s, &tx,
p) == 1) {
2573 if (DetectRunTxFirewallRuleNoMatch(det_ctx, s, &tx, &fw_state,
p, flow_flags) ==
2578 DetectVarProcessList(det_ctx,
p->
flow,
p);
2587 uint32_t prev_array_idx = array_idx;
2590 if (
ts->app_inspect != NULL) {
2598 SCLogDebug(
"%p/%" PRIu64
" rule %u (%u) added from 'post match' prefilter",
2602 SCLogDebug(
"%p/%" PRIu64
" rules added from 'post match' prefilter: %u", tx.
tx_ptr,
2603 tx.
tx_id, array_idx - prev_array_idx);
2604 if (prev_array_idx != array_idx) {
2607 DetectRunTxSortHelper);
2623 flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient");
2624 const uint8_t inspected_flag = (flow_flags & STREAM_TOSERVER)
2628 SCLogDebug(
"%p/%" PRIu64
" tx is done for direction %s. Progress %02x", tx.
tx_ptr,
2629 tx.
tx_id, flow_flags & STREAM_TOSERVER ?
"toserver" :
"toclient",
2652 if (tx_inspected == 0 && have_fw_rules) {
2653 SCLogDebug(
"default accept: no app inspect performed");
2654 DetectRunAppendDefaultAccept(det_ctx,
p);
2669 SCLogDebug(
"pcap_cnt %" PRIu64
": %s: skip frame inspection for TCP w/o APP UPDATE",
2674 if (frames_container == NULL) {
2679 frames = &frames_container->
toserver;
2681 frames = &frames_container->
toclient;
2684 for (uint32_t idx = 0; idx < frames->
cnt; idx++) {
2687 if (frame == NULL) {
2692 uint32_t array_idx = 0;
2700 SCLogDebug(
"%p/%" PRIi64
" rules added from prefilter: %u candidates", frame, frame->
id,
2705 if (!(RuleMatchCandidateTxArrayHasSpace(
2706 det_ctx, total_rules))) {
2707 RuleMatchCandidateTxArrayExpand(det_ctx, total_rules);
2722 uint32_t x = array_idx;
2733 SCLogDebug(
"%p/%" PRIi64
" rule %u (%u) added from 'match' list", frame, frame->
id,
2737 SCLogDebug(
"%p/%" PRIi64
" rules added from 'match' list: %u", frame, frame->
id,
2742 for (uint32_t i = 0; i < array_idx; i++) {
2749 while ((i + 1) < array_idx &&
2753 SCLogDebug(
"%p/%" PRIi64
" inspecting: sid %u (%u)", frame, frame->
id, s->
id, s->
iid);
2756 SCLogDebug(
"%p/%" PRIi64
" Start sid %u", frame, frame->
id, s->
id);
2760 bool r = DetectRunInspectRuleHeader(
p, f, s, s->
flags);
2765 DetectRunPostMatch(
tv, det_ctx,
p, s);
2770 "%p/%" PRIi64
" sig %u (%u) matched", frame, frame->
id, s->
id, s->
iid);
2777 DetectVarProcessList(det_ctx,
p->
flow,
p);
2788 "frame->inspect_progress: %" PRIu64
" -> not updated", frame->
inspect_progress);
2791 SCLogDebug(
"%p/%" PRIi64
" rules inspected, running cleanup", frame, frame->
id);
2839 SCLogDebug(
"p->pcap %" PRIu64
": no detection on packet, "
2840 "PKT_NOPACKET_INSPECTION is set",
2898 if (det_ctx == NULL) {
2899 printf(
"ERROR: Detect has no thread ctx\n");
2905 SCLogDebug(
"Detect Engine using new det_ctx - %p",
2916 if (tenant_id > 0 && tenant_id < det_ctx->mt_det_ctxs_cnt) {
2919 if (det_ctx == NULL)
2927 SCLogDebug(
"MT de_ctx %p det_ctx %p (tenant %u)",
de_ctx, det_ctx, tenant_id);
2943 #ifdef PROFILE_RULES
2946 gettimeofday(&
ts, NULL);
2947 if (
ts.tv_sec != det_ctx->rule_perf_last_sync) {
2948 SCProfilingRuleThreatAggregate(det_ctx);
2949 det_ctx->rule_perf_last_sync =
ts.tv_sec;
2963 DetectPostInspectFileFlagsUpdate(f, NULL , STREAM_TOSERVER);
2964 DetectPostInspectFileFlagsUpdate(f, NULL , STREAM_TOCLIENT);
2967 #if defined(UNITTESTS) || defined(FUZZ)