Skip to content

Commit

Permalink
detect: log app-layer metadata in alert with single tx
Browse files Browse the repository at this point in the history
Ticket: 7199

When there is a single live transaction, we cannot pick a wrong
transaction to log, even if the rule does not use app-layer
keywords.
  • Loading branch information
catenacyber committed Nov 27, 2024
1 parent bd7d38e commit cd4cf6b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,15 +813,16 @@ static inline void DetectRulePacketRules(
DetectRunPostMatch(tv, det_ctx, p, s);

uint64_t txid = PACKET_ALERT_NOTX;
if ((alert_flags & PACKET_ALERT_FLAG_STREAM_MATCH) ||
(s->alproto != ALPROTO_UNKNOWN && pflow->proto == IPPROTO_UDP)) {
// if there is a stream match (TCP), or
// a UDP specific app-layer signature,
// try to use the good tx for the packet direction
if (pflow->alstate) {
uint8_t dir =
(p->flowflags & FLOW_PKT_TOCLIENT) ? STREAM_TOCLIENT : STREAM_TOSERVER;
txid = AppLayerParserGetTransactionInspectId(pflow->alparser, dir);
if (pflow && pflow->alstate) {
uint8_t dir = (p->flowflags & FLOW_PKT_TOCLIENT) ? STREAM_TOCLIENT : STREAM_TOSERVER;
txid = AppLayerParserGetTransactionInspectId(pflow->alparser, dir);
if ((alert_flags & PACKET_ALERT_FLAG_STREAM_MATCH) ||
(s->alproto != ALPROTO_UNKNOWN && pflow->proto == IPPROTO_UDP) ||
AppLayerParserGetTxCnt(pflow, pflow->alstate) == txid + 1) {
// if there is a stream match (TCP), or
// a UDP specific app-layer signature,
// or only one live transaction
// try to use the good tx for the packet direction
void *tx_ptr =
AppLayerParserGetTx(pflow->proto, pflow->alproto, pflow->alstate, txid);
AppLayerTxData *txd =
Expand Down

0 comments on commit cd4cf6b

Please sign in to comment.