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

Detect revflow 7552 v5 #12716

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app-layer-htp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5628,6 +5628,7 @@ static int HTPParserTest25(void)
f->protoctx = &ssn;
f->proto = IPPROTO_TCP;
f->alproto = ALPROTO_HTTP1;
f->flags |= FLOW_SGH_TOCLIENT | FLOW_SGH_TOSERVER;

const char *str = "GET / HTTP/1.1\r\nHost: www.google.com\r\nUser-Agent: Suricata/1.0\r\n\r\n";
int r = AppLayerParserParse(NULL, alp_tctx, f, ALPROTO_HTTP1, STREAM_TOSERVER | STREAM_START,
Expand Down
1 change: 1 addition & 0 deletions src/app-layer-ike.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static int IkeParserTest(void)
f.proto = IPPROTO_UDP;
f.protomap = FlowGetProtoMapping(f.proto);
f.alproto = ALPROTO_IKE;
f.flags |= FLOW_SGH_TOCLIENT | FLOW_SGH_TOSERVER;

StreamTcpInitConfig(true);

Expand Down
6 changes: 4 additions & 2 deletions src/app-layer-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,8 @@ void AppLayerParserTransactionsCleanup(Flow *f, const uint8_t pkt_dir)
}

if (txd && has_tx_detect_flags) {
if (!IS_DISRUPTED(ts_disrupt_flags) && f->sgh_toserver != NULL) {
if (!IS_DISRUPTED(ts_disrupt_flags) &&
(f->sgh_toserver != NULL || (f->flags & FLOW_SGH_TOSERVER) == 0)) {
uint64_t detect_flags_ts = AppLayerParserGetTxDetectFlags(txd, STREAM_TOSERVER);
if (!(detect_flags_ts &
(APP_LAYER_TX_INSPECTED_FLAG | APP_LAYER_TX_SKIP_INSPECT_FLAG))) {
Expand All @@ -967,7 +968,8 @@ void AppLayerParserTransactionsCleanup(Flow *f, const uint8_t pkt_dir)
tx_skipped = true;
}
}
if (!IS_DISRUPTED(tc_disrupt_flags) && f->sgh_toclient != NULL) {
if (!IS_DISRUPTED(tc_disrupt_flags) &&
(f->sgh_toclient != NULL || (f->flags & FLOW_SGH_TOCLIENT) == 0)) {
uint64_t detect_flags_tc = AppLayerParserGetTxDetectFlags(txd, STREAM_TOCLIENT);
if (!(detect_flags_tc &
(APP_LAYER_TX_INSPECTED_FLAG | APP_LAYER_TX_SKIP_INSPECT_FLAG))) {
Expand Down
1 change: 1 addition & 0 deletions src/app-layer-smb.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static int SMBParserTxCleanupTest(void)
f->protoctx = &ssn;
f->proto = IPPROTO_TCP;
f->alproto = ALPROTO_SMB;
f->flags |= FLOW_SGH_TOCLIENT | FLOW_SGH_TOSERVER;

char req_str[] ="\x00\x00\x00\x79\xfe\x53\x4d\x42\x40\x00\x01\x00\x00\x00\x00\x00" \
"\x05\x00\xe0\x1e\x10\x00\x00\x00\x00\x00\x00\x00\x0b\x00\x00\x00" \
Expand Down
2 changes: 2 additions & 0 deletions src/app-layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ static int TCPProtoDetect(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
SCLogDebug("reversing flow after proto detect told us so");
PacketSwap(p);
FlowSwap(f);
// Will reset signature groups in DetectRunSetup
f->de_ctx_version = UINT32_MAX;
SWAP_FLAGS(flags, STREAM_TOSERVER, STREAM_TOCLIENT);
if (*stream == &ssn->client) {
*stream = &ssn->server;
Expand Down
Loading