Skip to content

Commit

Permalink
detect: flush when setting no_inspection
Browse files Browse the repository at this point in the history
Ticket: 6578

When a protocol such as SSH sets no_inspection, we still have to
flush the current streams and packets that contain clear-text
for detection.
  • Loading branch information
catenacyber authored and victorjulien committed Mar 18, 2024
1 parent 4c4f7ff commit cc3b4b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/app-layer-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,6 @@ int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow
/* set the packets to no inspection and reassembly if required */
if (pstate->flags & APP_LAYER_PARSER_NO_INSPECTION) {
AppLayerParserSetEOF(pstate);
FlowSetNoPayloadInspectionFlag(f);

if (f->proto == IPPROTO_TCP) {
StreamTcpDisableAppLayer(f);
Expand All @@ -1462,6 +1461,9 @@ int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow
StreamTcpSetSessionBypassFlag(ssn);
}
}
} else {
// for TCP, this is set after flushing
FlowSetNoPayloadInspectionFlag(f);
}
}

Expand Down
10 changes: 9 additions & 1 deletion src/flow-worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,16 @@ static inline void FlowWorkerStreamTCPUpdate(ThreadVars *tv, FlowWorkerThreadDat
StreamTcp(tv, p, fw->stream_thread, &fw->pq);
FLOWWORKER_PROFILING_END(p, PROFILE_FLOWWORKER_STREAM);

if (FlowChangeProto(p->flow)) {
// this is the first packet that sets no payload inspection
bool setting_nopayload =
p->flow->alparser &&
AppLayerParserStateIssetFlag(p->flow->alparser, APP_LAYER_PARSER_NO_INSPECTION) &&
!(p->flags & PKT_NOPAYLOAD_INSPECTION);
if (FlowChangeProto(p->flow) || setting_nopayload) {
StreamTcpDetectLogFlush(tv, fw->stream_thread, p->flow, p, &fw->pq);
if (setting_nopayload) {
FlowSetNoPayloadInspectionFlag(p->flow);
}
AppLayerParserStateSetFlag(p->flow->alparser, APP_LAYER_PARSER_EOF_TS);
AppLayerParserStateSetFlag(p->flow->alparser, APP_LAYER_PARSER_EOF_TC);
}
Expand Down

0 comments on commit cc3b4b0

Please sign in to comment.