Maximum transactions
~~~~~~~~~~~~~~~~~~~~
-MQTT, FTP, PostgreSQL, SMB and NFS have each a `max-tx` parameter that can be customized.
+MQTT, FTP, PostgreSQL, SMB, DCERPC and NFS have each a `max-tx` parameter that can be customized.
`max-tx` refers to the maximum number of live transactions for each flow.
An app-layer event `protocol.too_many_transactions` is triggered when this value is reached.
The point of this parameter is to find a balance between the completeness of analysis
use std::cmp;
use std::ffi::CString;
use std::collections::VecDeque;
+use crate::conf::conf_get;
// Constant DCERPC UDP Header length
pub const DCERPC_HDR_LEN: u16 = 16;
pub const DCERPC_TYPE_RTS: u8 = 20;
pub const DCERPC_TYPE_UNKNOWN: u8 = 99;
+static mut DCERPC_MAX_TX: usize = 1024;
+
pub static mut ALPROTO_DCERPC: AppProto = ALPROTO_UNKNOWN;
pub fn dcerpc_type_string(t: u8) -> String {
pub bind: Option<DCERPCBind>,
pub bindack: Option<DCERPCBindAck>,
pub transactions: VecDeque<DCERPCTransaction>,
+ tx_index_completed: usize,
pub buffer_ts: Vec<u8>,
pub buffer_tc: Vec<u8>,
pub pad: u8,
self.tx_id += 1;
tx.req_done = self.ts_ssn_trunc;
tx.resp_done = self.tc_ssn_trunc;
+ if self.transactions.len() > unsafe { DCERPC_MAX_TX } {
+ let mut index = self.tx_index_completed;
+ for tx_old in &mut self.transactions.range_mut(self.tx_index_completed..) {
+ index += 1;
+ if !tx_old.req_done || !tx_old.resp_done {
+ tx_old.req_done = true;
+ tx_old.resp_done = true;
+ break;
+ }
+ }
+ self.tx_index_completed = index;
+ }
tx
}
if found {
SCLogDebug!("freeing TX with ID {} TX.ID {} at index {} left: {} max id: {}",
tx_id, tx_id+1, index, self.transactions.len(), self.tx_id);
+ self.tx_index_completed = 0;
self.transactions.remove(index);
}
}
{
let _ = AppLayerRegisterParser(&parser, alproto);
}
+ if let Some(val) = conf_get("app-layer.protocols.dcerpc.max-tx") {
+ if let Ok(v) = val.parse::<usize>() {
+ DCERPC_MAX_TX = v;
+ } else {
+ SCLogError!("Invalid value for smb.max-tx");
+ }
+ }
SCLogDebug!("Rust DCERPC parser registered.");
} else {
SCLogDebug!("Protocol detector and parser disabled for DCERPC.");