diff --git a/rust/src/nasl/builtin/http/mod.rs b/rust/src/nasl/builtin/http/mod.rs index bae5cee4d..e9224562f 100644 --- a/rust/src/nasl/builtin/http/mod.rs +++ b/rust/src/nasl/builtin/http/mod.rs @@ -199,10 +199,10 @@ impl NaslHttp { } /// Perform request with the given method. - async fn http2_req<'a>( + async fn http2_req( &self, register: &Register, - ctx: &Context<'a>, + ctx: &Context<'_>, method: Method, ) -> Result { let handle_id = match register.named("handle") { diff --git a/rust/src/nasl/builtin/raw_ip/packet_forgery.rs b/rust/src/nasl/builtin/raw_ip/packet_forgery.rs index 30c47036b..6419fc0d1 100644 --- a/rust/src/nasl/builtin/raw_ip/packet_forgery.rs +++ b/rust/src/nasl/builtin/raw_ip/packet_forgery.rs @@ -165,8 +165,8 @@ fn forge_ip_packet(register: &Register, configs: &Context) -> Result Result *x as u8, @@ -420,8 +420,8 @@ fn dump_ip_packet(register: &Register) -> Result { for ip in positional.iter() { match ip { NaslValue::Data(data) => { - let pkt = packet::ipv4::Ipv4Packet::new(data) - .ok_or_else(|| PacketForgeryError::CreatePacket)?; + let pkt = + packet::ipv4::Ipv4Packet::new(data).ok_or(PacketForgeryError::CreatePacket)?; println!("\tip_hl={}", pkt.get_header_length()); println!("\tip_v={}", pkt.get_version()); @@ -1685,6 +1685,12 @@ fn dump_icmp_packet(register: &Register) -> Result { } // IGMP +// +// Due to this line in libpnet, the #[packet] macro results in a clippy lint. +// The line just tries to allow another linting rule, so disabling the `unexpected_cfg` lint +// here should be reasonably safe. +// https://github.com/libpnet/libpnet/blob/a01aa493e2ecead4c45e7322b6c5f7ab29e8a985/pnet_macros/src/decorator.rs#L1138 +#[allow(unexpected_cfgs)] pub mod igmp { use std::net::Ipv4Addr; @@ -1821,7 +1827,7 @@ fn forge_igmp_packet(register: &Register, _configs: &Context) -> Result { @@ -1872,7 +1878,7 @@ fn nasl_tcp_ping(register: &Register, configs: &Context) -> Result Result { } } -impl<'a> Interpreter<'a> { +impl Interpreter<'_> { /// Assign a right value to a left value. Return either the /// previous or the new value, based on the order. pub async fn assign( diff --git a/rust/src/nasl/interpreter/call.rs b/rust/src/nasl/interpreter/call.rs index 959c5ed9e..edce6c5f2 100644 --- a/rust/src/nasl/interpreter/call.rs +++ b/rust/src/nasl/interpreter/call.rs @@ -17,7 +17,7 @@ use std::collections::HashMap; use super::InterpretErrorKind; -impl<'a> Interpreter<'a> { +impl Interpreter<'_> { pub async fn call( &mut self, statement: &Statement, diff --git a/rust/src/nasl/interpreter/interpreter.rs b/rust/src/nasl/interpreter/interpreter.rs index 0718c9c48..db5e7a4fa 100644 --- a/rust/src/nasl/interpreter/interpreter.rs +++ b/rust/src/nasl/interpreter/interpreter.rs @@ -137,10 +137,10 @@ impl<'a> Interpreter<'a> { Some(self) } - async fn execute_statements<'b>( + async fn execute_statements( &self, key: &str, - inter: &mut Interpreter<'b>, + inter: &mut Interpreter<'_>, stmt: Result, ) -> InterpretResult { match stmt { diff --git a/rust/src/nasl/interpreter/loop_extension.rs b/rust/src/nasl/interpreter/loop_extension.rs index 000072c11..861ad9b5d 100644 --- a/rust/src/nasl/interpreter/loop_extension.rs +++ b/rust/src/nasl/interpreter/loop_extension.rs @@ -12,7 +12,7 @@ use super::interpreter::InterpretResult; /// Note that for all loops, we do not /// change the context, as the current NASL also does not change it too. -impl<'a> Interpreter<'a> { +impl Interpreter<'_> { /// Interpreting a NASL for loop. A NASL for loop is built up with the /// following: /// diff --git a/rust/src/nasl/interpreter/operator.rs b/rust/src/nasl/interpreter/operator.rs index a6619da37..90403ba15 100644 --- a/rust/src/nasl/interpreter/operator.rs +++ b/rust/src/nasl/interpreter/operator.rs @@ -9,7 +9,7 @@ use crate::nasl::interpreter::{error::InterpretError, interpreter::InterpretResu use crate::nasl::syntax::NaslValue; -impl<'a> Interpreter<'a> { +impl Interpreter<'_> { async fn execute( &mut self, stmts: &[Statement], @@ -106,7 +106,7 @@ macro_rules! minus_left_right_data { }}; } -impl<'a> Interpreter<'a> { +impl Interpreter<'_> { /// Return the result of a NASL operator. pub async fn operator( &mut self, diff --git a/rust/src/notus/vts.rs b/rust/src/notus/vts.rs index 85cf01b6a..9b60572e3 100644 --- a/rust/src/notus/vts.rs +++ b/rust/src/notus/vts.rs @@ -125,10 +125,7 @@ where full_name, } => { // Parse package from full name - let package = match P::from_full_name(full_name) { - Some(pkg) => pkg, - None => return None, - }; + let package = P::from_full_name(full_name)?; // Create Vulnerability Test Entry Some(( package.get_name(), @@ -147,10 +144,7 @@ where name, } => { // Parse package from name and full version - let package = match P::from_name_and_full_version(name, full_version) { - Some(pkg) => pkg, - None => return None, - }; + let package = P::from_name_and_full_version(name, full_version)?; // Create Vulnerability Test Entry Some(( package.get_name(), @@ -165,14 +159,8 @@ where } FixedPackage::ByRange { range, name } => { // Parse both packages from name and full version - let start = match P::from_name_and_full_version(name, &range.start) { - Some(pkg) => pkg, - None => return None, - }; - let end = match P::from_name_and_full_version(name, &range.end) { - Some(pkg) => pkg, - None => return None, - }; + let start = P::from_name_and_full_version(name, &range.start)?; + let end = P::from_name_and_full_version(name, &range.end)?; // Create Vulnerability Test Entry Some(( start.get_name(), diff --git a/rust/src/openvasd/controller/mod.rs b/rust/src/openvasd/controller/mod.rs index a51d6286f..23066bbda 100644 --- a/rust/src/openvasd/controller/mod.rs +++ b/rust/src/openvasd/controller/mod.rs @@ -58,7 +58,7 @@ fn retrieve_and_reset(id: Arc>) -> ClientIdentifier { cci } -pub async fn run<'a, S, DB>( +pub async fn run( mut ctx: Context, config: &config::Config, ) -> Result<(), Box> diff --git a/rust/src/openvasd/response.rs b/rust/src/openvasd/response.rs index 26691be55..59c89f73e 100644 --- a/rust/src/openvasd/response.rs +++ b/rust/src/openvasd/response.rs @@ -220,7 +220,7 @@ impl Response { return; }; } - if value.map(|v| send(SendState::Bytes(false, v))).any(|x| x) { + if value.any(|v| send(SendState::Bytes(false, v))) { return; } diff --git a/rust/src/scanner/running_scan.rs b/rust/src/scanner/running_scan.rs index 3f66de6b3..b415a7f21 100644 --- a/rust/src/scanner/running_scan.rs +++ b/rust/src/scanner/running_scan.rs @@ -113,7 +113,7 @@ impl RunningScan { .map_err(make_scheduling_error) } - async fn run_to_completion<'a>(&self, runner: ScanRunner<'a, S>) -> Phase { + async fn run_to_completion(&self, runner: ScanRunner<'_, S>) -> Phase { let mut end_phase = Phase::Succeeded; let mut stream = Box::pin(runner.stream()); while let Some(it) = stream.next().await { diff --git a/rust/src/scannerctl/osp/start_scan.rs b/rust/src/scannerctl/osp/start_scan.rs index c91425006..fb32e2264 100644 --- a/rust/src/scannerctl/osp/start_scan.rs +++ b/rust/src/scannerctl/osp/start_scan.rs @@ -25,9 +25,10 @@ pub struct Target { pub credentials: Option, } -impl Into> for Credentials { - fn into(self) -> Vec { - self.credential +impl From for Vec { + fn from(other: Credentials) -> Self { + other + .credential .into_iter() .flatten() .map(|x| { diff --git a/rust/src/scheduling/mod.rs b/rust/src/scheduling/mod.rs index 10973c1f9..c42d08980 100644 --- a/rust/src/scheduling/mod.rs +++ b/rust/src/scheduling/mod.rs @@ -116,9 +116,9 @@ pub trait ExecutionPlaner { /// /// If the second value (parameter) is None it indicates that this script in indirectly loaded /// and was not explicitly mentioned in the Scan. - fn execution_plan<'a, E>( + fn execution_plan( &self, - ids: &'a Scan, + ids: &Scan, ) -> Result, VTError> where E: ExecutionPlan; @@ -208,9 +208,9 @@ impl ExecutionPlaner for T where T: Retriever + ?Sized, { - fn execution_plan<'a, E>( + fn execution_plan( &self, - scan: &'a Scan, + scan: &Scan, ) -> Result, VTError> where E: ExecutionPlan,