Skip to content

Commit

Permalink
detect: rename stream_log variables
Browse files Browse the repository at this point in the history
to better reflect their true meaning
  • Loading branch information
catenacyber authored and jufajardini committed Dec 6, 2024
1 parent cbb5392 commit 6f201e2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion doc/userguide/configuration/suricata-yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ meaning it will repeat its actions over and over again. With the
option inspection-recursion-limit you can limit this action.

The stream-tx-log-limit defines the maximum number of times a
transaction will get logged for a stream-only rule match.
transaction will get logged for rules without app-layer keywords.
This is meant to avoid logging the same data an arbitrary number
of times.

Expand Down
9 changes: 5 additions & 4 deletions rust/src/applayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ pub struct AppLayerTxData {
/// STREAM_TOCLIENT: file tx , files only in toclient dir
/// STREAM_TOSERVER|STREAM_TOCLIENT: files possible in both dirs
pub file_tx: u8,
/// Number of times this tx data has already been logged for one stream match
pub stream_logged: u8,
/// Number of times this tx data has already been logged for signatures
/// not using application layer keywords
pub guessed_applayer_logged: u8,

/// detection engine flags for use by detection engine
detect_flags_ts: u64,
Expand Down Expand Up @@ -154,7 +155,7 @@ impl AppLayerTxData {
files_stored: 0,
file_flags: 0,
file_tx: 0,
stream_logged: 0,
guessed_applayer_logged: 0,
detect_flags_ts: 0,
detect_flags_tc: 0,
de_state: std::ptr::null_mut(),
Expand All @@ -177,7 +178,7 @@ impl AppLayerTxData {
files_stored: 0,
file_flags: 0,
file_tx: 0,
stream_logged: 0,
guessed_applayer_logged: 0,
detect_flags_ts,
detect_flags_tc,
de_state: std::ptr::null_mut(),
Expand Down
4 changes: 2 additions & 2 deletions src/detect-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -2931,10 +2931,10 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx)
de_ctx->inspection_recursion_limit);

// default value is 4
de_ctx->stream_tx_log_limit = 4;
de_ctx->guess_applayer_log_limit = 4;
if (ConfGetInt("detect.stream-tx-log-limit", &value) == 1) {
if (value >= 0 && value <= UINT8_MAX) {
de_ctx->stream_tx_log_limit = (uint8_t)value;
de_ctx->guess_applayer_log_limit = (uint8_t)value;
} else {
SCLogWarning("Invalid value for detect-engine.stream-tx-log-limit: must be between 0 "
"and 255, will default to 4");
Expand Down
4 changes: 2 additions & 2 deletions src/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,12 +827,12 @@ static inline void DetectRulePacketRules(
AppLayerTxData *txd =
tx_ptr ? AppLayerParserGetTxData(pflow->proto, pflow->alproto, tx_ptr)
: NULL;
if (txd && txd->stream_logged < de_ctx->stream_tx_log_limit) {
if (txd && txd->guessed_applayer_logged < de_ctx->guess_applayer_log_limit) {
alert_flags |= PACKET_ALERT_FLAG_TX;
if (pflow->proto != IPPROTO_UDP) {
alert_flags |= PACKET_ALERT_FLAG_TX_GUESSED;
}
txd->stream_logged++;
txd->guessed_applayer_logged++;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/detect.h
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,8 @@ typedef struct DetectEngineCtx_ {
/* maximum recursion depth for content inspection */
int inspection_recursion_limit;

/* maximum number of times a tx will get logged for a stream-only rule match */
uint8_t stream_tx_log_limit;
/* maximum number of times a tx will get logged for rules not using app-layer keywords */
uint8_t guess_applayer_log_limit;

/* force app-layer tx finding for alerts with signatures not having app-layer keywords */
bool guess_applayer;
Expand Down
2 changes: 1 addition & 1 deletion suricata.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,7 @@ detect:
toserver-groups: 25
sgh-mpm-context: auto
inspection-recursion-limit: 3000
# maximum number of times a tx will get logged for a stream-only rule match
# maximum number of times a tx will get logged for rules without app-layer keywords
# stream-tx-log-limit: 4
# try to tie an app-layer transaction for rules without app-layer keywords
# if there is only one live transaction for the flow
Expand Down

0 comments on commit 6f201e2

Please sign in to comment.