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/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/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/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() }