diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index ab12cda16fe2..48c86c9b7680 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -35,7 +35,7 @@ env: # A recent version of stable Rust that is known to pass build, test and other # verification steps in this workflow. This was added because using "stable" # could cause some steps to fail. - RUST_VERSION_KNOWN: "1.93.0" + RUST_VERSION_KNOWN: "1.98.0" jobs: diff --git a/rust/src/detect/byte_math.rs b/rust/src/detect/byte_math.rs index 735d0bdfa563..c7447330fbec 100644 --- a/rust/src/detect/byte_math.rs +++ b/rust/src/detect/byte_math.rs @@ -350,10 +350,8 @@ fn parse_bytemath(input: &str) -> IResult<&str, DetectByteMathData, RuleParseErr // Using left/right shift further restricts the value of nbytes. Note that // validation has already ensured nbytes is in [1..10] match byte_math.oper { - ByteMathOperator::LeftShift | ByteMathOperator::RightShift => { - if byte_math.nbytes > 4 { - return Err(make_error(format!("nbytes must be 1 through 4 (inclusive) when used with \"<<\" or \">>\"; {} is not valid", byte_math.nbytes))); - } + ByteMathOperator::LeftShift | ByteMathOperator::RightShift if byte_math.nbytes > 4 => { + return Err(make_error(format!("nbytes must be 1 through 4 (inclusive) when used with \"<<\" or \">>\"; {} is not valid", byte_math.nbytes))); } _ => {} }; diff --git a/rust/src/detect/requires.rs b/rust/src/detect/requires.rs index 4db997df6b42..5ad3dab8c489 100644 --- a/rust/src/detect/requires.rs +++ b/rust/src/detect/requires.rs @@ -408,7 +408,7 @@ pub unsafe extern "C" fn SCDetectRequiresStatusLog( "rule was" }, suricata_version, - &min_version + min_version ); parts.push(msg); } @@ -445,7 +445,7 @@ pub unsafe extern "C" fn SCDetectRequiresStatusLog( "rule was" }, if status.feature_count > 1 { "s" } else { "" }, - &features + features ); parts.push(msg); } diff --git a/rust/src/dhcp/logger.rs b/rust/src/dhcp/logger.rs index d2751bf427db..2ec3a7c5cf83 100644 --- a/rust/src/dhcp/logger.rs +++ b/rust/src/dhcp/logger.rs @@ -46,10 +46,8 @@ impl DHCPLogger { { #[allow(clippy::single_match)] match code { - DHCP_OPT_TYPE => { - if !option.data.is_empty() { - return Some(option.data[0]); - } + DHCP_OPT_TYPE if !option.data.is_empty() => { + return Some(option.data[0]); } _ => {} } @@ -156,10 +154,8 @@ impl DHCPLogger { self.log_opt_routers(js, option)?; } } - DHCP_OPT_VENDOR_CLASS_ID => { - if self.extended && !option.data.is_empty() { - js.set_string_from_bytes("vendor_class_identifier", &option.data)?; - } + DHCP_OPT_VENDOR_CLASS_ID if self.extended && !option.data.is_empty() => { + js.set_string_from_bytes("vendor_class_identifier", &option.data)?; } _ => {} }, diff --git a/rust/src/dhcp/parser.rs b/rust/src/dhcp/parser.rs index c5de4fd24afd..63e55d7cf380 100644 --- a/rust/src/dhcp/parser.rs +++ b/rust/src/dhcp/parser.rs @@ -234,7 +234,6 @@ pub fn parse_dhcp(input: &[u8]) -> IResult<&[u8], DHCPMessage> { #[cfg(test)] mod tests { - use crate::dhcp::dhcp::*; use crate::dhcp::parser::*; #[test] diff --git a/rust/src/http2/detect.rs b/rust/src/http2/detect.rs index 182fc7811fc6..7dd4e6dd4620 100644 --- a/rust/src/http2/detect.rs +++ b/rust/src/http2/detect.rs @@ -79,10 +79,8 @@ fn http2_tx_has_errorcode( return 1; } } - HTTP2FrameTypeData::RSTSTREAM(rst) => { - if rst.errorcode == code { - return 1; - } + HTTP2FrameTypeData::RSTSTREAM(rst) if rst.errorcode == code => { + return 1; } _ => {} } @@ -95,10 +93,8 @@ fn http2_tx_has_errorcode( return 1; } } - HTTP2FrameTypeData::RSTSTREAM(rst) => { - if rst.errorcode == code { - return 1; - } + HTTP2FrameTypeData::RSTSTREAM(rst) if rst.errorcode == code => { + return 1; } _ => {} } @@ -806,7 +802,7 @@ struct Http2ThreadBuf { #[no_mangle] pub unsafe extern "C" fn SCHttp2ThreadBufDataInit(_cfg: *mut c_void) -> *mut c_void { - let boxed = Box::new(Http2ThreadBuf::default()); + let boxed = Box::::default(); return Box::into_raw(boxed) as *mut c_void; } @@ -951,7 +947,7 @@ struct Http2ThreadMultiBuf { #[no_mangle] pub unsafe extern "C" fn SCHttp2ThreadMultiBufDataInit(_cfg: *mut c_void) -> *mut c_void { - let boxed = Box::new(Http2ThreadMultiBuf::default()); + let boxed = Box::::default(); return Box::into_raw(boxed) as *mut c_void; } diff --git a/rust/src/http2/logger.rs b/rust/src/http2/logger.rs index 2197d7a83e1e..8028e834d6dc 100644 --- a/rust/src/http2/logger.rs +++ b/rust/src/http2/logger.rs @@ -127,7 +127,7 @@ fn log_http2_frames(frames: &[HTTP2Frame], js: &mut JsonBuilder) -> Result { - if sa == "alg_dh" { - ret_val = e.0 as u32; - ret_code = 1; - break; - } + IkeV2Transform::DH(ref e) if sa == "alg_dh" => { + ret_val = e.0 as u32; + ret_code = 1; + break; } _ => (), } diff --git a/rust/src/jsonbuilder.rs b/rust/src/jsonbuilder.rs index b62ab18e3abd..cb4159c929f9 100644 --- a/rust/src/jsonbuilder.rs +++ b/rust/src/jsonbuilder.rs @@ -172,7 +172,7 @@ impl JsonBuilder { // Reset the builder to its initial state, without losing // the current capacity. pub fn reset(&mut self) { - self.buf.truncate(0); + self.buf.clear(); self.state.clear(); match self.init_type { Type::Array => { @@ -1618,6 +1618,4 @@ static ESCAPED: [u8; 256] = [ __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // F ]; -pub static HEX: [u8; 16] = [ - b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'a', b'b', b'c', b'd', b'e', b'f', -]; +pub static HEX: [u8; 16] = *b"0123456789abcdef"; diff --git a/rust/src/mime/mime.rs b/rust/src/mime/mime.rs index 852460efc33b..4935ab6a5e70 100644 --- a/rust/src/mime/mime.rs +++ b/rust/src/mime/mime.rs @@ -117,14 +117,10 @@ pub fn mime_find_header_token<'a>( // check for initial section of a parameter current_section_slice.extend_from_slice(token); current_section_slice.extend_from_slice(b"*0"); - match t.tokens.get(¤t_section_slice[..]) { - Some(value) => { - sections_values.extend_from_slice(value); - let l = current_section_slice.len(); - current_section_slice[l - 1] = b'1'; - } - None => return None, - } + let value = t.tokens.get(¤t_section_slice[..])?; + sections_values.extend_from_slice(value); + let l = current_section_slice.len(); + current_section_slice[l - 1] = b'1'; } } diff --git a/rust/src/nfs/nfs4.rs b/rust/src/nfs/nfs4.rs index 9e3b4f7b0944..0335725183af 100644 --- a/rust/src/nfs/nfs4.rs +++ b/rust/src/nfs/nfs4.rs @@ -380,11 +380,11 @@ impl NFSState { .put(rd.value.to_vec(), xidmap.file_name.to_vec()); } } - Nfs4ResponseContent::PutRootFH(s) => { - if s == NFS4_OK && xidmap.file_name.is_empty() { - xidmap.file_name = b"".to_vec(); - SCLogDebug!("filename {:?}", xidmap.file_name); - } + Nfs4ResponseContent::PutRootFH(s) + if s == NFS4_OK && xidmap.file_name.is_empty() => + { + xidmap.file_name = b"".to_vec(); + SCLogDebug!("filename {:?}", xidmap.file_name); } _ => {} } diff --git a/rust/src/sdp/parser.rs b/rust/src/sdp/parser.rs index 105bc51f6c28..f4656039c3d0 100644 --- a/rust/src/sdp/parser.rs +++ b/rust/src/sdp/parser.rs @@ -263,9 +263,9 @@ fn parse_connection_data(i: &[u8]) -> IResult<&[u8], String> { let mut connection_data = format!( "{} {} {}", - &nettype, - &addrtype, - &connection_address.to_string() + nettype, + addrtype, + connection_address ); if let Some(ttl) = ttl { connection_data = format!("{}/{}", connection_data, ttl); @@ -463,7 +463,7 @@ fn parse_media_description(i: &[u8]) -> IResult<&[u8], MediaDescription> { } else { format!("{}", port) }; - let mut media_str = format!("{} {} {}", &media, &port, &proto); + let mut media_str = format!("{} {} {}", media, port, proto); if !fmt.is_empty() { let fmt: Vec = fmt.into_iter().map(String::from).collect(); media_str = format!("{} {}", media_str, fmt.join(" ")); diff --git a/rust/src/ssh/parser.rs b/rust/src/ssh/parser.rs index 68784c32d8bc..d5e05545c245 100644 --- a/rust/src/ssh/parser.rs +++ b/rust/src/ssh/parser.rs @@ -164,7 +164,7 @@ pub struct SshPacketKeyExchange<'a> { pub reserved: u32, } -const SSH_HASSH_STRING_DELIMITER_SLICE: [u8; 1] = [b';']; +const SSH_HASSH_STRING_DELIMITER_SLICE: [u8; 1] = *b";"; impl SshPacketKeyExchange<'_> { pub fn generate_hassh( diff --git a/rust/suricatasc/src/unix/client.rs b/rust/suricatasc/src/unix/client.rs index 9ba55e309636..20a1c693fd8a 100644 --- a/rust/suricatasc/src/unix/client.rs +++ b/rust/suricatasc/src/unix/client.rs @@ -62,7 +62,7 @@ impl Client { { let mut encoded = serde_json::to_string(&msg)?; if self.verbose { - println!("SND: {}", &encoded); + println!("SND: {}", encoded); } encoded.push('\n'); self.socket.write_all(encoded.as_bytes())?; diff --git a/rust/suricatasc/src/unix/main.rs b/rust/suricatasc/src/unix/main.rs index 535ae8d116d2..bff39208b264 100644 --- a/rust/suricatasc/src/unix/main.rs +++ b/rust/suricatasc/src/unix/main.rs @@ -39,13 +39,13 @@ pub fn main() -> Result<(), Box> { let verbose = args.verbose; if verbose { - println!("Using Suricata command socket: {}", &socket_filename); + println!("Using Suricata command socket: {}", socket_filename); } let client = match Client::connect(&socket_filename, verbose) { Ok(client) => client, Err(err) => { - eprintln!("Unable to connect socket to {}: {}", &socket_filename, err); + eprintln!("Unable to connect socket to {}: {}", socket_filename, err); std::process::exit(1); } }; @@ -95,7 +95,7 @@ fn run_interactive(mut client: Client) -> Result<(), Box> break; } if let Err(err) = client.reconnect() { - println!("Error: {}", &err); + println!("Error: {}", err); break; } else { retry = true;