From: Philippe Antoine Date: Thu, 6 May 2021 11:30:49 +0000 (+0200) Subject: rust: SCLogDebug is real nop when built as release X-Git-Tag: suricata-5.0.7~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb73684da296c42789ab1266a63b530fc6421108;p=thirdparty%2Fsuricata.git rust: SCLogDebug is real nop when built as release Before, even if there were no outputs, all the arguments were evaluated, which could turn expensive All variables which are used only in certain build configurations are now prefixed by underscore to avoid warnings (cherry picked from commit ef5755338fa6404b60e7f90bfbaca039b2bfda1e) --- diff --git a/rust/src/applayertemplate/template.rs b/rust/src/applayertemplate/template.rs index 760e67ced3..2e301343ab 100644 --- a/rust/src/applayertemplate/template.rs +++ b/rust/src/applayertemplate/template.rs @@ -17,7 +17,6 @@ use std; use crate::core::{self, ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_TCP}; -use crate::log::*; use std::mem::transmute; use crate::applayer::{self, LoggerFlags}; use crate::parser::*; diff --git a/rust/src/conf.rs b/rust/src/conf.rs index 92d3ccd696..bc3582f73c 100644 --- a/rust/src/conf.rs +++ b/rust/src/conf.rs @@ -22,8 +22,6 @@ use std::ffi::{CString, CStr}; use std::ptr; use std::str; -use crate::log::*; - extern { fn ConfGet(key: *const c_char, res: *mut *const c_char) -> i8; fn ConfGetChildValue(conf: *const c_void, key: *const c_char, diff --git a/rust/src/dhcp/dhcp.rs b/rust/src/dhcp/dhcp.rs index 4c5af84c71..5ed17277c5 100644 --- a/rust/src/dhcp/dhcp.rs +++ b/rust/src/dhcp/dhcp.rs @@ -20,7 +20,6 @@ use crate::core; use crate::core::{ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_UDP}; use crate::core::{sc_detect_engine_state_free, sc_app_layer_decoder_events_free_events}; use crate::dhcp::parser::*; -use crate::log::*; use crate::parser::*; use std; use std::ffi::{CStr,CString}; diff --git a/rust/src/dns/dns.rs b/rust/src/dns/dns.rs index c9b688f1ff..2b73ef2dd5 100644 --- a/rust/src/dns/dns.rs +++ b/rust/src/dns/dns.rs @@ -20,7 +20,6 @@ extern crate nom; use std; use std::mem::transmute; -use crate::log::*; use crate::applayer::LoggerFlags; use crate::core; use crate::dns::parser; diff --git a/rust/src/filecontainer.rs b/rust/src/filecontainer.rs index 38520cfa9e..b3b321c274 100644 --- a/rust/src/filecontainer.rs +++ b/rust/src/filecontainer.rs @@ -18,7 +18,6 @@ use std::ptr; use std::os::raw::{c_void}; -use crate::log::*; use crate::core::*; pub struct File; diff --git a/rust/src/filetracker.rs b/rust/src/filetracker.rs index 1981b54e00..2dcb9ce1c8 100644 --- a/rust/src/filetracker.rs +++ b/rust/src/filetracker.rs @@ -28,7 +28,6 @@ * The tracker does continue to follow the file. */ -use crate::log::*; use crate::core::*; use std::collections::HashMap; use std::collections::hash_map::Entry::{Occupied, Vacant}; @@ -122,10 +121,10 @@ impl FileTransferTracker { self.file_is_truncated = true; } - pub fn create(&mut self, name: &[u8], file_size: u64) { + pub fn create(&mut self, _name: &[u8], _file_size: u64) { if self.file_open == true { panic!("close existing file first"); } - SCLogDebug!("CREATE: name {:?} file_size {}", name, file_size); + SCLogDebug!("CREATE: name {:?} file_size {}", _name, _file_size); } pub fn new_chunk(&mut self, config: &'static SuricataFileContext, @@ -251,7 +250,7 @@ impl FileTransferTracker { if self.chunk_is_ooo == false { loop { - let offset = self.tracked; + let _offset = self.tracked; match self.chunks.remove(&self.tracked) { Some(c) => { let res = files.file_append(&self.track_id, &c.chunk, c.contains_gap); @@ -269,10 +268,10 @@ impl FileTransferTracker { self.tracked += c.chunk.len() as u64; self.cur_ooo -= c.chunk.len() as u64; - SCLogDebug!("STORED OOO CHUNK at offset {}, tracked now {}, stored len {}", offset, self.tracked, c.chunk.len()); + SCLogDebug!("STORED OOO CHUNK at offset {}, tracked now {}, stored len {}", _offset, self.tracked, c.chunk.len()); }, _ => { - SCLogDebug!("NO STORED CHUNK found at offset {}", self.tracked); + SCLogDebug!("NO STORED CHUNK found at _offset {}", self.tracked); break; }, }; diff --git a/rust/src/ftp/mod.rs b/rust/src/ftp/mod.rs index e07bebb8ec..2e387baacb 100644 --- a/rust/src/ftp/mod.rs +++ b/rust/src/ftp/mod.rs @@ -23,8 +23,6 @@ use std::str; use std; use std::str::FromStr; -use crate::log::*; - // We transform an integer string into a i64, ignoring surrounding whitespaces // We look for a digit suite, and try to convert it. // If either str::from_utf8 or FromStr::from_str fail, @@ -105,11 +103,9 @@ pub extern "C" fn rs_ftp_pasv_response(input: *const u8, len: u32) -> u16 { return dport; }, Err(nom::Err::Incomplete(_)) => { - let buf = unsafe{std::slice::from_raw_parts(input, len as usize)}; SCLogDebug!("pasv incomplete: '{:?}'", String::from_utf8_lossy(buf)); }, Err(_) => { - let buf = unsafe{std::slice::from_raw_parts(input, len as usize)}; SCLogDebug!("pasv error on '{:?}'", String::from_utf8_lossy(buf)); }, } @@ -169,11 +165,9 @@ pub extern "C" fn rs_ftp_epsv_response(input: *const u8, len: u32) -> u16 { return dport; }, Err(nom::Err::Incomplete(_)) => { - let buf = unsafe{std::slice::from_raw_parts(input, len as usize)}; SCLogDebug!("epsv incomplete: '{:?}'", String::from_utf8_lossy(buf)); }, Err(_) => { - let buf = unsafe{std::slice::from_raw_parts(input, len as usize)}; SCLogDebug!("epsv incomplete: '{:?}'", String::from_utf8_lossy(buf)); }, diff --git a/rust/src/ikev2/ikev2.rs b/rust/src/ikev2/ikev2.rs index bbf626d90f..8e1bdba234 100644 --- a/rust/src/ikev2/ikev2.rs +++ b/rust/src/ikev2/ikev2.rs @@ -26,8 +26,6 @@ use crate::parser::*; use std; use std::ffi::{CStr,CString}; -use crate::log::*; - use nom; #[repr(u32)] @@ -187,8 +185,8 @@ impl IKEV2State { self.dh_group = kex.dh_group; } }, - IkeV2PayloadContent::Nonce(ref n) => { - SCLogDebug!("Nonce: {:?}", n); + IkeV2PayloadContent::Nonce(ref _n) => { + SCLogDebug!("Nonce: {:?}", _n); }, IkeV2PayloadContent::Notify(ref n) => { SCLogDebug!("Notify: {:?}", n); @@ -216,7 +214,7 @@ impl IKEV2State { } }; }, - e => { SCLogDebug!("parse_ikev2_payload_with_type: {:?}",e); () }, + _e => { SCLogDebug!("parse_ikev2_payload_with_type: {:?}",_e); () }, } 1 }, @@ -341,8 +339,8 @@ impl IKEV2State { _ => (), } }, - IkeV2Transform::Unknown(tx_type,tx_id) => { - SCLogDebug!("Unknown proposal: type={:?}, id={}", tx_type, tx_id); + IkeV2Transform::Unknown(_tx_type,_tx_id) => { + SCLogDebug!("Unknown proposal: type={:?}, id={}", _tx_type, _tx_id); self.set_event(IKEV2Event::UnknownProposal); }, _ => (), diff --git a/rust/src/kerberos.rs b/rust/src/kerberos.rs index 02343bf57e..631bc8fc82 100644 --- a/rust/src/kerberos.rs +++ b/rust/src/kerberos.rs @@ -22,8 +22,6 @@ use nom::{ErrorKind, IResult, le_u16}; use der_parser; use der_parser::parse_der_oid; -use crate::log::*; - pub const SECBLOB_NOT_SPNEGO : u32 = 128; pub const SECBLOB_KRB_FMT_ERR : u32 = 129; diff --git a/rust/src/krb/krb5.rs b/rust/src/krb/krb5.rs index eb753600db..58e0c3c03d 100644 --- a/rust/src/krb/krb5.rs +++ b/rust/src/krb/krb5.rs @@ -29,8 +29,6 @@ use crate::core; use crate::core::{AppProto,Flow,ALPROTO_FAILED,ALPROTO_UNKNOWN,STREAM_TOCLIENT,STREAM_TOSERVER,sc_detect_engine_state_free}; use crate::parser::*; -use crate::log::*; - #[repr(u32)] pub enum KRB5Event { MalformedData = 0, diff --git a/rust/src/log.rs b/rust/src/log.rs index fdb0524ea3..eb74c6ebec 100644 --- a/rust/src/log.rs +++ b/rust/src/log.rs @@ -22,6 +22,7 @@ use std::path::Path; use crate::core::*; #[derive(Debug)] +#[repr(C)] pub enum Level { NotSet = -1, None = 0, @@ -67,19 +68,33 @@ pub fn sclog(level: Level, file: &str, line: u32, function: &str, message); } +#[cfg(feature = "function-macro")] +#[macro_export(local_inner_macros)] +macro_rules!function { + () => {{ + // Okay, this is ugly, I get it. However, this is the best we can get on a stable rust. + fn __f() {} + fn type_name_of(_: T) -> &'static str { + std::any::type_name::() + } + let name = type_name_of(__f); + &name[..name.len() - 5] + }} +} /// Return the function name, but for now just return as Rust /// has no macro to return the function name, but may in the future, /// see: https://github.com/rust-lang/rfcs/pull/1719 +#[cfg(not(feature = "function-macro"))] +#[macro_export(local_inner_macros)] macro_rules!function { () => {{ "" }} } #[macro_export] macro_rules!do_log { - ($level:expr, $file:expr, $line:expr, $function:expr, $code:expr, - $($arg:tt)*) => { - if get_log_level() >= $level as i32 { - sclog($level, $file, $line, $function, $code, + ($level:expr, $code:expr, $($arg:tt)*) => { + if $crate::log::get_log_level() >= $level as i32 { + $crate::log::sclog($level, file!(), line!(), $crate::function!(), $code, &(format!($($arg)*))); } } @@ -88,37 +103,44 @@ macro_rules!do_log { #[macro_export] macro_rules!SCLogNotice { ($($arg:tt)*) => { - do_log!(Level::Notice, file!(), line!(), function!(), 0, $($arg)*); + $crate::do_log!($crate::log::Level::Notice, 0, $($arg)*); } } #[macro_export] macro_rules!SCLogInfo { ($($arg:tt)*) => { - do_log!(Level::Info, file!(), line!(), function!(), 0, $($arg)*); + $crate::do_log!($crate::log::Level::Info, 0, $($arg)*); } } #[macro_export] macro_rules!SCLogPerf { ($($arg:tt)*) => { - do_log!(Level::Perf, file!(), line!(), function!(), 0, $($arg)*); + $crate::do_log!($crate::log::Level::Perf, 0, $($arg)*); } } #[macro_export] macro_rules!SCLogConfig { ($($arg:tt)*) => { - do_log!(Level::Config, file!(), line!(), function!(), 0, $($arg)*); + $crate::do_log!($crate::log::Level::Config, 0, $($arg)*); } } +#[macro_export] +macro_rules!SCLogError { + ($($arg:tt)*) => { + $crate::do_log!($crate::log::Level::Error, 0, $($arg)*); + }; +} + // Debug mode: call C SCLogDebug #[cfg(feature = "debug")] #[macro_export] macro_rules!SCLogDebug { ($($arg:tt)*) => { - do_log!(Level::Debug, file!(), line!(), function!(), 0, $($arg)*); + do_log!($crate::log::Level::Debug, 0, $($arg)*); } } @@ -127,7 +149,7 @@ macro_rules!SCLogDebug { #[cfg(not(feature = "debug"))] #[macro_export] macro_rules!SCLogDebug { - ($last:expr) => { let _ = &$last; let _ = Level::Debug; }; + ($last:expr) => { let _ = &$last; let _ = $crate::log::Level::Debug; }; ($one:expr, $($arg:tt)*) => { let _ = &$one; SCLogDebug!($($arg)*); }; } diff --git a/rust/src/nfs/nfs.rs b/rust/src/nfs/nfs.rs index b68b57759a..8518a8c278 100644 --- a/rust/src/nfs/nfs.rs +++ b/rust/src/nfs/nfs.rs @@ -25,7 +25,6 @@ use std::ffi::CStr; use nom; -use crate::log::*; use crate::applayer; use crate::applayer::LoggerFlags; use crate::core::*; @@ -1094,9 +1093,9 @@ impl NFSState { if self.ts_gap { SCLogDebug!("TS trying to catch up after GAP (input {})", cur_i.len()); - let mut cnt = 0; + let mut _cnt = 0; while cur_i.len() > 0 { - cnt += 1; + _cnt += 1; match nfs_probe(cur_i, STREAM_TOSERVER) { 1 => { SCLogDebug!("expected data found"); @@ -1104,14 +1103,15 @@ impl NFSState { break; }, 0 => { - SCLogDebug!("incomplete, queue and retry with the next block (input {}). Looped {} times.", cur_i.len(), cnt); + SCLogDebug!("incomplete, queue and retry with the next block (input {}). Looped {} times.", + cur_i.len(), _cnt); self.tcp_buffer_ts.extend_from_slice(cur_i); return 0; }, -1 => { cur_i = &cur_i[1..]; if cur_i.len() == 0 { - SCLogDebug!("all post-GAP data in this chunk was bad. Looped {} times.", cnt); + SCLogDebug!("all post-GAP data in this chunk was bad. Looped {} times.", _cnt); } }, _ => { return 1; }, @@ -1258,9 +1258,9 @@ impl NFSState { if self.tc_gap { SCLogDebug!("TC trying to catch up after GAP (input {})", cur_i.len()); - let mut cnt = 0; + let mut _cnt = 0; while cur_i.len() > 0 { - cnt += 1; + _cnt += 1; match nfs_probe(cur_i, STREAM_TOCLIENT) { 1 => { SCLogDebug!("expected data found"); @@ -1268,14 +1268,15 @@ impl NFSState { break; }, 0 => { - SCLogDebug!("incomplete, queue and retry with the next block (input {}). Looped {} times.", cur_i.len(), cnt); + SCLogDebug!("incomplete, queue and retry with the next block (input {}). Looped {} times.", + cur_i.len(), _cnt); self.tcp_buffer_tc.extend_from_slice(cur_i); return 0; }, -1 => { cur_i = &cur_i[1..]; if cur_i.len() == 0 { - SCLogDebug!("all post-GAP data in this chunk was bad. Looped {} times.", cnt); + SCLogDebug!("all post-GAP data in this chunk was bad. Looped {} times.", _cnt); } }, _ => { return 1; }, diff --git a/rust/src/nfs/nfs2.rs b/rust/src/nfs/nfs2.rs index 719ed41ca6..9c907912e3 100644 --- a/rust/src/nfs/nfs2.rs +++ b/rust/src/nfs/nfs2.rs @@ -18,7 +18,6 @@ // written by Victor Julien use nom; -use crate::log::*; use crate::nfs::nfs::*; use crate::nfs::types::*; diff --git a/rust/src/nfs/nfs3.rs b/rust/src/nfs/nfs3.rs index 7e58593233..bf76274c92 100644 --- a/rust/src/nfs/nfs3.rs +++ b/rust/src/nfs/nfs3.rs @@ -18,7 +18,6 @@ // written by Victor Julien use nom; -use crate::log::*; use crate::core::*; use crate::nfs::nfs::*; diff --git a/rust/src/nfs/nfs4.rs b/rust/src/nfs/nfs4.rs index 9f33d9b5a4..698105d0ac 100644 --- a/rust/src/nfs/nfs4.rs +++ b/rust/src/nfs/nfs4.rs @@ -21,7 +21,6 @@ use nom; use nom::be_u32; use crate::core::*; -use crate::log::*; use crate::nfs::nfs::*; use crate::nfs::types::*; @@ -194,8 +193,8 @@ impl NFSState { self.commit_v4(r, fh); } } - &Nfs4RequestContent::Close(ref rd) => { - SCLogDebug!("CLOSEv4: {:?}", rd); + &Nfs4RequestContent::Close(ref _rd) => { + SCLogDebug!("CLOSEv4: {:?}", _rd); } &Nfs4RequestContent::Create(ref rd) => { SCLogDebug!("CREATEv4: {:?}", rd); @@ -210,11 +209,11 @@ impl NFSState { xidmap.file_name = rd.to_vec(); main_opcode = NFSPROC4_REMOVE; } - &Nfs4RequestContent::SetClientId(ref rd) => { + &Nfs4RequestContent::SetClientId(ref _rd) => { SCLogDebug!("SETCLIENTIDv4: client id {} r_netid {} r_addr {}", - String::from_utf8_lossy(&rd.client_id), - String::from_utf8_lossy(&rd.r_netid), - String::from_utf8_lossy(&rd.r_addr)); + String::from_utf8_lossy(&_rd.client_id), + String::from_utf8_lossy(&_rd.r_netid), + String::from_utf8_lossy(&_rd.r_addr)); } &_ => { }, } @@ -300,13 +299,13 @@ impl NFSState { for c in &cr.commands { SCLogDebug!("c {:?}", c); match c { - &Nfs4ResponseContent::ReadDir(s, ref rd) => { + &Nfs4ResponseContent::ReadDir(_s, ref rd) => { if let &Some(ref rd) = rd { - SCLogDebug!("READDIRv4: status {} eof {}", s, rd.eof); + SCLogDebug!("READDIRv4: status {} eof {}", _s, rd.eof); for d in &rd.listing { - if let &Some(ref d) = d { - SCLogDebug!("READDIRv4: dir {}", String::from_utf8_lossy(&d.name)); + if let &Some(ref _d) = d { + SCLogDebug!("READDIRv4: dir {}", String::from_utf8_lossy(&_d.name)); } } @@ -338,9 +337,9 @@ impl NFSState { self.process_read_record(r, &reply, Some(&xidmap)); } }, - &Nfs4ResponseContent::Open(s, ref rd) => { - if let &Some(ref rd) = rd { - SCLogDebug!("OPENv4: status {} opendata {:?}", s, rd); + &Nfs4ResponseContent::Open(_s, ref rd) => { + if let &Some(ref _rd) = rd { + SCLogDebug!("OPENv4: status {} opendata {:?}", _s, _rd); insert_filename_with_getfh = true; } }, diff --git a/rust/src/ntp/ntp.rs b/rust/src/ntp/ntp.rs index 8dfe62c6a9..3cbb031eea 100644 --- a/rust/src/ntp/ntp.rs +++ b/rust/src/ntp/ntp.rs @@ -26,8 +26,6 @@ use crate::parser::*; use std; use std::ffi::{CStr,CString}; -use crate::log::*; - use nom; #[repr(u32)] diff --git a/rust/src/sip/sip.rs b/rust/src/sip/sip.rs index 8df2a2f347..a49067f5af 100755 --- a/rust/src/sip/sip.rs +++ b/rust/src/sip/sip.rs @@ -23,7 +23,6 @@ use applayer; use conf; use core; use core::{sc_detect_engine_state_free, AppProto, Flow, ALPROTO_UNKNOWN}; -use log::*; use parser::*; use sip::parser::*; use std; diff --git a/rust/src/smb/auth.rs b/rust/src/smb/auth.rs index ba15a2b72f..79fbc8d150 100644 --- a/rust/src/smb/auth.rs +++ b/rust/src/smb/auth.rs @@ -17,7 +17,6 @@ use crate::kerberos::*; -use crate::log::*; use crate::smb::ntlmssp_records::*; use crate::smb::smb::*; diff --git a/rust/src/smb/dcerpc.rs b/rust/src/smb/dcerpc.rs index 7cb9b7d6d9..4bb9fa0196 100644 --- a/rust/src/smb/dcerpc.rs +++ b/rust/src/smb/dcerpc.rs @@ -17,8 +17,6 @@ // written by Victor Julien -use crate::log::*; - use crate::smb::smb::*; use crate::smb::smb2::*; use crate::smb::dcerpc_records::*; diff --git a/rust/src/smb/debug.rs b/rust/src/smb/debug.rs index 3387111ead..4545196292 100644 --- a/rust/src/smb/debug.rs +++ b/rust/src/smb/debug.rs @@ -17,9 +17,6 @@ use crate::smb::smb::*; -#[cfg(feature = "debug")] -use log::*; - impl SMBState { #[cfg(not(feature = "debug"))] pub fn _debug_tx_stats(&self) { } diff --git a/rust/src/smb/detect.rs b/rust/src/smb/detect.rs index 58d65c3224..5c2b344cb0 100644 --- a/rust/src/smb/detect.rs +++ b/rust/src/smb/detect.rs @@ -18,7 +18,6 @@ use std; use std::ptr; use crate::core::*; -use crate::log::*; use crate::smb::smb::*; #[no_mangle] diff --git a/rust/src/smb/events.rs b/rust/src/smb/events.rs index 3093d08e2f..1b29da7d43 100644 --- a/rust/src/smb/events.rs +++ b/rust/src/smb/events.rs @@ -16,7 +16,6 @@ */ use crate::core::*; -use crate::log::*; use crate::smb::smb::*; #[repr(u32)] diff --git a/rust/src/smb/files.rs b/rust/src/smb/files.rs index b8667e3fb8..f1c455fbdb 100644 --- a/rust/src/smb/files.rs +++ b/rust/src/smb/files.rs @@ -16,7 +16,6 @@ */ use crate::core::*; -use crate::log::*; use crate::filetracker::*; use crate::filecontainer::*; diff --git a/rust/src/smb/session.rs b/rust/src/smb/session.rs index 941b9eb300..43883a77d5 100644 --- a/rust/src/smb/session.rs +++ b/rust/src/smb/session.rs @@ -15,7 +15,6 @@ * 02110-1301, USA. */ -use crate::log::*; use crate::kerberos::*; use crate::smb::smb::*; use crate::smb::smb1_session::*; diff --git a/rust/src/smb/smb.rs b/rust/src/smb/smb.rs index 964e74ce09..231be9aaa7 100644 --- a/rust/src/smb/smb.rs +++ b/rust/src/smb/smb.rs @@ -35,7 +35,6 @@ use std::collections::HashMap; use nom; use crate::core::*; -use crate::log::*; use crate::applayer; use crate::applayer::LoggerFlags; @@ -1723,8 +1722,8 @@ impl SMBState { } cur_i = rem; }, - Err(nom::Err::Incomplete(needed)) => { - SCLogDebug!("INCOMPLETE have {} needed {:?}", cur_i.len(), needed); + Err(nom::Err::Incomplete(_needed)) => { + SCLogDebug!("INCOMPLETE have {} needed {:?}", cur_i.len(), _needed); let consumed = self.parse_tcp_data_tc_partial(cur_i); cur_i = &cur_i[consumed ..]; diff --git a/rust/src/smb/smb1.rs b/rust/src/smb/smb1.rs index 47e2d90dd4..fe7c553133 100644 --- a/rust/src/smb/smb1.rs +++ b/rust/src/smb/smb1.rs @@ -22,7 +22,6 @@ use nom; use crate::core::*; -use crate::log::*; use crate::smb::smb::*; use crate::smb::dcerpc::*; @@ -235,14 +234,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 { true }, - Err(nom::Err::Incomplete(n)) => { - SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION INCOMPLETE {:?}", n); + Err(nom::Err::Incomplete(_n)) => { + SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION INCOMPLETE {:?}", _n); events.push(SMBEvent::MalformedData); false }, - Err(nom::Err::Error(e)) | - Err(nom::Err::Failure(e)) => { - SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION ERROR {:?}", e); + Err(nom::Err::Error(_e)) | + Err(nom::Err::Failure(_e)) => { + SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION ERROR {:?}", _e); events.push(SMBEvent::MalformedData); false }, @@ -263,14 +262,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 { tx.vercmd.set_smb1_cmd(SMB1_COMMAND_TRANS2); true }, - Err(nom::Err::Incomplete(n)) => { - SCLogDebug!("TRANS2 SET_PATH_INFO DATA RENAME INCOMPLETE {:?}", n); + Err(nom::Err::Incomplete(_n)) => { + SCLogDebug!("TRANS2 SET_PATH_INFO DATA RENAME INCOMPLETE {:?}", _n); events.push(SMBEvent::MalformedData); false }, - Err(nom::Err::Error(e)) | - Err(nom::Err::Failure(e)) => { - SCLogDebug!("TRANS2 SET_PATH_INFO DATA RENAME ERROR {:?}", e); + Err(nom::Err::Error(_e)) | + Err(nom::Err::Failure(_e)) => { + SCLogDebug!("TRANS2 SET_PATH_INFO DATA RENAME ERROR {:?}", _e); events.push(SMBEvent::MalformedData); false }, @@ -279,14 +278,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 { false } }, - Err(nom::Err::Incomplete(n)) => { - SCLogDebug!("TRANS2 SET_PATH_INFO PARAMS INCOMPLETE {:?}", n); + Err(nom::Err::Incomplete(_n)) => { + SCLogDebug!("TRANS2 SET_PATH_INFO PARAMS INCOMPLETE {:?}", _n); events.push(SMBEvent::MalformedData); false }, - Err(nom::Err::Error(e)) | - Err(nom::Err::Failure(e)) => { - SCLogDebug!("TRANS2 SET_PATH_INFO PARAMS ERROR {:?}", e); + Err(nom::Err::Error(_e)) | + Err(nom::Err::Failure(_e)) => { + SCLogDebug!("TRANS2 SET_PATH_INFO PARAMS ERROR {:?}", _e); events.push(SMBEvent::MalformedData); false }, @@ -318,14 +317,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 { true }, - Err(nom::Err::Incomplete(n)) => { - SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION INCOMPLETE {:?}", n); + Err(nom::Err::Incomplete(_n)) => { + SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION INCOMPLETE {:?}", _n); events.push(SMBEvent::MalformedData); false }, - Err(nom::Err::Error(e)) | - Err(nom::Err::Failure(e)) => { - SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION ERROR {:?}", e); + Err(nom::Err::Error(_e)) | + Err(nom::Err::Failure(_e)) => { + SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION ERROR {:?}", _e); events.push(SMBEvent::MalformedData); false }, @@ -351,14 +350,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 { tx.vercmd.set_smb1_cmd(SMB1_COMMAND_TRANS2); true }, - Err(nom::Err::Incomplete(n)) => { - SCLogDebug!("TRANS2 SET_FILE_INFO DATA RENAME INCOMPLETE {:?}", n); + Err(nom::Err::Incomplete(_n)) => { + SCLogDebug!("TRANS2 SET_FILE_INFO DATA RENAME INCOMPLETE {:?}", _n); events.push(SMBEvent::MalformedData); false }, - Err(nom::Err::Error(e)) | - Err(nom::Err::Failure(e)) => { - SCLogDebug!("TRANS2 SET_FILE_INFO DATA RENAME ERROR {:?}", e); + Err(nom::Err::Error(_e)) | + Err(nom::Err::Failure(_e)) => { + SCLogDebug!("TRANS2 SET_FILE_INFO DATA RENAME ERROR {:?}", _e); events.push(SMBEvent::MalformedData); false }, @@ -367,14 +366,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 { false } }, - Err(nom::Err::Incomplete(n)) => { - SCLogDebug!("TRANS2 SET_FILE_INFO PARAMS INCOMPLETE {:?}", n); + Err(nom::Err::Incomplete(_n)) => { + SCLogDebug!("TRANS2 SET_FILE_INFO PARAMS INCOMPLETE {:?}", _n); events.push(SMBEvent::MalformedData); false }, - Err(nom::Err::Error(e)) | - Err(nom::Err::Failure(e)) => { - SCLogDebug!("TRANS2 SET_FILE_INFO PARAMS ERROR {:?}", e); + Err(nom::Err::Error(_e)) | + Err(nom::Err::Failure(_e)) => { + SCLogDebug!("TRANS2 SET_FILE_INFO PARAMS ERROR {:?}", _e); events.push(SMBEvent::MalformedData); false }, @@ -383,14 +382,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 { false } }, - Err(nom::Err::Incomplete(n)) => { - SCLogDebug!("TRANS2 INCOMPLETE {:?}", n); + Err(nom::Err::Incomplete(_n)) => { + SCLogDebug!("TRANS2 INCOMPLETE {:?}", _n); events.push(SMBEvent::MalformedData); false }, - Err(nom::Err::Error(e)) | - Err(nom::Err::Failure(e)) => { - SCLogDebug!("TRANS2 ERROR {:?}", e); + Err(nom::Err::Error(_e)) | + Err(nom::Err::Failure(_e)) => { + SCLogDebug!("TRANS2 ERROR {:?}", _e); events.push(SMBEvent::MalformedData); false }, @@ -813,11 +812,11 @@ pub fn smb1_trans_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) let mut frankenfid = pipe.fid.to_vec(); frankenfid.extend_from_slice(&u32_as_bytes(r.ssn_id)); - let (filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) { + let (_filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) { (n, x) => (n, x), }; SCLogDebug!("smb1_trans_request_record: name {} is_dcerpc {}", - filename, is_dcerpc); + _filename, is_dcerpc); pipe_dcerpc = is_dcerpc; } @@ -854,11 +853,11 @@ pub fn smb1_trans_response_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) let mut frankenfid = fid.to_vec(); frankenfid.extend_from_slice(&u32_as_bytes(r.ssn_id)); - let (filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) { + let (_filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) { (n, x) => (n, x), }; SCLogDebug!("smb1_trans_response_record: name {} is_dcerpc {}", - filename, is_dcerpc); + _filename, is_dcerpc); // if we get status 'BUFFER_OVERFLOW' this is only a part of // the data. Store it in the ssn/tree for later use. diff --git a/rust/src/smb/smb1_records.rs b/rust/src/smb/smb1_records.rs index 1ae9ac50f6..e7367e6443 100644 --- a/rust/src/smb/smb1_records.rs +++ b/rust/src/smb/smb1_records.rs @@ -15,7 +15,6 @@ * 02110-1301, USA. */ -use crate::log::*; use nom::{rest, le_u8, le_u16, le_u32, le_u64, IResult}; use crate::smb::smb::*; use crate::smb::smb_records::*; diff --git a/rust/src/smb/smb1_session.rs b/rust/src/smb/smb1_session.rs index 35d6495839..8c9b123974 100644 --- a/rust/src/smb/smb1_session.rs +++ b/rust/src/smb/smb1_session.rs @@ -15,8 +15,6 @@ * 02110-1301, USA. */ -use crate::log::*; - use crate::smb::smb_records::*; use crate::smb::smb1_records::*; use crate::smb::smb::*; diff --git a/rust/src/smb/smb2.rs b/rust/src/smb/smb2.rs index e5219dfebe..c25cf0cca6 100644 --- a/rust/src/smb/smb2.rs +++ b/rust/src/smb/smb2.rs @@ -18,7 +18,6 @@ use nom; use crate::core::*; -use crate::log::*; use crate::smb::smb::*; use crate::smb::smb2_records::*; @@ -580,20 +579,20 @@ pub fn smb2_response_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>) if r.nt_status == SMB_NTSTATUS_SUCCESS { match parse_smb2_response_write(r.data) { - Ok((_, wr)) => { - SCLogDebug!("SMBv2: Write response => {:?}", wr); + Ok((_, _wr)) => { + SCLogDebug!("SMBv2: Write response => {:?}", _wr); /* search key-guid map */ let guid_key = SMBCommonHdr::new(SMBHDR_TYPE_GUID, r.session_id, r.tree_id, r.message_id); - let guid_vec = match state.ssn2vec_map.remove(&guid_key) { + let _guid_vec = match state.ssn2vec_map.remove(&guid_key) { Some(p) => p, None => { SCLogDebug!("SMBv2 response: GUID NOT FOUND"); Vec::new() }, }; - SCLogDebug!("SMBv2 write response for GUID {:?}", guid_vec); + SCLogDebug!("SMBv2 write response for GUID {:?}", _guid_vec); } _ => { events.push(SMBEvent::MalformedData); diff --git a/rust/src/smb/smb2_ioctl.rs b/rust/src/smb/smb2_ioctl.rs index 480e8696bd..93e5f381d2 100644 --- a/rust/src/smb/smb2_ioctl.rs +++ b/rust/src/smb/smb2_ioctl.rs @@ -15,7 +15,6 @@ * 02110-1301, USA. */ -use crate::log::*; use crate::smb::smb::*; use crate::smb::smb2::*; use crate::smb::smb2_records::*; diff --git a/rust/src/smb/smb2_session.rs b/rust/src/smb/smb2_session.rs index 91399a5dbc..356c89e4b5 100644 --- a/rust/src/smb/smb2_session.rs +++ b/rust/src/smb/smb2_session.rs @@ -15,8 +15,6 @@ * 02110-1301, USA. */ -use crate::log::*; - use crate::smb::smb2_records::*; use crate::smb::smb::*; //use smb::events::*; diff --git a/rust/src/smb/smb_records.rs b/rust/src/smb/smb_records.rs index 110d8eafeb..dac72e7ba8 100644 --- a/rust/src/smb/smb_records.rs +++ b/rust/src/smb/smb_records.rs @@ -17,7 +17,6 @@ use nom; use nom::{ErrorKind, IResult}; -use crate::log::*; /// parse a UTF16 string that is null terminated. Normally by 2 null /// bytes, but at the end of the data it can also be a single null. diff --git a/rust/src/snmp/snmp.rs b/rust/src/snmp/snmp.rs index 6ad91745d4..4a9fd8fa1f 100644 --- a/rust/src/snmp/snmp.rs +++ b/rust/src/snmp/snmp.rs @@ -26,8 +26,6 @@ use std; use std::ffi::{CStr,CString}; use std::mem::transmute; -use crate::log::*; - use der_parser::{DerObjectContent,parse_der_sequence}; use der_parser::oid::Oid; use nom; @@ -196,8 +194,8 @@ impl SNMPState { Ok((_rem,SnmpGenericMessage::V1(msg))) | Ok((_rem,SnmpGenericMessage::V2(msg))) => self.handle_snmp_v12(msg, direction), Ok((_rem,SnmpGenericMessage::V3(msg))) => self.handle_snmp_v3(msg, direction), - Err(e) => { - SCLogDebug!("parse_snmp failed: {:?}", e); + Err(_e) => { + SCLogDebug!("parse_snmp failed: {:?}", _e); self.set_event(SNMPEvent::MalformedData); -1 },