diff --git a/rust/src/dcerpc/detect.rs b/rust/src/dcerpc/detect.rs index b513bee2cf12..e976391dfe7c 100644 --- a/rust/src/dcerpc/detect.rs +++ b/rust/src/dcerpc/detect.rs @@ -60,7 +60,7 @@ pub struct DCEOpnumData { } fn match_backuuid( - tx: &mut DCERPCTransaction, state: &mut DCERPCState, if_data: &mut DCEIfaceData, + tx: &DCERPCTransaction, state: &mut DCERPCState, if_data: &mut DCEIfaceData, ) -> u8 { let mut ret = 0; if let Some(ref bindack) = state.bindack { @@ -204,7 +204,7 @@ fn parse_opnum_data(arg: &str) -> Result { #[no_mangle] pub extern "C" fn rs_dcerpc_iface_match( - tx: &mut DCERPCTransaction, state: &mut DCERPCState, if_data: &mut DCEIfaceData, + tx: &DCERPCTransaction, state: &mut DCERPCState, if_data: &mut DCEIfaceData, ) -> u8 { let first_req_seen = tx.get_first_req_seen(); if first_req_seen == 0 { @@ -212,7 +212,7 @@ pub extern "C" fn rs_dcerpc_iface_match( } match state.get_hdr_type() { - Some(DCERPC_TYPE_REQUEST | DCERPC_TYPE_RESPONSE) => {}, + Some(DCERPC_TYPE_REQUEST | DCERPC_TYPE_RESPONSE) => {} _ => { return 0; } @@ -248,7 +248,7 @@ pub unsafe extern "C" fn rs_dcerpc_iface_free(ptr: *mut c_void) { #[no_mangle] pub unsafe extern "C" fn rs_dcerpc_opnum_match( - tx: &mut DCERPCTransaction, opnum_data: &mut DCEOpnumData, + tx: &DCERPCTransaction, opnum_data: &mut DCEOpnumData, ) -> u8 { let first_req_seen = tx.get_first_req_seen(); if first_req_seen == 0 { diff --git a/rust/src/dns/log.rs b/rust/src/dns/log.rs index 6e131e3d5e71..7003e70c1949 100644 --- a/rust/src/dns/log.rs +++ b/rust/src/dns/log.rs @@ -820,7 +820,7 @@ pub extern "C" fn SCDnsLogJsonQuery( /// "dns" object. /// /// This logger implements V3 style DNS logging. -fn log_json(tx: &mut DNSTransaction, flags: u64, jb: &mut JsonBuilder) -> Result<(), JsonError> { +fn log_json(tx: &DNSTransaction, flags: u64, jb: &mut JsonBuilder) -> Result<(), JsonError> { jb.open_object("dns")?; jb.set_int("version", 3)?; @@ -921,7 +921,7 @@ fn log_json(tx: &mut DNSTransaction, flags: u64, jb: &mut JsonBuilder) -> Result /// FFI wrapper around the common V3 style DNS logger. #[no_mangle] -pub extern "C" fn SCDnsLogJson(tx: &mut DNSTransaction, flags: u64, jb: &mut JsonBuilder) -> bool { +pub extern "C" fn SCDnsLogJson(tx: &DNSTransaction, flags: u64, jb: &mut JsonBuilder) -> bool { log_json(tx, flags, jb).is_ok() } diff --git a/rust/src/enip/detect.rs b/rust/src/enip/detect.rs index aee0afca6af5..ff1b38558bab 100644 --- a/rust/src/enip/detect.rs +++ b/rust/src/enip/detect.rs @@ -192,7 +192,7 @@ fn enip_cip_match_service(d: &CipData, ctx: &DetectCipServiceData) -> std::os::r } fn enip_tx_has_cip_service( - tx: &mut EnipTransaction, direction: Direction, ctx: &DetectCipServiceData, + tx: &EnipTransaction, direction: Direction, ctx: &DetectCipServiceData, ) -> std::os::raw::c_int { let pduo = if direction == Direction::ToServer { &tx.request @@ -227,9 +227,7 @@ fn enip_cip_match_status(d: &CipData, ctx: &DetectUintData) -> std::os::raw: return 0; } -fn enip_tx_has_cip_status( - tx: &mut EnipTransaction, ctx: &DetectUintData, -) -> std::os::raw::c_int { +fn enip_tx_has_cip_status(tx: &EnipTransaction, ctx: &DetectUintData) -> std::os::raw::c_int { if let Some(pdu) = &tx.response { if let EnipPayload::Cip(c) = &pdu.payload { for item in c.items.iter() { @@ -262,7 +260,7 @@ fn enip_cip_match_extendedstatus(d: &CipData, ctx: &DetectUintData) -> std: } fn enip_tx_has_cip_extendedstatus( - tx: &mut EnipTransaction, ctx: &DetectUintData, + tx: &EnipTransaction, ctx: &DetectUintData, ) -> std::os::raw::c_int { if let Some(pdu) = &tx.response { if let EnipPayload::Cip(c) = &pdu.payload { @@ -276,7 +274,7 @@ fn enip_tx_has_cip_extendedstatus( return 0; } -fn enip_get_status(tx: &mut EnipTransaction, direction: Direction) -> Option { +fn enip_get_status(tx: &EnipTransaction, direction: Direction) -> Option { if direction == Direction::ToServer { if let Some(req) = &tx.request { return Some(req.header.status); @@ -308,7 +306,7 @@ fn enip_cip_match_segment( } fn enip_tx_has_cip_segment( - tx: &mut EnipTransaction, ctx: &DetectUintData, segment_type: u8, + tx: &EnipTransaction, ctx: &DetectUintData, segment_type: u8, ) -> std::os::raw::c_int { if let Some(pdu) = &tx.request { if let EnipPayload::Cip(c) = &pdu.payload { @@ -358,7 +356,7 @@ fn enip_cip_match_attribute(d: &CipData, ctx: &DetectUintData) -> std::os:: } fn enip_tx_has_cip_attribute( - tx: &mut EnipTransaction, ctx: &DetectUintData, + tx: &EnipTransaction, ctx: &DetectUintData, ) -> std::os::raw::c_int { if let Some(pdu) = &tx.request { if let EnipPayload::Cip(c) = &pdu.payload { @@ -372,7 +370,7 @@ fn enip_tx_has_cip_attribute( return 0; } -fn tx_get_protocol_version(tx: &mut EnipTransaction, direction: Direction) -> Option { +fn tx_get_protocol_version(tx: &EnipTransaction, direction: Direction) -> Option { if direction == Direction::ToServer { if let Some(req) = &tx.request { if let EnipPayload::RegisterSession(rs) = &req.payload { @@ -511,7 +509,7 @@ unsafe extern "C" fn capabilities_setup( return 0; } -fn tx_get_capabilities(tx: &mut EnipTransaction) -> Option { +fn tx_get_capabilities(tx: &EnipTransaction) -> Option { if let Some(ref response) = tx.response { if let EnipPayload::ListServices(lsp) = &response.payload { if !lsp.is_empty() { @@ -647,7 +645,7 @@ unsafe extern "C" fn vendor_id_setup( return 0; } -fn tx_get_vendor_id(tx: &mut EnipTransaction) -> Option { +fn tx_get_vendor_id(tx: &EnipTransaction) -> Option { if let Some(ref response) = tx.response { if let EnipPayload::ListIdentity(lip) = &response.payload { if !lip.is_empty() { @@ -730,7 +728,7 @@ unsafe extern "C" fn state_setup( return 0; } -fn tx_get_state(tx: &mut EnipTransaction) -> Option { +fn tx_get_state(tx: &EnipTransaction) -> Option { if let Some(ref response) = tx.response { if let EnipPayload::ListIdentity(lip) = &response.payload { if !lip.is_empty() { @@ -778,7 +776,7 @@ unsafe extern "C" fn serial_setup( return 0; } -fn tx_get_serial(tx: &mut EnipTransaction) -> Option { +fn tx_get_serial(tx: &EnipTransaction) -> Option { if let Some(ref response) = tx.response { if let EnipPayload::ListIdentity(lip) = &response.payload { if !lip.is_empty() { @@ -828,7 +826,7 @@ unsafe extern "C" fn revision_setup( return 0; } -fn tx_get_revision(tx: &mut EnipTransaction) -> Option { +fn tx_get_revision(tx: &EnipTransaction) -> Option { if let Some(ref response) = tx.response { if let EnipPayload::ListIdentity(lip) = &response.payload { if !lip.is_empty() { @@ -927,7 +925,7 @@ unsafe extern "C" fn product_code_setup( return 0; } -fn tx_get_product_code(tx: &mut EnipTransaction) -> Option { +fn tx_get_product_code(tx: &EnipTransaction) -> Option { if let Some(ref response) = tx.response { if let EnipPayload::ListIdentity(lip) = &response.payload { if !lip.is_empty() { @@ -983,7 +981,7 @@ unsafe extern "C" fn identity_status_setup( return 0; } -fn tx_get_identity_status(tx: &mut EnipTransaction) -> Option { +fn tx_get_identity_status(tx: &EnipTransaction) -> Option { if let Some(ref response) = tx.response { if let EnipPayload::ListIdentity(lip) = &response.payload { if !lip.is_empty() { @@ -1039,7 +1037,7 @@ unsafe extern "C" fn device_type_setup( return 0; } -fn tx_get_device_type(tx: &mut EnipTransaction) -> Option { +fn tx_get_device_type(tx: &EnipTransaction) -> Option { if let Some(ref response) = tx.response { if let EnipPayload::ListIdentity(lip) = &response.payload { if !lip.is_empty() { @@ -1088,7 +1086,7 @@ unsafe extern "C" fn command_setup( return 0; } -fn tx_get_command(tx: &mut EnipTransaction, direction: u8) -> Option { +fn tx_get_command(tx: &EnipTransaction, direction: u8) -> Option { let direction: Direction = direction.into(); if direction == Direction::ToServer { if let Some(req) = &tx.request { diff --git a/rust/src/http2/detect.rs b/rust/src/http2/detect.rs index cc013881cae2..4a05b29103b5 100644 --- a/rust/src/http2/detect.rs +++ b/rust/src/http2/detect.rs @@ -27,7 +27,7 @@ use std::rc::Rc; use base64::{Engine, engine::general_purpose::STANDARD}; fn http2_tx_has_frametype( - tx: &mut HTTP2Transaction, direction: Direction, value: u8, + tx: &HTTP2Transaction, direction: Direction, value: u8, ) -> std::os::raw::c_int { if direction == Direction::ToServer { for i in 0..tx.frames_ts.len() { @@ -67,7 +67,7 @@ pub unsafe extern "C" fn rs_http2_parse_frametype( } fn http2_tx_has_errorcode( - tx: &mut HTTP2Transaction, direction: Direction, code: u32, + tx: &HTTP2Transaction, direction: Direction, code: u32, ) -> std::os::raw::c_int { if direction == Direction::ToServer { for i in 0..tx.frames_ts.len() { @@ -127,7 +127,7 @@ pub unsafe extern "C" fn rs_http2_parse_errorcode( } fn http2_tx_get_next_priority( - tx: &mut HTTP2Transaction, direction: Direction, nb: u32, + tx: &HTTP2Transaction, direction: Direction, nb: u32, ) -> std::os::raw::c_int { let mut pos = 0_u32; if direction == Direction::ToServer { @@ -187,7 +187,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_next_priority( } fn http2_tx_get_next_window( - tx: &mut HTTP2Transaction, direction: Direction, nb: u32, + tx: &HTTP2Transaction, direction: Direction, nb: u32, ) -> std::os::raw::c_int { let mut pos = 0_u32; if direction == Direction::ToServer { @@ -263,7 +263,7 @@ fn http2_detect_settings_match( } fn http2_detect_settingsctx_match( - ctx: &mut parser::DetectHTTP2settingsSigCtx, tx: &mut HTTP2Transaction, direction: Direction, + ctx: &parser::DetectHTTP2settingsSigCtx, tx: &HTTP2Transaction, direction: Direction, ) -> std::os::raw::c_int { if direction == Direction::ToServer { for i in 0..tx.frames_ts.len() { @@ -324,7 +324,7 @@ fn http2_header_blocks(frame: &HTTP2Frame) -> Option<&[parser::HTTP2FrameHeaderB } fn http2_detect_sizeupdatectx_match( - ctx: &mut DetectUintData, tx: &mut HTTP2Transaction, direction: Direction, + ctx: &DetectUintData, tx: &HTTP2Transaction, direction: Direction, ) -> std::os::raw::c_int { if direction == Direction::ToServer { for i in 0..tx.frames_ts.len() { @@ -359,7 +359,7 @@ pub unsafe extern "C" fn rs_http2_detect_sizeupdatectx_match( // and rs_http2_detect_sizeupdatectx_match explicitly casting #[no_mangle] pub unsafe extern "C" fn rs_http2_tx_get_header_name( - tx: &mut HTTP2Transaction, direction: u8, nb: u32, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &HTTP2Transaction, direction: u8, nb: u32, buffer: *mut *const u8, buffer_len: *mut u32, ) -> bool { let mut pos = 0_u32; match direction.into() { @@ -498,6 +498,7 @@ fn http2_frames_get_header_value<'a>( } } +// we mutate the tx to cache req_line fn http2_tx_get_req_line(tx: &mut HTTP2Transaction) { if !tx.req_line.is_empty() { return; diff --git a/rust/src/ike/detect.rs b/rust/src/ike/detect.rs index 64d27a462afb..0cc151fb6444 100644 --- a/rust/src/ike/detect.rs +++ b/rust/src/ike/detect.rs @@ -23,7 +23,7 @@ use std::ffi::CStr; use std::ptr; #[no_mangle] -pub extern "C" fn rs_ike_state_get_exch_type(tx: &mut IKETransaction, exch_type: *mut u8) -> u8 { +pub extern "C" fn rs_ike_state_get_exch_type(tx: &IKETransaction, exch_type: *mut u8) -> u8 { debug_validate_bug_on!(exch_type.is_null()); if tx.ike_version == 1 { @@ -45,7 +45,7 @@ pub extern "C" fn rs_ike_state_get_exch_type(tx: &mut IKETransaction, exch_type: #[no_mangle] pub extern "C" fn rs_ike_state_get_spi_initiator( - tx: &mut IKETransaction, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &IKETransaction, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { debug_validate_bug_on!(buffer.is_null() || buffer_len.is_null()); @@ -58,7 +58,7 @@ pub extern "C" fn rs_ike_state_get_spi_initiator( #[no_mangle] pub extern "C" fn rs_ike_state_get_spi_responder( - tx: &mut IKETransaction, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &IKETransaction, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { debug_validate_bug_on!(buffer.is_null() || buffer_len.is_null()); @@ -71,7 +71,7 @@ pub extern "C" fn rs_ike_state_get_spi_responder( #[no_mangle] pub extern "C" fn rs_ike_state_get_nonce( - tx: &mut IKETransaction, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &IKETransaction, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { debug_validate_bug_on!(buffer.is_null() || buffer_len.is_null()); @@ -94,7 +94,7 @@ pub extern "C" fn rs_ike_state_get_nonce( #[no_mangle] pub extern "C" fn rs_ike_state_get_key_exchange( - tx: &mut IKETransaction, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &IKETransaction, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { debug_validate_bug_on!(buffer.is_null() || buffer_len.is_null()); @@ -137,7 +137,7 @@ pub extern "C" fn rs_ike_tx_get_vendor( #[no_mangle] pub extern "C" fn rs_ike_state_get_sa_attribute( - tx: &mut IKETransaction, sa_type: *const std::os::raw::c_char, value: *mut u32, + tx: &IKETransaction, sa_type: *const std::os::raw::c_char, value: *mut u32, ) -> u8 { debug_validate_bug_on!(value.is_null()); let mut ret_val = 0; @@ -208,7 +208,7 @@ pub extern "C" fn rs_ike_state_get_sa_attribute( #[no_mangle] pub unsafe extern "C" fn rs_ike_state_get_key_exchange_payload_length( - tx: &mut IKETransaction, value: *mut u32, + tx: &IKETransaction, value: *mut u32, ) -> u8 { debug_validate_bug_on!(value.is_null()); @@ -223,7 +223,7 @@ pub unsafe extern "C" fn rs_ike_state_get_key_exchange_payload_length( #[no_mangle] pub unsafe extern "C" fn rs_ike_state_get_nonce_payload_length( - tx: &mut IKETransaction, value: *mut u32, + tx: &IKETransaction, value: *mut u32, ) -> u8 { debug_validate_bug_on!(value.is_null()); diff --git a/rust/src/krb/detect.rs b/rust/src/krb/detect.rs index 25cce9bcf826..8566d17687cd 100644 --- a/rust/src/krb/detect.rs +++ b/rust/src/krb/detect.rs @@ -31,14 +31,14 @@ use nom7::IResult; use std::ffi::CStr; #[no_mangle] -pub unsafe extern "C" fn rs_krb5_tx_get_msgtype(tx: &mut KRB5Transaction, ptr: *mut u32) { +pub unsafe extern "C" fn rs_krb5_tx_get_msgtype(tx: &KRB5Transaction, ptr: *mut u32) { *ptr = tx.msg_type.0; } /// Get error code, if present in transaction /// Return 0 if error code was filled, else 1 #[no_mangle] -pub unsafe extern "C" fn rs_krb5_tx_get_errcode(tx: &mut KRB5Transaction, ptr: *mut i32) -> u32 { +pub unsafe extern "C" fn rs_krb5_tx_get_errcode(tx: &KRB5Transaction, ptr: *mut i32) -> u32 { match tx.error_code { Some(ref e) => { *ptr = e.0; @@ -50,7 +50,7 @@ pub unsafe extern "C" fn rs_krb5_tx_get_errcode(tx: &mut KRB5Transaction, ptr: * #[no_mangle] pub unsafe extern "C" fn rs_krb5_tx_get_cname( - tx: &mut KRB5Transaction, i: u32, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &KRB5Transaction, i: u32, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { if let Some(ref s) = tx.cname { if (i as usize) < s.name_string.len() { @@ -65,7 +65,7 @@ pub unsafe extern "C" fn rs_krb5_tx_get_cname( #[no_mangle] pub unsafe extern "C" fn rs_krb5_tx_get_sname( - tx: &mut KRB5Transaction, i: u32, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &KRB5Transaction, i: u32, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { if let Some(ref s) = tx.sname { if (i as usize) < s.name_string.len() { @@ -103,7 +103,6 @@ impl DetectKrb5TicketEncryptionList { } } - // Suppress large enum variant lint as the LIST is very large compared // to the boolean variant. #[derive(Debug)] @@ -227,7 +226,7 @@ pub unsafe extern "C" fn rs_krb5_detect_encryption_parse( #[no_mangle] pub unsafe extern "C" fn rs_krb5_detect_encryption_match( - tx: &mut KRB5Transaction, ctx: &DetectKrb5TicketEncryptionData, + tx: &KRB5Transaction, ctx: &DetectKrb5TicketEncryptionData, ) -> std::os::raw::c_int { if let Some(x) = tx.ticket_etype { match ctx { diff --git a/rust/src/krb/log.rs b/rust/src/krb/log.rs index 58c0d64b4893..1f57da24f2c1 100644 --- a/rust/src/krb/log.rs +++ b/rust/src/krb/log.rs @@ -20,7 +20,7 @@ use crate::jsonbuilder::{JsonBuilder, JsonError}; use crate::krb::krb5::{KRB5Transaction,test_weak_encryption}; -fn krb5_log_response(jsb: &mut JsonBuilder, tx: &mut KRB5Transaction) -> Result<(), JsonError> +fn krb5_log_response(jsb: &mut JsonBuilder, tx: &KRB5Transaction) -> Result<(), JsonError> { jsb.open_object("krb5")?; match tx.error_code { @@ -70,7 +70,7 @@ fn krb5_log_response(jsb: &mut JsonBuilder, tx: &mut KRB5Transaction) -> Result< } #[no_mangle] -pub extern "C" fn rs_krb5_log_json_response(tx: &mut KRB5Transaction, jsb: &mut JsonBuilder) -> bool +pub extern "C" fn rs_krb5_log_json_response(tx: &KRB5Transaction, jsb: &mut JsonBuilder) -> bool { krb5_log_response(jsb, tx).is_ok() } diff --git a/rust/src/mime/smtp_log.rs b/rust/src/mime/smtp_log.rs index de8ab6d2341c..7862a0661f1b 100644 --- a/rust/src/mime/smtp_log.rs +++ b/rust/src/mime/smtp_log.rs @@ -23,7 +23,7 @@ use digest::Update; use md5::Md5; use std::ffi::CStr; -fn log_subject_md5(js: &mut JsonBuilder, ctx: &mut MimeStateSMTP) -> Result<(), JsonError> { +fn log_subject_md5(js: &mut JsonBuilder, ctx: &MimeStateSMTP) -> Result<(), JsonError> { for h in &ctx.headers[..ctx.main_headers_nb] { if mime::slice_equals_lowercase(&h.name, b"subject") { let hash = format!("{:x}", Md5::new().chain(&h.value).finalize()); @@ -36,12 +36,12 @@ fn log_subject_md5(js: &mut JsonBuilder, ctx: &mut MimeStateSMTP) -> Result<(), #[no_mangle] pub unsafe extern "C" fn SCMimeSmtpLogSubjectMd5( - js: &mut JsonBuilder, ctx: &mut MimeStateSMTP, + js: &mut JsonBuilder, ctx: &MimeStateSMTP, ) -> bool { return log_subject_md5(js, ctx).is_ok(); } -fn log_body_md5(js: &mut JsonBuilder, ctx: &mut MimeStateSMTP) -> Result<(), JsonError> { +fn log_body_md5(js: &mut JsonBuilder, ctx: &MimeStateSMTP) -> Result<(), JsonError> { if ctx.md5_state == MimeSmtpMd5State::MimeSmtpMd5Completed { let hash = format!("{:x}", ctx.md5_result); js.set_string("body_md5", &hash)?; @@ -50,14 +50,12 @@ fn log_body_md5(js: &mut JsonBuilder, ctx: &mut MimeStateSMTP) -> Result<(), Jso } #[no_mangle] -pub unsafe extern "C" fn SCMimeSmtpLogBodyMd5( - js: &mut JsonBuilder, ctx: &mut MimeStateSMTP, -) -> bool { +pub unsafe extern "C" fn SCMimeSmtpLogBodyMd5(js: &mut JsonBuilder, ctx: &MimeStateSMTP) -> bool { return log_body_md5(js, ctx).is_ok(); } fn log_field_array( - js: &mut JsonBuilder, ctx: &mut MimeStateSMTP, c: &str, e: &str, + js: &mut JsonBuilder, ctx: &MimeStateSMTP, c: &str, e: &str, ) -> Result<(), JsonError> { let mark = js.get_mark(); let mut found = false; @@ -81,7 +79,7 @@ fn log_field_array( #[no_mangle] pub unsafe extern "C" fn SCMimeSmtpLogFieldArray( - js: &mut JsonBuilder, ctx: &mut MimeStateSMTP, email: *const std::os::raw::c_char, + js: &mut JsonBuilder, ctx: &MimeStateSMTP, email: *const std::os::raw::c_char, config: *const std::os::raw::c_char, ) -> bool { let e: &CStr = CStr::from_ptr(email); //unsafe @@ -101,7 +99,7 @@ enum FieldCommaState { } fn log_field_comma( - js: &mut JsonBuilder, ctx: &mut MimeStateSMTP, c: &str, e: &str, + js: &mut JsonBuilder, ctx: &MimeStateSMTP, c: &str, e: &str, ) -> Result<(), JsonError> { for h in &ctx.headers[..ctx.main_headers_nb] { if mime::slice_equals_lowercase(&h.name, e.as_bytes()) { @@ -158,7 +156,7 @@ fn log_field_comma( #[no_mangle] pub unsafe extern "C" fn SCMimeSmtpLogFieldComma( - js: &mut JsonBuilder, ctx: &mut MimeStateSMTP, email: *const std::os::raw::c_char, + js: &mut JsonBuilder, ctx: &MimeStateSMTP, email: *const std::os::raw::c_char, config: *const std::os::raw::c_char, ) -> bool { let e: &CStr = CStr::from_ptr(email); //unsafe @@ -172,7 +170,7 @@ pub unsafe extern "C" fn SCMimeSmtpLogFieldComma( } fn log_field_string( - js: &mut JsonBuilder, ctx: &mut MimeStateSMTP, c: &str, e: &str, + js: &mut JsonBuilder, ctx: &MimeStateSMTP, c: &str, e: &str, ) -> Result<(), JsonError> { for h in &ctx.headers[..ctx.main_headers_nb] { if mime::slice_equals_lowercase(&h.name, e.as_bytes()) { @@ -185,7 +183,7 @@ fn log_field_string( #[no_mangle] pub unsafe extern "C" fn SCMimeSmtpLogFieldString( - js: &mut JsonBuilder, ctx: &mut MimeStateSMTP, email: *const std::os::raw::c_char, + js: &mut JsonBuilder, ctx: &MimeStateSMTP, email: *const std::os::raw::c_char, config: *const std::os::raw::c_char, ) -> bool { let e: &CStr = CStr::from_ptr(email); //unsafe @@ -199,7 +197,7 @@ pub unsafe extern "C" fn SCMimeSmtpLogFieldString( } fn log_data_header( - js: &mut JsonBuilder, ctx: &mut MimeStateSMTP, hname: &str, + js: &mut JsonBuilder, ctx: &MimeStateSMTP, hname: &str, ) -> Result<(), JsonError> { for h in &ctx.headers[..ctx.main_headers_nb] { if mime::slice_equals_lowercase(&h.name, hname.as_bytes()) { @@ -210,7 +208,7 @@ fn log_data_header( return Ok(()); } -fn log_data(js: &mut JsonBuilder, ctx: &mut MimeStateSMTP) -> Result<(), JsonError> { +fn log_data(js: &mut JsonBuilder, ctx: &MimeStateSMTP) -> Result<(), JsonError> { log_data_header(js, ctx, "from")?; log_field_comma(js, ctx, "to", "to")?; log_field_comma(js, ctx, "cc", "cc")?; @@ -236,6 +234,6 @@ fn log_data(js: &mut JsonBuilder, ctx: &mut MimeStateSMTP) -> Result<(), JsonErr } #[no_mangle] -pub unsafe extern "C" fn SCMimeSmtpLogData(js: &mut JsonBuilder, ctx: &mut MimeStateSMTP) -> bool { +pub unsafe extern "C" fn SCMimeSmtpLogData(js: &mut JsonBuilder, ctx: &MimeStateSMTP) -> bool { return log_data(js, ctx).is_ok(); } diff --git a/rust/src/modbus/log.rs b/rust/src/modbus/log.rs index 24e703c245f7..a77b92060455 100644 --- a/rust/src/modbus/log.rs +++ b/rust/src/modbus/log.rs @@ -21,7 +21,7 @@ use crate::jsonbuilder::{JsonBuilder, JsonError}; use sawp_modbus::{Data, Message, Read, Write}; #[no_mangle] -pub extern "C" fn rs_modbus_to_json(tx: &mut ModbusTransaction, js: &mut JsonBuilder) -> bool { +pub extern "C" fn rs_modbus_to_json(tx: &ModbusTransaction, js: &mut JsonBuilder) -> bool { log(tx, js).is_ok() } diff --git a/rust/src/nfs/log.rs b/rust/src/nfs/log.rs index f6fdc8f5828a..8e1d8c8325b1 100644 --- a/rust/src/nfs/log.rs +++ b/rust/src/nfs/log.rs @@ -23,7 +23,7 @@ use crc::crc32; #[no_mangle] pub extern "C" fn rs_nfs_tx_logging_is_filtered(state: &mut NFSState, - tx: &mut NFSTransaction) + tx: &NFSTransaction) -> u8 { // TODO probably best to make this configurable @@ -119,7 +119,7 @@ fn nfs_log_request(state: &NFSState, tx: &NFSTransaction, js: &mut JsonBuilder) } #[no_mangle] -pub extern "C" fn rs_nfs_log_json_request(state: &mut NFSState, tx: &mut NFSTransaction, +pub extern "C" fn rs_nfs_log_json_request(state: &mut NFSState, tx: &NFSTransaction, js: &mut JsonBuilder) -> bool { nfs_log_request(state, tx, js).is_ok() @@ -152,7 +152,7 @@ fn nfs_log_response(state: &NFSState, tx: &NFSTransaction, js: &mut JsonBuilder) } #[no_mangle] -pub extern "C" fn rs_nfs_log_json_response(state: &mut NFSState, tx: &mut NFSTransaction, +pub extern "C" fn rs_nfs_log_json_response(state: &mut NFSState, tx: &NFSTransaction, js: &mut JsonBuilder) -> bool { nfs_log_response(state, tx, js).is_ok() @@ -173,7 +173,7 @@ fn rpc_log_response(tx: &NFSTransaction, js: &mut JsonBuilder) } #[no_mangle] -pub extern "C" fn rs_rpc_log_json_response(tx: &mut NFSTransaction, +pub extern "C" fn rs_rpc_log_json_response(tx: &NFSTransaction, js: &mut JsonBuilder) -> bool { rpc_log_response(tx, js).is_ok() diff --git a/rust/src/rdp/log.rs b/rust/src/rdp/log.rs index e0a71a839b8f..a3d7b6043dd8 100644 --- a/rust/src/rdp/log.rs +++ b/rust/src/rdp/log.rs @@ -21,10 +21,10 @@ use super::rdp::{RdpTransaction, RdpTransactionItem}; use crate::jsonbuilder::{JsonBuilder, JsonError}; use crate::rdp::parser::*; use crate::rdp::windows; -use x509_parser::prelude::{X509Certificate, FromDer}; +use x509_parser::prelude::{FromDer, X509Certificate}; #[no_mangle] -pub extern "C" fn rs_rdp_to_json(tx: &mut RdpTransaction, js: &mut JsonBuilder) -> bool { +pub extern "C" fn rs_rdp_to_json(tx: &RdpTransaction, js: &mut JsonBuilder) -> bool { log(tx, js).is_ok() } diff --git a/rust/src/rfb/detect.rs b/rust/src/rfb/detect.rs index 3e0d9b27244e..81919330cc29 100644 --- a/rust/src/rfb/detect.rs +++ b/rust/src/rfb/detect.rs @@ -101,7 +101,7 @@ unsafe extern "C" fn rfb_sec_type_setup( return 0; } -fn rfb_sec_type_match_aux(tx: &mut RFBTransaction, ctx: &DetectUintData) -> c_int { +fn rfb_sec_type_match_aux(tx: &RFBTransaction, ctx: &DetectUintData) -> c_int { if let Some(r) = tx.chosen_security_type { if detect_match_uint(ctx, r) { return 1; diff --git a/rust/src/sip/detect.rs b/rust/src/sip/detect.rs index ce7fbc5d12d9..708d5640a160 100644 --- a/rust/src/sip/detect.rs +++ b/rust/src/sip/detect.rs @@ -41,7 +41,7 @@ static mut G_SIP_CONTENT_LENGTH_HDR_BUFFER_ID: c_int = 0; #[no_mangle] pub unsafe extern "C" fn rs_sip_tx_get_method( - tx: &mut SIPTransaction, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &SIPTransaction, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { if let Some(ref r) = tx.request { let m = &r.method; @@ -60,7 +60,7 @@ pub unsafe extern "C" fn rs_sip_tx_get_method( #[no_mangle] pub unsafe extern "C" fn rs_sip_tx_get_uri( - tx: &mut SIPTransaction, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &SIPTransaction, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { if let Some(ref r) = tx.request { let p = &r.path; diff --git a/rust/src/sip/log.rs b/rust/src/sip/log.rs index 058b7850cb69..49e30a00db95 100644 --- a/rust/src/sip/log.rs +++ b/rust/src/sip/log.rs @@ -57,6 +57,6 @@ fn log(tx: &SIPTransaction, js: &mut JsonBuilder) -> Result<(), JsonError> { } #[no_mangle] -pub extern "C" fn rs_sip_log_json(tx: &mut SIPTransaction, js: &mut JsonBuilder) -> bool { +pub extern "C" fn rs_sip_log_json(tx: &SIPTransaction, js: &mut JsonBuilder) -> bool { log(tx, js).is_ok() } diff --git a/rust/src/smb/detect.rs b/rust/src/smb/detect.rs index dd525ec825f3..968641406bd7 100644 --- a/rust/src/smb/detect.rs +++ b/rust/src/smb/detect.rs @@ -26,7 +26,7 @@ use std::ptr; #[no_mangle] pub unsafe extern "C" fn rs_smb_tx_get_share( - tx: &mut SMBTransaction, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &SMBTransaction, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { if let Some(SMBTransactionTypeData::TREECONNECT(ref x)) = tx.type_data { SCLogDebug!("is_pipe {}", x.is_pipe); @@ -44,7 +44,7 @@ pub unsafe extern "C" fn rs_smb_tx_get_share( #[no_mangle] pub unsafe extern "C" fn rs_smb_tx_get_named_pipe( - tx: &mut SMBTransaction, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &SMBTransaction, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { if let Some(SMBTransactionTypeData::TREECONNECT(ref x)) = tx.type_data { SCLogDebug!("is_pipe {}", x.is_pipe); @@ -62,7 +62,7 @@ pub unsafe extern "C" fn rs_smb_tx_get_named_pipe( #[no_mangle] pub unsafe extern "C" fn rs_smb_tx_get_stub_data( - tx: &mut SMBTransaction, direction: u8, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &SMBTransaction, direction: u8, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { if let Some(SMBTransactionTypeData::DCERPC(ref x)) = tx.type_data { let vref = if direction == Direction::ToServer as u8 { @@ -84,7 +84,7 @@ pub unsafe extern "C" fn rs_smb_tx_get_stub_data( #[no_mangle] pub extern "C" fn rs_smb_tx_match_dce_opnum( - tx: &mut SMBTransaction, dce_data: &mut DCEOpnumData, + tx: &SMBTransaction, dce_data: &mut DCEOpnumData, ) -> u8 { SCLogDebug!("rs_smb_tx_get_dce_opnum: start"); if let Some(SMBTransactionTypeData::DCERPC(ref x)) = tx.type_data { @@ -110,7 +110,7 @@ pub extern "C" fn rs_smb_tx_match_dce_opnum( * - only match on approved ifaces (so ack_result == 0) */ #[no_mangle] pub extern "C" fn rs_smb_tx_get_dce_iface( - state: &mut SMBState, tx: &mut SMBTransaction, dce_data: &mut DCEIfaceData, + state: &mut SMBState, tx: &SMBTransaction, dce_data: &mut DCEIfaceData, ) -> u8 { let if_uuid = dce_data.if_uuid.as_slice(); let is_dcerpc_request = match tx.type_data { @@ -152,7 +152,7 @@ pub extern "C" fn rs_smb_tx_get_dce_iface( #[no_mangle] pub unsafe extern "C" fn rs_smb_tx_get_ntlmssp_user( - tx: &mut SMBTransaction, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &SMBTransaction, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { if let Some(SMBTransactionTypeData::SESSIONSETUP(ref x)) = tx.type_data { if let Some(ref ntlmssp) = x.ntlmssp { @@ -169,7 +169,7 @@ pub unsafe extern "C" fn rs_smb_tx_get_ntlmssp_user( #[no_mangle] pub unsafe extern "C" fn rs_smb_tx_get_ntlmssp_domain( - tx: &mut SMBTransaction, buffer: *mut *const u8, buffer_len: *mut u32, + tx: &SMBTransaction, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { if let Some(SMBTransactionTypeData::SESSIONSETUP(ref x)) = tx.type_data { if let Some(ref ntlmssp) = x.ntlmssp { @@ -185,9 +185,7 @@ pub unsafe extern "C" fn rs_smb_tx_get_ntlmssp_domain( } #[no_mangle] -pub unsafe extern "C" fn rs_smb_version_match( - tx: &mut SMBTransaction, version_data: &mut u8, -) -> u8 { +pub unsafe extern "C" fn rs_smb_version_match(tx: &SMBTransaction, version_data: &mut u8) -> u8 { let version = tx.vercmd.get_version(); SCLogDebug!("smb_version: version returned: {}", version); if version == *version_data { @@ -247,4 +245,4 @@ mod tests { assert_eq!(1u8, parse_version_data(" 1").unwrap()); assert_eq!(2u8, parse_version_data(" 2 ").unwrap()); } -} \ No newline at end of file +} diff --git a/rust/src/smb/log.rs b/rust/src/smb/log.rs index 01d3d9e13846..d6b68dd070f9 100644 --- a/rust/src/smb/log.rs +++ b/rust/src/smb/log.rs @@ -445,13 +445,13 @@ fn smb_common_header(jsb: &mut JsonBuilder, state: &SMBState, tx: &SMBTransactio } #[no_mangle] -pub extern "C" fn rs_smb_log_json_request(jsb: &mut JsonBuilder, state: &mut SMBState, tx: &mut SMBTransaction) -> bool +pub extern "C" fn rs_smb_log_json_request(jsb: &mut JsonBuilder, state: &mut SMBState, tx: &SMBTransaction) -> bool { smb_common_header(jsb, state, tx).is_ok() } #[no_mangle] -pub extern "C" fn rs_smb_log_json_response(jsb: &mut JsonBuilder, state: &mut SMBState, tx: &mut SMBTransaction) -> bool +pub extern "C" fn rs_smb_log_json_response(jsb: &mut JsonBuilder, state: &mut SMBState, tx: &SMBTransaction) -> bool { smb_common_header(jsb, state, tx).is_ok() } diff --git a/rust/src/tftp/log.rs b/rust/src/tftp/log.rs index f6e63531a07e..da04521e7fa0 100644 --- a/rust/src/tftp/log.rs +++ b/rust/src/tftp/log.rs @@ -20,15 +20,12 @@ use crate::jsonbuilder::{JsonBuilder, JsonError}; use crate::tftp::tftp::TFTPTransaction; -fn tftp_log_request(tx: &mut TFTPTransaction, - jb: &mut JsonBuilder) - -> Result<(), JsonError> -{ +fn tftp_log_request(tx: &TFTPTransaction, jb: &mut JsonBuilder) -> Result<(), JsonError> { jb.open_object("tftp")?; match tx.opcode { 1 => jb.set_string("packet", "read")?, 2 => jb.set_string("packet", "write")?, - _ => jb.set_string("packet", "error")? + _ => jb.set_string("packet", "error")?, }; jb.set_string("file", tx.filename.as_str())?; jb.set_string("mode", tx.mode.as_str())?; @@ -37,9 +34,6 @@ fn tftp_log_request(tx: &mut TFTPTransaction, } #[no_mangle] -pub extern "C" fn rs_tftp_log_json_request(tx: &mut TFTPTransaction, - jb: &mut JsonBuilder) - -> bool -{ +pub extern "C" fn rs_tftp_log_json_request(tx: &TFTPTransaction, jb: &mut JsonBuilder) -> bool { tftp_log_request(tx, jb).is_ok() }