Skip to content

Commit

Permalink
pgsql: trigger raw stream reassembly at tx completion
Browse files Browse the repository at this point in the history
Once we are tracking tx progress per-direction for PGSQL, we can trigger
the raw stream reassembly, for detection purposes, as soonas the
transactions are completed in the given direction.

Task OISF#7000
  • Loading branch information
jufajardini committed Sep 11, 2024
1 parent e793bb8 commit da31926
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions rust/src/pgsql/pgsql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,6 @@ impl PgsqlState {
);
match PgsqlState::state_based_req_parsing(self.state_progress, start) {
Ok((rem, request)) => {
sc_app_layer_parser_trigger_raw_stream_reassembly(
flow,
Direction::ToServer as i32,
);
start = rem;
let new_state = PgsqlState::request_next_state(&request);

Expand Down Expand Up @@ -375,6 +371,7 @@ impl PgsqlState {
/* The server won't send any responses to such requests, so transaction should be over */
tx.tx_res_state = PgsqlTxProgress::TxDone;
}
sc_app_layer_parser_trigger_raw_stream_reassembly(flow, Direction::ToServer as i32);
}
}
} else {
Expand Down Expand Up @@ -511,10 +508,6 @@ impl PgsqlState {
while !start.is_empty() {
match PgsqlState::state_based_resp_parsing(self.state_progress, start) {
Ok((rem, response)) => {
sc_app_layer_parser_trigger_raw_stream_reassembly(
flow,
Direction::ToClient as i32,
);
start = rem;
SCLogDebug!("Response is {:?}", &response);
let (curr_state, tx_completed) =
Expand Down Expand Up @@ -547,6 +540,10 @@ impl PgsqlState {
if tx_completed {
tx.tx_req_state = PgsqlTxProgress::TxDone;
tx.tx_res_state = PgsqlTxProgress::TxDone;
sc_app_layer_parser_trigger_raw_stream_reassembly(
flow,
Direction::ToClient as i32,
);
}
}
} else {
Expand Down

0 comments on commit da31926

Please sign in to comment.