diff --git a/fuzzers/baby/baby_fuzzer/src/main.rs b/fuzzers/baby/baby_fuzzer/src/main.rs index c98b028026..19d20a655f 100644 --- a/fuzzers/baby/baby_fuzzer/src/main.rs +++ b/fuzzers/baby/baby_fuzzer/src/main.rs @@ -24,6 +24,8 @@ use libafl_bolts::{current_nanos, nonzero, rands::StdRand, tuples::tuple_list, A /// Coverage map with explicit assignments due to the lack of instrumentation static mut SIGNALS: [u8; 16] = [0; 16]; +// TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 +#[allow(static_mut_refs)] // only a problem in nightly static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() }; /// Assign a signal to the signals map @@ -31,7 +33,7 @@ fn signals_set(idx: usize) { unsafe { write(SIGNALS_PTR.add(idx), 1) }; } -#[allow(clippy::similar_names, clippy::manual_assert)] +#[expect(clippy::manual_assert)] pub fn main() { // The closure that we want to fuzz let mut harness = |input: &BytesInput| { @@ -61,6 +63,8 @@ pub fn main() { }; // Create an observation channel using the signals map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem in nightly let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) }; // Feedback to rate the interestingness of an input diff --git a/fuzzers/baby/baby_fuzzer_custom_executor/src/main.rs b/fuzzers/baby/baby_fuzzer_custom_executor/src/main.rs index f9c0b2e9ee..059aa6ef14 100644 --- a/fuzzers/baby/baby_fuzzer_custom_executor/src/main.rs +++ b/fuzzers/baby/baby_fuzzer_custom_executor/src/main.rs @@ -26,7 +26,9 @@ use libafl_bolts::{current_nanos, nonzero, rands::StdRand, tuples::tuple_list, A /// Coverage map with explicit assignments due to the lack of instrumentation static mut SIGNALS: [u8; 16] = [0; 16]; static mut SIGNALS_PTR: *mut u8 = &raw mut SIGNALS as _; -static SIGNALS_LEN: usize = unsafe { (*&raw const (SIGNALS)).len() }; +// TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 +#[allow(static_mut_refs)] // only a problem in nightly +static SIGNALS_LEN: usize = unsafe { SIGNALS.len() }; /// Assign a signal to the signals map fn signals_set(idx: usize) { @@ -81,7 +83,6 @@ where } } -#[allow(clippy::similar_names, clippy::manual_assert)] pub fn main() { // Create an observation channel using the signals map let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS_LEN) }; diff --git a/fuzzers/baby/baby_fuzzer_minimizing/src/main.rs b/fuzzers/baby/baby_fuzzer_minimizing/src/main.rs index a61f3bf682..79524c2ecb 100644 --- a/fuzzers/baby/baby_fuzzer_minimizing/src/main.rs +++ b/fuzzers/baby/baby_fuzzer_minimizing/src/main.rs @@ -7,6 +7,8 @@ use libafl_bolts::prelude::*; /// Coverage map with explicit assignments due to the lack of instrumentation static mut SIGNALS: [u8; 16] = [0; 16]; +// TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 +#[allow(static_mut_refs)] // only a problem in nightly static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() }; /// Assign a signal to the signals map @@ -14,7 +16,6 @@ fn signals_set(idx: usize) { unsafe { write(SIGNALS_PTR.add(idx), 1) }; } -#[allow(clippy::similar_names)] pub fn main() -> Result<(), Error> { // The closure that we want to fuzz let mut harness = |input: &BytesInput| { @@ -34,6 +35,8 @@ pub fn main() -> Result<(), Error> { }; // Create an observation channel using the signals map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem in nightly let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) }; let factory = MapEqualityFactory::new(&observer); diff --git a/fuzzers/baby/baby_fuzzer_swap_differential/src/main.rs b/fuzzers/baby/baby_fuzzer_swap_differential/src/main.rs index 582e1cd56c..dab3133063 100644 --- a/fuzzers/baby/baby_fuzzer_swap_differential/src/main.rs +++ b/fuzzers/baby/baby_fuzzer_swap_differential/src/main.rs @@ -61,8 +61,7 @@ mod slicemap { #[cfg(not(feature = "multimap"))] use slicemap::{HitcountsMapObserver, EDGES}; -#[allow(clippy::similar_names)] -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] pub fn main() { // The closure that we want to fuzz let mut first_harness = |input: &BytesInput| { @@ -144,6 +143,8 @@ pub fn main() { EDGES = core::slice::from_raw_parts_mut(alloc_zeroed(layout), num_edges * 2); } + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem on nightly let edges_ptr = unsafe { EDGES.as_mut_ptr() }; // create the base maps used to observe the different executors by splitting a slice diff --git a/fuzzers/baby/baby_fuzzer_unicode/src/main.rs b/fuzzers/baby/baby_fuzzer_unicode/src/main.rs index 77d5772b9d..fb9dfedfd8 100644 --- a/fuzzers/baby/baby_fuzzer_unicode/src/main.rs +++ b/fuzzers/baby/baby_fuzzer_unicode/src/main.rs @@ -25,14 +25,16 @@ use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice}; /// Coverage map with explicit assignments due to the lack of instrumentation static mut SIGNALS: [u8; 64] = [0; 64]; static mut SIGNALS_PTR: *mut u8 = (&raw mut SIGNALS).cast(); -static mut SIGNALS_LEN: usize = unsafe { (*&raw const SIGNALS).len() }; +// TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 +#[allow(static_mut_refs)] // only a problem in nightly +static mut SIGNALS_LEN: usize = unsafe { SIGNALS.len() }; /// Assign a signal to the signals map fn signals_set(idx: usize) { unsafe { write(SIGNALS_PTR.add(idx), 1) }; } -#[allow(clippy::similar_names, clippy::manual_assert)] +#[expect(clippy::manual_assert)] pub fn main() { // The closure that we want to fuzz let mut harness = |input: &BytesInput| { diff --git a/fuzzers/baby/backtrace_baby_fuzzers/c_code_with_fork_executor/src/main.rs b/fuzzers/baby/backtrace_baby_fuzzers/c_code_with_fork_executor/src/main.rs index 694aea946f..614dfba892 100644 --- a/fuzzers/baby/backtrace_baby_fuzzers/c_code_with_fork_executor/src/main.rs +++ b/fuzzers/baby/backtrace_baby_fuzzers/c_code_with_fork_executor/src/main.rs @@ -34,7 +34,6 @@ extern "C" { } -#[allow(clippy::similar_names)] pub fn main() { let mut shmem_provider = StdShMemProvider::new().unwrap(); unsafe { create_shmem_array() }; diff --git a/fuzzers/baby/backtrace_baby_fuzzers/c_code_with_inprocess_executor/src/main.rs b/fuzzers/baby/backtrace_baby_fuzzers/c_code_with_inprocess_executor/src/main.rs index 88dece4d3e..43c3342286 100644 --- a/fuzzers/baby/backtrace_baby_fuzzers/c_code_with_inprocess_executor/src/main.rs +++ b/fuzzers/baby/backtrace_baby_fuzzers/c_code_with_inprocess_executor/src/main.rs @@ -26,7 +26,6 @@ extern "C" { } -#[allow(clippy::similar_names)] pub fn main() { let mut harness = |input: &BytesInput| { let target = input.target_bytes(); diff --git a/fuzzers/baby/backtrace_baby_fuzzers/command_executor/build.rs b/fuzzers/baby/backtrace_baby_fuzzers/command_executor/build.rs index 6fc42bbab3..7e6445d46c 100644 --- a/fuzzers/baby/backtrace_baby_fuzzers/command_executor/build.rs +++ b/fuzzers/baby/backtrace_baby_fuzzers/command_executor/build.rs @@ -2,9 +2,10 @@ use std::env; fn main() { let cwd = env::current_dir().unwrap().to_string_lossy().to_string(); - let mut cmd = cc::Build::new().get_compiler().to_command(); - cmd.args(["src/test_command.c", "-o"]) - .arg(&format!("{}/test_command", &cwd)) + let mut command = cc::Build::new().get_compiler().to_command(); + command + .args(["src/test_command.c", "-o"]) + .arg(format!("{}/test_command", &cwd)) .arg("-fsanitize=address") .status() .unwrap(); diff --git a/fuzzers/baby/backtrace_baby_fuzzers/command_executor/src/main.rs b/fuzzers/baby/backtrace_baby_fuzzers/command_executor/src/main.rs index 841115bd30..c239dafa2c 100644 --- a/fuzzers/baby/backtrace_baby_fuzzers/command_executor/src/main.rs +++ b/fuzzers/baby/backtrace_baby_fuzzers/command_executor/src/main.rs @@ -32,7 +32,6 @@ use libafl_bolts::{ AsSlice, AsSliceMut, }; -#[allow(clippy::similar_names)] pub fn main() { let mut shmem_provider = unix_shmem::UnixShMemProvider::new().unwrap(); let mut signals = shmem_provider.new_shmem(3).unwrap(); @@ -81,6 +80,7 @@ pub fn main() { let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective); // Create the executor for an in-process function with just one observer + #[expect(clippy::items_after_statements)] #[derive(Debug)] struct MyExecutor { shmem_id: ShMemId, @@ -88,6 +88,8 @@ pub fn main() { } impl CommandConfigurator for MyExecutor { + #[allow(unknown_lints)] // stable doesn't even know of the lint + #[allow(clippy::zombie_processes)] // only a problem on nightly fn spawn_child(&mut self, input: &BytesInput) -> Result { let mut command = Command::new("./test_command"); diff --git a/fuzzers/baby/backtrace_baby_fuzzers/forkserver_executor/build.rs b/fuzzers/baby/backtrace_baby_fuzzers/forkserver_executor/build.rs index d894c1097a..8694d70b12 100644 --- a/fuzzers/baby/backtrace_baby_fuzzers/forkserver_executor/build.rs +++ b/fuzzers/baby/backtrace_baby_fuzzers/forkserver_executor/build.rs @@ -40,7 +40,7 @@ fn main() { Command::new(afl_gcc_path) .args(["src/program.c", "-o"]) - .arg(&format!("{}/target/release/program", &cwd)) + .arg(format!("{}/target/release/program", &cwd)) .arg("-fsanitize=address") .status() .unwrap(); diff --git a/fuzzers/baby/backtrace_baby_fuzzers/forkserver_executor/src/main.rs b/fuzzers/baby/backtrace_baby_fuzzers/forkserver_executor/src/main.rs index 220f822643..600056c412 100644 --- a/fuzzers/baby/backtrace_baby_fuzzers/forkserver_executor/src/main.rs +++ b/fuzzers/baby/backtrace_baby_fuzzers/forkserver_executor/src/main.rs @@ -28,7 +28,6 @@ use libafl_bolts::{ AsSliceMut, }; -#[allow(clippy::similar_names)] pub fn main() { const MAP_SIZE: usize = 65536; diff --git a/fuzzers/baby/backtrace_baby_fuzzers/rust_code_with_fork_executor/src/main.rs b/fuzzers/baby/backtrace_baby_fuzzers/rust_code_with_fork_executor/src/main.rs index 88c6422598..9260055090 100644 --- a/fuzzers/baby/backtrace_baby_fuzzers/rust_code_with_fork_executor/src/main.rs +++ b/fuzzers/baby/backtrace_baby_fuzzers/rust_code_with_fork_executor/src/main.rs @@ -22,12 +22,11 @@ use libafl_bolts::{ nonzero, ownedref::OwnedRefMut, rands::StdRand, - shmem::{unix_shmem, ShMem, ShMemProvider}, + shmem::{unix_shmem, ShMemProvider}, tuples::tuple_list, AsSlice, AsSliceMut, }; -#[allow(clippy::similar_names)] pub fn main() { let mut shmem_provider = unix_shmem::UnixShMemProvider::new().unwrap(); let mut signals = shmem_provider.new_shmem(16).unwrap(); @@ -66,6 +65,7 @@ pub fn main() { }; // Create an observation channel using the signals map + let observer = unsafe { StdMapObserver::from_mut_ptr("signals", signals_ptr, signals_len) }; // Create a stacktrace observer let bt_observer = BacktraceObserver::new( diff --git a/fuzzers/baby/backtrace_baby_fuzzers/rust_code_with_inprocess_executor/src/main.rs b/fuzzers/baby/backtrace_baby_fuzzers/rust_code_with_inprocess_executor/src/main.rs index 79578e729c..461a77d0ec 100644 --- a/fuzzers/baby/backtrace_baby_fuzzers/rust_code_with_inprocess_executor/src/main.rs +++ b/fuzzers/baby/backtrace_baby_fuzzers/rust_code_with_inprocess_executor/src/main.rs @@ -22,6 +22,8 @@ use libafl_bolts::{nonzero, rands::StdRand, tuples::tuple_list, AsSlice}; /// Coverage map with explicit assignments due to the lack of instrumentation static mut SIGNALS: [u8; 16] = [0; 16]; +// TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 +#[allow(static_mut_refs)] // only a problem in nightly static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() }; /// Assign a signal to the signals map @@ -29,7 +31,6 @@ fn signals_set(idx: usize) { unsafe { write(SIGNALS_PTR.add(idx), 1) }; } -#[allow(clippy::similar_names)] pub fn main() { // The closure that we want to fuzz let mut harness = |input: &BytesInput| { @@ -59,6 +60,8 @@ pub fn main() { }; // Create an observation channel using the signals map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem in nightly let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) }; // Create a stacktrace observer to add the observers tuple let bt_observer = BacktraceObserver::owned( diff --git a/fuzzers/baby/tutorial/src/input.rs b/fuzzers/baby/tutorial/src/input.rs index 4c84e69026..f21eaa4199 100644 --- a/fuzzers/baby/tutorial/src/input.rs +++ b/fuzzers/baby/tutorial/src/input.rs @@ -1,3 +1,4 @@ +#![expect(unexpected_cfgs)] // deriving NewFuzzed etc. introduces these use std::hash::Hash; use lain::prelude::*; diff --git a/fuzzers/binary_only/frida_executable_libpng/src/fuzzer.rs b/fuzzers/binary_only/frida_executable_libpng/src/fuzzer.rs index 623e121a73..65493e720f 100644 --- a/fuzzers/binary_only/frida_executable_libpng/src/fuzzer.rs +++ b/fuzzers/binary_only/frida_executable_libpng/src/fuzzer.rs @@ -85,7 +85,7 @@ pub unsafe fn lib(main: extern "C" fn(i32, *const *const u8, *const *const u8) - } /// The actual fuzzer -#[allow(clippy::too_many_lines, clippy::too_many_arguments)] +#[expect(clippy::too_many_lines)] unsafe fn fuzz( options: &FuzzerOptions, mut frida_harness: &dyn Fn(&BytesInput) -> ExitKind, diff --git a/fuzzers/binary_only/frida_executable_libpng/src/lib.rs b/fuzzers/binary_only/frida_executable_libpng/src/lib.rs index da9fdeae51..1f72a04071 100644 --- a/fuzzers/binary_only/frida_executable_libpng/src/lib.rs +++ b/fuzzers/binary_only/frida_executable_libpng/src/lib.rs @@ -34,7 +34,6 @@ pub unsafe extern "C" fn main_hook( } #[no_mangle] -#[allow(clippy::similar_names)] pub unsafe extern "C" fn __libc_start_main( main: extern "C" fn(i32, *const *const u8, *const *const u8) -> i32, argc: i32, diff --git a/fuzzers/binary_only/frida_libpng/src/fuzzer.rs b/fuzzers/binary_only/frida_libpng/src/fuzzer.rs index 31973d11fc..6f49f06a72 100644 --- a/fuzzers/binary_only/frida_libpng/src/fuzzer.rs +++ b/fuzzers/binary_only/frida_libpng/src/fuzzer.rs @@ -66,7 +66,7 @@ pub fn main() { } /// The actual fuzzer -#[allow(clippy::too_many_lines, clippy::too_many_arguments)] +#[expect(clippy::too_many_lines)] unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> { log::info!("Frida fuzzer starting up."); diff --git a/fuzzers/binary_only/frida_windows_gdiplus/src/fuzzer.rs b/fuzzers/binary_only/frida_windows_gdiplus/src/fuzzer.rs index c33fca2f81..41afe956b5 100644 --- a/fuzzers/binary_only/frida_windows_gdiplus/src/fuzzer.rs +++ b/fuzzers/binary_only/frida_windows_gdiplus/src/fuzzer.rs @@ -77,7 +77,7 @@ pub fn main() { } /// The actual fuzzer -#[allow(clippy::too_many_lines, clippy::too_many_arguments)] +#[expect(clippy::too_many_lines)] unsafe fn fuzz(options: &FuzzerOptions) -> Result<(), Error> { // 'While the stats are state, they are usually used in the broker - which is likely never restarted let monitor = MultiMonitor::new(|s| println!("{s}")); diff --git a/fuzzers/binary_only/fuzzbench_fork_qemu/src/fuzzer.rs b/fuzzers/binary_only/fuzzbench_fork_qemu/src/fuzzer.rs index bce4a5c3cc..19e2ca5b54 100644 --- a/fuzzers/binary_only/fuzzbench_fork_qemu/src/fuzzer.rs +++ b/fuzzers/binary_only/fuzzbench_fork_qemu/src/fuzzer.rs @@ -243,7 +243,7 @@ fn fuzz( let cmplog = cmp_shmem.as_slice_mut(); // Beginning of a page should be properly aligned. - #[allow(clippy::cast_ptr_alignment)] + #[expect(clippy::cast_ptr_alignment)] let cmplog_map_ptr = cmplog .as_mut_ptr() .cast::(); diff --git a/fuzzers/binary_only/intel_pt_baby_fuzzer/src/main.rs b/fuzzers/binary_only/intel_pt_baby_fuzzer/src/main.rs index cc84cfce2f..eaae1771c5 100644 --- a/fuzzers/binary_only/intel_pt_baby_fuzzer/src/main.rs +++ b/fuzzers/binary_only/intel_pt_baby_fuzzer/src/main.rs @@ -28,7 +28,8 @@ use proc_maps::get_process_maps; // Coverage map const MAP_SIZE: usize = 4096; static mut MAP: [u8; MAP_SIZE] = [0; MAP_SIZE]; -#[allow(static_mut_refs)] +// TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 +#[allow(static_mut_refs)] // only a problem in nightly static mut MAP_PTR: *mut u8 = unsafe { MAP.as_mut_ptr() }; pub fn main() { diff --git a/fuzzers/binary_only/intel_pt_command_executor/src/main.rs b/fuzzers/binary_only/intel_pt_command_executor/src/main.rs index 8ef4c606ef..b8b110ca14 100644 --- a/fuzzers/binary_only/intel_pt_command_executor/src/main.rs +++ b/fuzzers/binary_only/intel_pt_command_executor/src/main.rs @@ -25,7 +25,8 @@ use libafl_intelpt::{IntelPT, PAGE_SIZE}; // Coverage map const MAP_SIZE: usize = 4096; static mut MAP: [u8; MAP_SIZE] = [0; MAP_SIZE]; -#[allow(static_mut_refs)] +// TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 +#[allow(static_mut_refs)] // only a problem in nightly static mut MAP_PTR: *mut u8 = unsafe { MAP.as_mut_ptr() }; pub fn main() { diff --git a/fuzzers/binary_only/qemu_cmin/src/fuzzer.rs b/fuzzers/binary_only/qemu_cmin/src/fuzzer.rs index ba00041efd..bb6715fd6c 100644 --- a/fuzzers/binary_only/qemu_cmin/src/fuzzer.rs +++ b/fuzzers/binary_only/qemu_cmin/src/fuzzer.rs @@ -172,7 +172,6 @@ pub fn fuzz() -> Result<(), Error> { let mut feedback = MaxMapFeedback::new(&edges_observer); - #[allow(clippy::let_unit_value)] let mut objective = (); let mut state = state.unwrap_or_else(|| { diff --git a/fuzzers/binary_only/qemu_coverage/src/fuzzer.rs b/fuzzers/binary_only/qemu_coverage/src/fuzzer.rs index 45f80b0f47..d5826a4fa4 100644 --- a/fuzzers/binary_only/qemu_coverage/src/fuzzer.rs +++ b/fuzzers/binary_only/qemu_coverage/src/fuzzer.rs @@ -214,10 +214,8 @@ pub fn fuzz() { Err(Error::ShuttingDown)? } - #[allow(clippy::let_unit_value)] let mut feedback = (); - #[allow(clippy::let_unit_value)] let mut objective = (); let mut state = state.unwrap_or_else(|| { diff --git a/fuzzers/binary_only/qemu_launcher/src/client.rs b/fuzzers/binary_only/qemu_launcher/src/client.rs index cf399682c2..1016788ae6 100644 --- a/fuzzers/binary_only/qemu_launcher/src/client.rs +++ b/fuzzers/binary_only/qemu_launcher/src/client.rs @@ -27,7 +27,7 @@ use crate::{ options::FuzzerOptions, }; -#[allow(clippy::module_name_repetitions)] +#[expect(clippy::module_name_repetitions)] pub type ClientState = StdState, StdRand, OnDiskCorpus>; @@ -50,14 +50,14 @@ impl Client<'_> { Ok(args) } - #[allow(clippy::unused_self)] // Api should look the same as args above + #[expect(clippy::unused_self)] // Api should look the same as args above pub fn env(&self) -> Vec<(String, String)> { env::vars() .filter(|(k, _v)| k != "LD_LIBRARY_PATH") .collect::>() } - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] pub fn run( &self, state: Option, diff --git a/fuzzers/binary_only/qemu_launcher/src/harness.rs b/fuzzers/binary_only/qemu_launcher/src/harness.rs index 6376348d0c..2a26620235 100644 --- a/fuzzers/binary_only/qemu_launcher/src/harness.rs +++ b/fuzzers/binary_only/qemu_launcher/src/harness.rs @@ -21,12 +21,12 @@ pub const MAX_INPUT_SIZE: usize = 1_048_576; // 1MB impl Harness { /// Change environment #[inline] - #[allow(clippy::ptr_arg)] + #[expect(clippy::ptr_arg)] pub fn edit_env(_env: &mut Vec<(String, String)>) {} /// Change arguments #[inline] - #[allow(clippy::ptr_arg)] + #[expect(clippy::ptr_arg)] pub fn edit_args(_args: &mut Vec) {} /// Helper function to find the function we want to fuzz. @@ -80,7 +80,7 @@ impl Harness { /// If we need to do extra work after forking, we can do that here. #[inline] - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] pub fn post_fork(&self) {} pub fn run(&self, input: &BytesInput) -> ExitKind { diff --git a/fuzzers/binary_only/qemu_launcher/src/instance.rs b/fuzzers/binary_only/qemu_launcher/src/instance.rs index 317d21a36f..0bcebdbb96 100644 --- a/fuzzers/binary_only/qemu_launcher/src/instance.rs +++ b/fuzzers/binary_only/qemu_launcher/src/instance.rs @@ -73,7 +73,6 @@ pub struct Instance<'a, M: Monitor> { } impl Instance<'_, M> { - #[allow(clippy::similar_names)] // elf != self fn coverage_filter(&self, qemu: Qemu) -> Result { /* Conversion is required on 32-bit targets, but not on 64-bit ones */ if let Some(includes) = &self.options.include { @@ -106,7 +105,7 @@ impl Instance<'_, M> { } } - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] pub fn run(&mut self, modules: ET, state: Option) -> Result<(), Error> where ET: EmulatorModuleTuple + Debug, diff --git a/fuzzers/binary_only/qemu_launcher/src/options.rs b/fuzzers/binary_only/qemu_launcher/src/options.rs index 2465196e31..ea6823ac3e 100644 --- a/fuzzers/binary_only/qemu_launcher/src/options.rs +++ b/fuzzers/binary_only/qemu_launcher/src/options.rs @@ -11,7 +11,6 @@ use crate::version::Version; #[readonly::make] #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] -#[allow(clippy::module_name_repetitions)] #[command( name = format!("qemu_coverage-{}",env!("CPU_TARGET")), version = Version::default(), diff --git a/fuzzers/forkserver/baby_fuzzer_with_forkexecutor/src/main.rs b/fuzzers/forkserver/baby_fuzzer_with_forkexecutor/src/main.rs index ca36d11c97..1a84e91cc5 100644 --- a/fuzzers/forkserver/baby_fuzzer_with_forkexecutor/src/main.rs +++ b/fuzzers/forkserver/baby_fuzzer_with_forkexecutor/src/main.rs @@ -25,10 +25,10 @@ use libafl_bolts::{ AsSlice, AsSliceMut, }; -#[allow(clippy::similar_names)] pub fn main() { let mut shmem_provider = unix_shmem::UnixShMemProvider::new().unwrap(); let mut signals = shmem_provider.new_shmem(16).unwrap(); + let signals_len = signals.as_slice().len(); let signals_ptr = signals.as_slice_mut().as_mut_ptr(); @@ -64,6 +64,7 @@ pub fn main() { }; // Create an observation channel using the signals map + let observer = unsafe { StdMapObserver::from_mut_ptr("signals", signals_ptr, signals_len) }; // Create a stacktrace observer to add the observers tuple diff --git a/fuzzers/forkserver/forkserver_libafl_cc/src/main.rs b/fuzzers/forkserver/forkserver_libafl_cc/src/main.rs index 34f97f5b28..6d5f7f3998 100644 --- a/fuzzers/forkserver/forkserver_libafl_cc/src/main.rs +++ b/fuzzers/forkserver/forkserver_libafl_cc/src/main.rs @@ -83,7 +83,6 @@ struct Opt { signal: Signal, } -#[allow(clippy::similar_names)] pub fn main() { env_logger::init(); diff --git a/fuzzers/forkserver/forkserver_simple/src/main.rs b/fuzzers/forkserver/forkserver_simple/src/main.rs index c026197738..c08b44084b 100644 --- a/fuzzers/forkserver/forkserver_simple/src/main.rs +++ b/fuzzers/forkserver/forkserver_simple/src/main.rs @@ -83,7 +83,6 @@ struct Opt { signal: Signal, } -#[allow(clippy::similar_names)] pub fn main() { env_logger::init(); const MAP_SIZE: usize = 65536; diff --git a/fuzzers/forkserver/fuzzbench_forkserver/src/main.rs b/fuzzers/forkserver/fuzzbench_forkserver/src/main.rs index 9bead73df2..f47334b429 100644 --- a/fuzzers/forkserver/fuzzbench_forkserver/src/main.rs +++ b/fuzzers/forkserver/fuzzbench_forkserver/src/main.rs @@ -205,7 +205,7 @@ pub fn main() { } /// The actual fuzzer -#[allow(clippy::too_many_arguments)] +#[expect(clippy::too_many_arguments)] fn fuzz( corpus_dir: PathBuf, objective_dir: PathBuf, diff --git a/fuzzers/forkserver/fuzzbench_forkserver_cmplog/src/main.rs b/fuzzers/forkserver/fuzzbench_forkserver_cmplog/src/main.rs index 4480972337..cd63d37f00 100644 --- a/fuzzers/forkserver/fuzzbench_forkserver_cmplog/src/main.rs +++ b/fuzzers/forkserver/fuzzbench_forkserver_cmplog/src/main.rs @@ -207,7 +207,7 @@ pub fn main() { } /// The actual fuzzer -#[allow(clippy::too_many_arguments)] +#[expect(clippy::too_many_arguments)] fn fuzz( corpus_dir: PathBuf, objective_dir: PathBuf, diff --git a/fuzzers/forkserver/libafl-fuzz/src/corpus.rs b/fuzzers/forkserver/libafl-fuzz/src/corpus.rs index ccf7d7ba88..a69efdb702 100644 --- a/fuzzers/forkserver/libafl-fuzz/src/corpus.rs +++ b/fuzzers/forkserver/libafl-fuzz/src/corpus.rs @@ -41,7 +41,7 @@ pub fn generate_base_filename(state: &mut LibaflFuzzState, id: CorpusId) -> Stri } // The function needs to be compatible with CustomFilepathToTestcaseFeedback -#[allow(clippy::unnecessary_wraps)] +#[expect(clippy::unnecessary_wraps)] pub fn set_corpus_filepath( state: &mut LibaflFuzzState, testcase: &mut Testcase, @@ -58,7 +58,7 @@ pub fn set_corpus_filepath( } // The function needs to be compatible with CustomFilepathToTestcaseFeedback -#[allow(clippy::unnecessary_wraps)] +#[expect(clippy::unnecessary_wraps)] pub fn set_solution_filepath( state: &mut LibaflFuzzState, testcase: &mut Testcase, diff --git a/fuzzers/forkserver/libafl-fuzz/src/executor.rs b/fuzzers/forkserver/libafl-fuzz/src/executor.rs index 06082e8a73..aa60fe982d 100644 --- a/fuzzers/forkserver/libafl-fuzz/src/executor.rs +++ b/fuzzers/forkserver/libafl-fuzz/src/executor.rs @@ -201,7 +201,7 @@ pub fn find_afl_binary(filename: &str, same_dir_as: Option) -> Result

::Input>, &Path) -> Result<(), Error>, { - #[allow(clippy::wrong_self_convention)] #[inline] fn is_interesting( &mut self, diff --git a/fuzzers/forkserver/libafl-fuzz/src/feedback/persistent_record.rs b/fuzzers/forkserver/libafl-fuzz/src/feedback/persistent_record.rs index c8db9e440c..ba1dda32a1 100644 --- a/fuzzers/forkserver/libafl-fuzz/src/feedback/persistent_record.rs +++ b/fuzzers/forkserver/libafl-fuzz/src/feedback/persistent_record.rs @@ -56,7 +56,6 @@ where S::Corpus: Corpus, I: Input, { - #[allow(clippy::wrong_self_convention)] #[inline] fn is_interesting( &mut self, diff --git a/fuzzers/forkserver/libafl-fuzz/src/feedback/seed.rs b/fuzzers/forkserver/libafl-fuzz/src/feedback/seed.rs index f1eb674feb..9f18cb5665 100644 --- a/fuzzers/forkserver/libafl-fuzz/src/feedback/seed.rs +++ b/fuzzers/forkserver/libafl-fuzz/src/feedback/seed.rs @@ -13,7 +13,7 @@ use crate::Opt; /// A wrapper feedback used to determine actions for initial seeds. /// Handles `AFL_EXIT_ON_SEED_ISSUES`, `AFL_IGNORE_SEED_ISSUES` & default afl-fuzz behavior /// then, essentially becomes benign -#[allow(clippy::module_name_repetitions, clippy::struct_excessive_bools)] +#[expect(clippy::module_name_repetitions, clippy::struct_excessive_bools)] #[derive(Debug)] pub struct SeedFeedback { /// Inner [`Feedback`] diff --git a/fuzzers/forkserver/libafl-fuzz/src/main.rs b/fuzzers/forkserver/libafl-fuzz/src/main.rs index 87dc0dd5b3..602b26cc1e 100644 --- a/fuzzers/forkserver/libafl-fuzz/src/main.rs +++ b/fuzzers/forkserver/libafl-fuzz/src/main.rs @@ -21,6 +21,7 @@ clippy::similar_names, clippy::too_many_lines, clippy::into_iter_without_iter, // broken + clippy::multiple_crate_versions )] #![cfg_attr(not(test), warn( missing_debug_implementations, @@ -105,7 +106,6 @@ const DEFER_SIG: &str = "##SIG_AFL_DEFER_FORKSRV##\0"; const SHMEM_ENV_VAR: &str = "__AFL_SHM_ID"; static AFL_HARNESS_FILE_INPUT: &str = "@@"; -#[allow(clippy::too_many_lines)] fn main() { env_logger::init(); let mut opt = Opt::parse(); @@ -202,7 +202,7 @@ fn main() { }; } -#[allow(clippy::struct_excessive_bools)] +#[expect(clippy::struct_excessive_bools)] #[derive(Debug, Parser, Clone)] #[command( name = "afl-fuzz", @@ -358,7 +358,7 @@ struct Opt { non_instrumented_mode: bool, } -#[allow(dead_code, clippy::struct_excessive_bools)] +#[expect(dead_code, clippy::struct_excessive_bools)] #[derive(Debug, Clone)] pub struct CmplogOpts { file_size: CmplogFileSize, @@ -387,7 +387,7 @@ impl From<&str> for CmplogFileSize { } } -#[allow(clippy::unnecessary_wraps)] // we need to be compatible with Clap's value_parser +#[expect(clippy::unnecessary_wraps)] // we need to be compatible with Clap's value_parser fn parse_cmplog_args(s: &str) -> Result { Ok(CmplogOpts { file_size: s.into(), diff --git a/fuzzers/forkserver/libafl-fuzz/src/stages/mutational_stage.rs b/fuzzers/forkserver/libafl-fuzz/src/stages/mutational_stage.rs index efde3a29cb..7e91d65027 100644 --- a/fuzzers/forkserver/libafl-fuzz/src/stages/mutational_stage.rs +++ b/fuzzers/forkserver/libafl-fuzz/src/stages/mutational_stage.rs @@ -63,7 +63,6 @@ where P: Stage, { #[inline] - #[allow(clippy::let_and_return)] fn perform( &mut self, fuzzer: &mut Z, diff --git a/fuzzers/fuzz_anything/baby_fuzzer_wasm/src/lib.rs b/fuzzers/fuzz_anything/baby_fuzzer_wasm/src/lib.rs index 6af42b74d2..93d91961e0 100644 --- a/fuzzers/fuzz_anything/baby_fuzzer_wasm/src/lib.rs +++ b/fuzzers/fuzz_anything/baby_fuzzer_wasm/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(unexpected_cfgs)] // the wasm_bindgen introduces these on nightly only mod utils; use libafl::{ @@ -25,7 +26,11 @@ use crate::utils::set_panic_hook; // Defined for internal use by LibAFL #[no_mangle] -#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)] +#[expect( + clippy::cast_sign_loss, + clippy::cast_possible_truncation, + clippy::missing_panics_doc +)] pub extern "C" fn external_current_millis() -> u64 { let window: Window = web_sys::window().expect("should be in browser to run this demo"); let performance: Performance = window @@ -34,7 +39,7 @@ pub extern "C" fn external_current_millis() -> u64 { performance.now() as u64 } -#[allow(clippy::missing_panics_doc)] +#[allow(clippy::missing_panics_doc)] // expect does not work, likely because of `wasm_bindgen` #[wasm_bindgen] pub fn fuzz() { set_panic_hook(); @@ -64,7 +69,6 @@ pub fn fuzz() { signals_set(1); if buf.len() > 1 && buf[1] == b'b' { signals_set(2); - #[allow(clippy::manual_assert)] if buf.len() > 2 && buf[2] == b'c' { // WASM cannot handle traps: https://webassembly.github.io/spec/core/intro/overview.html // in a "real" fuzzing campaign, you should prefer to setup trap handling in JS, @@ -77,6 +81,8 @@ pub fn fuzz() { }; // Create an observation channel using the signals map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem in nightly let observer = unsafe { StdMapObserver::from_mut_ptr("signals", signals.as_mut_ptr(), signals.len()) }; diff --git a/fuzzers/fuzz_anything/baby_no_std/src/main.rs b/fuzzers/fuzz_anything/baby_no_std/src/main.rs index 6567720ada..f64132105d 100644 --- a/fuzzers/fuzz_anything/baby_no_std/src/main.rs +++ b/fuzzers/fuzz_anything/baby_no_std/src/main.rs @@ -64,7 +64,6 @@ pub extern "C" fn external_current_millis() -> u64 { /// The main of this program. /// # Panics /// Will panic once the fuzzer finds the correct conditions. -#[allow(clippy::similar_names)] #[no_mangle] pub extern "C" fn main(_argc: isize, _argv: *const *const u8) -> isize { // The closure that we want to fuzz @@ -76,7 +75,7 @@ pub extern "C" fn main(_argc: isize, _argv: *const *const u8) -> isize { signals_set(1); if buf.len() > 1 && buf[1] == b'b' { signals_set(2); - #[allow(clippy::manual_assert)] + #[expect(clippy::manual_assert)] if buf.len() > 2 && buf[2] == b'c' { panic!("=)"); } diff --git a/fuzzers/fuzz_anything/cargo_fuzz/src/lib.rs b/fuzzers/fuzz_anything/cargo_fuzz/src/lib.rs index 05a12ff8ed..42e5c6edae 100644 --- a/fuzzers/fuzz_anything/cargo_fuzz/src/lib.rs +++ b/fuzzers/fuzz_anything/cargo_fuzz/src/lib.rs @@ -1,4 +1,8 @@ -#[allow(clippy::collapsible_if)] +#[expect( + clippy::collapsible_if, + clippy::manual_assert, + clippy::missing_panics_doc +)] pub fn do_thing(data: &[u8]) { if data.first() == Some(&b'a') { if data.get(1) == Some(&b'b') { diff --git a/fuzzers/fuzz_anything/libafl_atheris/src/lib.rs b/fuzzers/fuzz_anything/libafl_atheris/src/lib.rs index 9d64af0899..0d00e2778e 100644 --- a/fuzzers/fuzz_anything/libafl_atheris/src/lib.rs +++ b/fuzzers/fuzz_anything/libafl_atheris/src/lib.rs @@ -47,7 +47,6 @@ use libafl_targets::{extra_counters, CmpLogObserver}; /// The `harness_fn` parameter is the function that will be called by `LibAFL` for each iteration /// and jumps back into `Atheris'` instrumented python code. #[no_mangle] -#[allow(non_snake_case)] pub extern "C" fn LLVMFuzzerRunDriver( _argc: *const c_int, _argv: *const *const c_char, diff --git a/fuzzers/fuzz_anything/push_harness/src/main.rs b/fuzzers/fuzz_anything/push_harness/src/main.rs index 2dd1d9dfee..87c561b422 100644 --- a/fuzzers/fuzz_anything/push_harness/src/main.rs +++ b/fuzzers/fuzz_anything/push_harness/src/main.rs @@ -29,7 +29,6 @@ fn signals_set(idx: usize) { } /// This generates the input, using klo-routines. -#[allow(clippy::similar_names)] fn input_generator() { // The closure that produced the input for the generator let mut harness = |input: &BytesInput| { @@ -43,6 +42,7 @@ fn input_generator() { let signals_len = unsafe { *signals_ptr }.len(); // Create an observation channel using the signals map + let observer = unsafe { StdMapObserver::from_mut_ptr("signals", &raw mut SIGNALS as _, signals_len) }; @@ -111,7 +111,7 @@ fn input_generator() { /// the main function loops independently of the fuzzer. /// `Klo` internally switches between the `LibAFL` and harness coroutines to generate the inputs. -#[allow(clippy::manual_assert)] +#[expect(clippy::manual_assert)] pub fn main() { // Set up the Klo-routines harness let mut input_generator = input_generator; diff --git a/fuzzers/fuzz_anything/push_stage_harness/src/main.rs b/fuzzers/fuzz_anything/push_stage_harness/src/main.rs index e1eb51e1ff..a95fe17d34 100644 --- a/fuzzers/fuzz_anything/push_stage_harness/src/main.rs +++ b/fuzzers/fuzz_anything/push_stage_harness/src/main.rs @@ -31,9 +31,11 @@ fn signals_set(idx: usize) { unsafe { SIGNALS[idx] = 1 }; } -#[allow(clippy::similar_names, clippy::manual_assert)] +#[expect(clippy::manual_assert)] pub fn main() { // Create an observation channel using the signals map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem in nightly let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS.as_mut_ptr(), SIGNALS.len()) }; diff --git a/fuzzers/inprocess/dynamic_analysis/build.rs b/fuzzers/inprocess/dynamic_analysis/build.rs index 863d3cb258..f9e1b126f3 100644 --- a/fuzzers/inprocess/dynamic_analysis/build.rs +++ b/fuzzers/inprocess/dynamic_analysis/build.rs @@ -7,7 +7,7 @@ fn main() { println!("cargo:warning=Downloading Little-CMS"); // Clone the Little-CMS repository if the directory doesn't exist let status = Command::new("git") - .args(&[ + .args([ "clone", "https://github.com/mm2/Little-CMS", lcms_dir.to_str().unwrap(), @@ -15,9 +15,7 @@ fn main() { .status() .expect("Failed to clone Little-CMS repository"); - if !status.success() { - panic!("Failed to clone Little-CMS repository"); - } + assert!(status.success(), "Failed to clone Little-CMS repository"); } // Tell Cargo that if the given file changes, to rerun this build script diff --git a/fuzzers/inprocess/dynamic_analysis/src/lib.rs b/fuzzers/inprocess/dynamic_analysis/src/lib.rs index 616bb8960e..35bc9e0c00 100644 --- a/fuzzers/inprocess/dynamic_analysis/src/lib.rs +++ b/fuzzers/inprocess/dynamic_analysis/src/lib.rs @@ -198,7 +198,7 @@ fn run_testcases(filenames: &[&str]) { } /// The actual fuzzer -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] fn fuzz( corpus_dir: PathBuf, objective_dir: PathBuf, @@ -252,8 +252,9 @@ fn fuzz( // Create an observation channel to keep track of the execution time let time_observer = TimeObserver::new("time"); - let func_list = - unsafe { OwnedMutPtr::from_raw_mut(Lazy::force_mut(&mut *&raw mut FUNCTION_LIST)) }; + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem in nightly + let func_list = unsafe { OwnedMutPtr::from_raw_mut(Lazy::force_mut(&mut FUNCTION_LIST)) }; let profiling_observer = ProfilingObserver::new("concatenated.json", func_list)?; let callhook = CallHook::new(); diff --git a/fuzzers/inprocess/fuzzbench/src/lib.rs b/fuzzers/inprocess/fuzzbench/src/lib.rs index 99b6e94b79..8851abe92d 100644 --- a/fuzzers/inprocess/fuzzbench/src/lib.rs +++ b/fuzzers/inprocess/fuzzbench/src/lib.rs @@ -196,7 +196,7 @@ fn run_testcases(filenames: &[&str]) { } /// The actual fuzzer -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] fn fuzz( corpus_dir: PathBuf, objective_dir: PathBuf, diff --git a/fuzzers/inprocess/fuzzbench_ctx/src/lib.rs b/fuzzers/inprocess/fuzzbench_ctx/src/lib.rs index 1fc485c250..8bf1081663 100644 --- a/fuzzers/inprocess/fuzzbench_ctx/src/lib.rs +++ b/fuzzers/inprocess/fuzzbench_ctx/src/lib.rs @@ -201,7 +201,7 @@ fn run_testcases(filenames: &[&str]) { } /// The actual fuzzer -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] fn fuzz( corpus_dir: PathBuf, objective_dir: PathBuf, diff --git a/fuzzers/inprocess/fuzzbench_text/src/lib.rs b/fuzzers/inprocess/fuzzbench_text/src/lib.rs index f717c19491..62426bead5 100644 --- a/fuzzers/inprocess/fuzzbench_text/src/lib.rs +++ b/fuzzers/inprocess/fuzzbench_text/src/lib.rs @@ -63,7 +63,7 @@ use nix::unistd::dup; /// The fuzzer main (as `no_mangle` C function) #[no_mangle] -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] pub extern "C" fn libafl_main() { // Registry the metadata types used in this fuzzer // Needed only on no_std @@ -258,7 +258,7 @@ fn run_testcases(filenames: &[&str]) { } /// The actual fuzzer -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] fn fuzz_binary( corpus_dir: PathBuf, objective_dir: PathBuf, @@ -469,7 +469,7 @@ fn fuzz_binary( } /// The actual fuzzer based on `Grimoire` -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] fn fuzz_text( corpus_dir: PathBuf, objective_dir: PathBuf, diff --git a/fuzzers/inprocess/libfuzzer_libmozjpeg/src/lib.rs b/fuzzers/inprocess/libfuzzer_libmozjpeg/src/lib.rs index 2384a53239..fa696fda5f 100644 --- a/fuzzers/inprocess/libfuzzer_libmozjpeg/src/lib.rs +++ b/fuzzers/inprocess/libfuzzer_libmozjpeg/src/lib.rs @@ -81,10 +81,14 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re let edges_observer = unsafe { std_edges_map_observer("edges") }; // Create an observation channel using the cmp map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem on nightly let cmps_observer = unsafe { StdMapObserver::from_mut_ptr("cmps", CMP_MAP.as_mut_ptr(), CMP_MAP.len()) }; // Create an observation channel using the allocations map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem on nightly let allocs_observer = unsafe { StdMapObserver::from_mut_ptr( "allocs", diff --git a/fuzzers/inprocess/libfuzzer_libpng/src/lib.rs b/fuzzers/inprocess/libfuzzer_libpng/src/lib.rs index e783ed5116..09d5357bfd 100644 --- a/fuzzers/inprocess/libfuzzer_libpng/src/lib.rs +++ b/fuzzers/inprocess/libfuzzer_libpng/src/lib.rs @@ -79,6 +79,8 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re }; // Create an observation channel using the coverage map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem on nightly let edges_observer = unsafe { HitcountsMapObserver::new(StdMapObserver::from_mut_ptr( "edges", diff --git a/fuzzers/inprocess/libfuzzer_libpng_accounting/Cargo.toml b/fuzzers/inprocess/libfuzzer_libpng_accounting/Cargo.toml index 2a83735cce..b6a72e565f 100644 --- a/fuzzers/inprocess/libfuzzer_libpng_accounting/Cargo.toml +++ b/fuzzers/inprocess/libfuzzer_libpng_accounting/Cargo.toml @@ -25,6 +25,7 @@ which = "6.0.3" libafl = { path = "../../../libafl", features = [ "std", "derive", + "tcp_manager", "llmp_compression", "introspection", ] } diff --git a/fuzzers/inprocess/libfuzzer_libpng_accounting/src/lib.rs b/fuzzers/inprocess/libfuzzer_libpng_accounting/src/lib.rs index 474493963d..1619b1410a 100644 --- a/fuzzers/inprocess/libfuzzer_libpng_accounting/src/lib.rs +++ b/fuzzers/inprocess/libfuzzer_libpng_accounting/src/lib.rs @@ -139,6 +139,8 @@ pub extern "C" fn libafl_main() { let mut run_client = |state: Option<_>, mut restarting_mgr, _client_description| { // Create an observation channel using the coverage map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem on nightly let edges_observer = HitcountsMapObserver::new(unsafe { StdMapObserver::from_mut_ptr("edges", EDGES_MAP.as_mut_ptr(), MAX_EDGES_FOUND) }) diff --git a/fuzzers/inprocess/libfuzzer_libpng_centralized/src/lib.rs b/fuzzers/inprocess/libfuzzer_libpng_centralized/src/lib.rs index 62da02c185..1ffbabb60d 100644 --- a/fuzzers/inprocess/libfuzzer_libpng_centralized/src/lib.rs +++ b/fuzzers/inprocess/libfuzzer_libpng_centralized/src/lib.rs @@ -262,7 +262,7 @@ pub extern "C" fn libafl_main() { Ok(()) }; - let mut main_run_client = secondary_run_client.clone(); // clone it just for borrow checker + let mut main_run_client = secondary_run_client; // clone it just for borrow checker match CentralizedLauncher::builder() .shmem_provider(shmem_provider) diff --git a/fuzzers/inprocess/libfuzzer_libpng_tcp_manager/src/lib.rs b/fuzzers/inprocess/libfuzzer_libpng_tcp_manager/src/lib.rs index 033d6814cf..65a2044d19 100644 --- a/fuzzers/inprocess/libfuzzer_libpng_tcp_manager/src/lib.rs +++ b/fuzzers/inprocess/libfuzzer_libpng_tcp_manager/src/lib.rs @@ -77,6 +77,8 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re }; // Create an observation channel using the coverage map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem on nightly let edges_observer = unsafe { HitcountsMapObserver::new(StdMapObserver::from_mut_ptr( "edges", diff --git a/fuzzers/structure_aware/baby_fuzzer_custom_input/src/main.rs b/fuzzers/structure_aware/baby_fuzzer_custom_input/src/main.rs index 5e85ecf321..e741403416 100644 --- a/fuzzers/structure_aware/baby_fuzzer_custom_input/src/main.rs +++ b/fuzzers/structure_aware/baby_fuzzer_custom_input/src/main.rs @@ -53,7 +53,7 @@ fn signals_set(idx: usize) { unsafe { write(SIGNALS_PTR.add(idx), 1) }; } -#[allow(clippy::similar_names, clippy::manual_assert)] +#[expect(clippy::manual_assert)] pub fn main() { // The closure that we want to fuzz // The pseudo program under test uses all parts of the custom input @@ -87,6 +87,7 @@ pub fn main() { }; // Create an observation channel using the signals map + let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS_LEN) }; // Feedback to rate the interestingness of an input diff --git a/fuzzers/structure_aware/baby_fuzzer_gramatron/src/main.rs b/fuzzers/structure_aware/baby_fuzzer_gramatron/src/main.rs index c07e1b2f16..f60f9596fb 100644 --- a/fuzzers/structure_aware/baby_fuzzer_gramatron/src/main.rs +++ b/fuzzers/structure_aware/baby_fuzzer_gramatron/src/main.rs @@ -45,7 +45,6 @@ fn read_automaton_from_file>(path: P) -> Automaton { postcard::from_bytes(&buffer).unwrap() } -#[allow(clippy::similar_names)] pub fn main() { let mut bytes = vec![]; @@ -59,6 +58,7 @@ pub fn main() { }; // Create an observation channel using the signals map + let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS_LEN) }; // Feedback to rate the interestingness of an input diff --git a/fuzzers/structure_aware/baby_fuzzer_grimoire/src/main.rs b/fuzzers/structure_aware/baby_fuzzer_grimoire/src/main.rs index 60162e5919..9f3f4b9d40 100644 --- a/fuzzers/structure_aware/baby_fuzzer_grimoire/src/main.rs +++ b/fuzzers/structure_aware/baby_fuzzer_grimoire/src/main.rs @@ -25,6 +25,8 @@ use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice}; /// Coverage map with explicit assignments due to the lack of instrumentation static mut SIGNALS: [u8; 16] = [0; 16]; +// TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 +#[allow(static_mut_refs)] // only a problem in nightly static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() }; /// Assign a signal to the signals map fn signals_set(idx: usize) { @@ -44,7 +46,6 @@ fn is_sub(mut haystack: &[T], needle: &[T]) -> bool { false } -#[allow(clippy::similar_names)] pub fn main() { let mut initial_inputs = vec![]; for entry in fs::read_dir("./corpus").unwrap() { @@ -83,6 +84,8 @@ pub fn main() { }; // Create an observation channel using the signals map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem in nightly let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()).track_novelties() }; diff --git a/fuzzers/structure_aware/baby_fuzzer_multi/src/main.rs b/fuzzers/structure_aware/baby_fuzzer_multi/src/main.rs index 2cda5ebebd..5842936ff7 100644 --- a/fuzzers/structure_aware/baby_fuzzer_multi/src/main.rs +++ b/fuzzers/structure_aware/baby_fuzzer_multi/src/main.rs @@ -40,7 +40,7 @@ fn count_set(count: usize) { unsafe { LAST_COUNT[0] = count }; } -#[allow(clippy::similar_names, clippy::manual_assert)] +#[expect(clippy::manual_assert)] pub fn main() { // The closure that we want to fuzz let mut harness = |input: &MultipartInput| { diff --git a/fuzzers/structure_aware/baby_fuzzer_nautilus/src/main.rs b/fuzzers/structure_aware/baby_fuzzer_nautilus/src/main.rs index 780ebef137..71dcb912f8 100644 --- a/fuzzers/structure_aware/baby_fuzzer_nautilus/src/main.rs +++ b/fuzzers/structure_aware/baby_fuzzer_nautilus/src/main.rs @@ -25,6 +25,8 @@ use libafl_bolts::{rands::StdRand, tuples::tuple_list}; /// Coverage map with explicit assignments due to the lack of instrumentation static mut SIGNALS: [u8; 16] = [0; 16]; +// TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 +#[allow(static_mut_refs)] // only a problem in nightly static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() }; /* /// Assign a signal to the signals map @@ -33,7 +35,6 @@ fn signals_set(idx: usize) { } */ -#[allow(clippy::similar_names)] pub fn main() { let context = NautilusContext::from_file(15, "grammar.json").unwrap(); let mut bytes = vec![]; @@ -48,6 +49,8 @@ pub fn main() { }; // Create an observation channel using the signals map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem in nightly let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) }; // Feedback to rate the interestingness of an input diff --git a/fuzzers/structure_aware/baby_fuzzer_tokens/src/main.rs b/fuzzers/structure_aware/baby_fuzzer_tokens/src/main.rs index a47f76d677..194c2acd72 100644 --- a/fuzzers/structure_aware/baby_fuzzer_tokens/src/main.rs +++ b/fuzzers/structure_aware/baby_fuzzer_tokens/src/main.rs @@ -20,6 +20,8 @@ use libafl_bolts::{rands::StdRand, tuples::tuple_list}; /// Coverage map with explicit assignments due to the lack of instrumentation static mut SIGNALS: [u8; 16] = [0; 16]; +// TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 +#[allow(static_mut_refs)] // only a problem in nightly static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() }; /* @@ -29,7 +31,6 @@ fn signals_set(idx: usize) { } */ -#[allow(clippy::similar_names)] pub fn main() { let mut tokenizer = NaiveTokenizer::default(); let mut encoder_decoder = TokenInputEncoderDecoder::new(); @@ -67,6 +68,8 @@ pub fn main() { }; // Create an observation channel using the signals map + // TODO: This will break soon, fix me! See https://github.com/AFLplusplus/LibAFL/issues/2786 + #[allow(static_mut_refs)] // only a problem in nightly let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) }; // Feedback to rate the interestingness of an input diff --git a/fuzzers/structure_aware/forkserver_simple_nautilus/src/main.rs b/fuzzers/structure_aware/forkserver_simple_nautilus/src/main.rs index 61dbede569..682a65a9a2 100644 --- a/fuzzers/structure_aware/forkserver_simple_nautilus/src/main.rs +++ b/fuzzers/structure_aware/forkserver_simple_nautilus/src/main.rs @@ -85,7 +85,6 @@ struct Opt { grammar: PathBuf, } -#[allow(clippy::similar_names)] pub fn main() { env_logger::init(); const MAP_SIZE: usize = 65536; diff --git a/fuzzers/structure_aware/nautilus_sync/src/bin/libafl_cc.rs b/fuzzers/structure_aware/nautilus_sync/src/bin/libafl_cc.rs index ff4d871f97..4f78a0875d 100644 --- a/fuzzers/structure_aware/nautilus_sync/src/bin/libafl_cc.rs +++ b/fuzzers/structure_aware/nautilus_sync/src/bin/libafl_cc.rs @@ -2,7 +2,6 @@ use std::env; use libafl_cc::{ClangWrapper, CompilerWrapper, ToolWrapper}; -#[allow(clippy::missing_panics_doc)] pub fn main() { let args: Vec = env::args().collect(); if args.len() > 1 { diff --git a/fuzzers/structure_aware/nautilus_sync/src/lib.rs b/fuzzers/structure_aware/nautilus_sync/src/lib.rs index 92fc4926a5..ebe5654e8b 100644 --- a/fuzzers/structure_aware/nautilus_sync/src/lib.rs +++ b/fuzzers/structure_aware/nautilus_sync/src/lib.rs @@ -98,7 +98,7 @@ struct Opt { /// The main fn, `no_mangle` as it is a C symbol #[no_mangle] -#[allow(clippy::missing_panics_doc, clippy::too_many_lines)] +#[expect(clippy::missing_panics_doc, clippy::too_many_lines)] pub extern "C" fn libafl_main() { // Registry the metadata types used in this fuzzer // Needed only on no_std diff --git a/libafl/src/common/mod.rs b/libafl/src/common/mod.rs index c3e75a9498..69345a1fa1 100644 --- a/libafl/src/common/mod.rs +++ b/libafl/src/common/mod.rs @@ -1,7 +1,5 @@ //! This module defines trait shared across different `LibAFL` modules -#![allow(unused, missing_docs)] - use alloc::boxed::Box; use core::any::type_name; diff --git a/libafl/src/common/nautilus/grammartec/context.rs b/libafl/src/common/nautilus/grammartec/context.rs index dc6c9badc9..c29901b9fd 100644 --- a/libafl/src/common/nautilus/grammartec/context.rs +++ b/libafl/src/common/nautilus/grammartec/context.rs @@ -1,5 +1,4 @@ use alloc::{borrow::ToOwned, string::String, vec::Vec}; -use core::num::NonZero; use hashbrown::HashMap; use libafl_bolts::{ diff --git a/libafl/src/common/nautilus/grammartec/mutator.rs b/libafl/src/common/nautilus/grammartec/mutator.rs index 2ec854f79c..dbc1aee927 100644 --- a/libafl/src/common/nautilus/grammartec/mutator.rs +++ b/libafl/src/common/nautilus/grammartec/mutator.rs @@ -27,7 +27,7 @@ impl Mutator { } //Return value indicates if minimization is complete: true: complete, false: not complete - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn minimize_tree( &mut self, rand: &mut R, @@ -353,7 +353,7 @@ mod tests { .iter() .map(|x| RuleIdOrCustom::Rule(*x)) .collect::>(); - let mut tree = Tree::from_rule_vec(rules, &ctx); + let tree = Tree::from_rule_vec(rules, &ctx); println!("tree: {tree:?}"); let mut mutator = Mutator::new(&ctx); @@ -529,7 +529,6 @@ mod tests { #[test] fn deterministic_splice() { - let mut rand = StdRand::new(); let mut ctx = Context::new(); let mut rand = StdRand::new(); let mut cks = ChunkStore::new("/tmp/".to_string()); diff --git a/libafl/src/common/nautilus/grammartec/newtypes.rs b/libafl/src/common/nautilus/grammartec/newtypes.rs index bd3e0a3bab..0e38a7af10 100644 --- a/libafl/src/common/nautilus/grammartec/newtypes.rs +++ b/libafl/src/common/nautilus/grammartec/newtypes.rs @@ -64,6 +64,7 @@ impl Add for NodeId { } impl NodeId { + #[expect(dead_code)] fn steps_between(start: Self, end: Self) -> Option { let start_i = start.to_i(); let end_i = end.to_i(); @@ -72,12 +73,18 @@ impl NodeId { } Some(end_i - start_i) } + + #[expect(dead_code)] fn add_one(self) -> Self { self.add(1) } + + #[expect(dead_code)] fn sub_one(self) -> Self { NodeId(self.0 - 1) } + + #[expect(dead_code)] fn add_usize(self, n: usize) -> Option { self.0.checked_add(n).map(NodeId::from) } diff --git a/libafl/src/common/nautilus/grammartec/python_grammar_loader.rs b/libafl/src/common/nautilus/grammartec/python_grammar_loader.rs index 75d1119d88..7ed7ab5f9b 100644 --- a/libafl/src/common/nautilus/grammartec/python_grammar_loader.rs +++ b/libafl/src/common/nautilus/grammartec/python_grammar_loader.rs @@ -2,7 +2,7 @@ use std::{string::String, vec::Vec}; use pyo3::{prelude::*, pyclass, types::IntoPyDict}; -use crate::{nautilus::grammartec::context::Context, Error}; +use crate::nautilus::grammartec::context::Context; #[pyclass] struct PyContext { @@ -23,7 +23,7 @@ impl PyContext { } } - fn rule(&mut self, py: Python, nt: &str, format: &Bound) -> PyResult<()> { + fn rule(&mut self, _py: Python, nt: &str, format: &Bound) -> PyResult<()> { if let Ok(s) = format.extract::<&str>() { self.ctx.add_rule(nt, s.as_bytes()); } else if let Ok(s) = format.extract::<&[u8]>() { @@ -36,7 +36,7 @@ impl PyContext { Ok(()) } - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] fn script(&mut self, nt: &str, nts: Vec, script: PyObject) { self.ctx.add_script(nt, &nts, script); } diff --git a/libafl/src/common/nautilus/grammartec/recursion_info.rs b/libafl/src/common/nautilus/grammartec/recursion_info.rs index 49d7e5c99d..6933be1c59 100644 --- a/libafl/src/common/nautilus/grammartec/recursion_info.rs +++ b/libafl/src/common/nautilus/grammartec/recursion_info.rs @@ -53,7 +53,7 @@ impl RecursionInfo { // different recursions. Therefore we use the weight of the node to sample the endpoint of a path trough the // recursion tree. Then we just sample the length of this path uniformly as `(1.. weight)`. This // yields a uniform sample from the whole set of recursions inside the tree. If you read this, Good luck you are on your own. - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] fn find_parents( t: &Tree, nt: NTermId, @@ -82,7 +82,7 @@ impl RecursionInfo { res } - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] fn build_sampler(depths: &[usize]) -> Result { let mut weights = depths.iter().map(|x| *x as f64).collect::>(); let norm: f64 = weights.iter().sum(); diff --git a/libafl/src/common/nautilus/grammartec/rule.rs b/libafl/src/common/nautilus/grammartec/rule.rs index 7df06852b0..c3b6984d91 100644 --- a/libafl/src/common/nautilus/grammartec/rule.rs +++ b/libafl/src/common/nautilus/grammartec/rule.rs @@ -1,5 +1,4 @@ use alloc::{string::String, vec::Vec}; -use core::cell::OnceCell; use std::sync::OnceLock; use libafl_bolts::rands::Rand; diff --git a/libafl/src/common/nautilus/grammartec/tree.rs b/libafl/src/common/nautilus/grammartec/tree.rs index 30ea6992df..d330076736 100644 --- a/libafl/src/common/nautilus/grammartec/tree.rs +++ b/libafl/src/common/nautilus/grammartec/tree.rs @@ -6,7 +6,7 @@ use libafl_bolts::rands::Rand; use pyo3::{ prelude::{PyObject, PyResult, Python}, types::{PyAnyMethods, PyBytes, PyBytesMethods, PyString, PyStringMethods, PyTuple}, - FromPyObject, PyTypeInfo, + PyTypeInfo, }; use serde::{Deserialize, Serialize}; @@ -211,9 +211,11 @@ impl TreeLike for Tree { fn get_rule<'c>(&self, n: NodeId, ctx: &'c Context) -> &'c Rule { ctx.get_rule(self.get_rule_id(n)) } + fn get_custom_rule_data(&self, n: NodeId) -> &[u8] { self.rules[n.to_i()].data() } + fn get_rule_or_custom(&self, n: NodeId) -> &RuleIdOrCustom { &self.rules[n.to_i()] } @@ -240,6 +242,7 @@ impl Tree { self.rules[n.to_i()].id() } + #[expect(dead_code)] fn get_rule_or_custom(&self, n: NodeId) -> &RuleIdOrCustom { &self.rules[n.to_i()] } @@ -384,6 +387,7 @@ impl Tree { } } + #[expect(dead_code)] fn find_recursions_iter(&self, ctx: &Context) -> Vec<(NodeId, NodeId)> { let mut found_recursions = Vec::new(); //Only search for iterations for up to 10000 nodes @@ -442,6 +446,7 @@ impl TreeLike for TreeMutation<'_> { fn size(&self) -> usize { self.prefix.len() + self.repl.len() + self.postfix.len() } + fn get_rule_or_custom(&self, n: NodeId) -> &RuleIdOrCustom { self.get_at(n) } diff --git a/libafl/src/common/nautilus/mod.rs b/libafl/src/common/nautilus/mod.rs index 73f51b5c95..15b1ab2276 100644 --- a/libafl/src/common/nautilus/mod.rs +++ b/libafl/src/common/nautilus/mod.rs @@ -2,5 +2,7 @@ //! #![doc = include_str!("README.md")] +#[allow(missing_docs)] pub mod grammartec; +#[allow(missing_docs)] pub mod regex_mutator; diff --git a/libafl/src/common/nautilus/regex_mutator/mod.rs b/libafl/src/common/nautilus/regex_mutator/mod.rs index b7ece90ba3..00d4525fe1 100644 --- a/libafl/src/common/nautilus/regex_mutator/mod.rs +++ b/libafl/src/common/nautilus/regex_mutator/mod.rs @@ -53,7 +53,6 @@ fn append_unicode_range( cls: ClassUnicodeRange, ) { let mut chr_a_buf = [0; 4]; - #[allow(clippy::similar_names)] let mut chr_b_buf = [0; 4]; cls.start().encode_utf8(&mut chr_a_buf); cls.end().encode_utf8(&mut chr_b_buf); diff --git a/libafl/src/corpus/inmemory_ondisk.rs b/libafl/src/corpus/inmemory_ondisk.rs index e879881098..c2e0a5536b 100644 --- a/libafl/src/corpus/inmemory_ondisk.rs +++ b/libafl/src/corpus/inmemory_ondisk.rs @@ -470,11 +470,14 @@ impl InMemoryOnDiskCorpus { #[cfg(test)] mod tests { + #[cfg(not(miri))] use std::{env, fs, io::Write}; + #[cfg(not(miri))] use super::{create_new, try_create_new}; #[test] + #[cfg(not(miri))] fn test() { let tmp = env::temp_dir(); let path = tmp.join("testfile.tmp"); diff --git a/libafl/src/corpus/minimizer.rs b/libafl/src/corpus/minimizer.rs index c6599ca75d..0e513863df 100644 --- a/libafl/src/corpus/minimizer.rs +++ b/libafl/src/corpus/minimizer.rs @@ -64,7 +64,7 @@ where TS: TestcaseScore, { /// Do the minimization - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] pub fn minimize( &self, fuzzer: &mut Z, diff --git a/libafl/src/corpus/testcase.rs b/libafl/src/corpus/testcase.rs index 8c76399594..776de28c70 100644 --- a/libafl/src/corpus/testcase.rs +++ b/libafl/src/corpus/testcase.rs @@ -358,7 +358,6 @@ where } /// Get the `len` or calculate it, if not yet calculated. - #[allow(clippy::len_without_is_empty)] pub fn load_len>(&mut self, corpus: &C) -> Result { match &self.input { Some(i) => { @@ -389,7 +388,7 @@ impl From for Testcase { #[derive(Serialize, Deserialize, Clone, Debug)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct SchedulerTestcaseMetadata { /// Number of bits set in bitmap, updated in `calibrate_case` diff --git a/libafl/src/events/broker_hooks/centralized.rs b/libafl/src/events/broker_hooks/centralized.rs index eaa6c6bb4b..831ae29fcb 100644 --- a/libafl/src/events/broker_hooks/centralized.rs +++ b/libafl/src/events/broker_hooks/centralized.rs @@ -89,7 +89,7 @@ where } /// Handle arriving events in the broker - #[allow(clippy::unnecessary_wraps)] + #[expect(clippy::unnecessary_wraps)] fn handle_in_broker( _client_id: ClientId, event: &Event, diff --git a/libafl/src/events/broker_hooks/mod.rs b/libafl/src/events/broker_hooks/mod.rs index 90a4cedb2a..cc3d470b9d 100644 --- a/libafl/src/events/broker_hooks/mod.rs +++ b/libafl/src/events/broker_hooks/mod.rs @@ -104,7 +104,7 @@ where } /// Handle arriving events in the broker - #[allow(clippy::unnecessary_wraps)] + #[expect(clippy::unnecessary_wraps)] fn handle_in_broker( monitor: &mut MT, client_id: ClientId, diff --git a/libafl/src/events/centralized.rs b/libafl/src/events/centralized.rs index e0b1a441f5..9d818e8686 100644 --- a/libafl/src/events/centralized.rs +++ b/libafl/src/events/centralized.rs @@ -27,8 +27,6 @@ use serde::{Deserialize, Serialize}; use super::NopEventManager; #[cfg(feature = "llmp_compression")] use crate::events::llmp::COMPRESS_THRESHOLD; -#[cfg(feature = "scalability_introspection")] -use crate::state::HasScalabilityMonitor; use crate::{ corpus::Corpus, events::{ @@ -278,7 +276,7 @@ where self.inner.should_send() } - #[allow(clippy::match_same_arms)] + #[expect(clippy::match_same_arms)] fn fire( &mut self, state: &mut Self::State, diff --git a/libafl/src/events/launcher.rs b/libafl/src/events/launcher.rs index 50a4e457ac..7dcba580fb 100644 --- a/libafl/src/events/launcher.rs +++ b/libafl/src/events/launcher.rs @@ -380,7 +380,7 @@ where /// Launch the broker and the clients and fuzz #[cfg(any(windows, not(feature = "fork")))] - #[allow(clippy::too_many_lines, clippy::match_wild_err_arm)] + #[expect(clippy::too_many_lines, clippy::match_wild_err_arm)] pub fn launch_with_hooks(&mut self, hooks: EMH) -> Result<(), Error> where S: State + HasExecutions, @@ -453,7 +453,7 @@ where for overcommit_i in 0..self.overcommit { index += 1; // Forward own stdio to child processes, if requested by user - #[allow(unused_mut)] + #[allow(unused_mut)] // mut only on certain cfgs let (mut stdout, mut stderr) = (Stdio::null(), Stdio::null()); #[cfg(unix)] { diff --git a/libafl/src/events/llmp/mgr.rs b/libafl/src/events/llmp/mgr.rs index 687d7e10d4..1b76f0813c 100644 --- a/libafl/src/events/llmp/mgr.rs +++ b/libafl/src/events/llmp/mgr.rs @@ -365,7 +365,7 @@ where let msg = TcpRequest::ClientQuit { client_id }; // Send this mesasge off and we are leaving. match send_tcp_msg(&mut stream, &msg) { - Ok(_) => (), + Ok(()) => (), Err(e) => log::error!("Failed to send tcp message {:#?}", e), } log::debug!("Asking he broker to be disconnected"); @@ -393,7 +393,6 @@ where SP: ShMemProvider, { // Handle arriving events in the client - #[allow(clippy::unused_self)] fn handle_in_client( &mut self, fuzzer: &mut Z, diff --git a/libafl/src/events/llmp/mod.rs b/libafl/src/events/llmp/mod.rs index 0175d33c6f..629ff6006a 100644 --- a/libafl/src/events/llmp/mod.rs +++ b/libafl/src/events/llmp/mod.rs @@ -341,7 +341,6 @@ where } /// Handle arriving events in the client - #[allow(clippy::unused_self)] pub fn process( &mut self, fuzzer: &mut Z, diff --git a/libafl/src/events/llmp/restarting.rs b/libafl/src/events/llmp/restarting.rs index 731c9e932d..4feeababcf 100644 --- a/libafl/src/events/llmp/restarting.rs +++ b/libafl/src/events/llmp/restarting.rs @@ -333,7 +333,7 @@ pub enum ManagerKind { /// /// The restarting mgr is a combination of restarter and runner, that can be used on systems with and without `fork` support. /// The restarter will spawn a new process each time the child crashes or timeouts. -#[allow(clippy::type_complexity)] +#[expect(clippy::type_complexity)] pub fn setup_restarting_mgr_std( monitor: MT, broker_port: u16, @@ -364,7 +364,7 @@ where /// The restarting mgr is a combination of restarter and runner, that can be used on systems with and without `fork` support. /// The restarter will spawn a new process each time the child crashes or timeouts. /// This one, additionally uses the timeobserver for the adaptive serialization -#[allow(clippy::type_complexity)] +#[expect(clippy::type_complexity)] pub fn setup_restarting_mgr_std_adaptive( monitor: MT, broker_port: u16, @@ -397,7 +397,6 @@ where /// The [`RestartingMgr`] is is a combination of a /// `restarter` and `runner`, that can be used on systems both with and without `fork` support. The /// `restarter` will start a new process each time the child crashes or times out. -#[allow(clippy::default_trait_access, clippy::ignored_unit_patterns)] #[derive(TypedBuilder, Debug)] pub struct RestartingMgr { /// The shared memory provider to use for the broker or client spawned by the restarting @@ -439,7 +438,7 @@ pub struct RestartingMgr { phantom_data: PhantomData<(EMH, S)>, } -#[allow(clippy::type_complexity, clippy::too_many_lines)] +#[expect(clippy::type_complexity, clippy::too_many_lines)] impl RestartingMgr where EMH: EventManagerHooksTuple + Copy + Clone, @@ -612,15 +611,12 @@ where return Err(Error::shutting_down()); } - #[allow(clippy::manual_assert)] if !staterestorer.has_content() && !self.serialize_state.oom_safe() { if let Err(err) = mgr.detach_from_broker(self.broker_port) { log::error!("Failed to detach from broker: {err}"); } #[cfg(unix)] - if child_status == 9 { - panic!("Target received SIGKILL!. This could indicate the target crashed due to OOM, user sent SIGKILL, or the target was in an unrecoverable situation and could not save state to restart"); - } + assert_ne!(9, child_status, "Target received SIGKILL!. This could indicate the target crashed due to OOM, user sent SIGKILL, or the target was in an unrecoverable situation and could not save state to restart"); // Storing state in the last round did not work panic!("Fuzzer-respawner: Storing state in crashed fuzzer instance did not work, no point to spawn the next client! This can happen if the child calls `exit()`, in that case make sure it uses `abort()`, if it got killed unrecoverable (OOM), or if there is a bug in the fuzzer itself. (Child exited with: {child_status})"); } diff --git a/libafl/src/events/mod.rs b/libafl/src/events/mod.rs index 81ab7f7d32..93dddc4f07 100644 --- a/libafl/src/events/mod.rs +++ b/libafl/src/events/mod.rs @@ -11,13 +11,11 @@ pub mod centralized; #[cfg(all(unix, feature = "std"))] pub use centralized::*; #[cfg(feature = "std")] -#[allow(clippy::ignored_unit_patterns)] pub mod launcher; -#[allow(clippy::ignored_unit_patterns)] + pub mod llmp; pub use llmp::*; #[cfg(feature = "tcp_manager")] -#[allow(clippy::ignored_unit_patterns)] pub mod tcp; pub mod broker_hooks; diff --git a/libafl/src/events/multi_machine.rs b/libafl/src/events/multi_machine.rs index f55e41ea24..51f8d7a145 100644 --- a/libafl/src/events/multi_machine.rs +++ b/libafl/src/events/multi_machine.rs @@ -122,7 +122,6 @@ impl NodeId { /// The state of the hook shared between the background threads and the main thread. #[derive(Debug)] -#[allow(dead_code)] pub struct TcpMultiMachineState { node_descriptor: NodeDescriptor, /// the parent to which the testcases should be forwarded when deemed interesting @@ -364,7 +363,7 @@ where /// Read a [`TcpMultiMachineMsg`] from a stream. /// Expects a message written by [`TcpMultiMachineState::write_msg`]. /// If there is nothing to read from the stream, return asap with Ok(None). - #[allow(clippy::uninit_vec)] + #[expect(clippy::uninit_vec)] async fn read_msg<'a, I: Input + 'a>( stream: &mut TcpStream, ) -> Result>, Error> { diff --git a/libafl/src/events/simple.rs b/libafl/src/events/simple.rs index 5289eaa2f7..122bdd3fb6 100644 --- a/libafl/src/events/simple.rs +++ b/libafl/src/events/simple.rs @@ -200,7 +200,7 @@ where } /// Handle arriving events in the broker - #[allow(clippy::unnecessary_wraps)] + #[expect(clippy::unnecessary_wraps)] fn handle_in_broker( monitor: &mut MT, event: &Event, @@ -273,7 +273,6 @@ where } // Handle arriving events in the client - #[allow(clippy::needless_pass_by_value, clippy::unused_self)] fn handle_in_client(&mut self, state: &mut S, event: Event) -> Result<(), Error> { match event { Event::CustomBuf { buf, tag } => { @@ -299,7 +298,6 @@ where /// `restarter` and `runner`, that can be used on systems both with and without `fork` support. The /// `restarter` will start a new process each time the child crashes or times out. #[cfg(feature = "std")] -#[allow(clippy::default_trait_access)] #[derive(Debug)] pub struct SimpleRestartingEventManager where @@ -433,7 +431,6 @@ where } #[cfg(feature = "std")] -#[allow(clippy::type_complexity, clippy::too_many_lines)] impl SimpleRestartingEventManager where S: UsesInput + Stoppable, @@ -451,7 +448,6 @@ where /// Launch the simple restarting manager. /// This [`EventManager`] is simple and single threaded, /// but can still used shared maps to recover from crashes and timeouts. - #[allow(clippy::similar_names)] pub fn launch(mut monitor: MT, shmem_provider: &mut SP) -> Result<(Option, Self), Error> where S: DeserializeOwned + Serialize + HasCorpus + HasSolutions, @@ -519,7 +515,7 @@ where return Err(Error::shutting_down()); } - #[allow(clippy::manual_assert)] + #[expect(clippy::manual_assert)] if !staterestorer.has_content() { #[cfg(unix)] if child_status == 9 { diff --git a/libafl/src/events/tcp.rs b/libafl/src/events/tcp.rs index 5b4ac815db..c16c3eaf93 100644 --- a/libafl/src/events/tcp.rs +++ b/libafl/src/events/tcp.rs @@ -112,9 +112,9 @@ where } /// Run in the broker until all clients exit - // TODO: remove allow(clippy::needless_return) when clippy is fixed + // TODO: remove expect(clippy::needless_return) when clippy is fixed #[tokio::main(flavor = "current_thread")] - #[allow(clippy::too_many_lines, clippy::needless_return)] + #[expect(clippy::too_many_lines)] pub async fn broker_loop(&mut self) -> Result<(), Error> { let (tx_bc, rx) = broadcast::channel(65536); let (tx, mut rx_mpsc) = mpsc::channel(65536); @@ -289,10 +289,9 @@ where let event_bytes = &buf[4..]; #[cfg(feature = "tcp_compression")] - let event_bytes = GzipCompressor::new().decompress(event_bytes)?; + let event_bytes = &GzipCompressor::new().decompress(event_bytes)?; - #[allow(clippy::needless_borrow)] // make decompressed vec and slice compatible - let event: Event = postcard::from_bytes(&event_bytes)?; + let event: Event = postcard::from_bytes(event_bytes)?; match Self::handle_in_broker(&mut self.monitor, client_id, &event)? { BrokerEventResult::Forward => { tx_bc.send(buf).expect("Could not send"); @@ -311,7 +310,7 @@ where } /// Handle arriving events in the broker - #[allow(clippy::unnecessary_wraps)] + #[expect(clippy::unnecessary_wraps)] fn handle_in_broker( monitor: &mut MT, client_id: ClientId, @@ -593,7 +592,6 @@ where } // Handle arriving events in the client - #[allow(clippy::unused_self)] fn handle_in_client( &mut self, fuzzer: &mut Z, @@ -789,7 +787,6 @@ where let buf = self.compressor.decompress(buf)?; // make decompressed vec and slice compatible - #[allow(clippy::needless_borrow)] let event = postcard::from_bytes(&buf)?; self.handle_in_client(fuzzer, executor, state, other_client_id, event)?; @@ -1067,7 +1064,7 @@ pub enum TcpManagerKind { /// /// The [`TcpRestartingEventManager`] is a combination of restarter and runner, that can be used on systems with and without `fork` support. /// The restarter will spawn a new process each time the child crashes or timeouts. -#[allow(clippy::type_complexity)] +#[expect(clippy::type_complexity)] pub fn setup_restarting_mgr_tcp( monitor: MT, broker_port: u16, @@ -1099,7 +1096,6 @@ where /// The [`TcpRestartingMgr`] is a combination of a /// `restarter` and `runner`, that can be used on systems both with and without `fork` support. The /// `restarter` will start a new process each time the child crashes or times out. -#[allow(clippy::default_trait_access, clippy::ignored_unit_patterns)] #[derive(TypedBuilder, Debug)] pub struct TcpRestartingMgr where @@ -1142,7 +1138,7 @@ where phantom_data: PhantomData, } -#[allow(clippy::type_complexity, clippy::too_many_lines)] +#[expect(clippy::type_complexity, clippy::too_many_lines)] impl TcpRestartingMgr where EMH: EventManagerHooksTuple + Copy + Clone, @@ -1289,7 +1285,7 @@ where return Err(Error::shutting_down()); } - #[allow(clippy::manual_assert)] + #[expect(clippy::manual_assert)] if !staterestorer.has_content() && self.serialize_state { #[cfg(unix)] if child_status == 137 { diff --git a/libafl/src/executors/command.rs b/libafl/src/executors/command.rs index 9218dfd18a..375af104e6 100644 --- a/libafl/src/executors/command.rs +++ b/libafl/src/executors/command.rs @@ -80,7 +80,6 @@ pub enum InputLocation { /// A simple Configurator that takes the most common parameters /// Writes the input either to stdio or to a file /// Use [`CommandExecutor::builder()`] to use this configurator. -#[allow(clippy::struct_excessive_bools)] #[derive(Debug)] pub struct StdCommandConfigurator { /// If set to true, the child output will remain visible diff --git a/libafl/src/executors/differential.rs b/libafl/src/executors/differential.rs index 95b0e093cb..4c5ae3fb5a 100644 --- a/libafl/src/executors/differential.rs +++ b/libafl/src/executors/differential.rs @@ -208,7 +208,7 @@ where B: MatchName, DOT: MatchName, { - #[allow(deprecated)] + #[expect(deprecated)] fn match_name(&self, name: &str) -> Option<&T> { if let Some(t) = self.primary.as_ref().match_name::(name) { Some(t) @@ -219,7 +219,7 @@ where } } - #[allow(deprecated)] + #[expect(deprecated)] fn match_name_mut(&mut self, name: &str) -> Option<&mut T> { if let Some(t) = self.primary.as_mut().match_name_mut::(name) { Some(t) diff --git a/libafl/src/executors/forkserver.rs b/libafl/src/executors/forkserver.rs index 2b0e8dec82..db8c0a8430 100644 --- a/libafl/src/executors/forkserver.rs +++ b/libafl/src/executors/forkserver.rs @@ -54,43 +54,43 @@ use crate::{ }; const FORKSRV_FD: i32 = 198; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_NEW_ERROR: i32 = 0xeffe0000_u32 as i32; const FS_NEW_VERSION_MIN: u32 = 1; const FS_NEW_VERSION_MAX: u32 = 1; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_OPT_ENABLED: i32 = 0x80000001_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_NEW_OPT_MAPSIZE: i32 = 1_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_OPT_MAPSIZE: i32 = 0x40000000_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_OPT_SHDMEM_FUZZ: i32 = 0x01000000_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_NEW_OPT_SHDMEM_FUZZ: i32 = 2_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_NEW_OPT_AUTODTCT: i32 = 0x00000800_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_OPT_AUTODTCT: i32 = 0x10000000_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_ERROR_MAP_SIZE: i32 = 1_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_ERROR_MAP_ADDR: i32 = 2_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_ERROR_SHM_OPEN: i32 = 4_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_ERROR_SHMAT: i32 = 8_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_ERROR_MMAP: i32 = 16_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_ERROR_OLD_CMPLOG: i32 = 32_u32 as i32; -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] const FS_ERROR_OLD_CMPLOG_QEMU: i32 = 64_u32 as i32; /// Forkserver message. We'll reuse it in a testcase. @@ -209,7 +209,7 @@ impl ConfigTarget for Command { } } - #[allow(trivial_numeric_casts, clippy::cast_possible_wrap)] + #[expect(trivial_numeric_casts)] fn setlimit(&mut self, memlimit: u64) -> &mut Self { if memlimit == 0 { return self; @@ -315,10 +315,10 @@ const fn fs_opt_get_mapsize(x: i32) -> i32 { ((x & 0x00fffffe) >> 1) + 1 } -#[allow(clippy::fn_params_excessive_bools)] +#[expect(clippy::fn_params_excessive_bools)] impl Forkserver { /// Create a new [`Forkserver`] - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn new( target: OsString, args: Vec, @@ -351,7 +351,7 @@ impl Forkserver { /// Create a new [`Forkserver`] that will kill child processes /// with the given `kill_signal`. /// Using `Forkserver::new(..)` will default to [`Signal::SIGTERM`]. - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn with_kill_signal( target: OsString, args: Vec, @@ -540,7 +540,7 @@ impl Forkserver { #[allow( clippy::uninit_vec, reason = "The vec will be filled right after setting the length." - )] + )] // expect for some reason does not work unsafe { buf.set_len(size); } @@ -806,7 +806,7 @@ where /// The builder for `ForkserverExecutor` #[derive(Debug)] -#[allow(clippy::struct_excessive_bools)] +#[expect(clippy::struct_excessive_bools)] pub struct ForkserverExecutorBuilder<'a, TC, SP> { program: Option, arguments: Vec, @@ -839,7 +839,7 @@ where /// Else this forkserver will pass the input to the target via `stdin` /// in case no input file is specified. /// If `debug_child` is set, the child will print to `stdout`/`stderr`. - #[allow(clippy::pedantic)] + #[expect(clippy::pedantic)] pub fn build(mut self, observers: OT) -> Result, Error> where OT: ObserversTuple, @@ -902,7 +902,7 @@ where } /// Builds `ForkserverExecutor` downsizing the coverage map to fit exaclty the AFL++ map size. - #[allow(clippy::pedantic)] + #[expect(clippy::pedantic)] pub fn build_dynamic_map( mut self, mut map_observer: A, @@ -967,7 +967,7 @@ where }) } - #[allow(clippy::pedantic)] + #[expect(clippy::pedantic)] fn build_helper(&mut self) -> Result<(Forkserver, InputFile, Option), Error> where SP: ShMemProvider, @@ -1040,8 +1040,8 @@ where } /// Intialize forkserver > v4.20c - #[allow(clippy::cast_possible_wrap)] - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_possible_wrap)] + #[expect(clippy::cast_sign_loss)] fn initialize_forkserver( &mut self, status: i32, @@ -1139,8 +1139,7 @@ where } /// Intialize old forkserver. < v4.20c - #[allow(clippy::cast_possible_wrap)] - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] fn initialize_old_forkserver( &mut self, status: i32, @@ -1214,7 +1213,7 @@ where Ok(()) } - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] fn set_map_size(&mut self, fsrv_map_size: i32) -> Result { // When 0, we assume that map_size was filled by the user or const /* TODO autofill map size from the observer diff --git a/libafl/src/executors/hooks/inprocess.rs b/libafl/src/executors/hooks/inprocess.rs index 876016b972..36ec47bbc5 100644 --- a/libafl/src/executors/hooks/inprocess.rs +++ b/libafl/src/executors/hooks/inprocess.rs @@ -25,19 +25,19 @@ use crate::executors::hooks::timer::TimerStruct; use crate::executors::hooks::unix::unix_signal_handler; #[cfg(windows)] use crate::state::State; +#[cfg(any(unix, windows))] +use crate::{corpus::Corpus, observers::ObserversTuple, state::UsesState}; use crate::{ - corpus::Corpus, events::{EventFirer, EventRestarter}, executors::{hooks::ExecutorHook, inprocess::HasInProcessHooks, Executor, HasObservers}, feedbacks::Feedback, inputs::UsesInput, - observers::ObserversTuple, - state::{HasCorpus, HasExecutions, HasSolutions, UsesState}, + state::{HasCorpus, HasExecutions, HasSolutions}, Error, HasObjective, }; /// The inmem executor's handlers. -#[allow(missing_debug_implementations)] +#[expect(missing_debug_implementations)] pub struct InProcessHooks { /// On crash C function pointer #[cfg(feature = "std")] @@ -128,7 +128,7 @@ where } #[cfg(all(unix, feature = "std"))] - #[allow(unused)] + #[allow(unused_variables)] // depends on the features fn handle_timeout(&mut self, data: &mut InProcessExecutorHandlerData) -> bool { #[cfg(not(target_os = "linux"))] { @@ -197,8 +197,7 @@ where { fn init(&mut self, _state: &mut S) {} /// Call before running a target. - #[allow(clippy::unused_self)] - #[allow(unused_variables)] + #[expect(unused_variables)] fn pre_exec(&mut self, state: &mut S, input: &S::Input) { #[cfg(feature = "std")] unsafe { @@ -212,7 +211,6 @@ where } /// Call after running a target. - #[allow(clippy::unused_self)] fn post_exec(&mut self, _state: &mut S, _input: &S::Input) { // timeout stuff // # Safety @@ -228,7 +226,7 @@ where { /// Create new [`InProcessHooks`]. #[cfg(unix)] - #[allow(unused_variables)] + #[allow(unused_variables)] // for `exec_tmout` without `std` pub fn new(exec_tmout: Duration) -> Result where E: Executor + HasObservers + HasInProcessHooks, @@ -243,7 +241,8 @@ where // # Safety // We get a pointer to `GLOBAL_STATE` that will be initialized at this point in time. // This unsafe is needed in stable but not in nightly. Remove in the future(?) - #[allow(unused_unsafe)] + #[expect(unused_unsafe)] + #[cfg(all(not(miri), unix, feature = "std"))] let data = unsafe { &raw mut GLOBAL_STATE }; #[cfg(feature = "std")] unix_signal_handler::setup_panic_hook::(); @@ -271,7 +270,7 @@ where /// Create new [`InProcessHooks`]. #[cfg(windows)] - #[allow(unused)] + #[allow(unused_variables)] // for `exec_tmout` without `std` pub fn new(exec_tmout: Duration) -> Result where E: Executor + HasObservers + HasInProcessHooks, @@ -329,7 +328,7 @@ where /// Create a new [`InProcessHooks`] #[cfg(all(not(unix), not(windows)))] - #[allow(unused_variables)] + #[expect(unused_variables)] pub fn new(exec_tmout: Duration) -> Result where E: Executor + HasObservers + HasInProcessHooks, diff --git a/libafl/src/executors/hooks/timer.rs b/libafl/src/executors/hooks/timer.rs index bf0639f389..3f335848be 100644 --- a/libafl/src/executors/hooks/timer.rs +++ b/libafl/src/executors/hooks/timer.rs @@ -38,7 +38,7 @@ pub(crate) struct Timeval { #[cfg(all(unix, not(target_os = "linux")))] impl core::fmt::Debug for Timeval { - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!( f, @@ -69,7 +69,7 @@ extern "C" { /// The strcut about all the internals of the timer. /// This struct absorb all platform specific differences about timer. -#[allow(missing_debug_implementations)] +#[expect(missing_debug_implementations)] pub struct TimerStruct { // timeout time (windows) #[cfg(windows)] @@ -103,7 +103,7 @@ pub struct TimerStruct { } #[cfg(windows)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types)] type PTP_TIMER_CALLBACK = unsafe extern "system" fn( param0: PTP_CALLBACK_INSTANCE, param1: *mut c_void, @@ -201,8 +201,6 @@ impl TimerStruct { #[cfg(target_os = "linux")] #[must_use] - #[allow(unused_unsafe)] - #[allow(unused_mut)] /// Create a `TimerStruct` with the specified timeout pub fn new(exec_tmout: Duration) -> Self { let milli_sec = exec_tmout.as_millis(); @@ -218,9 +216,10 @@ impl TimerStruct { it_interval, it_value, }; + #[allow(unused_mut)] // miri doesn't mutate this let mut timerid: libc::timer_t = null_mut(); + #[cfg(not(miri))] unsafe { - #[cfg(not(miri))] // creates a new per-process interval timer libc::timer_create(libc::CLOCK_MONOTONIC, null_mut(), &raw mut timerid); } @@ -264,7 +263,7 @@ impl TimerStruct { } #[cfg(windows)] - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] /// Set timer pub fn set_timer(&mut self) { unsafe { @@ -324,7 +323,6 @@ impl TimerStruct { /// Disable the timer #[cfg(target_os = "linux")] - #[allow(unused_variables)] pub fn unset_timer(&mut self) { // # Safety // Just API calls, no user-provided inputs @@ -351,9 +349,9 @@ impl TimerStruct { } } } else { + #[cfg(not(miri))] unsafe { let disarmed: libc::itimerspec = zeroed(); - #[cfg(not(miri))] libc::timer_settime(self.timerid, 0, &raw const disarmed, null_mut()); } } diff --git a/libafl/src/executors/hooks/unix.rs b/libafl/src/executors/hooks/unix.rs index 25ece10a70..e0f63d91a8 100644 --- a/libafl/src/executors/hooks/unix.rs +++ b/libafl/src/executors/hooks/unix.rs @@ -122,7 +122,7 @@ pub mod unix_signal_handler { /// # Safety /// Well, signal handling is not safe #[cfg(unix)] - #[allow(clippy::needless_pass_by_value)] + #[allow(clippy::needless_pass_by_value)] // nightly no longer requires this pub unsafe fn inproc_timeout_handler( _signal: Signal, _info: &mut siginfo_t, @@ -179,8 +179,7 @@ pub mod unix_signal_handler { /// /// # Safety /// Well, signal handling is not safe - #[allow(clippy::too_many_lines)] - #[allow(clippy::needless_pass_by_value)] + #[allow(clippy::needless_pass_by_value)] // nightly no longer requires this pub unsafe fn inproc_crash_handler( signal: Signal, _info: &mut siginfo_t, diff --git a/libafl/src/executors/hooks/windows.rs b/libafl/src/executors/hooks/windows.rs index ec2aef5a04..f0554848e9 100644 --- a/libafl/src/executors/hooks/windows.rs +++ b/libafl/src/executors/hooks/windows.rs @@ -154,7 +154,6 @@ pub mod windows_exception_handler { impl ExceptionHandler for InProcessExecutorHandlerData { /// # Safety /// Will dereference `EXCEPTION_POINTERS` and access `GLOBAL_STATE`. - #[allow(clippy::not_unsafe_ptr_arg_deref)] unsafe fn handle( &mut self, _code: ExceptionCode, @@ -316,7 +315,6 @@ pub mod windows_exception_handler { /// /// # Safety /// Well, exception handling is not safe - #[allow(clippy::too_many_lines)] pub unsafe fn inproc_crash_handler( exception_pointers: *mut EXCEPTION_POINTERS, data: &mut InProcessExecutorHandlerData, diff --git a/libafl/src/executors/inprocess/mod.rs b/libafl/src/executors/inprocess/mod.rs index 366532cbf7..431ab3ed0a 100644 --- a/libafl/src/executors/inprocess/mod.rs +++ b/libafl/src/executors/inprocess/mod.rs @@ -2,8 +2,6 @@ //! It should usually be paired with extra error-handling, such as a restarting event manager, to be effective. //! //! Needs the `fork` feature flag. -#![allow(clippy::needless_pass_by_value)] - use alloc::boxed::Box; use core::{ borrow::BorrowMut, @@ -57,7 +55,6 @@ pub type OwnedInProcessExecutor = GenericInProcessExecutor< >; /// The inmem executor simply calls a target function, then returns afterwards. -#[allow(dead_code)] pub struct GenericInProcessExecutor where H: FnMut(&S::Input) -> ExitKind + ?Sized, @@ -426,7 +423,6 @@ where } #[inline] -#[allow(clippy::too_many_arguments)] /// Save state if it is an objective pub fn run_observers_and_save_state( executor: &mut E, @@ -550,7 +546,6 @@ mod tests { } #[test] - #[allow(clippy::let_unit_value)] fn test_inmem_exec() { let mut harness = |_buf: &NopInput| ExitKind::Ok; let rand = XkcdRand::new(); diff --git a/libafl/src/executors/inprocess/stateful.rs b/libafl/src/executors/inprocess/stateful.rs index 159d87fac5..b24d3b54b0 100644 --- a/libafl/src/executors/inprocess/stateful.rs +++ b/libafl/src/executors/inprocess/stateful.rs @@ -44,7 +44,6 @@ pub type OwnedInProcessExecutor = StatefulGenericInProcessExecutor< /// The inmem executor simply calls a target function, then returns afterwards. /// The harness can access the internal state of the executor. -#[allow(dead_code)] pub struct StatefulGenericInProcessExecutor where H: FnMut(&mut ES, &mut S, &S::Input) -> ExitKind + ?Sized, @@ -318,7 +317,7 @@ where /// Create a new in mem executor with the default timeout and use batch mode(5 sec) #[cfg(all(feature = "std", target_os = "linux"))] - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn batched_timeout_generic( user_hooks: HT, harness_fn: HB, @@ -357,7 +356,7 @@ where /// * `observers` - the observers observing the target during execution /// /// This may return an error on unix, if signal handler setup fails - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn with_timeout_generic( user_hooks: HT, harness_fn: HB, diff --git a/libafl/src/executors/inprocess_fork/inner.rs b/libafl/src/executors/inprocess_fork/inner.rs index e34d1eb56b..ad4b08b348 100644 --- a/libafl/src/executors/inprocess_fork/inner.rs +++ b/libafl/src/executors/inprocess_fork/inner.rs @@ -254,7 +254,6 @@ where /// Creates a new [`GenericInProcessForkExecutorInner`] with custom hooks #[cfg(target_os = "linux")] - #[allow(clippy::too_many_arguments)] pub fn with_hooks( userhooks: HT, observers: OT, @@ -279,7 +278,6 @@ where /// Creates a new [`GenericInProcessForkExecutorInner`], non linux #[cfg(not(target_os = "linux"))] - #[allow(clippy::too_many_arguments)] pub fn with_hooks( userhooks: HT, observers: OT, diff --git a/libafl/src/executors/inprocess_fork/mod.rs b/libafl/src/executors/inprocess_fork/mod.rs index e313405bdc..485f6cdfdf 100644 --- a/libafl/src/executors/inprocess_fork/mod.rs +++ b/libafl/src/executors/inprocess_fork/mod.rs @@ -57,7 +57,6 @@ where S: HasSolutions, Z: HasObjective, { - #[allow(clippy::too_many_arguments)] /// The constructor for `InProcessForkExecutor` pub fn new( harness_fn: &'a mut H, @@ -147,7 +146,6 @@ where HT: ExecutorHooksTuple, EM: EventFirer + EventRestarter, { - #[allow(unreachable_code)] #[inline] fn run_target( &mut self, @@ -190,7 +188,7 @@ where Z: HasObjective, { /// Creates a new [`GenericInProcessForkExecutor`] with custom hooks - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn with_hooks( userhooks: HT, harness_fn: &'a mut H, @@ -301,7 +299,7 @@ pub mod child_signal_handlers { /// The function should only be called from a child crash handler. /// It will dereference the `data` pointer and assume it's valid. #[cfg(unix)] - #[allow(clippy::needless_pass_by_value)] + #[allow(clippy::needless_pass_by_value)] // nightly no longer requires this pub(crate) unsafe fn child_crash_handler( _signal: Signal, _info: &mut siginfo_t, @@ -325,9 +323,9 @@ pub mod child_signal_handlers { } #[cfg(unix)] - #[allow(clippy::needless_pass_by_value)] + #[allow(clippy::needless_pass_by_value)] // nightly no longer requires this pub(crate) unsafe fn child_timeout_handler( - _signal: Signal, + #[cfg(unix)] _signal: Signal, _info: &mut siginfo_t, _context: Option<&mut ucontext_t>, data: &mut InProcessForkExecutorGlobalData, diff --git a/libafl/src/executors/inprocess_fork/stateful.rs b/libafl/src/executors/inprocess_fork/stateful.rs index 027f272abd..82757511f7 100644 --- a/libafl/src/executors/inprocess_fork/stateful.rs +++ b/libafl/src/executors/inprocess_fork/stateful.rs @@ -38,7 +38,7 @@ where OT: ObserversTuple, S: State, { - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] /// The constructor for `InProcessForkExecutor` pub fn new( harness_fn: &'a mut H, @@ -126,7 +126,6 @@ where SP: ShMemProvider, Z: HasObjective, { - #[allow(unreachable_code)] #[inline] fn run_target( &mut self, @@ -166,7 +165,7 @@ where S: State, { /// Creates a new [`StatefulGenericInProcessForkExecutor`] with custom hooks - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn with_hooks( userhooks: HT, harness_fn: &'a mut H, diff --git a/libafl/src/executors/mod.rs b/libafl/src/executors/mod.rs index a15ce0e1ef..ed4f3c6634 100644 --- a/libafl/src/executors/mod.rs +++ b/libafl/src/executors/mod.rs @@ -45,7 +45,7 @@ pub mod hooks; #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub enum ExitKind { /// The run exited normally. @@ -71,7 +71,7 @@ pub enum ExitKind { #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub enum DiffExitKind { /// The run exited normally. diff --git a/libafl/src/feedbacks/capture_feedback.rs b/libafl/src/feedbacks/capture_feedback.rs index ea112e264e..c7d37b89cc 100644 --- a/libafl/src/feedbacks/capture_feedback.rs +++ b/libafl/src/feedbacks/capture_feedback.rs @@ -41,7 +41,6 @@ where S: HasCorpus + HasMetadata, I: Debug + Serialize + DeserializeOwned + Default + 'static + Clone, { - #[allow(clippy::wrong_self_convention)] #[inline] fn is_interesting( &mut self, diff --git a/libafl/src/feedbacks/concolic.rs b/libafl/src/feedbacks/concolic.rs index 93cdd658f2..79b99ba99a 100644 --- a/libafl/src/feedbacks/concolic.rs +++ b/libafl/src/feedbacks/concolic.rs @@ -31,7 +31,6 @@ pub struct ConcolicFeedback<'map> { impl<'map> ConcolicFeedback<'map> { /// Creates a concolic feedback from an observer - #[allow(unused)] #[must_use] pub fn from_observer(observer: &ConcolicObserver<'map>) -> Self { Self { diff --git a/libafl/src/feedbacks/differential.rs b/libafl/src/feedbacks/differential.rs index 54c3f6ffc7..c5d537a5b3 100644 --- a/libafl/src/feedbacks/differential.rs +++ b/libafl/src/feedbacks/differential.rs @@ -145,7 +145,6 @@ where OT: MatchName, C: DiffComparator, { - #[allow(clippy::wrong_self_convention)] fn is_interesting( &mut self, _state: &mut S, diff --git a/libafl/src/feedbacks/list.rs b/libafl/src/feedbacks/list.rs index d1590a957d..0a1f76b256 100644 --- a/libafl/src/feedbacks/list.rs +++ b/libafl/src/feedbacks/list.rs @@ -129,7 +129,6 @@ where S: HasNamedMetadata, T: Debug + Eq + Hash + for<'a> Deserialize<'a> + Serialize + Default + Copy + 'static, { - #[allow(clippy::wrong_self_convention)] fn is_interesting( &mut self, state: &mut S, diff --git a/libafl/src/feedbacks/map.rs b/libafl/src/feedbacks/map.rs index e54269a7cf..7e8cb9700a 100644 --- a/libafl/src/feedbacks/map.rs +++ b/libafl/src/feedbacks/map.rs @@ -216,7 +216,7 @@ where /// A testcase metadata holding a list of indexes of a map #[derive(Debug, Serialize, Deserialize)] -#[allow(clippy::unsafe_derive_deserialize)] // for SerdeAny +#[expect(clippy::unsafe_derive_deserialize)] // for SerdeAny pub struct MapIndexesMetadata { /// The list of indexes. pub list: Vec, @@ -261,7 +261,7 @@ impl MapIndexesMetadata { /// A testcase metadata holding a list of indexes of a map #[derive(Debug, Serialize, Deserialize)] -#[allow(clippy::unsafe_derive_deserialize)] // for SerdeAny +#[expect(clippy::unsafe_derive_deserialize)] // for SerdeAny pub struct MapNoveltiesMetadata { /// A `list` of novelties. pub list: Vec, @@ -296,7 +296,7 @@ impl MapNoveltiesMetadata { /// The state of [`MapFeedback`] #[derive(Default, Serialize, Deserialize, Clone, Debug)] -#[allow(clippy::unsafe_derive_deserialize)] // for SerdeAny +#[expect(clippy::unsafe_derive_deserialize)] // for SerdeAny pub struct MapFeedbackMetadata { /// Contains information about untouched entries pub history_map: Vec, @@ -374,7 +374,7 @@ pub struct MapFeedback { #[cfg(feature = "track_hit_feedbacks")] last_result: Option, /// Phantom Data of Reducer - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] phantom: PhantomData (N, O, R)>, } @@ -543,8 +543,6 @@ where OT: MatchName, S: HasNamedMetadata + UsesInput, { - #[allow(clippy::wrong_self_convention)] - #[allow(clippy::needless_range_loop)] fn is_interesting( &mut self, state: &mut S, @@ -564,7 +562,7 @@ impl Named for MapFeedback { } } -#[allow(clippy::ptr_arg)] +#[expect(clippy::ptr_arg)] fn create_stats_name(name: &Cow<'static, str>) -> Cow<'static, str> { if name.chars().all(char::is_lowercase) { name.clone() @@ -616,8 +614,6 @@ where O: MapObserver + for<'a> AsSlice<'a, Entry = u8> + for<'a> AsIter<'a, Item = u8>, C: CanTrack + AsRef, { - #[allow(clippy::wrong_self_convention)] - #[allow(clippy::needless_range_loop)] fn is_interesting_u8_simd_optimized(&mut self, state: &mut S, observers: &OT) -> bool where S: HasNamedMetadata, @@ -739,9 +735,6 @@ where N: IsNovel, C: AsRef, { - #[allow(clippy::wrong_self_convention)] - #[allow(clippy::needless_range_loop)] - #[allow(clippy::trivially_copy_pass_by_ref)] fn is_interesting_default(&mut self, state: &mut S, observers: &OT) -> bool where S: HasNamedMetadata, diff --git a/libafl/src/feedbacks/mod.rs b/libafl/src/feedbacks/mod.rs index 5a2e463583..5fbf13f64a 100644 --- a/libafl/src/feedbacks/mod.rs +++ b/libafl/src/feedbacks/mod.rs @@ -71,7 +71,6 @@ pub trait StateInitializer { /// indicating the "interestingness" of the last run. pub trait Feedback: StateInitializer + Named { /// `is_interesting ` return if an input is worth the addition to the corpus - #[allow(clippy::wrong_self_convention)] fn is_interesting( &mut self, _state: &mut S, @@ -86,8 +85,6 @@ pub trait Feedback: StateInitializer + Named { /// Returns if the result of a run is interesting and the value input should be stored in a corpus. /// It also keeps track of introspection stats. #[cfg(feature = "introspection")] - #[allow(clippy::too_many_arguments)] - #[allow(clippy::wrong_self_convention)] fn is_interesting_introspection( &mut self, state: &mut S, @@ -135,7 +132,6 @@ pub trait Feedback: StateInitializer + Named { /// /// Precondition: `testcase` must contain an input. #[inline] - #[allow(unused_variables)] fn append_metadata( &mut self, _state: &mut S, @@ -220,7 +216,6 @@ where B: Feedback, FL: FeedbackLogic, { - #[allow(clippy::wrong_self_convention)] fn is_interesting( &mut self, state: &mut S, @@ -247,7 +242,6 @@ where } #[cfg(feature = "introspection")] - #[allow(clippy::wrong_self_convention)] fn is_interesting_introspection( &mut self, state: &mut S, @@ -640,7 +634,6 @@ impl Feedback for NotFeedback where A: Feedback, { - #[allow(clippy::wrong_self_convention)] fn is_interesting( &mut self, state: &mut S, @@ -840,7 +833,6 @@ impl Feedback for ExitKindFeedback where L: ExitKindLogic, { - #[allow(clippy::wrong_self_convention)] fn is_interesting( &mut self, _state: &mut S, @@ -977,7 +969,6 @@ impl StateInitializer for ConstFeedback {} impl Feedback for ConstFeedback { #[inline] - #[allow(clippy::wrong_self_convention)] fn is_interesting( &mut self, _state: &mut S, diff --git a/libafl/src/feedbacks/nautilus.rs b/libafl/src/feedbacks/nautilus.rs index 5cc4986a5a..b070d57c9e 100644 --- a/libafl/src/feedbacks/nautilus.rs +++ b/libafl/src/feedbacks/nautilus.rs @@ -96,7 +96,6 @@ where S: HasMetadata + HasCorpus, S::Corpus: Corpus, { - #[allow(clippy::wrong_self_convention)] fn is_interesting( &mut self, _state: &mut S, diff --git a/libafl/src/feedbacks/new_hash_feedback.rs b/libafl/src/feedbacks/new_hash_feedback.rs index b33d14790e..5fa7a4b825 100644 --- a/libafl/src/feedbacks/new_hash_feedback.rs +++ b/libafl/src/feedbacks/new_hash_feedback.rs @@ -32,7 +32,7 @@ pub trait HashSetState { /// The state of [`NewHashFeedback`] #[derive(Default, Serialize, Deserialize, Clone, Debug)] -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] pub struct NewHashFeedbackMetadata { /// Contains information about untouched entries hash_set: HashSet, @@ -104,7 +104,6 @@ impl NewHashFeedback where O: ObserverWithHashField + Named, { - #[allow(clippy::wrong_self_convention)] fn has_interesting_backtrace_hash_observation( &mut self, state: &mut S, @@ -156,7 +155,6 @@ where OT: MatchName, S: HasNamedMetadata, { - #[allow(clippy::wrong_self_convention)] fn is_interesting( &mut self, state: &mut S, diff --git a/libafl/src/feedbacks/stdio.rs b/libafl/src/feedbacks/stdio.rs index b4a140e228..2d3106b761 100644 --- a/libafl/src/feedbacks/stdio.rs +++ b/libafl/src/feedbacks/stdio.rs @@ -19,8 +19,7 @@ use crate::{ /// Metadata for [`StdOutToMetadataFeedback`]. #[derive(Debug, Serialize, Deserialize)] pub struct StdOutMetadata { - #[allow(missing_docs)] - pub stdout: String, + stdout: String, } impl_serdeany!(StdOutMetadata); @@ -104,8 +103,7 @@ impl StdOutToMetadataFeedback { /// Metadata for [`StdErrToMetadataFeedback`]. #[derive(Debug, Serialize, Deserialize)] pub struct StdErrMetadata { - #[allow(missing_docs)] - pub stderr: String, + stderr: String, } impl_serdeany!(StdErrMetadata); diff --git a/libafl/src/fuzzer/mod.rs b/libafl/src/fuzzer/mod.rs index 44804c7178..5b5728e3b0 100644 --- a/libafl/src/fuzzer/mod.rs +++ b/libafl/src/fuzzer/mod.rs @@ -78,7 +78,6 @@ pub trait ExecutionProcessor { ) -> Result; /// Process `ExecuteInputResult`. Add to corpus, solution or ignore - #[allow(clippy::too_many_arguments)] fn process_execution( &mut self, state: &mut S, diff --git a/libafl/src/inputs/encoded.rs b/libafl/src/inputs/encoded.rs index e3f5897e18..b602cd0e94 100644 --- a/libafl/src/inputs/encoded.rs +++ b/libafl/src/inputs/encoded.rs @@ -34,7 +34,6 @@ where /// Trait to decode encoded input to bytes pub trait InputDecoder { /// Decode encoded input to bytes - #[allow(clippy::ptr_arg)] // we reuse the alloced `Vec` fn decode(&self, input: &EncodedInput, bytes: &mut Vec) -> Result<(), Error>; } diff --git a/libafl/src/inputs/generalized.rs b/libafl/src/inputs/generalized.rs index 48c7e09b45..91b7c00365 100644 --- a/libafl/src/inputs/generalized.rs +++ b/libafl/src/inputs/generalized.rs @@ -26,7 +26,7 @@ pub enum GeneralizedItem { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct GeneralizedInputMetadata { generalized: Vec, diff --git a/libafl/src/lib.rs b/libafl/src/lib.rs index 2ed3ed5371..58464b3ee6 100644 --- a/libafl/src/lib.rs +++ b/libafl/src/lib.rs @@ -9,43 +9,41 @@ Welcome to `LibAFL` #![cfg_attr(nightly, feature(specialization))] // For `std::simd` #![cfg_attr(nightly, feature(portable_simd))] -#![cfg_attr(not(test), warn( - missing_debug_implementations, - missing_docs, - //trivial_casts, - trivial_numeric_casts, - unused_extern_crates, - unused_import_braces, - unused_qualifications, - //unused_results -))] -#![cfg_attr(test, deny( - missing_debug_implementations, - missing_docs, - //trivial_casts, - trivial_numeric_casts, - unused_extern_crates, - unused_import_braces, - unused_qualifications, - unused_must_use, - //unused_results -))] +#![cfg_attr( + not(test), + warn( + missing_debug_implementations, + missing_docs, + trivial_numeric_casts, + unused_extern_crates, + unused_import_braces, + unused_qualifications, + ) +)] #![cfg_attr( test, deny( bad_style, dead_code, improper_ctypes, - non_shorthand_field_patterns, + missing_debug_implementations, + missing_docs, no_mangle_generic_items, + non_shorthand_field_patterns, overflowing_literals, path_statements, patterns_in_fns_without_body, + trivial_numeric_casts, unconditional_recursion, - unused, + unfulfilled_lint_expectations, unused_allocation, unused_comparisons, + unused_extern_crates, + unused_import_braces, + unused_must_use, unused_parens, + unused_qualifications, + unused, while_true ) )] @@ -59,7 +57,7 @@ pub extern crate alloc; // Re-export derive(SerdeAny) #[cfg(feature = "derive")] -#[allow(unused_imports)] +#[expect(unused_imports)] #[macro_use] extern crate libafl_derive; #[cfg(feature = "derive")] @@ -131,7 +129,6 @@ mod tests { }; #[test] - #[allow(clippy::similar_names)] fn test_fuzzer() { // # Safety // No concurrency per testcase diff --git a/libafl/src/monitors/mod.rs b/libafl/src/monitors/mod.rs index 0a6cf0f6bc..48d31e1005 100644 --- a/libafl/src/monitors/mod.rs +++ b/libafl/src/monitors/mod.rs @@ -174,7 +174,7 @@ impl UserStatsValue { } /// Divide by the number of elements - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] pub fn stats_div(&mut self, divisor: usize) -> Option { match self { Self::Number(x) => Some(Self::Float(*x as f64 / divisor as f64)), @@ -186,7 +186,7 @@ impl UserStatsValue { } /// min user stats with the other - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] pub fn stats_max(&mut self, other: &Self) -> Option { match (self, other) { (Self::Number(x), Self::Number(y)) => { @@ -224,7 +224,7 @@ impl UserStatsValue { } /// min user stats with the other - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] pub fn stats_min(&mut self, other: &Self) -> Option { match (self, other) { (Self::Number(x), Self::Number(y)) => { @@ -262,7 +262,7 @@ impl UserStatsValue { } /// add user stats with the other - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] pub fn stats_add(&mut self, other: &Self) -> Option { match (self, other) { (Self::Number(x), Self::Number(y)) => Some(Self::Number(*x + *y)), @@ -412,7 +412,7 @@ impl ClientStats { } /// Get the calculated executions per second for this client - #[allow(clippy::cast_precision_loss, clippy::cast_sign_loss)] + #[expect(clippy::cast_precision_loss, clippy::cast_sign_loss)] #[cfg(feature = "afl_exec_sec")] pub fn execs_per_sec(&mut self, cur_time: Duration) -> f64 { if self.executions == 0 { @@ -443,7 +443,7 @@ impl ClientStats { } /// Get the calculated executions per second for this client - #[allow(clippy::cast_precision_loss, clippy::cast_sign_loss)] + #[expect(clippy::cast_precision_loss, clippy::cast_sign_loss)] #[cfg(not(feature = "afl_exec_sec"))] pub fn execs_per_sec(&mut self, cur_time: Duration) -> f64 { if self.executions == 0 { @@ -535,7 +535,6 @@ pub trait Monitor { } /// Executions per second - #[allow(clippy::cast_sign_loss)] #[inline] fn execs_per_sec(&mut self) -> f64 { let cur_time = current_time(); @@ -1234,7 +1233,7 @@ impl ClientPerfMonitor { #[cfg(feature = "introspection")] impl fmt::Display for ClientPerfMonitor { - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { // Calculate the elapsed time from the monitor let elapsed: f64 = self.elapsed_cycles() as f64; diff --git a/libafl/src/monitors/prometheus.rs b/libafl/src/monitors/prometheus.rs index 8dcf8d769d..e3f01f01ee 100644 --- a/libafl/src/monitors/prometheus.rs +++ b/libafl/src/monitors/prometheus.rs @@ -117,7 +117,6 @@ where self.aggregator.aggregate(name, &self.client_stats); } - #[allow(clippy::cast_sign_loss)] fn display(&mut self, event_msg: &str, sender_id: ClientId) { // Update the prometheus metrics // The gauges must take signed i64's, with max value of 2^63-1 so it is @@ -196,7 +195,7 @@ where for (key, val) in &self.aggregator.aggregated { // print global aggregated custom stats write!(global_fmt, ", {key}: {val}").unwrap(); - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] let value: f64 = match val { UserStatsValue::Number(n) => *n as f64, UserStatsValue::Float(f) => *f, @@ -303,7 +302,7 @@ where write!(fmt, ", {key}: {val}").unwrap(); // Update metrics added to the user_stats hashmap by feedback event-fires // You can filter for each custom stat in promQL via labels of both the stat name and client id - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] let value: f64 = match val.value() { UserStatsValue::Number(n) => *n as f64, UserStatsValue::Float(f) => *f, diff --git a/libafl/src/monitors/tui/mod.rs b/libafl/src/monitors/tui/mod.rs index 77cbbe0ee9..0e3d93f232 100644 --- a/libafl/src/monitors/tui/mod.rs +++ b/libafl/src/monitors/tui/mod.rs @@ -32,7 +32,7 @@ use typed_builder::TypedBuilder; use super::{ClientPerfMonitor, PerfFeature}; use crate::monitors::{Aggregator, AggregatorOps, ClientStats, Monitor, UserStats, UserStatsValue}; -#[allow(missing_docs)] +#[expect(missing_docs)] pub mod ui; use ui::TuiUi; @@ -143,7 +143,7 @@ pub struct PerfTuiContext { #[cfg(feature = "introspection")] impl PerfTuiContext { /// Get the data for performance metrics - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] pub fn grab_data(&mut self, m: &ClientPerfMonitor) { // Calculate the elapsed time from the monitor let elapsed: f64 = m.elapsed_cycles() as f64; @@ -230,7 +230,7 @@ impl ProcessTiming { } /// The geometry of a single data point -#[allow(missing_docs)] +#[expect(missing_docs)] #[derive(Debug, Default, Clone)] pub struct ItemGeometry { pub pending: u64, @@ -251,7 +251,7 @@ impl ItemGeometry { } /// The context for a single client tracked in this [`TuiMonitor`] -#[allow(missing_docs)] +#[expect(missing_docs)] #[derive(Debug, Default, Clone)] pub struct ClientTuiContext { pub corpus: u64, @@ -322,7 +322,7 @@ impl ClientTuiContext { } /// The [`TuiContext`] for this [`TuiMonitor`] -#[allow(missing_docs)] +#[expect(missing_docs)] #[derive(Debug, Clone)] pub struct TuiContext { pub graphs: Vec, @@ -393,7 +393,7 @@ pub struct TuiMonitor { } impl From for TuiMonitor { - #[allow(deprecated)] + #[expect(deprecated)] fn from(builder: TuiMonitorConfig) -> Self { Self::with_time( TuiUi::with_version(builder.title, builder.version, builder.enhanced_graphics), @@ -427,7 +427,7 @@ impl Monitor for TuiMonitor { self.start_time = time; } - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] fn display(&mut self, event_msg: &str, sender_id: ClientId) { let cur_time = current_time(); @@ -523,7 +523,7 @@ impl TuiMonitor { note = "Please use TuiMonitor::builder() instead of creating TuiUi directly." )] #[must_use] - #[allow(deprecated)] + #[expect(deprecated)] pub fn new(tui_ui: TuiUi) -> Self { Self::with_time(tui_ui, current_time()) } diff --git a/libafl/src/monitors/tui/ui.rs b/libafl/src/monitors/tui/ui.rs index e4c07c9116..e209909f40 100644 --- a/libafl/src/monitors/tui/ui.rs +++ b/libafl/src/monitors/tui/ui.rs @@ -129,7 +129,7 @@ impl TuiUi { } } - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] fn draw_overall_ui(&mut self, f: &mut Frame, app: &Arc>, area: Rect) { let top_layout = Layout::default() .direction(Direction::Vertical) @@ -254,7 +254,7 @@ impl TuiUi { )) .borders(Borders::ALL); - #[allow(unused_mut)] + #[allow(unused_mut)] // cfg dependent let mut client_area = client_block.inner(area); f.render_widget(client_block, area); @@ -292,7 +292,7 @@ impl TuiUi { self.draw_client_results_text(f, app, right_bottom_layout); } - #[allow(clippy::too_many_lines, clippy::cast_precision_loss)] + #[expect(clippy::too_many_lines, clippy::cast_precision_loss)] fn draw_time_chart( &mut self, title: &str, @@ -776,7 +776,7 @@ impl TuiUi { .widths([Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)]); f.render_widget(table, area); } - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] fn draw_logs(&mut self, f: &mut Frame, app: &Arc>, area: Rect) { let app = app.read().unwrap(); let logs: Vec = app diff --git a/libafl/src/mutators/gramatron.rs b/libafl/src/mutators/gramatron.rs index 987a81f210..605c0f2358 100644 --- a/libafl/src/mutators/gramatron.rs +++ b/libafl/src/mutators/gramatron.rs @@ -83,7 +83,7 @@ where #[derive(Debug, Serialize, Deserialize)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct GramatronIdxMapMetadata { /// The map containing a vec for each terminal @@ -95,7 +95,6 @@ libafl_bolts::impl_serdeany!(GramatronIdxMapMetadata); impl GramatronIdxMapMetadata { /// Creates a new [`struct@GramatronIdxMapMetadata`]. #[must_use] - #[allow(clippy::or_fun_call)] pub fn new(input: &GramatronInput) -> Self { let mut map = HashMap::default(); for i in 0..input.terminals().len() { @@ -226,12 +225,11 @@ where return Ok(MutationResult::Skipped); }; - #[allow(clippy::cast_sign_loss, clippy::pedantic)] - let mut first = state.rand_mut().below(minus_one) as i64; - #[allow(clippy::cast_sign_loss, clippy::pedantic)] - let mut second = state - .rand_mut() - .between(first as usize + 1, chosen_nums - 1) as i64; + let first = state.rand_mut().below(minus_one); + let second = state.rand_mut().between(first + 1, chosen_nums - 1); + + let mut first: isize = first.try_into().unwrap(); + let mut second: isize = second.try_into().unwrap(); let mut idx_1 = 0; let mut idx_2 = 0; diff --git a/libafl/src/mutators/mod.rs b/libafl/src/mutators/mod.rs index f3875c7b43..22dec0d64f 100644 --- a/libafl/src/mutators/mod.rs +++ b/libafl/src/mutators/mod.rs @@ -77,7 +77,7 @@ impl From for MutationId { } impl From for MutationId { - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] fn from(value: i32) -> Self { debug_assert!(value >= 0); MutationId(value as usize) diff --git a/libafl/src/mutators/mopt_mutator.rs b/libafl/src/mutators/mopt_mutator.rs index ae90267358..c3d0a827a9 100644 --- a/libafl/src/mutators/mopt_mutator.rs +++ b/libafl/src/mutators/mopt_mutator.rs @@ -29,7 +29,7 @@ use crate::{ #[derive(Serialize, Deserialize, Clone)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct MOpt { /// Random number generator @@ -189,7 +189,6 @@ impl MOpt { } /// initialize pso - #[allow(clippy::cast_precision_loss)] pub fn pso_initialize(&mut self) -> Result<(), Error> { if self.g_now > self.g_max { self.g_now = 0.0; @@ -245,7 +244,7 @@ impl MOpt { /// Update the `PSO` algorithm parameters /// See - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] pub fn pso_update(&mut self) -> Result<(), Error> { self.g_now += 1.0; if self.g_now > self.g_max { @@ -311,7 +310,6 @@ impl MOpt { /// This function is used to decide the operator that we want to apply next /// see - #[allow(clippy::cast_precision_loss)] pub fn select_algorithm(&mut self) -> Result { let mut res = 0; let mut sentry = 0; @@ -381,7 +379,7 @@ where self.scheduled_mutate(state, input) } - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] fn post_exec(&mut self, state: &mut S, _new_corpus_id: Option) -> Result<(), Error> { let before = self.finds_before; let after = state.corpus().count() + state.solutions().count(); @@ -430,7 +428,6 @@ where } } - #[allow(clippy::cast_lossless)] if mopt.pilot_time > mopt.period_pilot { let new_finds = mopt.total_finds - mopt.finds_until_last_swarm; let f = (new_finds as f64) / ((mopt.pilot_time as f64) / (PERIOD_PILOT_COEF)); diff --git a/libafl/src/mutators/mutations.rs b/libafl/src/mutators/mutations.rs index 6cf41e1b37..e9f729a0d9 100644 --- a/libafl/src/mutators/mutations.rs +++ b/libafl/src/mutators/mutations.rs @@ -340,7 +340,7 @@ macro_rules! add_mutator_impl { #[derive(Default, Debug)] pub struct $name; - #[allow(trivial_numeric_casts)] + #[allow(trivial_numeric_casts)] // only for some calls of the macro impl Mutator for $name where S: HasRand, @@ -413,7 +413,7 @@ macro_rules! interesting_mutator_impl { S: HasRand, I: HasMutatorBytes, { - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] fn mutate(&mut self, state: &mut S, input: &mut I) -> Result { if input.bytes().len() < size_of::<$size>() { Ok(MutationResult::Skipped) @@ -882,7 +882,7 @@ pub struct BytesSwapMutator { tmp_buf: Vec, } -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] impl Mutator for BytesSwapMutator where S: HasRand, @@ -1475,7 +1475,6 @@ fn locate_diffs(this: &[u8], other: &[u8]) -> (i64, i64) { let mut first_diff: i64 = -1; let mut last_diff: i64 = -1; for (i, (this_el, other_el)) in this.iter().zip(other.iter()).enumerate() { - #[allow(clippy::cast_possible_wrap)] if this_el != other_el { if first_diff < 0 { first_diff = i64::try_from(i).unwrap(); @@ -1497,7 +1496,7 @@ where ::Input: HasMutatorBytes, I: HasMutatorBytes, { - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] fn mutate(&mut self, state: &mut S, input: &mut I) -> Result { let id = random_corpus_id_with_disabled!(state.corpus(), state.rand_mut()); // We don't want to use the testcase we're already using for splicing diff --git a/libafl/src/mutators/numeric.rs b/libafl/src/mutators/numeric.rs index 748fd64faf..47b1513a88 100644 --- a/libafl/src/mutators/numeric.rs +++ b/libafl/src/mutators/numeric.rs @@ -150,7 +150,7 @@ macro_rules! impl_numeric_cast_randomize { } #[inline] - #[allow(trivial_numeric_casts, clippy::cast_possible_wrap)] + #[allow(trivial_numeric_casts, clippy::cast_possible_wrap)] // only for some macro calls fn randomize(&mut self, rand: &mut R) { *self = rand.next() as $t; } @@ -191,7 +191,7 @@ macro_rules! impl_numeric_128_bits_randomize { } #[inline] - #[allow(trivial_numeric_casts, clippy::cast_possible_wrap)] + #[allow(trivial_numeric_casts, clippy::cast_possible_wrap)] // only for some macro calls fn randomize(&mut self, rand: &mut R) { *self = (u128::from(rand.next()) << 64 | u128::from(rand.next())) as $t; } diff --git a/libafl/src/mutators/scheduled.rs b/libafl/src/mutators/scheduled.rs index dc3d76a02e..79c6cfd3fd 100644 --- a/libafl/src/mutators/scheduled.rs +++ b/libafl/src/mutators/scheduled.rs @@ -30,7 +30,7 @@ use crate::{ #[derive(Debug, Serialize, Deserialize)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct LogMutationMetadata { /// A list of logs diff --git a/libafl/src/mutators/token_mutations.rs b/libafl/src/mutators/token_mutations.rs index 00c8a0975f..5d5d3c8e12 100644 --- a/libafl/src/mutators/token_mutations.rs +++ b/libafl/src/mutators/token_mutations.rs @@ -36,7 +36,7 @@ use crate::{ }; /// A state metadata holding a list of tokens -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct Tokens { // We keep a vec and a set, set for faster deduplication, vec for access @@ -145,7 +145,7 @@ impl Tokens { /// Adds a token to a dictionary, checking it is not a duplicate /// Returns `false` if the token was already present and did not get added. - #[allow(clippy::ptr_arg)] + #[expect(clippy::ptr_arg)] pub fn add_token(&mut self, token: &Vec) -> bool { if !self.tokens_set.insert(token.clone()) { return false; @@ -437,7 +437,7 @@ where S: HasMetadata + HasRand + HasMaxSize, I: HasMutatorBytes, { - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] fn mutate(&mut self, state: &mut S, input: &mut I) -> Result { let size = input.bytes().len(); let Some(size) = NonZero::new(size) else { @@ -638,7 +638,7 @@ where S: HasMetadata + HasRand + HasMaxSize, I: HasMutatorBytes, { - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] fn mutate(&mut self, state: &mut S, input: &mut I) -> Result { let Some(size) = NonZero::new(input.bytes().len()) else { return Ok(MutationResult::Skipped); @@ -847,12 +847,13 @@ impl AFLppRedQueen { } /// Cmplog Pattern Matching - #[allow(clippy::cast_sign_loss)] - #[allow(clippy::too_many_arguments)] - #[allow(clippy::too_many_lines)] - #[allow(clippy::cast_possible_wrap)] - #[allow(clippy::if_not_else)] - #[allow(clippy::cast_precision_loss)] + #[expect( + clippy::cast_sign_loss, + clippy::too_many_arguments, + clippy::too_many_lines, + clippy::cast_possible_wrap, + clippy::cast_precision_loss + )] pub fn cmp_extend_encoding( &self, pattern: u64, @@ -1244,7 +1245,7 @@ impl AFLppRedQueen { } /// rtn part from AFL++ - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn rtn_extend_encoding( &self, pattern: &[u8], @@ -1307,8 +1308,7 @@ where S: HasMetadata + HasRand + HasMaxSize + HasCorpus + HasCurrentCorpusId, I: HasMutatorBytes + From>, { - #[allow(clippy::needless_range_loop)] - #[allow(clippy::too_many_lines)] + #[expect(clippy::needless_range_loop, clippy::too_many_lines)] fn multi_mutate( &mut self, state: &mut S, @@ -1932,7 +1932,7 @@ impl AFLppRedQueen { } } - #[allow(clippy::needless_range_loop)] + #[expect(clippy::needless_range_loop)] fn try_add_autotokens(tokens: &mut Tokens, b: &[u8], shape: usize) { let mut cons_ff = 0; let mut cons_0 = 0; diff --git a/libafl/src/mutators/tuneable.rs b/libafl/src/mutators/tuneable.rs index 29b4647a10..c03e35e89e 100644 --- a/libafl/src/mutators/tuneable.rs +++ b/libafl/src/mutators/tuneable.rs @@ -25,7 +25,7 @@ use crate::{ #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct TuneableScheduledMutatorMetadata { /// The offsets of mutators to run, in order. Clear to fall back to random, @@ -137,7 +137,6 @@ where } else { // We will sample using the mutation probabilities. // Doing this outside of the original if branch to make the borrow checker happy. - #[allow(clippy::cast_precision_loss)] let coin = state.rand_mut().next_float() as f32; let metadata = TuneableScheduledMutatorMetadata::get_mut(state).unwrap(); @@ -156,7 +155,6 @@ where // Assumption: we can not reach this code path without previously adding this metadatum. let metadata = TuneableScheduledMutatorMetadata::get_mut(state).unwrap(); - #[allow(clippy::cast_possible_truncation)] if !metadata.mutation_ids.is_empty() { // using pre-set ids. let ret = metadata.mutation_ids[metadata.next_id.0]; @@ -174,7 +172,6 @@ where if !metadata.mutation_probabilities_cumulative.is_empty() { // We will sample using the mutation probabilities. // Doing this outside of the original if branch to make the borrow checker happy. - #[allow(clippy::cast_precision_loss)] let coin = state.rand_mut().next_float() as f32; let metadata = TuneableScheduledMutatorMetadata::get_mut(state).unwrap(); diff --git a/libafl/src/mutators/unicode/mod.rs b/libafl/src/mutators/unicode/mod.rs index d73e5fd58a..c719377736 100644 --- a/libafl/src/mutators/unicode/mod.rs +++ b/libafl/src/mutators/unicode/mod.rs @@ -24,9 +24,7 @@ use crate::{ }; /// Unicode category data, as used by string analysis and mutators. -#[allow(unused)] -#[allow(missing_docs)] -#[allow(clippy::redundant_static_lifetimes)] +#[expect(missing_docs, clippy::redundant_static_lifetimes)] pub mod unicode_categories; /// Input which contains the context necessary to perform unicode mutations diff --git a/libafl/src/observers/cmp.rs b/libafl/src/observers/cmp.rs index de35f6e1f3..58fb3dd738 100644 --- a/libafl/src/observers/cmp.rs +++ b/libafl/src/observers/cmp.rs @@ -88,7 +88,7 @@ impl CmpValues { #[derive(Debug, Default, Serialize, Deserialize)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct CmpValuesMetadata { /// A `list` of values. @@ -262,7 +262,6 @@ where fn post_exec(&mut self, state: &mut S, _input: &I, _exit_kind: &ExitKind) -> Result<(), Error> { if self.add_meta { - #[allow(clippy::option_if_let_else)] // we can't mutate state in a closure let meta = state.metadata_or_insert_with(CmpValuesMetadata::new); meta.add_from(self.usable_count(), self.cmp_map_mut()); @@ -359,7 +358,7 @@ struct cmp_map { #[derive(Debug, Default, Serialize, Deserialize)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct AFLppCmpValuesMetadata { /// The first map of `AFLppCmpLogVals` retrieved by running the un-mutated input diff --git a/libafl/src/observers/concolic/metadata.rs b/libafl/src/observers/concolic/metadata.rs index cb9d34a795..624baf66e6 100644 --- a/libafl/src/observers/concolic/metadata.rs +++ b/libafl/src/observers/concolic/metadata.rs @@ -6,7 +6,7 @@ use crate::observers::concolic::{serialization_format::MessageFileReader, SymExp /// A metadata holding a buffer of a concolic trace. #[derive(Default, Serialize, Deserialize, Debug)] -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] pub struct ConcolicMetadata { /// Constraints data buffer: Vec, diff --git a/libafl/src/observers/concolic/mod.rs b/libafl/src/observers/concolic/mod.rs index 9031b0f8aa..d4edf13ddc 100644 --- a/libafl/src/observers/concolic/mod.rs +++ b/libafl/src/observers/concolic/mod.rs @@ -57,8 +57,8 @@ impl From for Location { /// `SymExpr` represents a message in the serialization format. /// The messages in the format are a perfect mirror of the methods that are called on the runtime during execution. #[cfg(feature = "std")] -#[derive(Serialize, Deserialize, Debug, PartialEq)] #[allow(missing_docs)] +#[derive(Serialize, Deserialize, Debug, PartialEq)] pub enum SymExpr { InputByte { offset: usize, diff --git a/libafl/src/observers/concolic/serialization_format.rs b/libafl/src/observers/concolic/serialization_format.rs index 72735bb702..9c7bcba2ad 100644 --- a/libafl/src/observers/concolic/serialization_format.rs +++ b/libafl/src/observers/concolic/serialization_format.rs @@ -109,7 +109,7 @@ impl MessageFileReader { /// This transforms the given message from it's serialized form into its in-memory form, making relative references /// absolute and counting the `SymExprRef`s. - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] fn transform_message(&mut self, message: &mut SymExpr) -> SymExprRef { let ret = self.current_id; match message { @@ -283,7 +283,7 @@ impl MessageFileWriter { /// Writes a message to the stream and returns the [`SymExprRef`] that should be used to refer back to this message. /// May error when the underlying `Write` errors or when there is a serialization error. - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] pub fn write_message(&mut self, mut message: SymExpr) -> Result { let current_id = self.id_counter; match &mut message { diff --git a/libafl/src/observers/list.rs b/libafl/src/observers/list.rs index 752ab23f12..125e7db064 100644 --- a/libafl/src/observers/list.rs +++ b/libafl/src/observers/list.rs @@ -9,7 +9,6 @@ use crate::observers::Observer; /// A simple observer with a list of things. #[derive(Serialize, Deserialize, Debug)] #[serde(bound = "T: Serialize + for<'a> Deserialize<'a>")] -#[allow(clippy::unsafe_derive_deserialize)] pub struct ListObserver { name: Cow<'static, str>, /// The list diff --git a/libafl/src/observers/map/const_map.rs b/libafl/src/observers/map/const_map.rs index d383bc0cc3..ba2fe4ccce 100644 --- a/libafl/src/observers/map/const_map.rs +++ b/libafl/src/observers/map/const_map.rs @@ -20,7 +20,7 @@ use crate::{ /// Use a const size to speedup `Feedback::is_interesting` when the user can /// know the size of the map at compile time. #[derive(Serialize, Deserialize, Debug)] -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] pub struct ConstMapObserver<'a, T, const N: usize> { map: OwnedMutSizedSlice<'a, T, N>, initial: T, diff --git a/libafl/src/observers/map/hitcount_map.rs b/libafl/src/observers/map/hitcount_map.rs index 56a6dbfc6e..1e369b0882 100644 --- a/libafl/src/observers/map/hitcount_map.rs +++ b/libafl/src/observers/map/hitcount_map.rs @@ -95,7 +95,7 @@ where } #[inline] - #[allow(clippy::cast_ptr_alignment)] + #[expect(clippy::cast_ptr_alignment)] fn post_exec(&mut self, state: &mut S, input: &I, exit_kind: &ExitKind) -> Result<(), Error> { let mut map = self.as_slice_mut(); let mut len = map.len(); @@ -130,7 +130,7 @@ where let count_class_lookup_16 = &raw mut COUNT_CLASS_LOOKUP_16; // 2022-07: Adding `enumerate` here increases execution speed/register allocation on x86_64. - #[allow(clippy::unused_enumerate_index)] + #[expect(clippy::unused_enumerate_index)] for (_i, item) in map16[0..cnt].iter_mut().enumerate() { unsafe { let count_class_lookup_16 = &mut *count_class_lookup_16; @@ -357,7 +357,6 @@ where } #[inline] - #[allow(clippy::cast_ptr_alignment)] fn post_exec(&mut self, state: &mut S, input: &I, exit_kind: &ExitKind) -> Result<(), Error> { for mut item in self.as_iter_mut() { *item = unsafe { *COUNT_CLASS_LOOKUP.get_unchecked((*item) as usize) }; diff --git a/libafl/src/observers/map/mod.rs b/libafl/src/observers/map/mod.rs index d73dedfbb3..3d85a867bf 100644 --- a/libafl/src/observers/map/mod.rs +++ b/libafl/src/observers/map/mod.rs @@ -437,7 +437,7 @@ where /// that will get updated by the target. /// A well-known example is the AFL-Style coverage map. #[derive(Clone, Serialize, Deserialize, Debug)] -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] pub struct StdMapObserver<'a, T, const DIFFERENTIAL: bool> { map: OwnedMutSlice<'a, T>, initial: T, diff --git a/libafl/src/observers/map/multi_map.rs b/libafl/src/observers/map/multi_map.rs index 7c0bf533b9..ce7a04f786 100644 --- a/libafl/src/observers/map/multi_map.rs +++ b/libafl/src/observers/map/multi_map.rs @@ -22,7 +22,6 @@ use crate::{ /// The Multi Map Observer merge different maps into one observer #[derive(Serialize, Deserialize, Debug)] -#[allow(clippy::unsafe_derive_deserialize)] pub struct MultiMapObserver<'a, T, const DIFFERENTIAL: bool> { maps: Vec>, intervals: IntervalTree, diff --git a/libafl/src/observers/map/owned_map.rs b/libafl/src/observers/map/owned_map.rs index 66d0fc7e8b..4ade2a948f 100644 --- a/libafl/src/observers/map/owned_map.rs +++ b/libafl/src/observers/map/owned_map.rs @@ -18,7 +18,6 @@ use crate::{ /// Exact copy of `StdMapObserver` that owns its map #[derive(Serialize, Deserialize, Debug, Clone)] -#[allow(clippy::unsafe_derive_deserialize)] pub struct OwnedMapObserver { map: Vec, initial: T, diff --git a/libafl/src/observers/map/variable_map.rs b/libafl/src/observers/map/variable_map.rs index ec1a5feda3..d98cca17dc 100644 --- a/libafl/src/observers/map/variable_map.rs +++ b/libafl/src/observers/map/variable_map.rs @@ -21,7 +21,7 @@ use crate::{ /// Overlooking a variable bitmap #[derive(Serialize, Deserialize, Debug)] -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] pub struct VariableMapObserver<'a, T> { map: OwnedMutSlice<'a, T>, size: OwnedMutPtr, diff --git a/libafl/src/observers/mod.rs b/libafl/src/observers/mod.rs index d312b1e693..6cd5c103ab 100644 --- a/libafl/src/observers/mod.rs +++ b/libafl/src/observers/mod.rs @@ -201,7 +201,7 @@ pub trait ObserverWithHashField { /// cleanup in `Observer::post_exec`. For individual executions, use /// `DifferentialObserver::{pre,post}_observe_{first,second}` as necessary for first and second, /// respectively. -#[allow(unused_variables)] +#[expect(unused_variables)] pub trait DifferentialObserver: Observer { /// Perform an operation with the first set of observers before they are `pre_exec`'d. fn pre_observe_first(&mut self, observers: &mut OTA) -> Result<(), Error> { @@ -309,7 +309,6 @@ mod instant_serializer { use serde::{Deserialize, Deserializer, Serialize, Serializer}; - #[allow(clippy::trivially_copy_pass_by_ref)] pub fn serialize(instant: &Instant, serializer: S) -> Result where S: Serializer, diff --git a/libafl/src/observers/stacktrace.rs b/libafl/src/observers/stacktrace.rs index 9c6b13958e..c379db4bce 100644 --- a/libafl/src/observers/stacktrace.rs +++ b/libafl/src/observers/stacktrace.rs @@ -17,7 +17,7 @@ use std::{ use backtrace::Backtrace; use libafl_bolts::{ownedref::OwnedRefMut, Named}; -#[allow(unused_imports)] +#[allow(unused_imports)] // expect breaks here for some reason #[cfg(feature = "casr")] use libcasr::{ asan::AsanStacktrace, @@ -111,7 +111,6 @@ pub enum HarnessType { } /// An observer looking at the backtrace after the harness crashes -#[allow(clippy::unsafe_derive_deserialize)] #[derive(Serialize, Deserialize, Debug)] pub struct BacktraceObserver<'a> { observer_name: Cow<'static, str>, diff --git a/libafl/src/observers/value.rs b/libafl/src/observers/value.rs index 47fcde05a2..37d0a35960 100644 --- a/libafl/src/observers/value.rs +++ b/libafl/src/observers/value.rs @@ -23,7 +23,7 @@ use crate::{ /// The intent is that the value is something with interior mutability which the target could write to even though this /// observer has a reference to it. Use [`RefCellValueObserver`] if using a [`RefCell`] around the value. #[derive(Serialize, Deserialize, Debug)] -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] pub struct ValueObserver<'a, T> { /// The name of this observer. name: Cow<'static, str>, @@ -83,7 +83,7 @@ impl ObserverWithHashField for ValueObserver<'_, T> { /// A simple observer with a single [`RefCell`]'d value. #[derive(Serialize, Deserialize, Debug)] -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] pub struct RefCellValueObserver<'a, T> { /// The name of this observer. name: Cow<'static, str>, diff --git a/libafl/src/schedulers/accounting.rs b/libafl/src/schedulers/accounting.rs index 13c167cd99..23bb60d2c0 100644 --- a/libafl/src/schedulers/accounting.rs +++ b/libafl/src/schedulers/accounting.rs @@ -26,7 +26,7 @@ use crate::{ #[derive(Debug, Serialize, Deserialize)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct AccountingIndexesMetadata { /// The list of indexes. @@ -77,7 +77,7 @@ impl AccountingIndexesMetadata { #[derive(Debug, Serialize, Deserialize)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct TopAccountingMetadata { /// map index -> corpus index @@ -178,8 +178,7 @@ where O: CanTrack, { /// Update the `Corpus` score - #[allow(clippy::unused_self)] - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_possible_wrap)] pub fn update_accounting_score(&self, state: &mut S, id: CorpusId) -> Result<(), Error> where S: HasCorpus + HasMetadata, @@ -267,7 +266,6 @@ where } /// Cull the `Corpus` - #[allow(clippy::unused_self)] pub fn accounting_cull(&self, state: &S) -> Result<(), Error> where S: HasCorpus + HasMetadata, diff --git a/libafl/src/schedulers/minimizer.rs b/libafl/src/schedulers/minimizer.rs index bbee468aa8..17f6dcc307 100644 --- a/libafl/src/schedulers/minimizer.rs +++ b/libafl/src/schedulers/minimizer.rs @@ -26,7 +26,7 @@ pub const DEFAULT_SKIP_NON_FAVORED_PROB: f64 = 0.95; #[derive(Debug, Serialize, Deserialize)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct IsFavoredMetadata {} @@ -36,7 +36,7 @@ libafl_bolts::impl_serdeany!(IsFavoredMetadata); #[derive(Debug, Serialize, Deserialize)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct TopRatedsMetadata { /// map index -> corpus index @@ -248,8 +248,7 @@ where M: for<'a> AsIter<'a, Item = usize> + SerdeAny + HasRefCnt, { /// Update the [`Corpus`] score using the [`MinimizerScheduler`] - #[allow(clippy::unused_self)] - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_possible_wrap)] pub fn update_score(&self, state: &mut S, id: CorpusId) -> Result<(), Error> where F: TestcaseScore, @@ -327,7 +326,6 @@ where } /// Cull the [`Corpus`] using the [`MinimizerScheduler`] - #[allow(clippy::unused_self)] pub fn cull(&self, state: &S) -> Result<(), Error> where S: HasCorpus + HasMetadata, diff --git a/libafl/src/schedulers/powersched.rs b/libafl/src/schedulers/powersched.rs index 8da02f38c2..df9cf8194f 100644 --- a/libafl/src/schedulers/powersched.rs +++ b/libafl/src/schedulers/powersched.rs @@ -29,7 +29,7 @@ libafl_bolts::impl_serdeany!(SchedulerMetadata); #[derive(Serialize, Deserialize, Clone, Debug)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct SchedulerMetadata { /// Powerschedule strategy diff --git a/libafl/src/schedulers/probabilistic_sampling.rs b/libafl/src/schedulers/probabilistic_sampling.rs index ccd6b0e6c3..a7772a232f 100644 --- a/libafl/src/schedulers/probabilistic_sampling.rs +++ b/libafl/src/schedulers/probabilistic_sampling.rs @@ -25,7 +25,7 @@ pub struct ProbabilitySamplingScheduler { #[derive(Debug, Serialize, Deserialize)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct ProbabilityMetadata { /// corpus index -> probability @@ -63,8 +63,6 @@ impl ProbabilitySamplingScheduler { } /// Calculate the score and store in `ProbabilityMetadata` - #[allow(clippy::cast_precision_loss)] - #[allow(clippy::unused_self)] pub fn store_probability(&self, state: &mut S, id: CorpusId) -> Result<(), Error> where F: TestcaseScore, @@ -144,7 +142,6 @@ where } /// Gets the next entry - #[allow(clippy::cast_precision_loss)] fn next(&mut self, state: &mut S) -> Result { if state.corpus().count() == 0 { Err(Error::empty(String::from( diff --git a/libafl/src/schedulers/testcase_score.rs b/libafl/src/schedulers/testcase_score.rs index d406bc4233..b6a2e77d30 100644 --- a/libafl/src/schedulers/testcase_score.rs +++ b/libafl/src/schedulers/testcase_score.rs @@ -34,7 +34,7 @@ where S: HasCorpus, ::Input: HasLen, { - #[allow(clippy::cast_precision_loss, clippy::cast_lossless)] + #[expect(clippy::cast_precision_loss)] fn compute( state: &S, entry: &mut Testcase<::Input>, @@ -60,12 +60,7 @@ where S: HasCorpus + HasMetadata, { /// Compute the `power` we assign to each corpus entry - #[allow( - clippy::cast_precision_loss, - clippy::too_many_lines, - clippy::cast_sign_loss, - clippy::cast_lossless - )] + #[expect(clippy::cast_precision_loss, clippy::too_many_lines)] fn compute( state: &S, entry: &mut Testcase<::Input>, @@ -282,7 +277,7 @@ where S: HasCorpus + HasMetadata, { /// Compute the `weight` used in weighted corpus entry selection algo - #[allow(clippy::cast_precision_loss, clippy::cast_lossless)] + #[expect(clippy::cast_precision_loss)] fn compute( state: &S, entry: &mut Testcase<::Input>, diff --git a/libafl/src/schedulers/tuneable.rs b/libafl/src/schedulers/tuneable.rs index b677e71896..7505cc1ccf 100644 --- a/libafl/src/schedulers/tuneable.rs +++ b/libafl/src/schedulers/tuneable.rs @@ -18,7 +18,7 @@ use crate::{ #[derive(Default, Clone, Copy, Eq, PartialEq, Debug, Serialize, Deserialize)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny struct TuneableSchedulerMetadata { next: Option, diff --git a/libafl/src/schedulers/weighted.rs b/libafl/src/schedulers/weighted.rs index 6ee0162018..38d14e9b60 100644 --- a/libafl/src/schedulers/weighted.rs +++ b/libafl/src/schedulers/weighted.rs @@ -31,7 +31,7 @@ use crate::{ /// The Metadata for `WeightedScheduler` #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny #[derive(Serialize, Deserialize, Clone, Debug)] pub struct WeightedScheduleMetadata { @@ -156,12 +156,7 @@ where } /// Create a new alias table when the fuzzer finds a new corpus entry - #[allow( - clippy::unused_self, - clippy::similar_names, - clippy::cast_precision_loss, - clippy::cast_lossless - )] + #[expect(clippy::cast_precision_loss)] pub fn create_alias_table(&self, state: &mut S) -> Result<(), Error> where F: TestcaseScore, @@ -336,7 +331,6 @@ where on_evaluation_metadata_default(self, state, observers) } - #[allow(clippy::similar_names, clippy::cast_precision_loss)] fn next(&mut self, state: &mut S) -> Result { if self.table_invalidated { self.create_alias_table(state)?; diff --git a/libafl/src/stages/afl_stats.rs b/libafl/src/stages/afl_stats.rs index ece9ba1b73..78f78bc739 100644 --- a/libafl/src/stages/afl_stats.rs +++ b/libafl/src/stages/afl_stats.rs @@ -254,7 +254,7 @@ where C: AsRef + Named, Z::Scheduler: HasQueueCycles, { - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] fn perform( &mut self, fuzzer: &mut Z, @@ -321,7 +321,6 @@ where } else { 0 }; - #[allow(clippy::similar_names)] let stats = AFLFuzzerStats { start_time: self.start_time, last_update: self.last_report_time.as_secs(), @@ -356,7 +355,7 @@ where time_wo_finds: (current_time() - self.last_find).as_secs(), corpus_variable: 0, stability: self.calculate_stability(unstable_entries_in_map, filled_entries_in_map), - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] bitmap_cvg: (filled_entries_in_map as f64 / map_size as f64) * 100.0, saved_crashes: self.saved_crashes, saved_hangs: self.saved_hangs, @@ -532,8 +531,8 @@ where } } - #[allow(clippy::cast_precision_loss)] - #[allow(clippy::unused_self)] + #[expect(clippy::cast_precision_loss)] + #[expect(clippy::unused_self)] fn calculate_stability(&self, unstable_entries: usize, filled_entries: u64) -> f64 { ((filled_entries as f64 - unstable_entries as f64) / filled_entries as f64) * 100.0 } diff --git a/libafl/src/stages/calibrate.rs b/libafl/src/stages/calibrate.rs index 3cdbc2fd47..50c07aeb09 100644 --- a/libafl/src/stages/calibrate.rs +++ b/libafl/src/stages/calibrate.rs @@ -31,7 +31,7 @@ use crate::{ /// Formula is same as AFL++: number of unstable entries divided by the number of filled entries. #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny #[derive(Serialize, Deserialize, Clone, Debug)] pub struct UnstableEntriesMetadata { @@ -106,11 +106,7 @@ where ::Input: Input, { #[inline] - #[allow( - clippy::let_and_return, - clippy::too_many_lines, - clippy::cast_precision_loss - )] + #[expect(clippy::too_many_lines, clippy::cast_precision_loss)] fn perform( &mut self, fuzzer: &mut Z, diff --git a/libafl/src/stages/colorization.rs b/libafl/src/stages/colorization.rs index 732bbce1c2..5b97301439 100644 --- a/libafl/src/stages/colorization.rs +++ b/libafl/src/stages/colorization.rs @@ -65,7 +65,6 @@ pub const COLORIZATION_STAGE_NAME: &str = "colorization"; pub struct ColorizationStage { map_observer_handle: Handle, name: Cow<'static, str>, - #[allow(clippy::type_complexity)] phantom: PhantomData<(E, EM, O, E, S, Z)>, } @@ -94,7 +93,6 @@ where C: AsRef + Named, { #[inline] - #[allow(clippy::let_and_return)] fn perform( &mut self, fuzzer: &mut Z, @@ -124,7 +122,7 @@ where #[derive(Debug, Serialize, Deserialize)] #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny pub struct TaintMetadata { input_vec: Vec, @@ -175,7 +173,6 @@ where ::Input: HasMutatorBytes + Clone, { #[inline] - #[allow(clippy::let_and_return)] fn colorize( fuzzer: &mut Z, executor: &mut E, @@ -346,7 +343,7 @@ where } /// Replace bytes with random values but following certain rules - #[allow(clippy::needless_range_loop)] + #[expect(clippy::needless_range_loop)] fn type_replace(bytes: &mut [u8], state: &mut S) { let len = bytes.len(); for idx in 0..len { diff --git a/libafl/src/stages/concolic.rs b/libafl/src/stages/concolic.rs index d4b6641f6a..2f2ebd0876 100644 --- a/libafl/src/stages/concolic.rs +++ b/libafl/src/stages/concolic.rs @@ -111,7 +111,7 @@ impl<'a, EM, TE, S, Z> ConcolicTracingStage<'a, EM, TE, S, Z> { } #[cfg(feature = "concolic_mutation")] -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] fn generate_mutations(iter: impl Iterator) -> Vec> { use hashbrown::HashMap; use z3::{ diff --git a/libafl/src/stages/dump.rs b/libafl/src/stages/dump.rs index ca9f133cba..32d8365d88 100644 --- a/libafl/src/stages/dump.rs +++ b/libafl/src/stages/dump.rs @@ -23,7 +23,7 @@ use crate::{ /// Metadata used to store information about disk dump indexes for names #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny #[derive(Default, Serialize, Deserialize, Clone, Debug)] pub struct DumpToDiskMetadata { @@ -98,7 +98,7 @@ where } /// Default `generate_filename` function. - #[allow(clippy::trivially_copy_pass_by_ref)] + #[expect(clippy::trivially_copy_pass_by_ref)] fn generate_filename( testcase: &Testcase<::Input>, id: &CorpusId, diff --git a/libafl/src/stages/generalization.rs b/libafl/src/stages/generalization.rs index 123c6162ac..00e1fbacf3 100644 --- a/libafl/src/stages/generalization.rs +++ b/libafl/src/stages/generalization.rs @@ -51,7 +51,6 @@ pub static GENERALIZATION_STAGE_NAME: &str = "generalization"; pub struct GeneralizationStage { name: Cow<'static, str>, map_observer_handle: Handle, - #[allow(clippy::type_complexity)] phantom: PhantomData<(EM, O, OT, S, Z)>, } @@ -78,7 +77,7 @@ where EM: UsesState, { #[inline] - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] fn perform( &mut self, fuzzer: &mut Z, @@ -405,7 +404,7 @@ where payload.retain(|&x| !(x.is_none() & core::mem::replace(&mut previous, x.is_none()))); } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] fn find_gaps( &self, fuzzer: &mut Z, @@ -443,7 +442,7 @@ where Ok(()) } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] fn find_gaps_in_closures( &self, fuzzer: &mut Z, diff --git a/libafl/src/stages/mod.rs b/libafl/src/stages/mod.rs index 3e66848e9b..da01ae7886 100644 --- a/libafl/src/stages/mod.rs +++ b/libafl/src/stages/mod.rs @@ -180,7 +180,6 @@ where Some(idx) if idx == StageId(Self::LEN) => { // perform the stage, but don't set it - #[allow(clippy::similar_names)] let stage = &mut self.0; stage.perform_restartable(fuzzer, executor, state, manager)?; @@ -194,7 +193,6 @@ where _ => { state.set_current_stage_id(StageId(Self::LEN))?; - #[allow(clippy::similar_names)] let stage = &mut self.0; stage.perform_restartable(fuzzer, executor, state, manager)?; @@ -558,7 +556,7 @@ mod test { impl_serdeany!(TestProgress); impl TestProgress { - #[allow(clippy::unnecessary_wraps)] + #[expect(clippy::unnecessary_wraps)] fn should_restart(state: &mut S, _stage: &ST) -> Result where S: HasMetadata, @@ -630,7 +628,6 @@ mod test { } } - #[allow(clippy::similar_names)] let mut state = StdState::nop()?; let stage = StageWithOneTry; diff --git a/libafl/src/stages/mutational.rs b/libafl/src/stages/mutational.rs index b5347eccd2..61ac616eee 100644 --- a/libafl/src/stages/mutational.rs +++ b/libafl/src/stages/mutational.rs @@ -27,7 +27,7 @@ use crate::{ // TODO multi mutators stage /// Action performed after the un-transformed input is executed (e.g., updating metadata) -#[allow(unused_variables)] +#[expect(unused_variables)] pub trait MutatedTransformPost: Sized { /// Perform any post-execution steps necessary for the transformed input (e.g., updating metadata) #[inline] @@ -108,7 +108,6 @@ pub struct StdMutationalStage { mutator: M, /// The maximum amount of iterations we should do each round max_iterations: NonZeroUsize, - #[allow(clippy::type_complexity)] phantom: PhantomData<(E, EM, I, S, Z)>, } @@ -164,7 +163,6 @@ where S::Corpus: Corpus, { #[inline] - #[allow(clippy::let_and_return)] fn perform( &mut self, fuzzer: &mut Z, @@ -244,7 +242,6 @@ where } /// Runs this (mutational) stage for the given testcase - #[allow(clippy::cast_possible_wrap)] // more than i32 stages on 32 bit system - highly unlikely... fn perform_mutational( &mut self, fuzzer: &mut Z, @@ -298,7 +295,6 @@ where pub struct MultiMutationalStage { name: Cow<'static, str>, mutator: M, - #[allow(clippy::type_complexity)] phantom: PhantomData<(E, EM, I, S, Z)>, } @@ -334,8 +330,6 @@ where } #[inline] - #[allow(clippy::let_and_return)] - #[allow(clippy::cast_possible_wrap)] fn perform( &mut self, fuzzer: &mut Z, @@ -350,7 +344,6 @@ where drop(testcase); let generated = self.mutator.multi_mutate(state, &input, None)?; - // println!("Generated {}", generated.len()); for new_input in generated { // Time is measured directly the `evaluate_input` function let (untransformed, post) = new_input.try_transform_into(state)?; @@ -358,7 +351,6 @@ where self.mutator.multi_post_exec(state, corpus_id)?; post.post_exec(state, corpus_id)?; } - // println!("Found {}", found); Ok(()) } diff --git a/libafl/src/stages/power.rs b/libafl/src/stages/power.rs index abd05b0b01..e3d64def59 100644 --- a/libafl/src/stages/power.rs +++ b/libafl/src/stages/power.rs @@ -39,7 +39,6 @@ pub struct PowerMutationalStage { name: Cow<'static, str>, /// The mutators we use mutator: M, - #[allow(clippy::type_complexity)] phantom: PhantomData<(E, F, EM, I, S, Z)>, } @@ -68,7 +67,7 @@ where } /// Gets the number of iterations as a random number - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] fn iterations(&self, state: &mut S) -> Result { // Update handicap let mut testcase = state.current_testcase_mut()?; @@ -98,7 +97,7 @@ where ::Input: Input, { #[inline] - #[allow(clippy::let_and_return)] + #[expect(clippy::let_and_return)] fn perform( &mut self, fuzzer: &mut Z, @@ -155,7 +154,6 @@ where } /// Runs this (mutational) stage for the given testcase - #[allow(clippy::cast_possible_wrap)] // more than i32 stages on 32 bit system - highly unlikely... fn perform_mutational( &mut self, fuzzer: &mut Z, diff --git a/libafl/src/stages/push/mod.rs b/libafl/src/stages/push/mod.rs index b2caf3c2ad..eba9d9797e 100644 --- a/libafl/src/stages/push/mod.rs +++ b/libafl/src/stages/push/mod.rs @@ -70,7 +70,7 @@ pub struct PushStageHelper { /// This gets reset to `false` after one iteration of the stage is done. pub initialized: bool, /// The shared state, keeping track of the corpus and the fuzzer - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] pub shared_state: Rc>>>, /// If the last iteration failed pub errored: bool, @@ -87,7 +87,7 @@ pub struct PushStageHelper { impl PushStageHelper { /// Create a new [`PushStageHelper`] #[must_use] - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] pub fn new( shared_state: Rc>>>, exit_kind_ref: Rc>>, @@ -110,7 +110,6 @@ impl PushStageHelper { /// Takes the shared state from this helper, replacing it with `None` #[inline] - #[allow(clippy::type_complexity)] pub fn take_shared_state(&mut self) -> Option> { let shared_state_ref = &mut (*self.shared_state).borrow_mut(); shared_state_ref.take() @@ -207,7 +206,6 @@ pub trait PushStage { } /// Allows us to use a [`PushStage`] as a normal [`Stage`] -#[allow(clippy::type_complexity)] #[derive(Debug)] pub struct PushStageAdapter { name: Cow<'static, str>, diff --git a/libafl/src/stages/push/mutational.rs b/libafl/src/stages/push/mutational.rs index 76d28cfb09..fd0dd57be3 100644 --- a/libafl/src/stages/push/mutational.rs +++ b/libafl/src/stages/push/mutational.rs @@ -63,7 +63,7 @@ where ::Input: Clone + Debug, { /// Gets the number of iterations as a random number - #[allow(clippy::unused_self, clippy::unnecessary_wraps)] // TODO: we should put this function into a trait later + #[expect(clippy::unused_self, clippy::unnecessary_wraps)] // TODO: we should put this function into a trait later fn iterations(&self, state: &mut S, _corpus_id: CorpusId) -> Result { Ok(1 + state .rand_mut() @@ -232,7 +232,7 @@ where { /// Creates a new default mutational stage #[must_use] - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] pub fn new( mutator: M, shared_state: Rc< diff --git a/libafl/src/stages/sync.rs b/libafl/src/stages/sync.rs index 7f51ed6f13..5d8ecd6c5b 100644 --- a/libafl/src/stages/sync.rs +++ b/libafl/src/stages/sync.rs @@ -27,7 +27,7 @@ pub const SYNC_FROM_DISK_STAGE_NAME: &str = "sync"; /// Metadata used to store information about disk sync time #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny #[derive(Serialize, Deserialize, Debug)] pub struct SyncFromDiskMetadata { @@ -201,7 +201,7 @@ where /// Metadata used to store information about the last sent testcase with `SyncFromBrokerStage` #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny #[derive(Serialize, Deserialize, Debug)] pub struct SyncFromBrokerMetadata { diff --git a/libafl/src/stages/tmin.rs b/libafl/src/stages/tmin.rs index ff449b19fa..2e3a2d4490 100644 --- a/libafl/src/stages/tmin.rs +++ b/libafl/src/stages/tmin.rs @@ -53,7 +53,6 @@ pub struct StdTMinMutationalStage { runs: usize, /// The progress helper for this stage, keeping track of resumes after timeouts/crashes restart_helper: ExecutionCountRestartHelper, - #[allow(clippy::type_complexity)] phantom: PhantomData<(E, EM, F, S, Z)>, } @@ -166,7 +165,6 @@ where } /// Runs this (mutational) stage for new objectives - #[allow(clippy::cast_possible_wrap)] // more than i32 stages on 32 bit system - highly unlikely... fn perform_minification( &mut self, fuzzer: &mut Z, diff --git a/libafl/src/stages/tracing.rs b/libafl/src/stages/tracing.rs index 68f0fdfe76..acb81782c0 100644 --- a/libafl/src/stages/tracing.rs +++ b/libafl/src/stages/tracing.rs @@ -27,7 +27,6 @@ use crate::{ pub struct TracingStage { name: Cow<'static, str>, tracer_executor: TE, - #[allow(clippy::type_complexity)] phantom: PhantomData<(EM, TE, S, Z)>, } @@ -43,7 +42,7 @@ where + UsesInput::Input>, EM: UsesState, //delete me { - #[allow(rustdoc::broken_intra_doc_links)] + #[expect(rustdoc::broken_intra_doc_links)] /// Perform tracing on the given `CorpusId`. Useful for if wrapping [`TracingStage`] with your /// own stage and you need to manage [`super::NestedStageRetryCountRestartHelper`] differently /// see [`super::ConcolicTracingStage`]'s implementation as an example of usage. @@ -151,7 +150,6 @@ impl TracingStage { #[derive(Clone, Debug)] pub struct ShadowTracingStage { name: Cow<'static, str>, - #[allow(clippy::type_complexity)] phantom: PhantomData<(E, EM, SOT, S, Z)>, } diff --git a/libafl/src/stages/tuneable.rs b/libafl/src/stages/tuneable.rs index 25a2ec82ef..9c3aeab6af 100644 --- a/libafl/src/stages/tuneable.rs +++ b/libafl/src/stages/tuneable.rs @@ -25,7 +25,7 @@ use crate::{ #[cfg_attr( any(not(feature = "serdeany_autoreg"), miri), - allow(clippy::unsafe_derive_deserialize) + expect(clippy::unsafe_derive_deserialize) )] // for SerdeAny #[derive(Default, Clone, Copy, Eq, PartialEq, Debug, Serialize, Deserialize)] struct TuneableMutationalStageMetadata { @@ -209,7 +209,6 @@ where ::Input: Input, { #[inline] - #[allow(clippy::let_and_return)] fn perform( &mut self, fuzzer: &mut Z, diff --git a/libafl/src/stages/verify_timeouts.rs b/libafl/src/stages/verify_timeouts.rs index 9d62f61b57..74e3e88c16 100644 --- a/libafl/src/stages/verify_timeouts.rs +++ b/libafl/src/stages/verify_timeouts.rs @@ -1,4 +1,4 @@ -#![allow(clippy::too_long_first_doc_paragraph)] +#![expect(clippy::too_long_first_doc_paragraph)] //! Stage that re-runs captured Timeouts with double the timeout to verify //! Note: To capture the timeouts, use in conjunction with `CaptureTimeoutFeedback` //! Note: Will NOT work with in process executors due to the potential for restarts/crashes when diff --git a/libafl_bolts/src/cli.rs b/libafl_bolts/src/cli.rs index 51cc199b76..8c9486ffe6 100644 --- a/libafl_bolts/src/cli.rs +++ b/libafl_bolts/src/cli.rs @@ -122,7 +122,7 @@ pub enum FridaScriptBackend { subcommand_precedence_over_arg(true), args_conflicts_with_subcommands(true) )] -#[allow(clippy::struct_excessive_bools)] +#[expect(clippy::struct_excessive_bools)] pub struct FuzzerOptions { /// Timeout for each target execution (milliseconds) #[arg(short, long, default_value = "1000", value_parser = parse_timeout, help_heading = "Fuzz Options")] diff --git a/libafl_bolts/src/compress.rs b/libafl_bolts/src/compress.rs index 74a9a18327..e4e261ac0a 100644 --- a/libafl_bolts/src/compress.rs +++ b/libafl_bolts/src/compress.rs @@ -61,7 +61,6 @@ impl GzipCompressor { } /// Decompression. - #[allow(clippy::unused_self)] pub fn decompress(&self, buf: &[u8]) -> Result, Error> { let decompressed = decompress_to_vec(buf); diff --git a/libafl_bolts/src/core_affinity.rs b/libafl_bolts/src/core_affinity.rs index e921425e81..dcb4de85c1 100644 --- a/libafl_bolts/src/core_affinity.rs +++ b/libafl_bolts/src/core_affinity.rs @@ -251,7 +251,6 @@ mod linux { use super::CoreId; use crate::Error; - #[allow(trivial_numeric_casts)] pub fn get_core_ids() -> Result, Error> { let full_set = get_affinity_mask()?; let mut core_ids: Vec = Vec::new(); @@ -361,14 +360,14 @@ mod linux { // FIXME: no sense of cpu granularity (yet ?) #[cfg(target_os = "haiku")] -#[allow(clippy::unnecessary_wraps)] +#[expect(clippy::unnecessary_wraps)] #[inline] fn get_core_ids_helper() -> Result, Error> { haiku::get_core_ids() } #[cfg(target_os = "haiku")] -#[allow(clippy::unnecessary_wraps)] +#[expect(clippy::unnecessary_wraps)] #[inline] fn set_for_current_helper(_core_id: CoreId) -> Result<(), Error> { Ok(()) @@ -381,7 +380,7 @@ mod haiku { use crate::core_affinity::{CoreId, Error}; - #[allow(clippy::unnecessary_wraps)] + #[expect(clippy::unnecessary_wraps)] pub fn get_core_ids() -> Result, Error> { Ok((0..(usize::from(available_parallelism()?))) .map(CoreId) @@ -460,18 +459,15 @@ mod windows { } } - #[allow(trivial_numeric_casts)] - #[allow(clippy::cast_ptr_alignment)] - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_ptr_alignment)] pub fn get_num_logical_cpus_ex_windows() -> Option { use std::{ptr, slice}; - #[allow(non_upper_case_globals)] + #[expect(non_upper_case_globals)] const RelationProcessorCore: u32 = 0; #[repr(C)] - #[allow(non_camel_case_types)] - #[allow(dead_code)] + #[allow(non_camel_case_types)] // expect breaks for some reason struct GROUP_AFFINITY { mask: usize, group: u16, @@ -479,8 +475,7 @@ mod windows { } #[repr(C)] - #[allow(non_camel_case_types)] - #[allow(dead_code)] + #[allow(non_camel_case_types)] // expect breaks for some reason struct PROCESSOR_RELATIONSHIP { flags: u8, efficiency_class: u8, @@ -490,8 +485,7 @@ mod windows { } #[repr(C)] - #[allow(non_camel_case_types)] - #[allow(dead_code)] + #[allow(non_camel_case_types)] // expect breaks for some reason struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { relationship: u32, size: u32, @@ -626,7 +620,6 @@ mod apple { ) -> kern_return_t; } - #[allow(clippy::unnecessary_wraps)] pub fn get_core_ids() -> Result, Error> { Ok((0..(usize::from(available_parallelism()?))) .map(CoreId) @@ -659,7 +652,7 @@ mod apple { } #[cfg(target_arch = "aarch64")] - #[allow(clippy::unnecessary_wraps)] + #[expect(clippy::unnecessary_wraps)] pub fn set_for_current(_core_id: CoreId) -> Result<(), Error> { // This is the best we can do, unlike on intel architecture // the system does not allow to pin a process/thread to specific cpu. @@ -703,7 +696,7 @@ mod netbsd { use super::CoreId; use crate::Error; - #[allow(trivial_numeric_casts)] + #[expect(trivial_numeric_casts)] pub fn get_core_ids() -> Result, Error> { Ok((0..(usize::from(available_parallelism()?))) .map(CoreId) @@ -746,7 +739,7 @@ fn get_core_ids_helper() -> Result, Error> { } #[cfg(target_os = "openbsd")] -#[allow(clippy::unnecessary_wraps)] +#[expect(clippy::unnecessary_wraps)] #[inline] fn set_for_current_helper(_: CoreId) -> Result<(), Error> { Ok(()) // There is no notion of cpu affinity on this platform @@ -760,7 +753,7 @@ mod openbsd { use super::CoreId; use crate::Error; - #[allow(trivial_numeric_casts)] + #[expect(trivial_numeric_casts)] pub fn get_core_ids() -> Result, Error> { Ok((0..(usize::from(available_parallelism()?))) .map(CoreId) @@ -788,7 +781,7 @@ mod solaris { use super::CoreId; use crate::Error; - #[allow(clippy::unnecessary_wraps)] + #[expect(clippy::unnecessary_wraps)] pub fn get_core_ids() -> Result, Error> { Ok((0..(usize::from(available_parallelism()?))) .map(CoreId) diff --git a/libafl_bolts/src/lib.rs b/libafl_bolts/src/lib.rs index 79b27e7d05..2a3a68bff5 100644 --- a/libafl_bolts/src/lib.rs +++ b/libafl_bolts/src/lib.rs @@ -228,7 +228,7 @@ fn display_error_backtrace(f: &mut fmt::Formatter, err: &ErrorBacktrace) -> fmt: write!(f, "\nBacktrace: {err:?}") } #[cfg(not(feature = "errors_backtrace"))] -#[allow(clippy::unnecessary_wraps)] +#[expect(clippy::unnecessary_wraps)] fn display_error_backtrace(_f: &mut fmt::Formatter, _err: &ErrorBacktrace) -> fmt::Result { fmt::Result::Ok(()) } @@ -588,7 +588,6 @@ impl From for Error { #[cfg(feature = "alloc")] impl From for Error { - #[allow(unused_variables)] fn from(err: FromUtf8Error) -> Self { Self::unknown(format!("Could not convert byte / utf-8: {err:?}")) } @@ -596,7 +595,6 @@ impl From for Error { #[cfg(feature = "alloc")] impl From for Error { - #[allow(unused_variables)] fn from(err: Utf8Error) -> Self { Self::unknown(format!("Could not convert byte / utf-8: {err:?}")) } @@ -604,35 +602,34 @@ impl From for Error { #[cfg(feature = "std")] impl From for Error { - #[allow(unused_variables)] fn from(err: VarError) -> Self { Self::empty(format!("Could not get env var: {err:?}")) } } impl From for Error { - #[allow(unused_variables)] + #[allow(unused_variables)] // err is unused without std fn from(err: ParseIntError) -> Self { Self::unknown(format!("Failed to parse Int: {err:?}")) } } impl From for Error { - #[allow(unused_variables)] + #[allow(unused_variables)] // err is unused without std fn from(err: TryFromIntError) -> Self { Self::illegal_state(format!("Expected conversion failed: {err:?}")) } } impl From for Error { - #[allow(unused_variables)] + #[allow(unused_variables)] // err is unused without std fn from(err: TryFromSliceError) -> Self { Self::illegal_argument(format!("Could not convert slice: {err:?}")) } } impl From for Error { - #[allow(unused_variables)] + #[allow(unused_variables)] // err is unused without std fn from(err: SetLoggerError) -> Self { Self::illegal_state(format!("Failed to register logger: {err:?}")) } @@ -640,7 +637,7 @@ impl From for Error { #[cfg(windows)] impl From for Error { - #[allow(unused_variables)] + #[allow(unused_variables)] // err is unused without std fn from(err: windows_result::Error) -> Self { Self::unknown(format!("Windows API error: {err:?}")) } @@ -1100,7 +1097,7 @@ impl log::Log for SimpleFdLogger { /// # Safety /// The function is arguably safe, but it might have undesirable side effects since it closes `stdout` and `stderr`. #[cfg(all(unix, feature = "std"))] -#[allow(unused_qualifications)] +#[expect(unused_qualifications)] pub unsafe fn dup_and_mute_outputs() -> Result<(RawFd, RawFd), Error> { let old_stdout = stdout().as_raw_fd(); let old_stderr = stderr().as_raw_fd(); @@ -1159,7 +1156,7 @@ macro_rules! nonnull_raw_mut { } #[cfg(feature = "python")] -#[allow(missing_docs)] +#[allow(missing_docs)] // expect somehow breaks here pub mod pybind { use pyo3::{pymodule, types::PyModule, Bound, PyResult}; diff --git a/libafl_bolts/src/llmp.rs b/libafl_bolts/src/llmp.rs index 07abd68aa4..614d502557 100644 --- a/libafl_bolts/src/llmp.rs +++ b/libafl_bolts/src/llmp.rs @@ -397,14 +397,14 @@ impl Listener { /// Get sharedmem from a page #[inline] -#[allow(clippy::cast_ptr_alignment)] +#[expect(clippy::cast_ptr_alignment)] unsafe fn shmem2page_mut(afl_shmem: &mut SHM) -> *mut LlmpPage { afl_shmem.as_mut_ptr() as *mut LlmpPage } /// Get sharedmem from a page #[inline] -#[allow(clippy::cast_ptr_alignment)] +#[expect(clippy::cast_ptr_alignment)] unsafe fn shmem2page(afl_shmem: &SHM) -> *const LlmpPage { afl_shmem.as_ptr() as *const LlmpPage } @@ -591,7 +591,7 @@ unsafe fn llmp_next_msg_ptr_checked( /// # Safety /// Will dereference the `last_msg` ptr #[inline] -#[allow(clippy::cast_ptr_alignment)] +#[expect(clippy::cast_ptr_alignment)] unsafe fn llmp_next_msg_ptr(last_msg: *const LlmpMsg) -> *mut LlmpMsg { /* DBG("llmp_next_msg_ptr %p %lu + %lu\n", last_msg, last_msg->buf_len_padded, sizeof(llmp_message)); */ (last_msg as *mut u8) @@ -1411,7 +1411,7 @@ where * to consume */ let out = self.alloc_eop()?; - #[allow(clippy::cast_ptr_alignment)] + #[expect(clippy::cast_ptr_alignment)] let end_of_page_msg = (*out).buf.as_mut_ptr() as *mut LlmpPayloadSharedMapInfo; (*end_of_page_msg).map_size = new_map_shmem.shmem.len(); (*end_of_page_msg).shm_str = *new_map_shmem.shmem.id().as_array(); @@ -1737,7 +1737,7 @@ where size_of::() ); - #[allow(clippy::cast_ptr_alignment)] + #[expect(clippy::cast_ptr_alignment)] let pageinfo = (*msg).buf.as_mut_ptr() as *mut LlmpPayloadSharedMapInfo; /* The pageinfo points to the map we're about to unmap. @@ -1808,7 +1808,7 @@ where } /// Returns the next message, tag, buf, if available, else None - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] #[inline] pub fn recv_buf(&mut self) -> Result, Error> { if let Some((sender, tag, _flags, buf)) = self.recv_buf_with_flags()? { @@ -1819,7 +1819,7 @@ where } /// Receive the buffer, also reading the LLMP internal message flags - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] #[inline] pub fn recv_buf_with_flags(&mut self) -> Result, Error> { // # Safety @@ -1838,7 +1838,6 @@ where } /// Receive the buffer, also reading the LLMP internal message flags - #[allow(clippy::type_complexity)] #[inline] pub fn recv_buf_blocking_with_flags(&mut self) -> Result<(ClientId, Tag, Flags, &[u8]), Error> { // # Safety @@ -1989,7 +1988,7 @@ where /// /// # Safety /// This dereferences msg, make sure to pass a proper pointer to it. - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] pub unsafe fn msg_to_offset(&self, msg: *const LlmpMsg) -> Result { let page = self.page(); if llmp_msg_in_page(page, msg) { @@ -2033,7 +2032,7 @@ where /// Gets this message from this page, at the indicated offset. /// Will return [`crate::Error::illegal_argument`] error if the offset is out of bounds. - #[allow(clippy::cast_ptr_alignment)] + #[expect(clippy::cast_ptr_alignment)] pub fn msg_from_offset(&mut self, offset: u64) -> Result<*mut LlmpMsg, Error> { let offset = offset as usize; @@ -2206,7 +2205,6 @@ impl SignalHandler for LlmpShutdownSignalHandler { #[cfg(all(windows, feature = "std"))] impl CtrlHandler for LlmpShutdownSignalHandler { - #[allow(clippy::not_unsafe_ptr_arg_deref)] fn handle(&mut self, ctrl_type: u32) -> bool { log::info!("LLMP: Received shutdown signal, ctrl_type {:?}", ctrl_type); unsafe { @@ -2653,8 +2651,8 @@ where /// Returns `true` if new messages were broker-ed /// It is supposed that the message is never unmapped. #[inline] - #[allow(clippy::cast_ptr_alignment)] - #[allow(clippy::too_many_lines)] + #[expect(clippy::cast_ptr_alignment)] + #[expect(clippy::too_many_lines)] unsafe fn handle_new_msgs(&mut self, client_id: ClientId) -> Result { let mut new_messages = false; @@ -3039,7 +3037,7 @@ where /// Internal function, returns true when shuttdown is requested by a `SIGINT` signal #[inline] #[cfg(any(unix, all(windows, feature = "std")))] - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] fn is_shutting_down(&self) -> bool { // # Safety // No user-provided potentially unsafe parameters. @@ -3050,7 +3048,7 @@ where /// Always returns true on platforms, where no shutdown signal handlers are supported #[inline] #[cfg(not(any(unix, all(windows, feature = "std"))))] - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] fn is_shutting_down(&self) -> bool { false } @@ -3086,7 +3084,7 @@ where /// Announces a new client on the given shared map. /// Called from a background thread, typically. /// Upon receiving this message, the broker should map the announced page and start tracking it for new messages. - #[allow(dead_code)] + #[cfg(feature = "std")] fn announce_new_client( sender: &mut LlmpSender, shmem_description: &ShMemDescription, @@ -3096,7 +3094,7 @@ where .alloc_next(size_of::()) .expect("Could not allocate a new message in shared map."); (*msg).tag = LLMP_TAG_NEW_SHM_CLIENT; - #[allow(clippy::cast_ptr_alignment)] + #[expect(clippy::cast_ptr_alignment)] let pageinfo = (*msg).buf.as_mut_ptr() as *mut LlmpPayloadSharedMapInfo; (*pageinfo).shm_str = *shmem_description.id.as_array(); (*pageinfo).map_size = shmem_description.size; @@ -3114,7 +3112,7 @@ where .alloc_next(size_of::()) .expect("Could not allocate a new message in shared map."); (*msg).tag = LLMP_TAG_CLIENT_EXIT; - #[allow(clippy::cast_ptr_alignment)] + #[expect(clippy::cast_ptr_alignment)] let exitinfo = (*msg).buf.as_mut_ptr() as *mut LlmpClientExitInfo; (*exitinfo).client_id = client_id; sender.send(msg, true) @@ -3127,7 +3125,7 @@ where /// This function returns the [`ShMemDescription`] the client uses to place incoming messages. /// The thread exits, when the remote broker disconnects. #[cfg(feature = "std")] - #[allow(clippy::let_and_return, clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] fn b2b_thread_on( mut stream: TcpStream, b2b_client_id: ClientId, @@ -3470,7 +3468,7 @@ where /// Reattach to a vacant client map. /// It is essential, that the broker (or someone else) kept a pointer to the `out_shmem` /// else reattach will get a new, empty page, from the OS, or fail - #[allow(clippy::needless_pass_by_value)] + #[allow(clippy::needless_pass_by_value)] // no longer necessary on nightly pub fn on_existing_shmem( shmem_provider: SP, _current_out_shmem: SP::ShMem, @@ -3674,7 +3672,7 @@ where } /// Returns the next message, tag, buf, if available, else None - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] #[inline] pub fn recv_buf(&mut self) -> Result, Error> { self.receiver.recv_buf() @@ -3687,13 +3685,12 @@ where } /// Receive a `buf` from the broker, including the `flags` used during transmission. - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] pub fn recv_buf_with_flags(&mut self) -> Result, Error> { self.receiver.recv_buf_with_flags() } /// Receive a `buf` from the broker, including the `flags` used during transmission. - #[allow(clippy::type_complexity)] pub fn recv_buf_blocking_with_flags(&mut self) -> Result<(ClientId, Tag, Flags, &[u8]), Error> { self.receiver.recv_buf_blocking_with_flags() } @@ -3797,7 +3794,6 @@ mod tests { #[serial] #[cfg_attr(miri, ignore)] fn test_llmp_connection() { - #[allow(unused_variables)] let shmem_provider = StdShMemProvider::new().unwrap(); let mut broker = match LlmpConnection::on_port(shmem_provider.clone(), 1337).unwrap() { IsClient { client: _ } => panic!("Could not bind to port as broker"), diff --git a/libafl_bolts/src/minibsod.rs b/libafl_bolts/src/minibsod.rs index 757f5ebd7f..b2b2e384a7 100644 --- a/libafl_bolts/src/minibsod.rs +++ b/libafl_bolts/src/minibsod.rs @@ -29,7 +29,6 @@ use crate::os::unix_signals::{ucontext_t, Signal}; any(target_os = "linux", target_os = "android"), target_arch = "x86_64" ))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, ucontext: &ucontext_t, @@ -65,7 +64,6 @@ pub fn dump_registers( /// Write the content of all important registers #[cfg(all(any(target_os = "linux", target_os = "android"), target_arch = "x86"))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, ucontext: &ucontext_t, @@ -144,7 +142,6 @@ pub fn dump_registers( /// Write the content of all important registers #[cfg(all(target_os = "freebsd", target_arch = "aarch64"))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, ucontext: &ucontext_t, @@ -168,7 +165,6 @@ pub fn dump_registers( /// Write the content of all important registers #[cfg(all(target_vendor = "apple", target_arch = "aarch64"))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, ucontext: &ucontext_t, @@ -192,7 +188,7 @@ pub fn dump_registers( } /// Write the content of all important registers -#[allow(clippy::unnecessary_wraps, clippy::similar_names)] +#[expect(clippy::unnecessary_wraps, clippy::similar_names)] #[cfg(all(target_vendor = "apple", target_arch = "x86_64"))] pub fn dump_registers( writer: &mut BufWriter, @@ -228,7 +224,6 @@ pub fn dump_registers( any(target_os = "freebsd", target_os = "dragonfly"), target_arch = "x86_64" ))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, ucontext: &ucontext_t, @@ -258,7 +253,6 @@ pub fn dump_registers( /// Write the content of all important registers #[cfg(all(target_os = "netbsd", target_arch = "x86_64"))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, ucontext: &ucontext_t, @@ -368,7 +362,6 @@ pub fn dump_registers( /// Write the content of all important registers #[cfg(all(target_os = "openbsd", target_arch = "x86_64"))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, ucontext: &ucontext_t, @@ -396,7 +389,6 @@ pub fn dump_registers( /// Write the content of all important registers #[cfg(all(target_os = "openbsd", target_arch = "aarch64"))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, ucontext: &ucontext_t, @@ -419,7 +411,6 @@ pub fn dump_registers( any(target_os = "solaris", target_os = "illumos"), target_arch = "x86_64" ))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, ucontext: &ucontext_t, @@ -455,7 +446,6 @@ pub fn dump_registers( /// Write the content of all important registers #[cfg(all(target_os = "windows", target_arch = "x86_64"))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, context: &CONTEXT, @@ -484,7 +474,6 @@ pub fn dump_registers( /// Write the content of all important registers #[cfg(all(target_os = "windows", target_arch = "x86"))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, context: &CONTEXT, @@ -504,7 +493,6 @@ pub fn dump_registers( /// Write the content of all important registers #[cfg(all(target_os = "windows", target_arch = "aarch64"))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, context: &CONTEXT, @@ -531,7 +519,6 @@ pub fn dump_registers( /// Write the content of all important registers #[cfg(all(target_os = "haiku", target_arch = "x86_64"))] -#[allow(clippy::similar_names)] pub fn dump_registers( writer: &mut BufWriter, ucontext: &ucontext_t, @@ -558,7 +545,7 @@ pub fn dump_registers( Ok(()) } -#[allow(clippy::unnecessary_wraps)] +#[expect(clippy::unnecessary_wraps)] #[cfg(not(any( target_vendor = "apple", target_os = "linux", @@ -670,7 +657,6 @@ fn write_crash( } #[cfg(all(target_vendor = "apple", target_arch = "aarch64"))] -#[allow(clippy::similar_names)] fn write_crash( writer: &mut BufWriter, signal: Signal, @@ -687,7 +673,6 @@ fn write_crash( } #[cfg(all(target_vendor = "apple", target_arch = "x86_64"))] -#[allow(clippy::similar_names)] fn write_crash( writer: &mut BufWriter, signal: Signal, @@ -709,7 +694,6 @@ fn write_crash( } #[cfg(all(target_os = "freebsd", target_arch = "x86_64"))] -#[allow(clippy::similar_names)] fn write_crash( writer: &mut BufWriter, signal: Signal, @@ -725,7 +709,6 @@ fn write_crash( } #[cfg(all(target_os = "dragonfly", target_arch = "x86_64"))] -#[allow(clippy::similar_names)] fn write_crash( writer: &mut BufWriter, signal: Signal, @@ -741,7 +724,6 @@ fn write_crash( } #[cfg(all(target_os = "openbsd", target_arch = "x86_64"))] -#[allow(clippy::similar_names)] fn write_crash( writer: &mut BufWriter, signal: Signal, @@ -757,7 +739,6 @@ fn write_crash( } #[cfg(all(target_os = "openbsd", target_arch = "aarch64"))] -#[allow(clippy::similar_names)] fn write_crash( writer: &mut BufWriter, signal: Signal, @@ -883,7 +864,7 @@ fn write_minibsod(writer: &mut BufWriter) -> Result<(), std::io::Er } #[cfg(any(target_os = "freebsd", target_os = "netbsd"))] -#[allow(clippy::cast_ptr_alignment)] +#[expect(clippy::cast_ptr_alignment)] fn write_minibsod(writer: &mut BufWriter) -> Result<(), std::io::Error> { let mut s: usize = 0; #[cfg(target_os = "freebsd")] @@ -1003,7 +984,6 @@ fn write_minibsod(writer: &mut BufWriter) -> Result<(), std::io::Er } #[cfg(target_vendor = "apple")] -#[allow(non_camel_case_types)] fn write_minibsod(writer: &mut BufWriter) -> Result<(), std::io::Error> { let mut ptask = std::mem::MaybeUninit::::uninit(); // We start by the lowest virtual address from the userland' standpoint @@ -1105,7 +1085,7 @@ fn write_minibsod(writer: &mut BufWriter) -> Result<(), std::io::Er /// Generates a mini-BSOD given a signal and context. #[cfg(unix)] -#[allow(clippy::non_ascii_literal, clippy::too_many_lines)] +#[expect(clippy::non_ascii_literal)] pub fn generate_minibsod( writer: &mut BufWriter, signal: Signal, @@ -1132,11 +1112,7 @@ pub fn generate_minibsod( /// Generates a mini-BSOD given an `EXCEPTION_POINTERS` structure. #[cfg(windows)] -#[allow( - clippy::non_ascii_literal, - clippy::too_many_lines, - clippy::not_unsafe_ptr_arg_deref -)] +#[expect(clippy::non_ascii_literal, clippy::not_unsafe_ptr_arg_deref)] pub fn generate_minibsod( writer: &mut BufWriter, exception_pointers: *mut EXCEPTION_POINTERS, diff --git a/libafl_bolts/src/os/mod.rs b/libafl_bolts/src/os/mod.rs index 1c4d83862c..655d79e234 100644 --- a/libafl_bolts/src/os/mod.rs +++ b/libafl_bolts/src/os/mod.rs @@ -28,7 +28,7 @@ use std::{fs::File, os::fd::AsRawFd, sync::OnceLock}; // Allow a few extra features we need for the whole module #[cfg(all(windows, feature = "std"))] -#[allow(missing_docs, overflowing_literals)] +#[expect(missing_docs, overflowing_literals)] pub mod windows_exceptions; #[cfg(unix)] use libc::pid_t; diff --git a/libafl_bolts/src/os/unix_shmem_server.rs b/libafl_bolts/src/os/unix_shmem_server.rs index d8adfb2059..831b729d37 100644 --- a/libafl_bolts/src/os/unix_shmem_server.rs +++ b/libafl_bolts/src/os/unix_shmem_server.rs @@ -119,7 +119,7 @@ where SP: ShMemProvider, { /// Send a request to the server, and wait for a response - #[allow(clippy::similar_names)] // id and fd + #[expect(clippy::similar_names)] // id and fd fn send_receive(&mut self, request: ServedShMemRequest) -> Result<(i32, i32), Error> { //let bt = Backtrace::new(); //log::info!("Sending {:?} with bt:\n{:?}", request, bt); @@ -409,7 +409,6 @@ where }; } - #[allow(clippy::mutex_atomic)] let syncpair = Arc::new((Mutex::new(ShMemServiceStatus::Starting), Condvar::new())); let childsyncpair = Arc::clone(&syncpair); let join_handle = thread::spawn(move || { @@ -472,7 +471,7 @@ where } /// The struct for the worker, handling incoming requests for [`ShMem`]. -#[allow(clippy::type_complexity)] +#[expect(clippy::type_complexity)] struct ServedShMemServiceWorker where SP: ShMemProvider, @@ -567,7 +566,7 @@ where if client.maps.contains_key(&description_id) { // Using let else here as self needs to be accessed in the else branch. - #[allow(clippy::option_if_let_else)] + #[expect(clippy::option_if_let_else)] Ok(ServedShMemResponse::Mapping( if let Some(map) = client .maps diff --git a/libafl_bolts/src/os/unix_signals.rs b/libafl_bolts/src/os/unix_signals.rs index acd8a5f48e..e06be190f4 100644 --- a/libafl_bolts/src/os/unix_signals.rs +++ b/libafl_bolts/src/os/unix_signals.rs @@ -28,7 +28,7 @@ pub const CTRL_C_EXIT: i32 = 100; /// ARMv7-specific representation of a saved context #[cfg(target_arch = "arm")] #[derive(Debug)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types)] #[repr(C)] pub struct mcontext_t { /// Signal Number @@ -78,7 +78,7 @@ pub struct mcontext_t { /// User Context Struct on `arm` `linux` #[cfg(all(target_os = "linux", target_arch = "arm"))] #[derive(Debug)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types)] #[repr(C)] pub struct ucontext_t { /// Flags @@ -106,7 +106,8 @@ pub struct ucontext_t { #[cfg(all(target_vendor = "apple", target_arch = "aarch64"))] #[derive(Debug)] #[repr(C)] -#[allow(clippy::pub_underscore_fields)] +#[expect(clippy::pub_underscore_fields)] +#[allow(non_camel_case_types)] // expect breaks for some reason pub struct arm_exception_state64 { /// Virtual Fault Address pub __far: u64, @@ -131,7 +132,8 @@ pub struct arm_exception_state64 { #[cfg(all(target_vendor = "apple", target_arch = "aarch64"))] #[derive(Debug)] #[repr(C)] -#[allow(clippy::pub_underscore_fields)] +#[expect(clippy::pub_underscore_fields)] +#[allow(non_camel_case_types)] // expect breaks for some reason pub struct arm_thread_state64 { /// General purpose registers x0-x28 pub __x: [u64; 29], @@ -157,9 +159,9 @@ pub struct arm_thread_state64 { /// ```` #[cfg(all(target_vendor = "apple", target_arch = "aarch64"))] #[derive(Debug)] -#[allow(non_camel_case_types)] #[repr(C, align(16))] -//#[repr(align(16))] +#[allow(non_camel_case_types)] // expect breaks for some reason + //#[repr(align(16))] pub struct arm_neon_state64 { /// opaque pub opaque: [u8; (32 * 16) + (2 * size_of::())], @@ -174,10 +176,10 @@ pub struct arm_neon_state64 { ///}; /// ``` #[cfg(all(target_vendor = "apple", target_arch = "aarch64"))] -#[allow(non_camel_case_types)] #[derive(Debug)] #[repr(C)] -#[allow(clippy::pub_underscore_fields)] +#[expect(clippy::pub_underscore_fields)] +#[allow(non_camel_case_types)] // expect breaks for some reason pub struct mcontext64 { /// `_STRUCT_ARM_EXCEPTION_STATE64` pub __es: arm_exception_state64, @@ -197,8 +199,8 @@ pub struct mcontext64 { /// ``` #[cfg(all(target_vendor = "apple", target_arch = "aarch64"))] #[derive(Debug)] -#[allow(non_camel_case_types)] #[repr(C)] +#[allow(non_camel_case_types)] // expect breaks for some reason pub struct sigaltstack { /// signal stack base pub ss_sp: *mut c_void, @@ -226,8 +228,8 @@ pub struct sigaltstack { /// ``` #[cfg(all(target_vendor = "apple", target_arch = "aarch64"))] #[derive(Debug)] -#[allow(non_camel_case_types)] #[repr(C)] +#[allow(non_camel_case_types)] // expect breaks for some reason pub struct ucontext_t { /// onstack pub uc_onstack: c_int, @@ -515,7 +517,7 @@ pub unsafe fn setup_signal_handler( /// We wrap it here, as it seems to be (currently) /// not available on `MacOS` in the `libc` crate. #[cfg(unix)] -#[allow(clippy::inline_always)] // we assume that inlining will destroy less state +#[expect(clippy::inline_always)] // we assume that inlining will destroy less state #[inline(always)] pub fn ucontext() -> Result { let mut ucontext = unsafe { mem::zeroed() }; diff --git a/libafl_bolts/src/ownedref.rs b/libafl_bolts/src/ownedref.rs index f882554646..c271dba53e 100644 --- a/libafl_bolts/src/ownedref.rs +++ b/libafl_bolts/src/ownedref.rs @@ -447,7 +447,7 @@ where /// Wrap a slice and convert to a Vec on serialize. /// We use a hidden inner enum so the public API can be safe, /// unless the user uses the unsafe [`OwnedSlice::from_raw_parts`] -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] #[derive(Debug, Serialize, Deserialize)] pub struct OwnedSlice<'a, T: 'a + Sized> { inner: OwnedSliceInner<'a, T>, @@ -671,7 +671,7 @@ where } /// Wrap a mutable slice and convert to a Vec on serialize -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] #[derive(Debug, Serialize, Deserialize)] pub struct OwnedMutSlice<'a, T: 'a + Sized> { inner: OwnedMutSliceInner<'a, T>, @@ -860,7 +860,7 @@ impl<'a, T> From<&'a mut [T]> for OwnedMutSlice<'a, T> { } /// Create a new [`OwnedMutSlice`] from a reference to ref to a slice -#[allow(clippy::mut_mut)] // This makes use in some iterators easier +#[expect(clippy::mut_mut)] // This makes use in some iterators easier impl<'a, T> From<&'a mut &'a mut [T]> for OwnedMutSlice<'a, T> { fn from(r: &'a mut &'a mut [T]) -> Self { Self { @@ -912,7 +912,7 @@ where } /// Wrap a mutable slice of constant size N and convert to a Box on serialize -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] #[derive(Debug, Serialize, Deserialize)] pub struct OwnedMutSizedSlice<'a, T: 'a + Sized, const N: usize> { inner: OwnedMutSizedSliceInner<'a, T, N>, @@ -1046,7 +1046,7 @@ where } /// Create a new [`OwnedMutSizedSlice`] from a reference to a boxed sized slice -#[allow(clippy::mut_mut)] // This makes use in some iterators easier +// This makes use in some iterators easier impl<'a, T, const N: usize> From<&'a mut Box<[T; N]>> for OwnedMutSizedSlice<'a, T, N> { fn from(r: &'a mut Box<[T; N]>) -> Self { Self { @@ -1065,7 +1065,7 @@ impl<'a, T, const N: usize> From<&'a mut [T; N]> for OwnedMutSizedSlice<'a, T, N } /// Create a new [`OwnedMutSizedSlice`] from a reference to ref to a slice -#[allow(clippy::mut_mut)] // This makes use in some iterators easier +#[expect(clippy::mut_mut)] // This makes use in some iterators easier impl<'a, T, const N: usize> From<&'a mut &'a mut [T; N]> for OwnedMutSizedSlice<'a, T, N> { fn from(r: &'a mut &'a mut [T; N]) -> Self { Self { diff --git a/libafl_bolts/src/rands/loaded_dice.rs b/libafl_bolts/src/rands/loaded_dice.rs index 474515e14f..d03b1ab5d9 100644 --- a/libafl_bolts/src/rands/loaded_dice.rs +++ b/libafl_bolts/src/rands/loaded_dice.rs @@ -81,7 +81,7 @@ impl LoadedDiceSampler { } /// Create the table for this [`LoadedDiceSampler`] - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] fn construct_table(probs: &[f64]) -> Vec { let mut res = vec![]; let n = probs.len() as f64; @@ -116,7 +116,7 @@ mod tests { use crate::rands::{Rand, StdRand}; #[test] - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] fn test_loaded_dice() { let mut rng = StdRand::with_seed(1337); let len = rng.between(3, 9); diff --git a/libafl_bolts/src/rands/mod.rs b/libafl_bolts/src/rands/mod.rs index d2ba03ee5e..a6a8730c95 100644 --- a/libafl_bolts/src/rands/mod.rs +++ b/libafl_bolts/src/rands/mod.rs @@ -18,7 +18,7 @@ static SEED_COUNTER: AtomicUsize = AtomicUsize::new(0); /// Return a pseudo-random seed. For `no_std` environments, a single deterministic sequence is used. #[must_use] -#[allow(unreachable_code)] +#[expect(unreachable_code)] pub fn random_seed() -> u64 { #[cfg(feature = "std")] return random_seed_from_random_state(); @@ -34,7 +34,6 @@ fn random_seed_deterministic() -> u64 { splitmix64(&mut seed) } -#[allow(dead_code)] #[cfg(feature = "std")] fn random_seed_from_random_state() -> u64 { use std::{ @@ -115,7 +114,7 @@ pub trait Rand: Debug + Serialize + DeserializeOwned { /// Gets a value between 0.0 (inclusive) and 1.0 (exclusive) #[inline] - #[allow(clippy::cast_precision_loss)] + #[expect(clippy::cast_precision_loss)] fn next_float(&mut self) -> f64 { // both 2^53 and 2^-53 can be represented in f64 exactly const MAX: u64 = 1u64 << 53; @@ -370,7 +369,7 @@ impl Rand for Lehmer64Rand { } #[inline] - #[allow(clippy::unreadable_literal)] + #[expect(clippy::unreadable_literal)] fn next(&mut self) -> u64 { self.s *= 0xda942042e4dd58b5; (self.s >> 64) as u64 @@ -418,7 +417,7 @@ impl Rand for RomuTrioRand { } #[inline] - #[allow(clippy::unreadable_literal)] + #[expect(clippy::unreadable_literal)] fn next(&mut self) -> u64 { let xp = self.x_state; let yp = self.y_state; @@ -457,7 +456,7 @@ impl Rand for RomuDuoJrRand { } #[inline] - #[allow(clippy::unreadable_literal)] + #[expect(clippy::unreadable_literal)] fn next(&mut self) -> u64 { let xp = self.x_state; self.x_state = 15241094284759029579_u64.wrapping_mul(self.y_state); @@ -516,7 +515,6 @@ impl Rand for Sfc64Rand { /// fake rand, for testing purposes #[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)] -#[allow(clippy::upper_case_acronyms)] pub struct XkcdRand { val: u64, } @@ -675,8 +673,6 @@ mod tests { } #[cfg(feature = "python")] -#[allow(clippy::unnecessary_fallible_conversions, unused_qualifications)] -#[allow(missing_docs)] /// `Rand` Python bindings pub mod pybind { use pyo3::prelude::*; @@ -685,7 +681,7 @@ pub mod pybind { use super::{random_seed, Rand, StdRand}; #[pyclass(unsendable, name = "StdRand")] - #[allow(clippy::unsafe_derive_deserialize)] + #[expect(clippy::unsafe_derive_deserialize)] #[derive(Serialize, Deserialize, Debug, Clone)] /// Python class for StdRand pub struct PythonStdRand { @@ -721,7 +717,7 @@ pub mod pybind { /// Rand Trait binding #[pyclass(unsendable, name = "Rand")] - #[allow(clippy::unsafe_derive_deserialize)] + #[expect(clippy::unsafe_derive_deserialize)] #[derive(Serialize, Deserialize, Debug)] pub struct PythonRand { wrapper: PythonRandWrapper, diff --git a/libafl_bolts/src/serdeany.rs b/libafl_bolts/src/serdeany.rs index ccc34a59cc..6e2f8ffcb3 100644 --- a/libafl_bolts/src/serdeany.rs +++ b/libafl_bolts/src/serdeany.rs @@ -86,7 +86,7 @@ pub type DeserializeCallback = fn(&mut dyn erased_serde::Deserializer) -> Result, erased_serde::Error>; /// Callback struct for deserialization of a [`SerdeAny`] type. -#[allow(missing_debug_implementations)] +#[expect(missing_debug_implementations)] pub struct DeserializeCallbackSeed where B: ?Sized, @@ -141,7 +141,7 @@ pub mod serdeany_registry { /// Visitor object used internally for the [`crate::serdeany::SerdeAny`] registry. #[derive(Debug)] pub struct BoxDynVisitor {} - #[allow(unused_qualifications)] + #[expect(unused_qualifications)] impl<'de> serde::de::Visitor<'de> for BoxDynVisitor { type Value = Box; @@ -172,17 +172,15 @@ pub mod serdeany_registry { } } - #[allow(unused_qualifications)] struct Registry { deserializers: Option, finalized: bool, } - #[allow(unused_qualifications)] impl Registry { pub fn register(&mut self) where - T: crate::serdeany::SerdeAny + Serialize + serde::de::DeserializeOwned, + T: SerdeAny + Serialize + de::DeserializeOwned, { assert!(!self.finalized, "Registry is already finalized!"); @@ -217,7 +215,7 @@ pub mod serdeany_registry { #[derive(Debug)] pub struct RegistryBuilder {} - #[allow(unused_qualifications)] + #[expect(unused_qualifications)] impl RegistryBuilder { /// Register a given struct type for trait object (de)serialization /// @@ -249,7 +247,7 @@ pub mod serdeany_registry { /// A (de)serializable anymap containing (de)serializable trait objects registered /// in the registry - #[allow(clippy::unsafe_derive_deserialize)] + #[expect(clippy::unsafe_derive_deserialize)] #[derive(Debug, Serialize, Deserialize)] pub struct SerdeAnyMap { map: HashMap>, @@ -264,7 +262,7 @@ pub mod serdeany_registry { } } - #[allow(unused_qualifications)] + #[expect(unused_qualifications)] impl SerdeAnyMap { /// Get an element from the map. #[must_use] @@ -335,7 +333,7 @@ pub mod serdeany_registry { /// Get an entry to an element in this map. #[inline] - #[allow(unused_qualifications)] + #[expect(unused_qualifications)] pub fn raw_entry_mut( &mut self, ) -> hashbrown::hash_map::RawEntryMut< @@ -430,8 +428,8 @@ pub mod serdeany_registry { } /// A serializable [`HashMap`] wrapper for [`crate::serdeany::SerdeAny`] types, addressable by name. - #[allow(clippy::unsafe_derive_deserialize)] - #[allow(unused_qualifications)] + #[expect(clippy::unsafe_derive_deserialize)] + #[expect(unused_qualifications)] #[derive(Debug, Serialize, Deserialize)] pub struct NamedSerdeAnyMap { map: HashMap>>, @@ -446,7 +444,7 @@ pub mod serdeany_registry { } } - #[allow(unused_qualifications)] + #[expect(unused_qualifications)] impl NamedSerdeAnyMap { /// Get an element by name #[must_use] @@ -505,9 +503,9 @@ pub mod serdeany_registry { /// Get all elements of a type contained in this map. #[must_use] - #[allow(unused_qualifications)] + #[expect(unused_qualifications)] #[inline] - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] pub fn get_all( &self, ) -> Option< @@ -523,7 +521,7 @@ pub mod serdeany_registry { #[cfg(not(feature = "stable_anymap"))] let type_repr = &type_repr; - #[allow(clippy::manual_map)] + #[expect(clippy::manual_map)] match self.map.get(type_repr) { None => None, Some(h) => Some(h.values().map(|x| x.as_any().downcast_ref::().unwrap())), @@ -532,8 +530,8 @@ pub mod serdeany_registry { /// Get all elements contained in this map, as mut. #[inline] - #[allow(unused_qualifications)] - #[allow(clippy::type_complexity)] + #[expect(unused_qualifications)] + #[expect(clippy::type_complexity)] pub fn get_all_mut( &mut self, ) -> Option< @@ -549,7 +547,7 @@ pub mod serdeany_registry { #[cfg(not(feature = "stable_anymap"))] let type_repr = &type_repr; - #[allow(clippy::manual_map)] + #[expect(clippy::manual_map)] match self.map.get_mut(type_repr) { None => None, Some(h) => Some( @@ -561,7 +559,7 @@ pub mod serdeany_registry { /// Run `func` for each element in this map. #[inline] - #[allow(unused_qualifications)] + #[expect(unused_qualifications)] pub fn for_each< F: FnMut(&TypeRepr, &Box) -> Result<(), Error>, >( @@ -594,7 +592,7 @@ pub mod serdeany_registry { /// Insert an element into this map. #[inline] - #[allow(unused_qualifications)] + #[expect(unused_qualifications)] pub fn insert(&mut self, name: &str, val: T) where T: crate::serdeany::SerdeAny, @@ -604,7 +602,7 @@ pub mod serdeany_registry { /// Get a reference to the type map. #[inline] - #[allow(unused_qualifications)] + #[expect(unused_qualifications)] fn outer_map_mut( &mut self, ) -> &mut hashbrown::hash_map::HashMap> @@ -638,7 +636,7 @@ pub mod serdeany_registry { /// Get an entry to an element into this map. /// Prefer [`Self::raw_entry_mut`] as it won't need an owned key. #[inline] - #[allow(unused_qualifications)] + #[expect(unused_qualifications)] fn entry( &mut self, name: String, @@ -656,7 +654,7 @@ pub mod serdeany_registry { /// Get a raw entry to an element into this map. #[inline] - #[allow(unused_qualifications)] + #[expect(unused_qualifications)] fn raw_entry_mut( &mut self, name: &str, @@ -758,7 +756,7 @@ pub mod serdeany_registry { } } -#[allow(unused_qualifications)] +#[expect(unused_qualifications)] impl Serialize for dyn crate::serdeany::SerdeAny { fn serialize(&self, se: S) -> Result where @@ -783,7 +781,7 @@ impl Serialize for dyn crate::serdeany::SerdeAny { } } -#[allow(unused_qualifications)] +#[expect(unused_qualifications)] impl<'de> Deserialize<'de> for Box { fn deserialize(deserializer: D) -> Result, D::Error> where @@ -920,7 +918,7 @@ macro_rules! impl_serdeany { /// /// # Safety /// This may never be called concurrently as it dereferences the `RegistryBuilder` without acquiring a lock. - #[allow(unused)] + #[expect(unused)] pub unsafe fn register() { $crate::create_manual_register!($struct_name); } diff --git a/libafl_bolts/src/shmem.rs b/libafl_bolts/src/shmem.rs index 571169ed1b..5f1c00e7f2 100644 --- a/libafl_bolts/src/shmem.rs +++ b/libafl_bolts/src/shmem.rs @@ -771,7 +771,7 @@ pub mod unix_shmem { } } - #[allow(clippy::unnecessary_wraps)] + #[allow(clippy::unnecessary_wraps)] // cfg dependent fn shmem_from_id_and_size(id: ShMemId, map_size: usize) -> Result { // # Safety // No user-provided potentially unsafe parameters. @@ -1012,7 +1012,7 @@ pub mod unix_shmem { impl CommonUnixShMem { /// Create a new shared memory mapping, using shmget/shmat - #[allow(unused_qualifications)] + #[expect(unused_qualifications)] pub fn new(map_size: usize) -> Result { #[cfg(any(target_os = "solaris", target_os = "illumos"))] const SHM_R: libc::c_int = 0o400; @@ -1164,9 +1164,9 @@ pub mod unix_shmem { map_size: usize, } + #[allow(non_camel_case_types)] // expect somehow breaks here #[derive(Copy, Clone)] #[repr(C)] - #[allow(non_camel_case_types)] struct ashmem_pin { pub offset: c_uint, pub len: c_uint, @@ -1209,7 +1209,7 @@ pub mod unix_shmem { //return Err(Error::unknown("Failed to set the ashmem mapping's name".to_string())); //}; - #[allow(trivial_numeric_casts)] + #[expect(trivial_numeric_casts)] if ioctl(fd, ASHMEM_SET_SIZE as _, map_size) != 0 { close(fd); return Err(Error::unknown( @@ -1244,7 +1244,7 @@ pub mod unix_shmem { pub fn shmem_from_id_and_size(id: ShMemId, map_size: usize) -> Result { unsafe { let fd: i32 = id.to_string().parse().unwrap(); - #[allow(trivial_numeric_casts, clippy::cast_sign_loss)] + #[expect(trivial_numeric_casts, clippy::cast_sign_loss)] if ioctl(fd, ASHMEM_GET_SIZE as _) as u32 as usize != map_size { return Err(Error::unknown( "The mapping's size differs from the requested size".to_string(), @@ -1299,13 +1299,13 @@ pub mod unix_shmem { /// [`Drop`] implementation for [`AshmemShMem`], which cleans up the mapping. #[cfg(unix)] impl Drop for AshmemShMem { - #[allow(trivial_numeric_casts)] + #[expect(trivial_numeric_casts)] fn drop(&mut self) { unsafe { let fd: i32 = self.id.to_string().parse().unwrap(); - #[allow(trivial_numeric_casts)] - #[allow(clippy::cast_sign_loss)] + #[expect(trivial_numeric_casts)] + #[expect(clippy::cast_sign_loss)] let length = ioctl(fd, ASHMEM_GET_SIZE as _) as u32; let ap = ashmem_pin { @@ -1400,7 +1400,7 @@ pub mod unix_shmem { }; let fd = fd.into_raw_fd(); - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_possible_wrap)] if ftruncate(fd, map_size as i64) == -1 { close(fd); return Err(Error::last_os_error(format!( @@ -1438,7 +1438,7 @@ pub mod unix_shmem { "Failed to map the memfd mapping".to_string(), )); } - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] if stat.st_size as usize != map_size { return Err(Error::unknown( "The mapping's size differs from the requested size".to_string(), @@ -1490,7 +1490,6 @@ pub mod unix_shmem { /// [`Drop`] implementation for [`MemfdShMem`], which cleans up the mapping. #[cfg(unix)] impl Drop for MemfdShMem { - #[allow(trivial_numeric_casts)] fn drop(&mut self) { let fd = i32::from(self.id); diff --git a/libafl_bolts/src/staterestore.rs b/libafl_bolts/src/staterestore.rs index 1542c3b089..fbe27c492e 100644 --- a/libafl_bolts/src/staterestore.rs +++ b/libafl_bolts/src/staterestore.rs @@ -216,7 +216,7 @@ where 0, "Beginning of the page is not aligned at {ptr:?}!" ); - #[allow(clippy::cast_ptr_alignment)] // Beginning of the page will always be aligned + #[expect(clippy::cast_ptr_alignment)] // Beginning of the page will always be aligned unsafe { &mut *(ptr as *mut StateShMemContent) } @@ -224,7 +224,7 @@ where /// The content is either the name of the tmpfile, or the serialized bytes directly, if they fit on a single page. fn content(&self) -> &StateShMemContent { - #[allow(clippy::cast_ptr_alignment)] // Beginning of the page will always be aligned + #[expect(clippy::cast_ptr_alignment)] // Beginning of the page will always be aligned let ptr = self.shmem.as_slice().as_ptr() as *const StateShMemContent; unsafe { &*(ptr) } } diff --git a/libafl_bolts/src/subrange.rs b/libafl_bolts/src/subrange.rs index 6b9ddf12b8..58a356148e 100644 --- a/libafl_bolts/src/subrange.rs +++ b/libafl_bolts/src/subrange.rs @@ -198,7 +198,7 @@ impl<'a, T> PartialSubRangeSlice<'a, T> { /// Consumes `PartialBytesSubInput` and returns the partial slice if it was a partial slice, None otherwise. #[must_use] pub fn partial(self) -> Option> { - #[allow(clippy::match_wildcard_for_single_variants)] + #[expect(clippy::match_wildcard_for_single_variants)] match self { PartialSubRangeSlice::Partial(partial_slice) => Some(partial_slice), _ => None, diff --git a/libafl_bolts/src/tuples.rs b/libafl_bolts/src/tuples.rs index 05280f3298..f9497799a7 100644 --- a/libafl_bolts/src/tuples.rs +++ b/libafl_bolts/src/tuples.rs @@ -44,7 +44,7 @@ pub fn type_eq() -> bool { } // specialized implementation: Copy is only implemented if the types are the same - #[allow(clippy::mismatching_type_param_order)] + #[expect(clippy::mismatching_type_param_order)] impl Copy for W<'_, T, T> {} let detected = Cell::new(true); @@ -485,7 +485,7 @@ impl MatchName for () { } #[cfg(feature = "alloc")] -#[allow(deprecated)] +#[expect(deprecated)] impl MatchName for (Head, Tail) where Head: Named, @@ -585,7 +585,7 @@ pub trait MatchNameRef { } #[cfg(feature = "alloc")] -#[allow(deprecated)] +#[expect(deprecated)] impl MatchNameRef for M where M: MatchName, @@ -769,10 +769,8 @@ impl Map for () { /// Iterate over a tuple, executing the given `expr` for each element. #[macro_export] -#[allow(clippy::items_after_statements)] macro_rules! tuple_for_each { ($fn_name:ident, $trait_name:path, $tuple_name:ident, $body:expr) => { - #[allow(clippy::items_after_statements)] mod $fn_name { pub trait ForEach { fn for_each(&self); @@ -787,7 +785,7 @@ macro_rules! tuple_for_each { Head: $trait_name, Tail: tuple_list::TupleList + ForEach, { - #[allow(clippy::redundant_closure_call)] + #[allow(clippy::redundant_closure_call)] // macro may be called on a closure or a function fn for_each(&self) { ($body)(&self.0); self.1.for_each(); @@ -806,7 +804,6 @@ macro_rules! tuple_for_each { #[macro_export] macro_rules! tuple_for_each_mut { ($fn_name:ident, $trait_name:path, $tuple_name:ident, $body:expr) => { - #[allow(clippy::items_after_statements)] mod $fn_name { pub trait ForEachMut { fn for_each_mut(&mut self); @@ -821,7 +818,7 @@ macro_rules! tuple_for_each_mut { Head: $trait_name, Tail: tuple_list::TupleList + ForEachMut, { - #[allow(clippy::redundant_closure_call)] + #[allow(clippy::redundant_closure_call)] // macro may be called on a closure or a function fn for_each_mut(&mut self) { ($body)(&mut self.0); self.1.for_each_mut(); @@ -874,7 +871,7 @@ mod test { use crate::tuples::{type_eq, Map, MappingFunctor}; #[test] - #[allow(unused_qualifications)] // for type name tests + // for type name tests fn test_type_eq_simple() { // test eq assert!(type_eq::()); @@ -885,13 +882,13 @@ mod test { #[test] #[cfg(feature = "alloc")] - #[allow(unused_qualifications)] // for type name tests + #[expect(unused_qualifications)] // for type name tests fn test_type_eq() { // An alias for equality testing type OwnedMutSliceAlias<'a> = OwnedMutSlice<'a, u8>; // A function for lifetime testing - #[allow(clippy::extra_unused_lifetimes)] + #[expect(clippy::extra_unused_lifetimes)] fn test_lifetimes<'a, 'b>() { assert!(type_eq::, OwnedMutSlice<'b, u8>>()); assert!(type_eq::, OwnedMutSlice<'a, u8>>()); @@ -937,14 +934,13 @@ mod test { let mapped = orig.map(MyMapper); // this won't compile if the mapped type is not correct - #[allow(clippy::no_effect_underscore_binding)] + #[expect(clippy::no_effect_underscore_binding)] let _type_assert: tuple_list_type!(W, W, W) = mapped; } /// Function that tests the tuple macros #[test] #[cfg(feature = "std")] - #[allow(clippy::items_after_statements)] fn test_macros() { let mut t = tuple_list!(1, "a"); diff --git a/libafl_cc/build.rs b/libafl_cc/build.rs index 15f1403ec0..c602457e58 100644 --- a/libafl_cc/build.rs +++ b/libafl_cc/build.rs @@ -143,8 +143,7 @@ fn find_llvm_version() -> Option { None } -#[allow(clippy::too_many_arguments)] -#[allow(unused)] +#[expect(clippy::too_many_arguments)] fn build_pass( bindir_path: &Path, out_dir: &Path, @@ -224,8 +223,7 @@ fn build_pass( } } -#[allow(clippy::single_element_loop)] -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] fn main() { let out_dir = env::var_os("OUT_DIR").unwrap(); let out_dir = Path::new(&out_dir); diff --git a/libafl_cc/src/ar.rs b/libafl_cc/src/ar.rs index eb528c1962..373d6b4b2c 100644 --- a/libafl_cc/src/ar.rs +++ b/libafl_cc/src/ar.rs @@ -6,7 +6,7 @@ use std::{env, path::PathBuf, str::FromStr}; use crate::{Error, ToolWrapper, LIB_EXT, LIB_PREFIX}; /// Wrap Clang -#[allow(clippy::struct_excessive_bools)] +#[expect(clippy::struct_excessive_bools)] #[derive(Debug)] pub struct ArWrapper { is_silent: bool, @@ -21,9 +21,8 @@ pub struct ArWrapper { base_args: Vec, } -#[allow(clippy::match_same_arms)] // for the linking = false wip for "shared" +#[expect(clippy::match_same_arms)] // for the linking = false wip for "shared" impl ToolWrapper for ArWrapper { - #[allow(clippy::too_many_lines)] fn parse_args(&mut self, args: &[S]) -> Result<&'_ mut Self, Error> where S: AsRef, diff --git a/libafl_cc/src/cfg.rs b/libafl_cc/src/cfg.rs index 49789f3c5c..f22a19e0b1 100644 --- a/libafl_cc/src/cfg.rs +++ b/libafl_cc/src/cfg.rs @@ -256,7 +256,7 @@ where } /// Load a CFG from string generated by ``AFLCoverage`` pass. - #[allow(unused_must_use)] + #[expect(unused_must_use)] #[must_use] pub fn from_content(content: &str) -> ControlFlowGraph { let mut reader = CfgFileReader::new(); diff --git a/libafl_cc/src/clang.rs b/libafl_cc/src/clang.rs index 42d5b137b8..d8c57a9e10 100644 --- a/libafl_cc/src/clang.rs +++ b/libafl_cc/src/clang.rs @@ -24,7 +24,6 @@ fn dll_extension<'a>() -> &'a str { include!(concat!(env!("OUT_DIR"), "/clang_constants.rs")); /// The supported LLVM passes -#[allow(clippy::upper_case_acronyms)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum LLVMPasses { //CmpLogIns, @@ -84,7 +83,7 @@ impl LLVMPasses { } /// Wrap Clang -#[allow(clippy::struct_excessive_bools)] +#[expect(clippy::struct_excessive_bools)] #[derive(Debug)] pub struct ClangWrapper { is_silent: bool, @@ -115,9 +114,9 @@ pub struct ClangWrapper { passes_linking_args: Vec, } -#[allow(clippy::match_same_arms)] // for the linking = false wip for "shared" +#[expect(clippy::match_same_arms)] // for the linking = false wip for "shared" impl ToolWrapper for ClangWrapper { - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] fn parse_args(&mut self, args: &[S]) -> Result<&'_ mut Self, Error> where S: AsRef, @@ -326,7 +325,7 @@ impl ToolWrapper for ClangWrapper { self.command_for_configuration(crate::Configuration::Default) } - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] fn command_for_configuration( &mut self, configuration: crate::Configuration, diff --git a/libafl_cc/src/lib.rs b/libafl_cc/src/lib.rs index 8d71910c03..76de3f3dd2 100644 --- a/libafl_cc/src/lib.rs +++ b/libafl_cc/src/lib.rs @@ -224,7 +224,6 @@ pub trait ToolWrapper { fn command(&mut self) -> Result, Error>; /// Command to run the compiler for a given `Configuration` - #[allow(clippy::too_many_lines)] fn command_for_configuration( &mut self, configuration: Configuration, diff --git a/libafl_cc/src/libtool.rs b/libafl_cc/src/libtool.rs index 4117efc0af..0829b34292 100644 --- a/libafl_cc/src/libtool.rs +++ b/libafl_cc/src/libtool.rs @@ -6,7 +6,7 @@ use std::{env, path::PathBuf, str::FromStr}; use crate::{Error, ToolWrapper, LIB_EXT, LIB_PREFIX}; /// Wrap Clang -#[allow(clippy::struct_excessive_bools)] +#[expect(clippy::struct_excessive_bools)] #[derive(Debug)] pub struct LibtoolWrapper { is_silent: bool, @@ -22,9 +22,8 @@ pub struct LibtoolWrapper { base_args: Vec, } -#[allow(clippy::match_same_arms)] // for the linking = false wip for "shared" +#[expect(clippy::match_same_arms)] // for the linking = false wip for "shared" impl ToolWrapper for LibtoolWrapper { - #[allow(clippy::too_many_lines)] fn parse_args(&mut self, args: &[S]) -> Result<&'_ mut Self, Error> where S: AsRef, diff --git a/libafl_concolic/symcc_runtime/src/filter.rs b/libafl_concolic/symcc_runtime/src/filter.rs index 6059c93c8d..1b9c2aa690 100644 --- a/libafl_concolic/symcc_runtime/src/filter.rs +++ b/libafl_concolic/symcc_runtime/src/filter.rs @@ -2,6 +2,7 @@ use std::collections::HashSet; +// required for the import the macro `invoke_macro_with_rust_runtime_exports` that is dynamically generated in build.rs #[allow(clippy::wildcard_imports)] use crate::*; @@ -17,19 +18,19 @@ macro_rules! rust_filter_function_declaration { // push_path_constraint is not caught by the following case (because it has not return value), // but still needs to return something (pub fn push_path_constraint($( $arg:ident : $type:ty ),*$(,)?), $c_name:ident;) => { - #[allow(unused_variables)] + #[allow(unused_variables)] // only unused for some macro invocations fn push_path_constraint(&mut self, $($arg : $type),*) -> bool { true } }; (pub fn $name:ident($( $arg:ident : $type:ty ),*$(,)?) -> $ret:ty, $c_name:ident;) => { - #[allow(unused_variables)] + #[allow(unused_variables)] // only unused for some macro invocations fn $name(&mut self, $( $arg : $type),*) -> bool {true} }; (pub fn $name:ident($( $arg:ident : $type:ty ),*$(,)?), $c_name:ident;) => { - #[allow(unused_variables)] + #[allow(unused_variables)] // only unused for some macro invocations fn $name(&mut self, $( $arg : $type),*) {} }; } @@ -84,7 +85,7 @@ pub trait Filter { /// /// It applies the filter before passing expressions to the inner runtime. /// It also implements [`Runtime`], allowing for composing multiple [`Filter`]'s in a chain. -#[allow(clippy::module_name_repetitions)] +#[expect(clippy::module_name_repetitions)] pub struct FilterRuntime { filter: F, runtime: RT, diff --git a/libafl_concolic/symcc_runtime/src/filter/coverage.rs b/libafl_concolic/symcc_runtime/src/filter/coverage.rs index 1a56557a93..1d5e907abd 100644 --- a/libafl_concolic/symcc_runtime/src/filter/coverage.rs +++ b/libafl_concolic/symcc_runtime/src/filter/coverage.rs @@ -70,7 +70,6 @@ impl CallStackCoverage bool { self.is_interesting } @@ -139,6 +138,7 @@ macro_rules! call_stack_coverage_filter_function_implementation { }; } +// required for the import the macro `invoke_macro_with_rust_runtime_exports` that is dynamically generated in build.rs #[allow(clippy::wildcard_imports)] use crate::*; @@ -189,7 +189,7 @@ where } fn register_location_on_hitmap(&mut self, location: usize) { - #[allow(clippy::cast_possible_truncation)] // we cannot have more than usize elements.. + #[expect(clippy::cast_possible_truncation)] // we cannot have more than usize elements.. let hash = (self.build_hasher.hash_one(location) % usize::MAX as u64) as usize; let val = unsafe { // # Safety diff --git a/libafl_concolic/symcc_runtime/src/lib.rs b/libafl_concolic/symcc_runtime/src/lib.rs index 7caea28316..7746364cb6 100644 --- a/libafl_concolic/symcc_runtime/src/lib.rs +++ b/libafl_concolic/symcc_runtime/src/lib.rs @@ -135,7 +135,7 @@ macro_rules! unwrap_option { macro_rules! export_rust_runtime_fn { // special case for expression_unreachable, because we need to be convert pointer+length to slice (pub fn expression_unreachable(expressions: *mut RSymExpr, num_elements: usize), $c_name:ident; $rt_cb:path) => { - #[allow(clippy::missing_safety_doc)] + #[expect(clippy::missing_safety_doc)] #[no_mangle] pub unsafe extern "C" fn _rsym_expression_unreachable(expressions: *mut RSymExpr, num_elements: usize) { let slice = core::slice::from_raw_parts(expressions, num_elements); @@ -146,7 +146,7 @@ macro_rules! export_rust_runtime_fn { }; // special case for push_path_constraint, we are not returning a new expression while taking an expression as argument (pub fn push_path_constraint(constraint: RSymExpr, taken: bool, site_id: usize), $c_name:ident; $rt_cb:path) => { - #[allow(clippy::missing_safety_doc)] + #[expect(clippy::missing_safety_doc)] #[no_mangle] pub unsafe extern "C" fn _rsym_push_path_constraint(constraint: Option, taken: bool, site_id: usize) { if let Some(constraint) = constraint { @@ -160,7 +160,7 @@ macro_rules! export_rust_runtime_fn { (pub fn build_integer_from_buffer( buffer: *mut ::std::os::raw::c_void, num_bits: ::std::os::raw::c_uint$(,)?) -> RSymExpr,$c_name:ident; $rt_cb:path) => { - #[allow(clippy::missing_safety_doc)] + #[expect(clippy::missing_safety_doc)] #[no_mangle] pub unsafe extern "C" fn _rsym_build_integer_from_buffer(buffer: *mut ::std::os::raw::c_void, num_bits: ::std::os::raw::c_uint) { $rt_cb(|rt| { @@ -170,7 +170,7 @@ macro_rules! export_rust_runtime_fn { }; // all other methods are handled by this (pub fn $name:ident($( $arg:ident : $(::)?$($type:ident)::+ ),*$(,)?)$( -> $($ret:ident)::+)?, $c_name:ident; $rt_cb:path) => { - #[allow(clippy::missing_safety_doc)] + #[expect(clippy::missing_safety_doc)] #[no_mangle] pub unsafe extern "C" fn $c_name( $($arg: $crate::make_symexpr_optional!($($type)::+),)* )$( -> $crate::make_symexpr_optional!($($ret)::+))? { $rt_cb(|rt| { @@ -185,12 +185,12 @@ macro_rules! export_rust_runtime_fn { macro_rules! impl_nop_runtime_fn { // special case for expression_unreachable, because it has a different signature in our runtime trait than in the c interface. (pub fn expression_unreachable(expressions: *mut RSymExpr, num_elements: usize), $c_name:ident;) => { - #[allow(clippy::default_trait_access)] + // #[expect(clippy::default_trait_access)] fn expression_unreachable(&mut self, _exprs: &[RSymExpr]) {std::default::Default::default()} }; (pub fn $name:ident($( $arg:ident : $type:ty ),*$(,)?)$( -> $ret:ty)?, $c_name:ident;) => { - #[allow(clippy::default_trait_access)] + // #[expect(clippy::default_trait_access)] fn $name(&mut self, $( _ : $type),*)$( -> Option<$ret>)? {std::default::Default::default()} }; } @@ -222,7 +222,7 @@ impl OptionalRuntime { macro_rules! rust_runtime_function_declaration { (pub fn expression_unreachable(expressions: *mut RSymExpr, num_elements: usize), $c_name:ident;) => { - #[allow(clippy::default_trait_access)] + // #[expect(clippy::default_trait_access)] fn expression_unreachable(&mut self, exprs: &[RSymExpr]) { if let Some(inner) = &mut self.inner { inner.expression_unreachable(exprs); diff --git a/libafl_concolic/symcc_runtime/src/tracing.rs b/libafl_concolic/symcc_runtime/src/tracing.rs index 428b194d12..d456407340 100644 --- a/libafl_concolic/symcc_runtime/src/tracing.rs +++ b/libafl_concolic/symcc_runtime/src/tracing.rs @@ -25,7 +25,7 @@ impl TracingRuntime { } } - #[allow(clippy::unnecessary_wraps)] + #[expect(clippy::unnecessary_wraps)] fn write_message(&mut self, message: SymExpr) -> Option { Some(self.writer.write_message(message).unwrap()) } @@ -35,14 +35,14 @@ impl TracingRuntime { /// according to [`concolic::SymExpr`]. macro_rules! expression_builder { ($method_name:ident ( $($param_name:ident : $param_type:ty ),+ ) => $message:ident) => { - #[allow(clippy::missing_safety_doc)] + // #[expect(clippy::missing_safety_doc)] #[no_mangle] fn $method_name(&mut self, $( $param_name : $param_type, )+ ) -> Option { self.write_message(SymExpr::$message { $($param_name,)+ }) } }; ($method_name:ident () => $message:ident) => { - #[allow(clippy::missing_safety_doc)] + // #[expect(clippy::missing_safety_doc)] #[no_mangle] fn $method_name(&mut self) -> Option { self.write_message(SymExpr::$message) @@ -63,7 +63,6 @@ macro_rules! binary_expression_builder { } impl Runtime for TracingRuntime { - #[allow(clippy::missing_safety_doc)] #[no_mangle] fn build_integer_from_buffer( &mut self, diff --git a/libafl_frida/src/alloc.rs b/libafl_frida/src/alloc.rs index c8b69e47b9..97114765dd 100644 --- a/libafl_frida/src/alloc.rs +++ b/libafl_frida/src/alloc.rs @@ -169,7 +169,7 @@ impl Allocator { /// Allocate a new allocation of the given size. #[must_use] - #[allow(clippy::missing_safety_doc)] + #[expect(clippy::missing_safety_doc)] pub unsafe fn alloc(&mut self, size: usize, _alignment: usize) -> *mut c_void { log::trace!("alloc"); let mut is_malloc_zero = false; @@ -180,7 +180,7 @@ impl Allocator { size }; if size > self.max_allocation { - #[allow(clippy::manual_assert)] + #[expect(clippy::manual_assert)] if self.max_allocation_panics { panic!("ASAN: Allocation is too large: 0x{size:x}"); } @@ -258,7 +258,7 @@ impl Allocator { } /// Releases the allocation at the given address. - #[allow(clippy::missing_safety_doc)] + #[expect(clippy::missing_safety_doc)] pub unsafe fn release(&mut self, ptr: *mut c_void) { log::trace!("release {:?}", ptr); let Some(metadata) = self.allocations.get_mut(&(ptr as usize)) else { diff --git a/libafl_frida/src/asan/asan_rt.rs b/libafl_frida/src/asan/asan_rt.rs index 5256475a25..0fd25d79d2 100644 --- a/libafl_frida/src/asan/asan_rt.rs +++ b/libafl_frida/src/asan/asan_rt.rs @@ -236,7 +236,6 @@ impl AsanRuntime { } /// Reset all allocations so that they can be reused for new allocation requests. - #[allow(clippy::unused_self)] pub fn reset_allocations(&mut self) { self.allocator.reset(); } @@ -259,13 +258,11 @@ impl AsanRuntime { /// Returns the `AsanErrors` from the recent run. /// Will block if some other thread holds on to the `ASAN_ERRORS` Mutex. - #[allow(clippy::unused_self)] pub fn errors(&mut self) -> MutexGuard<'static, AsanErrors> { ASAN_ERRORS.lock().unwrap() } /// Make sure the specified memory is unpoisoned - #[allow(clippy::unused_self)] pub fn unpoison(&mut self, address: usize, size: usize) { self.allocator .map_shadow_for_region(address, address + size, true); @@ -296,7 +293,6 @@ impl AsanRuntime { } /// Unpoison all the memory that is currently mapped with read/write permissions. - #[allow(clippy::unused_self)] pub fn unpoison_all_existing_memory(&mut self) { self.allocator.unpoison_all_existing_memory(); } @@ -312,7 +308,6 @@ impl AsanRuntime { /// Register the current thread with the runtime, implementing shadow memory for its stack and /// tls mappings. - #[allow(clippy::unused_self)] #[cfg(not(target_vendor = "apple"))] pub fn register_thread(&mut self) { let (stack_start, stack_end) = Self::current_stack(); @@ -329,7 +324,6 @@ impl AsanRuntime { } /// Register the current thread with the runtime, implementing shadow memory for its stack mapping. - #[allow(clippy::unused_self)] #[cfg(target_vendor = "apple")] pub fn register_thread(&mut self) { let (stack_start, stack_end) = Self::current_stack(); @@ -459,7 +453,7 @@ impl AsanRuntime { } /// Register the required hooks - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] pub fn register_hooks(&mut self, gum: &Gum) { let mut interceptor = Interceptor::obtain(gum); let module = Module::obtain(gum); @@ -475,7 +469,7 @@ impl AsanRuntime { let _ = [<$name:snake:upper _PTR>].set(unsafe {std::mem::transmute::<*const c_void, extern "C" fn($($param: $param_type),*) -> $return_type>(target_function.0)}).unwrap(); - #[allow(non_snake_case)] + #[allow(non_snake_case)] // depends on the values the macro is invoked with unsafe extern "C" fn []($($param: $param_type),*) -> $return_type { let mut invocation = Interceptor::current_invocation(); let this = &mut *(invocation.replacement_data().unwrap().0 as *mut AsanRuntime); @@ -515,7 +509,7 @@ impl AsanRuntime { let _ = [<$lib_ident:snake:upper _ $name:snake:upper _PTR>].set(unsafe {std::mem::transmute::<*const c_void, extern "C" fn($($param: $param_type),*) -> $return_type>(target_function.0)}).unwrap(); - #[allow(non_snake_case)] + #[expect(non_snake_case)] unsafe extern "C" fn []($($param: $param_type),*) -> $return_type { let mut invocation = Interceptor::current_invocation(); let this = &mut *(invocation.replacement_data().unwrap().0 as *mut AsanRuntime); @@ -545,7 +539,7 @@ impl AsanRuntime { }; } - #[allow(unused_macro_rules)] + #[expect(unused_macro_rules)] macro_rules! hook_func_with_check { //No library case ($name:ident, ($($param:ident : $param_type:ty),*), $return_type:ty) => { @@ -559,7 +553,7 @@ impl AsanRuntime { let _ = [<$name:snake:upper _PTR>].set(unsafe {std::mem::transmute::<*const c_void, extern "C" fn($($param: $param_type),*) -> $return_type>(target_function.0)}).unwrap_or_else(|e| println!("{:?}", e)); - #[allow(non_snake_case)] + #[allow(non_snake_case)] // depends on the values the macro is invoked with unsafe extern "C" fn []($($param: $param_type),*) -> $return_type { let mut invocation = Interceptor::current_invocation(); let this = &mut *(invocation.replacement_data().unwrap().0 as *mut AsanRuntime); @@ -599,7 +593,7 @@ impl AsanRuntime { let _ = [<$lib_ident:snake:upper _ $name:snake:upper _PTR>].set(unsafe {std::mem::transmute::<*const c_void, extern "C" fn($($param: $param_type),*) -> $return_type>(target_function.0)}).unwrap_or_else(|e| println!("{:?}", e)); - #[allow(non_snake_case)] + #[expect(non_snake_case)] unsafe extern "C" fn []($($param: $param_type),*) -> $return_type { let mut invocation = Interceptor::current_invocation(); let this = &mut *(invocation.replacement_data().unwrap().0 as *mut AsanRuntime); @@ -1255,8 +1249,8 @@ impl AsanRuntime { } #[cfg(target_arch = "x86_64")] - #[allow(clippy::cast_sign_loss)] - #[allow(clippy::too_many_lines)] + #[expect(clippy::cast_sign_loss)] + #[expect(clippy::too_many_lines)] extern "system" fn handle_trap(&mut self) { self.disable_hooks(); @@ -1326,7 +1320,6 @@ impl AsanRuntime { }; // log::trace!("{:x}", base_value); - #[allow(clippy::option_if_let_else)] let error = if fault_address >= stack_start && fault_address < stack_end { match access_type { Some(typ) => match typ { @@ -1425,8 +1418,8 @@ impl AsanRuntime { } #[cfg(target_arch = "aarch64")] - #[allow(clippy::cast_sign_loss)] // for displacement - #[allow(clippy::too_many_lines)] + #[expect(clippy::cast_sign_loss)] // for displacement + #[expect(clippy::too_many_lines)] extern "system" fn handle_trap(&mut self) { self.disable_hooks(); let mut actual_pc = self.regs[31]; @@ -1470,14 +1463,13 @@ impl AsanRuntime { } }; - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_possible_wrap)] let fault_address = (self.regs[base_reg as usize] as isize + displacement as isize) as usize; let backtrace = Backtrace::new(); let (stack_start, stack_end) = Self::current_stack(); - #[allow(clippy::option_if_let_else)] let error = if fault_address >= stack_start && fault_address < stack_end { if insn.opcode.to_string().starts_with('l') { AsanError::StackOobRead(( @@ -1549,7 +1541,7 @@ impl AsanRuntime { } #[cfg(target_arch = "x86_64")] - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] fn register_idx(&self, reg: X86Register) -> Option<(u16, u16)> { match reg { X86Register::Eax => Some((0, 32)), @@ -1671,7 +1663,6 @@ impl AsanRuntime { */ #[cfg(target_arch = "x86_64")] - #[allow(clippy::unused_self)] fn generate_shadow_check_blob(&mut self, size: u32) -> Box<[u8]> { let shadow_bit = self.allocator.shadow_bit(); // Rcx, Rax, Rdi, Rdx, Rsi, R8 are used, so we save them in emit_shadow_check @@ -1716,7 +1707,6 @@ impl AsanRuntime { } #[cfg(target_arch = "aarch64")] - #[allow(clippy::unused_self)] fn generate_shadow_check_blob(&mut self, width: u32) -> Box<[u8]> { /*x0 contains the shadow address x0 and x1 are saved by the asan_check @@ -1759,7 +1749,6 @@ impl AsanRuntime { } #[cfg(target_arch = "aarch64")] - #[allow(clippy::unused_self)] fn generate_shadow_check_large_blob(&mut self, width: u32) -> Box<[u8]> { //x0 contains the shadow address //x0 and x1 are saved by the asan_check @@ -1807,9 +1796,6 @@ impl AsanRuntime { // Five registers, Rdi, Rsi, Rdx, Rcx, Rax are saved in emit_shadow_check before entering this function // So we retrieve them after saving other registers #[cfg(target_arch = "x86_64")] - #[allow(clippy::similar_names)] - #[allow(clippy::cast_possible_wrap)] - #[allow(clippy::too_many_lines)] fn generate_instrumentation_blobs(&mut self) { let mut ops_report = dynasmrt::VecAssembler::::new(0); dynasm!(ops_report @@ -1897,9 +1883,7 @@ impl AsanRuntime { /// /// Generate the instrumentation blobs for the current arch. #[cfg(target_arch = "aarch64")] - #[allow(clippy::similar_names)] // We allow things like dword and qword - #[allow(clippy::cast_possible_wrap)] - #[allow(clippy::too_many_lines)] + #[expect(clippy::cast_possible_wrap)] fn generate_instrumentation_blobs(&mut self) { let mut ops_report = dynasmrt::VecAssembler::::new(0); dynasm!(ops_report @@ -2116,7 +2100,7 @@ impl AsanRuntime { #[cfg(target_arch = "aarch64")] #[must_use] #[inline] - #[allow(clippy::similar_names, clippy::type_complexity)] + #[expect(clippy::similar_names, clippy::type_complexity)] pub fn asan_is_interesting_instruction( decoder: InstDecoder, _address: u64, @@ -2179,7 +2163,7 @@ impl AsanRuntime { // println!("{:?} {}", instr, memory_access_size); //abuse the fact that the last operand is always the mem operand - #[allow(clippy::let_and_return)] + #[expect(clippy::let_and_return)] match instr.operands[operands_len - 1] { Operand::RegRegOffset(reg1, reg2, size, shift, shift_size) => { let ret = Some(( @@ -2216,7 +2200,6 @@ impl AsanRuntime { #[cfg(target_arch = "x86_64")] #[inline] #[must_use] - #[allow(clippy::result_unit_err)] pub fn asan_is_interesting_instruction( decoder: InstDecoder, address: u64, @@ -2280,8 +2263,8 @@ impl AsanRuntime { /// Emits a asan shadow byte check. #[inline] - #[allow(clippy::too_many_lines)] - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_lines)] + #[expect(clippy::too_many_arguments)] #[cfg(target_arch = "x86_64")] pub fn emit_shadow_check( &mut self, @@ -2464,7 +2447,7 @@ impl AsanRuntime { /// Emit a shadow memory check into the instruction stream #[cfg(target_arch = "aarch64")] #[inline] - #[allow(clippy::too_many_lines, clippy::too_many_arguments)] + #[expect(clippy::too_many_lines, clippy::too_many_arguments)] pub fn emit_shadow_check( &mut self, _address: u64, @@ -2479,7 +2462,7 @@ impl AsanRuntime { i32::try_from(frida_gum_sys::GUM_RED_ZONE_SIZE).is_ok(), "GUM_RED_ZONE_SIZE is bigger than i32::max" ); - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_possible_wrap)] let redzone_size = frida_gum_sys::GUM_RED_ZONE_SIZE as i32; let writer = output.writer(); @@ -2571,14 +2554,14 @@ impl AsanRuntime { if extender_encoding != -1 && shift_amount < 0b1000 { // emit add extended register: https://developer.arm.com/documentation/ddi0602/latest/Base-Instructions/ADD--extended-register---Add--extended-register-- - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] writer.put_bytes( &(0x8b210000 | ((extender_encoding as u32) << 13) | (shift_amount << 10)) .to_le_bytes(), ); //add x0, x0, w1, [shift] #[amount] } else if shift_encoding != -1 { //https://developer.arm.com/documentation/ddi0602/2024-03/Base-Instructions/ADD--shifted-register---Add--shifted-register-- add shifted register - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] writer.put_bytes( &(0x8b010000 | ((shift_encoding as u32) << 22) | (shift_amount << 10)) .to_le_bytes(), @@ -2602,10 +2585,9 @@ impl AsanRuntime { 0 }; - #[allow(clippy::comparison_chain)] + #[expect(clippy::comparison_chain)] if displacement < 0 { if displacement > -4096 { - #[allow(clippy::cast_sign_loss)] let displacement = displacement.unsigned_abs(); // Subtract the displacement into x0 writer.put_sub_reg_reg_imm( @@ -2614,7 +2596,6 @@ impl AsanRuntime { u64::from(displacement), ); } else { - #[allow(clippy::cast_sign_loss)] let displacement = displacement.unsigned_abs(); let displacement_hi = displacement / 4096; let displacement_lo = displacement % 4096; @@ -2626,7 +2607,7 @@ impl AsanRuntime { ); //sub x0, x0, #[displacement 4096] } } else if displacement > 0 { - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] let displacement = displacement as u32; if displacement < 4096 { // Add the displacement into x0 diff --git a/libafl_frida/src/asan/errors.rs b/libafl_frida/src/asan/errors.rs index b41b0b42ce..bdd062d262 100644 --- a/libafl_frida/src/asan/errors.rs +++ b/libafl_frida/src/asan/errors.rs @@ -50,7 +50,7 @@ pub(crate) struct AsanReadWriteError { pub backtrace: Backtrace, } -#[allow(clippy::type_complexity)] +#[expect(clippy::type_complexity)] #[derive(Debug, Clone, Serialize, Deserialize, SerdeAny)] pub(crate) enum AsanError { OobRead(AsanReadWriteError), @@ -108,7 +108,7 @@ impl AsanError { } /// A struct holding errors that occurred during frida address sanitizer runs -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] #[derive(Debug, Clone, Serialize, Deserialize, SerdeAny)] pub struct AsanErrors { continue_on_error: bool, @@ -153,7 +153,7 @@ impl AsanErrors { } /// Report an error - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] pub(crate) fn report_error(&mut self, error: AsanError) { let mut out_stream = default_output_stream(); let output = out_stream.as_mut(); @@ -168,7 +168,7 @@ impl AsanErrors { ); })); - #[allow(clippy::non_ascii_literal)] + #[expect(clippy::non_ascii_literal)] writeln!(output, "{:━^100}", " Memory error detected! ").unwrap(); output .set_color(ColorSpec::new().set_fg(Some(Color::Red))) @@ -201,7 +201,7 @@ impl AsanErrors { } output.reset().unwrap(); - #[allow(clippy::non_ascii_literal)] + #[expect(clippy::non_ascii_literal)] writeln!(output, "{:━^100}", " REGISTERS ").unwrap(); #[cfg(target_arch = "aarch64")] for reg in 0..=30 { @@ -248,7 +248,7 @@ impl AsanErrors { #[cfg(target_arch = "x86_64")] writeln!(output, "rip: 0x{:016x}", error.pc).unwrap(); - #[allow(clippy::non_ascii_literal)] + #[expect(clippy::non_ascii_literal)] writeln!(output, "{:━^100}", " CODE ").unwrap(); #[cfg(target_arch = "aarch64")] @@ -291,7 +291,7 @@ impl AsanErrors { .print_trace(&error.backtrace, output) .unwrap(); - #[allow(clippy::non_ascii_literal)] + #[expect(clippy::non_ascii_literal)] writeln!(output, "{:━^100}", " ALLOCATION INFO ").unwrap(); let fault_address: i64 = fault_address.try_into().unwrap(); let metadata_address: i64 = error.metadata.address.try_into().unwrap(); @@ -322,7 +322,7 @@ impl AsanErrors { } if error.metadata.freed { - #[allow(clippy::non_ascii_literal)] + #[expect(clippy::non_ascii_literal)] writeln!(output, "{:━^100}", " FREE INFO ").unwrap(); if let Some(backtrace) = &mut release_site_backtrace { writeln!(output, "free site backtrace:").unwrap(); @@ -357,7 +357,7 @@ impl AsanErrors { writeln!(output, " at 0x{_pc:x}").unwrap(); } - #[allow(clippy::non_ascii_literal)] + #[expect(clippy::non_ascii_literal)] writeln!(output, "{:━^100}", " REGISTERS ").unwrap(); for reg in 0..29 { let val = cpu_context.reg(reg); @@ -384,7 +384,7 @@ impl AsanErrors { output.reset().unwrap(); backtrace_printer.print_trace(backtrace, output).unwrap(); - #[allow(clippy::non_ascii_literal)] + #[expect(clippy::non_ascii_literal)] writeln!(output, "{:━^100}", " ALLOCATION INFO ").unwrap(); writeln!( output, @@ -405,7 +405,7 @@ impl AsanErrors { backtrace.resolve(); backtrace_printer.print_trace(backtrace, output).unwrap(); } - #[allow(clippy::non_ascii_literal)] + #[expect(clippy::non_ascii_literal)] writeln!(output, "{:━^100}", " FREE INFO ").unwrap(); if let Some(backtrace) = &mut release_site_backtrace { writeln!(output, "previous free site backtrace:").unwrap(); @@ -422,7 +422,7 @@ impl AsanErrors { writeln!(output, " of {ptr:#016x}").unwrap(); output.reset().unwrap(); - #[allow(clippy::non_ascii_literal)] + #[expect(clippy::non_ascii_literal)] writeln!(output, "{:━^100}", " ALLOCATION INFO ").unwrap(); writeln!( output, @@ -463,7 +463,7 @@ impl AsanErrors { } output.reset().unwrap(); - #[allow(clippy::non_ascii_literal)] + #[expect(clippy::non_ascii_literal)] writeln!(output, "{:━^100}", " REGISTERS ").unwrap(); #[cfg(target_arch = "aarch64")] @@ -512,7 +512,7 @@ impl AsanErrors { #[cfg(target_arch = "x86_64")] writeln!(output, "Rip: 0x{pc:016x}").unwrap(); - #[allow(clippy::non_ascii_literal)] + #[expect(clippy::non_ascii_literal)] writeln!(output, "{:━^100}", " CODE ").unwrap(); #[cfg(target_arch = "aarch64")] @@ -557,7 +557,7 @@ impl AsanErrors { self.errors.push(error); - #[allow(clippy::manual_assert)] + #[expect(clippy::manual_assert)] if !self.continue_on_error { panic!("ASAN: Crashing target!"); } @@ -569,7 +569,7 @@ pub static ASAN_ERRORS: Mutex = Mutex::new(AsanErrors::new(true)); /// An observer for frida address sanitizer `AsanError`s for a `Frida` executor run #[derive(Debug, Serialize, Deserialize)] -#[allow(clippy::unsafe_derive_deserialize)] +#[expect(clippy::unsafe_derive_deserialize)] pub enum AsanErrorsObserver { /// Observer referencing a list behind a [`OwnedPtr`] pointer. Ptr(OwnedPtr), @@ -653,7 +653,6 @@ where S: State + Debug, OT: MatchNameRef, { - #[allow(clippy::wrong_self_convention)] fn is_interesting( &mut self, _state: &mut S, diff --git a/libafl_frida/src/asan/hook_funcs.rs b/libafl_frida/src/asan/hook_funcs.rs index 3d5a122f61..d7e391c5b5 100644 --- a/libafl_frida/src/asan/hook_funcs.rs +++ b/libafl_frida/src/asan/hook_funcs.rs @@ -1,5 +1,3 @@ -#![allow(clippy::used_underscore_items)] - //! The allocator hooks for address sanitizer. use std::ffi::c_void; @@ -22,7 +20,7 @@ extern "system" { extern "system" { fn memset(s: *mut c_void, c: i32, n: usize) -> *mut c_void; } -#[allow(clippy::not_unsafe_ptr_arg_deref)] +#[expect(clippy::not_unsafe_ptr_arg_deref)] impl AsanRuntime { #[inline] #[allow(non_snake_case)] @@ -65,7 +63,7 @@ impl AsanRuntime { ) } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_CreateFileMappingW( &mut self, @@ -95,7 +93,7 @@ impl AsanRuntime { ) } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_LdrLoadDll( &mut self, @@ -118,7 +116,7 @@ impl AsanRuntime { result } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_LdrpCallInitRoutine( &mut self, @@ -140,7 +138,7 @@ impl AsanRuntime { 0 } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_LoadLibraryExW( &mut self, @@ -157,7 +155,7 @@ impl AsanRuntime { } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_RtlCreateHeap( &mut self, @@ -179,7 +177,7 @@ impl AsanRuntime { 0xc0debeef as *mut c_void } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_RtlDestroyHeap( &mut self, @@ -190,7 +188,7 @@ impl AsanRuntime { } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_HeapAlloc( &mut self, @@ -213,7 +211,7 @@ impl AsanRuntime { ret } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_RtlAllocateHeap( &mut self, @@ -236,7 +234,7 @@ impl AsanRuntime { ret } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_HeapReAlloc( &mut self, @@ -280,7 +278,7 @@ impl AsanRuntime { ret } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_RtlReAllocateHeap( &mut self, @@ -325,7 +323,7 @@ impl AsanRuntime { ret } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_RtlFreeHeap( &mut self, @@ -336,7 +334,7 @@ impl AsanRuntime { self.allocator_mut().is_managed(ptr) } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_RtlFreeHeap( &mut self, @@ -349,7 +347,7 @@ impl AsanRuntime { 0 } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_HeapFree( &mut self, @@ -360,7 +358,7 @@ impl AsanRuntime { self.allocator_mut().is_managed(ptr) } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_HeapFree( &mut self, @@ -373,7 +371,7 @@ impl AsanRuntime { true } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_HeapSize( &mut self, @@ -384,7 +382,7 @@ impl AsanRuntime { self.allocator_mut().is_managed(ptr) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_HeapSize( &mut self, @@ -396,7 +394,7 @@ impl AsanRuntime { self.allocator().get_usable_size(ptr) } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_RtlSizeHeap( &mut self, @@ -407,7 +405,7 @@ impl AsanRuntime { self.allocator_mut().is_managed(ptr) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_RtlSizeHeap( &mut self, @@ -419,7 +417,7 @@ impl AsanRuntime { self.allocator().get_usable_size(ptr) } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_RtlValidateHeap( &mut self, @@ -430,7 +428,7 @@ impl AsanRuntime { self.allocator_mut().is_managed(ptr) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_RtlValidateHeap( &mut self, @@ -442,7 +440,7 @@ impl AsanRuntime { true } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_LocalAlloc( &mut self, @@ -459,7 +457,7 @@ impl AsanRuntime { } ret } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_LocalReAlloc( &mut self, @@ -479,14 +477,14 @@ impl AsanRuntime { ret } } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_LocalFree(&mut self, mem: *mut c_void) -> bool { let res = self.allocator_mut().is_managed(mem); res } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_LocalFree( &mut self, @@ -497,12 +495,12 @@ impl AsanRuntime { mem } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_LocalHandle(&mut self, mem: *mut c_void) -> bool { self.allocator_mut().is_managed(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_LocalHandle( &mut self, @@ -511,13 +509,13 @@ impl AsanRuntime { ) -> *mut c_void { mem } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_LocalLock(&mut self, mem: *mut c_void) -> bool { self.allocator_mut().is_managed(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_LocalLock( &mut self, @@ -526,12 +524,12 @@ impl AsanRuntime { ) -> *mut c_void { mem } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_LocalUnlock(&mut self, mem: *mut c_void) -> bool { self.allocator_mut().is_managed(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_LocalUnlock( &mut self, @@ -540,12 +538,12 @@ impl AsanRuntime { ) -> bool { false } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_LocalSize(&mut self, mem: *mut c_void) -> bool { self.allocator_mut().is_managed(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_LocalSize( &mut self, @@ -554,12 +552,12 @@ impl AsanRuntime { ) -> usize { self.allocator_mut().get_usable_size(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_LocalFlags(&mut self, mem: *mut c_void) -> bool { self.allocator_mut().is_managed(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_LocalFlags( &mut self, @@ -569,7 +567,7 @@ impl AsanRuntime { 0 } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_GlobalAlloc( &mut self, @@ -589,7 +587,7 @@ impl AsanRuntime { } ret } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_GlobalReAlloc( &mut self, @@ -609,12 +607,12 @@ impl AsanRuntime { ret } } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_GlobalFree(&mut self, mem: *mut c_void) -> bool { self.allocator_mut().is_managed(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_GlobalFree( &mut self, @@ -625,12 +623,12 @@ impl AsanRuntime { mem } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_GlobalHandle(&mut self, mem: *mut c_void) -> bool { self.allocator_mut().is_managed(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_GlobalHandle( &mut self, @@ -639,13 +637,13 @@ impl AsanRuntime { ) -> *mut c_void { mem } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_GlobalLock(&mut self, mem: *mut c_void) -> bool { self.allocator_mut().is_managed(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_GlobalLock( &mut self, @@ -654,12 +652,12 @@ impl AsanRuntime { ) -> *mut c_void { mem } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_GlobalUnlock(&mut self, mem: *mut c_void) -> bool { self.allocator_mut().is_managed(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_GlobalUnlock( &mut self, @@ -668,12 +666,12 @@ impl AsanRuntime { ) -> bool { false } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_GlobalSize(&mut self, mem: *mut c_void) -> bool { self.allocator_mut().is_managed(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_GlobalSize( &mut self, @@ -682,12 +680,12 @@ impl AsanRuntime { ) -> usize { self.allocator_mut().get_usable_size(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_check_GlobalFlags(&mut self, mem: *mut c_void) -> bool { self.allocator_mut().is_managed(mem) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_GlobalFlags( &mut self, @@ -715,7 +713,7 @@ impl AsanRuntime { unsafe { self.allocator_mut().alloc(size, 8) } } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[inline] pub fn hook__Znam( &mut self, @@ -725,7 +723,7 @@ impl AsanRuntime { unsafe { self.allocator_mut().alloc(size, 8) } } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[inline] pub fn hook__ZnamRKSt9nothrow_t( &mut self, @@ -736,7 +734,7 @@ impl AsanRuntime { unsafe { self.allocator_mut().alloc(size, 8) } } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[inline] pub fn hook__ZnamSt11align_val_t( &mut self, @@ -747,7 +745,7 @@ impl AsanRuntime { unsafe { self.allocator_mut().alloc(size, alignment) } } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[inline] pub fn hook__ZnamSt11align_val_tRKSt9nothrow_t( &mut self, @@ -763,7 +761,9 @@ impl AsanRuntime { unsafe { self.allocator_mut().alloc(size, alignment) } } - #[allow(non_snake_case)] + #[expect(non_snake_case)] + #[allow(unknown_lints)] // the compiler is contradicting itself + #[expect(clippy::used_underscore_items)] #[inline] pub fn hook__Znwm( &mut self, @@ -785,7 +785,7 @@ impl AsanRuntime { } } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[inline] pub fn hook__ZnwmRKSt9nothrow_t( &mut self, @@ -796,7 +796,9 @@ impl AsanRuntime { unsafe { self.allocator_mut().alloc(size, 8) } } - #[allow(non_snake_case)] + #[expect(non_snake_case)] + #[allow(unknown_lints)] // the compiler is contradicting itself + #[expect(clippy::used_underscore_items)] #[inline] pub fn hook__ZnwmSt11align_val_t( &mut self, @@ -817,7 +819,7 @@ impl AsanRuntime { result } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[inline] pub fn hook__ZnwmSt11align_val_tRKSt9nothrow_t( &mut self, @@ -833,7 +835,7 @@ impl AsanRuntime { unsafe { self.allocator_mut().alloc(size, alignment) } } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[inline] pub fn hook__o_malloc( &mut self, @@ -859,7 +861,7 @@ impl AsanRuntime { ret } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[inline] pub fn hook__o_calloc( &mut self, @@ -877,9 +879,8 @@ impl AsanRuntime { ret } - #[allow(non_snake_case)] #[inline] - #[allow(clippy::cmp_null)] + #[expect(clippy::cmp_null)] pub fn hook_realloc( &mut self, _original: extern "C" fn(ptr: *mut c_void, size: usize) -> *mut c_void, @@ -898,9 +899,9 @@ impl AsanRuntime { } } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[inline] - #[allow(clippy::cmp_null)] + #[expect(clippy::cmp_null)] pub fn hook__o_realloc( &mut self, _original: extern "C" fn(ptr: *mut c_void, size: usize) -> *mut c_void, @@ -919,15 +920,15 @@ impl AsanRuntime { } } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[inline] pub fn hook_check__o_free(&mut self, ptr: *mut c_void) -> bool { self.allocator_mut().is_managed(ptr) } - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[inline] - #[allow(clippy::cmp_null)] + #[expect(clippy::cmp_null)] pub fn hook__o_free( &mut self, _original: extern "C" fn(ptr: *mut c_void) -> usize, @@ -944,7 +945,7 @@ impl AsanRuntime { } #[inline] - #[allow(clippy::cmp_null)] + #[expect(clippy::cmp_null)] pub fn hook_free( &mut self, _original: extern "C" fn(ptr: *mut c_void) -> usize, @@ -992,7 +993,7 @@ impl AsanRuntime { } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] #[cfg(windows)] pub fn hook_MapViewOfFile( &mut self, @@ -1020,8 +1021,8 @@ impl AsanRuntime { ret } - #[allow(non_snake_case)] - #[allow(clippy::cmp_null)] + #[expect(non_snake_case)] + #[expect(clippy::cmp_null)] #[inline] pub fn hook__ZdaPv( &mut self, @@ -1034,8 +1035,8 @@ impl AsanRuntime { 0 } - #[allow(non_snake_case)] - #[allow(clippy::cmp_null)] + #[expect(non_snake_case)] + #[expect(clippy::cmp_null)] #[inline] pub fn hook__ZdaPvm( &mut self, @@ -1049,8 +1050,8 @@ impl AsanRuntime { 0 } - #[allow(non_snake_case)] - #[allow(clippy::cmp_null)] + #[expect(non_snake_case)] + #[expect(clippy::cmp_null)] #[inline] pub fn hook__ZdaPvmSt11align_val_t( &mut self, @@ -1065,8 +1066,8 @@ impl AsanRuntime { 0 } - #[allow(non_snake_case)] - #[allow(clippy::cmp_null)] + #[expect(non_snake_case)] + #[expect(clippy::cmp_null)] #[inline] pub fn hook__ZdaPvRKSt9nothrow_t( &mut self, @@ -1080,8 +1081,8 @@ impl AsanRuntime { 0 } - #[allow(non_snake_case)] - #[allow(clippy::cmp_null)] + #[expect(non_snake_case)] + #[expect(clippy::cmp_null)] #[inline] pub fn hook__ZdaPvSt11align_val_tRKSt9nothrow_t( &mut self, @@ -1100,8 +1101,8 @@ impl AsanRuntime { 0 } - #[allow(non_snake_case)] - #[allow(clippy::cmp_null)] + #[expect(non_snake_case)] + #[expect(clippy::cmp_null)] #[inline] pub fn hook__ZdaPvSt11align_val_t( &mut self, @@ -1115,8 +1116,8 @@ impl AsanRuntime { 0 } - #[allow(non_snake_case)] - #[allow(clippy::cmp_null)] + #[expect(non_snake_case)] + #[expect(clippy::cmp_null)] #[inline] pub fn hook__ZdlPv( &mut self, @@ -1129,8 +1130,8 @@ impl AsanRuntime { 0 } - #[allow(non_snake_case)] - #[allow(clippy::cmp_null)] + #[expect(non_snake_case)] + #[expect(clippy::cmp_null)] #[inline] pub fn hook__ZdlPvm( &mut self, @@ -1144,8 +1145,8 @@ impl AsanRuntime { 0 } - #[allow(non_snake_case)] - #[allow(clippy::cmp_null)] + #[expect(non_snake_case)] + #[expect(clippy::cmp_null)] #[inline] pub fn hook__ZdlPvmSt11align_val_t( &mut self, @@ -1160,8 +1161,8 @@ impl AsanRuntime { 0 } - #[allow(non_snake_case)] - #[allow(clippy::cmp_null)] + #[expect(non_snake_case)] + #[expect(clippy::cmp_null)] #[inline] pub fn hook__ZdlPvRKSt9nothrow_t( &mut self, @@ -1175,8 +1176,8 @@ impl AsanRuntime { 0 } - #[allow(non_snake_case)] - #[allow(clippy::cmp_null)] + #[expect(non_snake_case)] + #[expect(clippy::cmp_null)] #[inline] pub fn hook__ZdlPvSt11align_val_tRKSt9nothrow_t( &mut self, @@ -1195,8 +1196,8 @@ impl AsanRuntime { 0 } - #[allow(non_snake_case)] - #[allow(clippy::cmp_null)] + #[expect(non_snake_case)] + #[expect(clippy::cmp_null)] #[inline] pub fn hook__ZdlPvSt11align_val_t( &mut self, @@ -1211,7 +1212,7 @@ impl AsanRuntime { } #[inline] - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn hook_mmap( &mut self, original: extern "C" fn( @@ -1254,7 +1255,7 @@ impl AsanRuntime { } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] pub fn hook__write( &mut self, original: extern "C" fn(fd: i32, buf: *const c_void, count: usize) -> usize, @@ -1285,7 +1286,7 @@ impl AsanRuntime { } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] pub fn hook__read( &mut self, original: extern "C" fn(fd: i32, buf: *mut c_void, count: usize) -> usize, @@ -1952,7 +1953,7 @@ impl AsanRuntime { } #[inline] - #[allow(non_snake_case)] + #[expect(non_snake_case)] pub fn hook__strdup( &mut self, original: extern "C" fn(s: *const c_char) -> *mut c_char, diff --git a/libafl_frida/src/asan/mod.rs b/libafl_frida/src/asan/mod.rs index 040461d325..cb63dc3875 100644 --- a/libafl_frida/src/asan/mod.rs +++ b/libafl_frida/src/asan/mod.rs @@ -1,5 +1,6 @@ //! Address sanitization using [`frida`](https://frida.re/) pub mod asan_rt; pub mod errors; -#[allow(missing_docs)] + +#[allow(missing_docs)] // cfg dependent pub mod hook_funcs; diff --git a/libafl_frida/src/cmplog_rt.rs b/libafl_frida/src/cmplog_rt.rs index 7e9e8fa724..687ab5ce8e 100644 --- a/libafl_frida/src/cmplog_rt.rs +++ b/libafl_frida/src/cmplog_rt.rs @@ -62,7 +62,7 @@ use yaxpeax_x86::long_mode::InstDecoder; /// # Panic /// In debug mode, will panic on wraparound (which should never happen in practice) #[cfg(all(feature = "cmplog", target_arch = "aarch64"))] -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] fn gum_red_zone_size_i32() -> i32 { debug_assert!( i32::try_from(frida_gum_sys::GUM_RED_ZONE_SIZE).is_ok(), @@ -161,7 +161,7 @@ impl CmpLogRuntime { } /// Call the external function that populates the `cmplog_map` with the relevant values - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] #[cfg(target_arch = "aarch64")] extern "C" fn populate_lists(&mut self, op1: u64, op2: u64, retaddr: u64) { // log::trace!( @@ -177,7 +177,6 @@ impl CmpLogRuntime { } } - #[allow(clippy::unused_self)] #[cfg(target_arch = "x86_64")] extern "C" fn populate_lists(size: u8, op1: u64, op2: u64, retaddr: u64) { // log::trace!( @@ -194,7 +193,7 @@ impl CmpLogRuntime { } /// Generate the instrumentation blobs for the current arch. - #[allow(clippy::similar_names)] + #[expect(clippy::similar_names)] #[cfg(target_arch = "aarch64")] fn generate_instrumentation_blobs(&mut self) { macro_rules! blr_to_populate { @@ -307,7 +306,7 @@ impl CmpLogRuntime { ); } - #[allow(clippy::similar_names)] + #[expect(clippy::similar_names)] #[cfg(all(windows, target_arch = "x86_64"))] fn generate_instrumentation_blobs(&mut self) { macro_rules! save_registers { @@ -343,7 +342,6 @@ impl CmpLogRuntime { self.restore_registers = Some(restore_registers.finalize().unwrap().into_boxed_slice()); } - #[allow(clippy::similar_names)] #[cfg(all(unix, target_arch = "x86_64"))] fn generate_instrumentation_blobs(&mut self) { macro_rules! save_registers { @@ -405,7 +403,7 @@ impl CmpLogRuntime { /// Emit the instrumentation code which is responsible for operands value extraction and cmplog map population #[cfg(all(feature = "cmplog", target_arch = "x86_64"))] - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] #[inline] pub fn emit_comparison_handling( &self, @@ -557,7 +555,7 @@ impl CmpLogRuntime { /// Emit the instrumentation code which is responsible for operands value extraction and cmplog map population #[cfg(all(feature = "cmplog", target_arch = "aarch64"))] - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] #[inline] pub fn emit_comparison_handling( &self, @@ -639,7 +637,6 @@ impl CmpLogRuntime { } #[cfg(all(feature = "cmplog", target_arch = "x86_64"))] - #[allow(clippy::similar_names)] #[inline] /// Check if the current instruction is cmplog relevant one(any opcode which sets the flags) #[must_use] @@ -692,7 +689,7 @@ impl CmpLogRuntime { OpKind::Memory => { // can't use try_into here, since we need to cast u64 to i64 // which is fine in this case - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_possible_wrap)] CmplogOperandType::Mem( instruction.memory_base(), instruction.memory_index(), @@ -714,7 +711,7 @@ impl CmpLogRuntime { | OpKind::Immediate32to64 => CmplogOperandType::Imm(instruction.immediate(1)), OpKind::Memory => { - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_possible_wrap)] CmplogOperandType::Mem( instruction.memory_base(), instruction.memory_index(), @@ -747,7 +744,7 @@ impl CmpLogRuntime { } #[cfg(all(feature = "cmplog", target_arch = "aarch64"))] - #[allow(clippy::similar_names, clippy::type_complexity)] + #[expect(clippy::similar_names, clippy::type_complexity)] #[inline] /// Check if the current instruction is cmplog relevant one(any opcode which sets the flags) #[must_use] @@ -821,10 +818,10 @@ impl CmpLogRuntime { } // cbz marked as special since there is only 1 operand - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] let special_case = matches!(instr.opcode, Opcode::CBZ | Opcode::CBNZ); - #[allow(clippy::cast_sign_loss, clippy::similar_names)] + #[expect(clippy::cast_sign_loss, clippy::similar_names)] let operand1 = match instr.operands[0] { //the only possibilities are registers for the first operand //precompute the aarch64 frida register because it is ambiguous if register=31 means xzr or sp in yaxpeax @@ -837,7 +834,7 @@ impl CmpLogRuntime { _ => panic!("First argument is not a register"), //this should never be possible in arm64 }; - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] let operand2 = if special_case { Some((CmplogOperandType::Imm(0), None)) } else { diff --git a/libafl_frida/src/coverage_rt.rs b/libafl_frida/src/coverage_rt.rs index 3a6226b6de..f73a78ea17 100644 --- a/libafl_frida/src/coverage_rt.rs +++ b/libafl_frida/src/coverage_rt.rs @@ -55,8 +55,8 @@ impl FridaRuntime for CoverageRuntime { impl CoverageRuntime { /// Create a new coverage runtime - #[must_use] #[allow(clippy::large_stack_arrays)] + #[must_use] pub fn new() -> Self { Self(Rc::pin(RefCell::new(CoverageRuntimeInner { map: [0_u8; MAP_SIZE], @@ -74,7 +74,7 @@ impl CoverageRuntime { /// every time we need a copy that is within a direct branch of the start of the transformed basic /// block. #[cfg(target_arch = "aarch64")] - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_possible_wrap)] pub fn generate_inline_code(&mut self, h64: u64) -> Box<[u8]> { let mut borrow = self.0.borrow_mut(); let prev_loc_ptr = &raw mut borrow.previous_pc; diff --git a/libafl_frida/src/helper.rs b/libafl_frida/src/helper.rs index 5c03edb6c0..d7148a6a7b 100644 --- a/libafl_frida/src/helper.rs +++ b/libafl_frida/src/helper.rs @@ -141,7 +141,7 @@ pub enum SkipRange { pub struct FridaInstrumentationHelperBuilder { stalker_enabled: bool, disable_excludes: bool, - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] instrument_module_predicate: Option bool>>, skip_module_predicate: Box bool>, skip_ranges: Vec, @@ -488,7 +488,6 @@ where println!("msg: {msg:}, bytes: {bytes:x?}"); } - #[allow(clippy::too_many_lines)] fn build_transformer( gum: &'a Gum, ranges: &Rc>>, @@ -508,7 +507,7 @@ where }) } - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] fn transform( basic_block: StalkerIterator, output: &StalkerOutput, diff --git a/libafl_frida/src/lib.rs b/libafl_frida/src/lib.rs index acc6a148be..aa4ad95744 100644 --- a/libafl_frida/src/lib.rs +++ b/libafl_frida/src/lib.rs @@ -24,26 +24,22 @@ Additional documentation is available in [the `LibAFL` book](https://aflplus.plu unused_extern_crates, unused_import_braces, unused_qualifications, + unfulfilled_lint_expectations, unused_must_use, - //unused_results -))] -#![cfg_attr( - test, - deny( - bad_style, - dead_code, - improper_ctypes, - non_shorthand_field_patterns, - no_mangle_generic_items, - overflowing_literals, - path_statements, - patterns_in_fns_without_body, - unconditional_recursion, - unused, - unused_allocation, - unused_comparisons, - unused_parens, - while_true + bad_style, + dead_code, + improper_ctypes, + non_shorthand_field_patterns, + no_mangle_generic_items, + overflowing_literals, + path_statements, + patterns_in_fns_without_body, + unconditional_recursion, + unused, + unused_allocation, + unused_comparisons, + unused_parens, + while_true ) )] @@ -81,7 +77,7 @@ pub mod utils; use libafl_bolts::core_affinity::{get_core_ids, CoreId, Cores}; /// A representation of the various Frida options #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[allow(clippy::struct_excessive_bools)] +#[expect(clippy::struct_excessive_bools)] pub struct FridaOptions { enable_asan: bool, enable_asan_leak_detection: bool, @@ -104,7 +100,7 @@ impl FridaOptions { /// # Panics /// Panics, if no `=` sign exists in input, or or `value` behind `=` has zero length. #[must_use] - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] pub fn parse_env_options() -> Self { let mut options = Self::default(); let mut asan_cores = None; @@ -370,7 +366,7 @@ mod tests { static GUM: OnceLock = OnceLock::new(); - #[allow(clippy::too_many_lines)] + #[expect(clippy::too_many_lines)] unsafe fn test_asan(options: &FuzzerOptions) { // The names of the functions to run let tests = vec![ diff --git a/libafl_frida/src/pthread_hook.rs b/libafl_frida/src/pthread_hook.rs index 284a7bcdaa..f6c83d8b7d 100644 --- a/libafl_frida/src/pthread_hook.rs +++ b/libafl_frida/src/pthread_hook.rs @@ -5,7 +5,7 @@ const PTHREAD_INTROSPECTION_THREAD_START: libc::c_uint = 2; const PTHREAD_INTROSPECTION_THREAD_TERMINATE: libc::c_uint = 3; const PTHREAD_INTROSPECTION_THREAD_DESTROY: libc::c_uint = 4; -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types)] type pthread_introspection_hook_t = extern "C" fn( event: libc::c_uint, thread: libc::pthread_t, diff --git a/libafl_frida/src/utils.rs b/libafl_frida/src/utils.rs index 364b32a527..2b59e366d9 100644 --- a/libafl_frida/src/utils.rs +++ b/libafl_frida/src/utils.rs @@ -192,7 +192,6 @@ pub fn get_register(context: &CpuContext, reg: X86Register) -> u64 { #[cfg(target_arch = "x86_64")] #[must_use] #[inline] -#[allow(clippy::unused_self)] pub fn writer_register(reg: RegSpec) -> X86Register { for (reg1, reg2) in &X86_64_REGS { // println!("reg1:{:#?} reg2:{:#?}", reg1, reg); @@ -277,7 +276,7 @@ pub fn immediate_value(operand: &Operand) -> Option { Operand::ImmediateI32 { imm } => Some(i64::from(*imm)), Operand::ImmediateU32 { imm } => Some(i64::from(*imm)), Operand::ImmediateI64 { imm } => Some(*imm), - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_possible_wrap)] Operand::ImmediateU64 { imm } => Some(*imm as i64), _ => None, } diff --git a/libafl_libfuzzer/build.rs b/libafl_libfuzzer/build.rs index 1293fe89b6..46342c7405 100644 --- a/libafl_libfuzzer/build.rs +++ b/libafl_libfuzzer/build.rs @@ -13,7 +13,7 @@ const NAMESPACE: &str = "🐇"; const NAMESPACE: &str = "__libafl"; const NAMESPACE_LEN: usize = NAMESPACE.len(); -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] fn main() -> Result<(), Box> { if cfg!(any(clippy, docsrs)) { return Ok(()); // skip when clippy or docs is running diff --git a/libafl_libfuzzer/runtime/build.rs b/libafl_libfuzzer/runtime/build.rs index f3926213dc..619ad9b3fe 100644 --- a/libafl_libfuzzer/runtime/build.rs +++ b/libafl_libfuzzer/runtime/build.rs @@ -1,6 +1,6 @@ use std::{env, path::Path}; -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] fn main() { let out_dir = env::var_os("OUT_DIR").unwrap(); diff --git a/libafl_libfuzzer/runtime/src/lib.rs b/libafl_libfuzzer/runtime/src/lib.rs index 36096e05df..e7331d660b 100644 --- a/libafl_libfuzzer/runtime/src/lib.rs +++ b/libafl_libfuzzer/runtime/src/lib.rs @@ -107,7 +107,7 @@ mod harness_wrap { pub(crate) use harness_wrap::libafl_libfuzzer_test_one_input; -#[allow(clippy::struct_excessive_bools)] +#[expect(clippy::struct_excessive_bools)] struct CustomMutationStatus { std_mutational: bool, std_no_mutate: bool, @@ -512,11 +512,11 @@ macro_rules! fuzz_with { grimoire, ); - #[allow(clippy::unnecessary_mut_passed)] // the functions may not require these many `mut`s + #[expect(clippy::unnecessary_mut_passed)] // the functions may not require these many `mut`s $operation(&$options, &mut fuzzer, &mut stages, &mut executor, &mut state, &mut mgr) }; - #[allow(clippy::redundant_closure_call)] + #[expect(clippy::redundant_closure_call)] $and_then(closure) }}; @@ -592,7 +592,7 @@ pub const STDERR_FD_VAR: &str = "_LIBAFL_LIBFUZZER_STDERR_FD"; /// Will dereference all parameters. /// This will then call the (potentially unsafe) harness. /// The fuzzer itself should catch any side effects and, hence be reasonably safe, if the `harness_fn` parameter is correct. -#[allow(non_snake_case, clippy::similar_names, clippy::missing_safety_doc)] +#[expect(non_snake_case, clippy::similar_names, clippy::missing_safety_doc)] #[no_mangle] pub unsafe extern "C" fn LLVMFuzzerRunDriver( argc: *mut c_int, diff --git a/libafl_libfuzzer/runtime/src/merge.rs b/libafl_libfuzzer/runtime/src/merge.rs index 506e0a2e41..c5400a6a27 100644 --- a/libafl_libfuzzer/runtime/src/merge.rs +++ b/libafl_libfuzzer/runtime/src/merge.rs @@ -36,7 +36,7 @@ use crate::{ schedulers::MergeScheduler, }; -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] pub fn merge( options: &LibfuzzerOptions, harness: &extern "C" fn(*const u8, usize) -> c_int, @@ -236,7 +236,7 @@ pub fn merge( .on_remove(&mut state, id, &Some(testcase))?; } else { // False-positive: file_path is used just below - #[allow(clippy::needless_borrows_for_generic_args)] + #[expect(clippy::needless_borrows_for_generic_args)] rename(&file_path, &new_file_path)?; *file_path = new_file_path; } diff --git a/libafl_libfuzzer/runtime/src/options.rs b/libafl_libfuzzer/runtime/src/options.rs index 8126c50aa4..656422480c 100644 --- a/libafl_libfuzzer/runtime/src/options.rs +++ b/libafl_libfuzzer/runtime/src/options.rs @@ -100,7 +100,7 @@ impl Default for ArtifactPrefix { } #[derive(Debug, Clone)] -#[allow(clippy::struct_excessive_bools)] +#[expect(clippy::struct_excessive_bools)] pub struct LibfuzzerOptions { fuzzer_name: String, mode: LibfuzzerMode, @@ -234,7 +234,7 @@ impl LibfuzzerOptions { } #[derive(Debug, Default)] -#[allow(clippy::struct_excessive_bools)] +#[expect(clippy::struct_excessive_bools)] struct LibfuzzerOptionsBuilder<'a> { mode: Option, artifact_prefix: Option<&'a str>, diff --git a/libafl_libfuzzer/runtime/src/report.rs b/libafl_libfuzzer/runtime/src/report.rs index 8c22b28bde..e196fcd267 100644 --- a/libafl_libfuzzer/runtime/src/report.rs +++ b/libafl_libfuzzer/runtime/src/report.rs @@ -13,7 +13,7 @@ use libafl::{ use crate::{fuzz_with, options::LibfuzzerOptions}; -#[allow(clippy::unnecessary_wraps, clippy::cast_precision_loss)] +#[expect(clippy::unnecessary_wraps, clippy::cast_precision_loss)] fn do_report( _options: &LibfuzzerOptions, _fuzzer: &mut F, diff --git a/libafl_libfuzzer/src/lib.rs b/libafl_libfuzzer/src/lib.rs index 188d9be378..057c831c86 100644 --- a/libafl_libfuzzer/src/lib.rs +++ b/libafl_libfuzzer/src/lib.rs @@ -94,25 +94,21 @@ unused_import_braces, unused_qualifications, unused_must_use, - //unused_results -))] -#![cfg_attr( - test, - deny( - bad_style, - dead_code, - improper_ctypes, - non_shorthand_field_patterns, - no_mangle_generic_items, - overflowing_literals, - path_statements, - patterns_in_fns_without_body, - unconditional_recursion, - unused, - unused_allocation, - unused_comparisons, - unused_parens, - while_true + unfulfilled_lint_expectations, + bad_style, + dead_code, + improper_ctypes, + non_shorthand_field_patterns, + no_mangle_generic_items, + overflowing_literals, + path_statements, + patterns_in_fns_without_body, + unconditional_recursion, + unused, + unused_allocation, + unused_comparisons, + unused_parens, + while_true ) )] diff --git a/libafl_libfuzzer_runtime/build.rs b/libafl_libfuzzer_runtime/build.rs index f3926213dc..cfffcfc9c7 100644 --- a/libafl_libfuzzer_runtime/build.rs +++ b/libafl_libfuzzer_runtime/build.rs @@ -1,6 +1,5 @@ use std::{env, path::Path}; -#[allow(clippy::too_many_lines)] fn main() { let out_dir = env::var_os("OUT_DIR").unwrap(); diff --git a/libafl_qemu/build_linux.rs b/libafl_qemu/build_linux.rs index 239ec2ede2..bbe796047e 100644 --- a/libafl_qemu/build_linux.rs +++ b/libafl_qemu/build_linux.rs @@ -13,7 +13,7 @@ static LIBAFL_QEMU_RUNTIME_TEST: &str = r#" void __libafl_qemu_testfile() {} "#; -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] pub fn build() { // Note: Unique features are checked in libafl_qemu_sys println!( @@ -133,7 +133,6 @@ pub fn build() { .expect("Could not copy libafl_qemu.h to out directory."); fs::copy( - libafl_qemu_arch_hdr.clone(), include_dir.join(libafl_qemu_arch_hdr_name), ) diff --git a/libafl_qemu/libafl_qemu_build/src/build.rs b/libafl_qemu/libafl_qemu_build/src/build.rs index 9b854d34f5..70c17de121 100644 --- a/libafl_qemu/libafl_qemu_build/src/build.rs +++ b/libafl_qemu/libafl_qemu_build/src/build.rs @@ -13,7 +13,6 @@ pub const QEMU_URL: &str = "https://github.com/AFLplusplus/qemu-libafl-bridge"; pub const QEMU_DIRNAME: &str = "qemu-libafl-bridge"; pub const QEMU_REVISION: &str = "06bf8facec33548840413fba1b20858f58e38e2d"; -#[allow(clippy::module_name_repetitions)] pub struct BuildResult { pub qemu_path: PathBuf, pub build_dir: PathBuf, @@ -59,7 +58,7 @@ fn get_config_signature(config_cmd: &Command) -> String { signature_string } -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] fn configure_qemu( cc_compiler: &cc::Tool, cpp_compiler: &cc::Tool, @@ -245,7 +244,7 @@ fn build_qemu( cmd } -#[allow(clippy::too_many_lines, clippy::missing_panics_doc)] +#[expect(clippy::too_many_lines, clippy::missing_panics_doc)] #[must_use] pub fn build( cpu_target: &str, diff --git a/libafl_qemu/libafl_qemu_build/src/lib.rs b/libafl_qemu/libafl_qemu_build/src/lib.rs index 57445cfe46..b51076c9b1 100644 --- a/libafl_qemu/libafl_qemu_build/src/lib.rs +++ b/libafl_qemu/libafl_qemu_build/src/lib.rs @@ -386,7 +386,6 @@ pub fn store_generated_content_if_different( //} #[rustversion::nightly] -#[allow(unused)] pub fn maybe_generate_stub_bindings( cpu_target: &str, emulation_mode: &str, diff --git a/libafl_qemu/libafl_qemu_sys/src/lib.rs b/libafl_qemu/libafl_qemu_sys/src/lib.rs index 8c524fe5bf..4f1bc18138 100644 --- a/libafl_qemu/libafl_qemu_sys/src/lib.rs +++ b/libafl_qemu/libafl_qemu_sys/src/lib.rs @@ -53,14 +53,14 @@ macro_rules! extern_c_checked { ($visibility:vis static $c_var:ident : $c_var_ty:ty; $($tail:tt)*) => { paste! { - #[allow(non_camel_case_types)] - #[allow(unused)] + #[expect(non_camel_case_types)] + #[expect(unused)] struct [<__ $c_var:upper _STRUCT__>] { member: *const $c_var_ty } unsafe impl Sync for [<__ $c_var:upper _STRUCT__>] {} #[cfg_attr(nightly, used(linker))] - #[allow(unused_unsafe)] + #[expect(unused_unsafe)] static [<__ $c_var:upper __>]: [<__ $c_var:upper _STRUCT__>] = unsafe { [<__ $c_var:upper _STRUCT__>] { member: &raw const $c_var } }; } @@ -73,14 +73,14 @@ macro_rules! extern_c_checked { ($visibility:vis static mut $c_var:ident : $c_var_ty:ty; $($tail:tt)*) => { paste! { - #[allow(non_camel_case_types)] - #[allow(unused)] + #[expect(non_camel_case_types)] + #[expect(unused)] struct [<__ $c_var:upper _STRUCT__>] { member: *const $c_var_ty } unsafe impl Sync for [<__ $c_var:upper _STRUCT__>] {} #[cfg_attr(nightly, used(linker))] - #[allow(unused_unsafe)] + #[expect(unused_unsafe)] static mut [<__ $c_var:upper __>]: [<__ $c_var:upper _STRUCT__>] = unsafe { [<__ $c_var:upper _STRUCT__>] { member: &raw const $c_var } }; } diff --git a/libafl_qemu/src/arch/aarch64.rs b/libafl_qemu/src/arch/aarch64.rs index f68fe27b35..aad7624b14 100644 --- a/libafl_qemu/src/arch/aarch64.rs +++ b/libafl_qemu/src/arch/aarch64.rs @@ -67,7 +67,7 @@ pub fn get_exit_arch_regs() -> &'static EnumMap { } /// alias registers -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] impl Regs { pub const Fp: Regs = Regs::X29; pub const Lr: Regs = Regs::X30; diff --git a/libafl_qemu/src/arch/arm.rs b/libafl_qemu/src/arch/arm.rs index 18955bb964..ad7918f412 100644 --- a/libafl_qemu/src/arch/arm.rs +++ b/libafl_qemu/src/arch/arm.rs @@ -51,7 +51,7 @@ pub fn get_exit_arch_regs() -> &'static EnumMap { } /// alias registers -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] impl Regs { pub const Sp: Regs = Regs::R13; pub const Lr: Regs = Regs::R14; diff --git a/libafl_qemu/src/arch/hexagon.rs b/libafl_qemu/src/arch/hexagon.rs index 113313dd6c..479ff2588e 100644 --- a/libafl_qemu/src/arch/hexagon.rs +++ b/libafl_qemu/src/arch/hexagon.rs @@ -82,7 +82,7 @@ pub fn get_exit_arch_regs() -> &'static EnumMap { } /// alias registers -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] impl Regs { pub const Sp: Regs = Regs::R29; pub const Fp: Regs = Regs::R30; diff --git a/libafl_qemu/src/arch/i386.rs b/libafl_qemu/src/arch/i386.rs index 56bbd28562..239010bf9d 100644 --- a/libafl_qemu/src/arch/i386.rs +++ b/libafl_qemu/src/arch/i386.rs @@ -43,7 +43,7 @@ pub fn get_exit_arch_regs() -> &'static EnumMap { } /// alias registers -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] impl Regs { pub const Sp: Regs = Regs::Esp; pub const Pc: Regs = Regs::Eip; diff --git a/libafl_qemu/src/arch/mips.rs b/libafl_qemu/src/arch/mips.rs index f770b96817..e9adfc714c 100644 --- a/libafl_qemu/src/arch/mips.rs +++ b/libafl_qemu/src/arch/mips.rs @@ -67,7 +67,7 @@ pub fn get_exit_arch_regs() -> &'static EnumMap { } /// alias registers -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] impl Regs { pub const Zero: Regs = Regs::R0; } diff --git a/libafl_qemu/src/arch/ppc.rs b/libafl_qemu/src/arch/ppc.rs index 4bc7a64cb8..373d0e15c8 100644 --- a/libafl_qemu/src/arch/ppc.rs +++ b/libafl_qemu/src/arch/ppc.rs @@ -106,7 +106,7 @@ pub fn get_exit_arch_regs() -> &'static EnumMap { } /// alias registers -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] impl Regs { pub const Pc: Regs = Regs::Nip; pub const Sp: Regs = Regs::R1; diff --git a/libafl_qemu/src/arch/riscv.rs b/libafl_qemu/src/arch/riscv.rs index 99daa56f4b..8dc4bac0a2 100644 --- a/libafl_qemu/src/arch/riscv.rs +++ b/libafl_qemu/src/arch/riscv.rs @@ -13,11 +13,11 @@ pub use syscall_numbers::riscv32::*; pub use syscall_numbers::riscv64::*; // QEMU specific -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] pub const SYS_syscalls: c_long = 447; -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] pub const SYS_riscv_flush_icache: c_long = SYS_arch_specific_syscall + 15; -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] pub const SYS_riscv_hwprobe: c_long = SYS_arch_specific_syscall + 14; use crate::{sync_exit::ExitArgs, CallingConvention, QemuRWError, QemuRWErrorKind}; diff --git a/libafl_qemu/src/arch/x86_64.rs b/libafl_qemu/src/arch/x86_64.rs index 119c5a9c62..0fbf62019f 100644 --- a/libafl_qemu/src/arch/x86_64.rs +++ b/libafl_qemu/src/arch/x86_64.rs @@ -49,7 +49,7 @@ pub fn get_exit_arch_regs() -> &'static EnumMap { } /// alias registers -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] impl Regs { pub const Sp: Regs = Regs::Rsp; pub const Pc: Regs = Regs::Rip; diff --git a/libafl_qemu/src/command/mod.rs b/libafl_qemu/src/command/mod.rs index ae87cfcc3f..f107171a19 100644 --- a/libafl_qemu/src/command/mod.rs +++ b/libafl_qemu/src/command/mod.rs @@ -231,7 +231,7 @@ where /// - `ret_reg`: The register in which the guest return value should be written, if any. /// Returns /// - `InnerHandlerResult`: How the high-level handler should behave - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] fn run( &self, emu: &mut Emulator, @@ -592,7 +592,7 @@ where ) -> Result>, EmulatorDriverError> { emu.modules_mut() .modules_mut() - .allow_page_id_all(self.page_id.clone()); + .allow_page_id_all(self.page_id); Ok(None) } } diff --git a/libafl_qemu/src/command/parser.rs b/libafl_qemu/src/command/parser.rs index 97914b266d..8183cafb4a 100644 --- a/libafl_qemu/src/command/parser.rs +++ b/libafl_qemu/src/command/parser.rs @@ -276,7 +276,7 @@ where type OutputCommand = LqprintfCommand; const COMMAND_ID: c_uint = bindings::LibaflQemuCommand_LIBAFL_QEMU_COMMAND_LQPRINTF.0; - #[allow(clippy::uninit_vec)] + #[expect(clippy::uninit_vec)] fn parse( qemu: Qemu, arch_regs_map: &'static EnumMap, @@ -316,7 +316,6 @@ where type OutputCommand = TestCommand; const COMMAND_ID: c_uint = bindings::LibaflQemuCommand_LIBAFL_QEMU_COMMAND_TEST.0; - #[allow(clippy::cast_sign_loss)] fn parse( qemu: Qemu, arch_regs_map: &'static EnumMap, diff --git a/libafl_qemu/src/emu/builder.rs b/libafl_qemu/src/emu/builder.rs index 67396d2c10..6adb97c12a 100644 --- a/libafl_qemu/src/emu/builder.rs +++ b/libafl_qemu/src/emu/builder.rs @@ -60,7 +60,7 @@ where S::Input: HasTargetBytes, { #[must_use] - #[allow(clippy::should_implement_trait)] + #[expect(clippy::should_implement_trait)] pub fn default() -> Self { Self { modules: tuple_list!(), @@ -79,6 +79,8 @@ where S: State + HasExecutions + Unpin, S::Input: HasTargetBytes, { + #[expect(clippy::should_implement_trait)] + #[must_use] pub fn default() -> Self { Self { modules: (), diff --git a/libafl_qemu/src/emu/drivers.rs b/libafl_qemu/src/emu/drivers.rs index 0fe0c6f161..41ccda5e50 100644 --- a/libafl_qemu/src/emu/drivers.rs +++ b/libafl_qemu/src/emu/drivers.rs @@ -85,7 +85,7 @@ where fn pre_qemu_exec(_emulator: &mut Emulator, _input: &S::Input) {} /// Just after QEMU exits - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] fn post_qemu_exec( _emulator: &mut Emulator, _state: &mut S, @@ -109,7 +109,7 @@ where } #[derive(Clone, Debug, Default, TypedBuilder)] -#[allow(clippy::struct_excessive_bools)] +#[allow(clippy::struct_excessive_bools)] // cfg dependent pub struct StdEmulatorDriver { #[builder(default = OnceCell::new())] snapshot_id: OnceCell, @@ -233,7 +233,6 @@ where }, }; - #[allow(clippy::type_complexity)] let (command, ret_reg): (Option, Option) = match &mut exit_reason { EmulatorExitResult::QemuExit(shutdown_cause) => match shutdown_cause { QemuShutdownCause::HostSignal(signal) => { diff --git a/libafl_qemu/src/emu/hooks.rs b/libafl_qemu/src/emu/hooks.rs index bb07522b60..6f7a8b625e 100644 --- a/libafl_qemu/src/emu/hooks.rs +++ b/libafl_qemu/src/emu/hooks.rs @@ -398,7 +398,7 @@ where } } - #[allow(clippy::similar_names)] + #[expect(clippy::similar_names)] pub fn reads( &mut self, generation_hook: ReadGenHook, @@ -486,7 +486,7 @@ where } } - #[allow(clippy::similar_names)] + #[expect(clippy::similar_names)] pub fn writes( &mut self, generation_hook: WriteGenHook, @@ -767,7 +767,6 @@ where ET: EmulatorModuleTuple, S: Unpin + UsesInput, { - #[allow(clippy::type_complexity)] pub fn syscalls(&mut self, hook: PreSyscallHook) -> Option { match hook { Hook::Function(f) => Some(self.syscalls_function(f)), @@ -780,7 +779,6 @@ where } } - #[allow(clippy::type_complexity)] pub fn syscalls_function(&mut self, hook: PreSyscallHookFn) -> PreSyscallHookId { // # Safety // Will dereference the hook as [`FatPtr`]. @@ -790,7 +788,6 @@ where } } - #[allow(clippy::type_complexity)] pub fn syscalls_closure(&mut self, hook: PreSyscallHookClosure) -> PreSyscallHookId { // # Safety // Will dereference the hook as [`FatPtr`]. @@ -821,7 +818,6 @@ where } } - #[allow(clippy::type_complexity)] pub fn after_syscalls(&mut self, hook: PostSyscallHook) -> Option { match hook { Hook::Function(f) => Some(self.after_syscalls_function(f)), @@ -834,7 +830,6 @@ where } } - #[allow(clippy::type_complexity)] pub fn after_syscalls_function(&mut self, hook: PostSyscallHookFn) -> PostSyscallHookId { // # Safety // Will dereference the hook as [`FatPtr`]. This should be ok. @@ -844,7 +839,6 @@ where } } - #[allow(clippy::type_complexity)] pub fn after_syscalls_closure( &mut self, hook: PostSyscallHookClosure, @@ -999,7 +993,6 @@ where .blocks(generation_hook, post_generation_hook, execution_hook) } - #[allow(clippy::similar_names)] pub fn reads( &mut self, generation_hook: ReadGenHook, @@ -1019,7 +1012,6 @@ where ) } - #[allow(clippy::similar_names)] pub fn writes( &mut self, generation_hook: WriteGenHook, @@ -1221,14 +1213,13 @@ where ET: EmulatorModuleTuple, S: Unpin + UsesInput, { - #[allow(clippy::type_complexity)] pub fn syscalls(&mut self, hook: PreSyscallHook) -> Option { self.hooks.syscalls(hook) } /// # Safety /// Calls through to the, potentially unsafe, `syscalls_function` - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] pub unsafe fn syscalls_function( &mut self, hook: fn( @@ -1250,7 +1241,7 @@ where /// # Safety /// Calls through to the, potentially unsafe, `syscalls_closure` - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] pub unsafe fn syscalls_closure( &mut self, hook: Box< @@ -1272,14 +1263,13 @@ where self.hooks.syscalls_closure(hook) } - #[allow(clippy::type_complexity)] pub fn after_syscalls(&mut self, hook: PostSyscallHook) -> Option { self.hooks.after_syscalls(hook) } /// # Safety /// Calls through to the, potentially unsafe, `after_syscalls_function` - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] pub unsafe fn after_syscalls_function( &mut self, hook: fn( @@ -1300,7 +1290,7 @@ where self.hooks.after_syscalls_function(hook) } - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] pub fn after_syscalls_closure( &mut self, hook: Box< diff --git a/libafl_qemu/src/emu/mod.rs b/libafl_qemu/src/emu/mod.rs index 0fcf92e3f6..8e05864d96 100644 --- a/libafl_qemu/src/emu/mod.rs +++ b/libafl_qemu/src/emu/mod.rs @@ -119,7 +119,7 @@ pub struct InputLocation { } #[derive(Debug)] -#[allow(clippy::type_complexity)] +#[expect(clippy::type_complexity)] pub struct Emulator where CM: CommandManager, @@ -140,7 +140,7 @@ where S: UsesInput, { #[must_use] - #[allow(clippy::match_wildcard_for_single_variants)] + #[expect(clippy::match_wildcard_for_single_variants)] pub fn end_of_run(&self) -> Option { match self { EmulatorDriverResult::EndOfRun(exit_kind) => Some(*exit_kind), @@ -321,7 +321,6 @@ where ET: EmulatorModuleTuple, S: UsesInput + Unpin, { - #[allow(clippy::must_use_candidate, clippy::similar_names)] pub fn new( qemu_args: &[String], modules: ET, @@ -471,7 +470,6 @@ where } } -#[allow(clippy::unused_self)] impl Emulator where CM: CommandManager, diff --git a/libafl_qemu/src/emu/systemmode.rs b/libafl_qemu/src/emu/systemmode.rs index 450144e393..786a32cfe1 100644 --- a/libafl_qemu/src/emu/systemmode.rs +++ b/libafl_qemu/src/emu/systemmode.rs @@ -63,12 +63,14 @@ impl Default for FastSnapshotManager { } impl FastSnapshotManager { + #[must_use] pub fn new() -> Self { Self { snapshots: HashMap::new(), } } - + #[allow(clippy::missing_safety_doc)] + #[must_use] pub unsafe fn get(&self, id: &SnapshotId) -> FastSnapshotPtr { *self.snapshots.get(id).unwrap() } @@ -86,10 +88,12 @@ impl Default for QemuSnapshotManager { } impl QemuSnapshotManager { + #[must_use] pub fn new(is_sync: bool) -> Self { Self { is_sync } } + #[must_use] pub fn snapshot_id_to_name(&self, snapshot_id: &SnapshotId) -> String { format!("__libafl_qemu_snapshot_{}", snapshot_id.inner()) } @@ -168,21 +172,23 @@ where S: UsesInput, { /// Write a value to a phsical guest address, including ROM areas. + #[allow(clippy::missing_safety_doc)] pub unsafe fn write_phys_mem(&self, paddr: GuestPhysAddr, buf: &[u8]) { - self.qemu.write_phys_mem(paddr, buf) + self.qemu.write_phys_mem(paddr, buf); } /// Read a value from a physical guest address. + #[allow(clippy::missing_safety_doc)] pub unsafe fn read_phys_mem(&self, paddr: GuestPhysAddr, buf: &mut [u8]) { - self.qemu.read_phys_mem(paddr, buf) + self.qemu.read_phys_mem(paddr, buf); } pub fn save_snapshot(&self, name: &str, sync: bool) { - self.qemu.save_snapshot(name, sync) + self.qemu.save_snapshot(name, sync); } pub fn load_snapshot(&self, name: &str, sync: bool) { - self.qemu.load_snapshot(name, sync) + self.qemu.load_snapshot(name, sync); } #[must_use] @@ -199,8 +205,9 @@ where self.qemu.create_fast_snapshot_filter(track, device_filter) } + #[allow(clippy::missing_safety_doc)] pub unsafe fn restore_fast_snapshot(&self, snapshot: FastSnapshotPtr) { - self.qemu.restore_fast_snapshot(snapshot) + self.qemu.restore_fast_snapshot(snapshot); } pub fn list_devices(&self) -> Vec { diff --git a/libafl_qemu/src/executor.rs b/libafl_qemu/src/executor.rs index b5ce9791c5..5c1978d720 100644 --- a/libafl_qemu/src/executor.rs +++ b/libafl_qemu/src/executor.rs @@ -9,6 +9,8 @@ use std::ptr; #[cfg(feature = "systemmode")] use std::sync::atomic::{AtomicBool, Ordering}; +#[cfg(any(feature = "usermode", feature = "fork"))] +use libafl::inputs::UsesInput; use libafl::{ corpus::Corpus, events::{EventFirer, EventRestarter}, @@ -20,7 +22,6 @@ use libafl::{ }, feedbacks::Feedback, fuzzer::HasObjective, - inputs::UsesInput, observers::ObserversTuple, state::{HasCorpus, HasExecutions, HasSolutions, State, UsesState}, Error, ExecutionProcessor, HasScheduler, @@ -355,7 +356,7 @@ where Z: HasObjective, Z::Objective: Feedback, { - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn new( emulator: Emulator, harness_fn: &'a mut H, diff --git a/libafl_qemu/src/lib.rs b/libafl_qemu/src/lib.rs index 6f27560e56..e27b7df3c4 100644 --- a/libafl_qemu/src/lib.rs +++ b/libafl_qemu/src/lib.rs @@ -71,7 +71,6 @@ use pyo3::prelude::*; #[cfg(feature = "python")] #[pymodule] #[pyo3(name = "libafl_qemu")] -#[allow(clippy::items_after_statements, clippy::too_many_lines)] pub fn python_module(m: &Bound<'_, PyModule>) -> PyResult<()> { use pyo3::types::PyString; diff --git a/libafl_qemu/src/modules/calls.rs b/libafl_qemu/src/modules/calls.rs index 1e280a0720..01687ef90f 100644 --- a/libafl_qemu/src/modules/calls.rs +++ b/libafl_qemu/src/modules/calls.rs @@ -269,6 +269,7 @@ where emulator_modules.get_mut::().unwrap().collectors = collectors; } + #[allow(clippy::needless_pass_by_value)] // no longer a problem in nightly fn gen_blocks_calls( emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, @@ -298,7 +299,7 @@ where let mut ret_addrs: Vec = Vec::new(); if let Some(h) = emulator_modules.modules().match_first_type::() { - #[allow(unused_mut)] + #[allow(unused_mut)] // cfg dependent let mut code = { #[cfg(feature = "usermode")] unsafe { @@ -492,7 +493,7 @@ impl<'a> CallTraceCollector for OnCrashBacktraceCollector<'a> where 'a: 'static, { - #[allow(clippy::unnecessary_cast)] + #[expect(clippy::unnecessary_cast)] fn on_call( &mut self, _emulator_modules: &mut EmulatorModules, @@ -506,7 +507,7 @@ where self.callstack_hash ^= pc as u64 + call_len as u64; } - #[allow(clippy::unnecessary_cast)] + #[expect(clippy::unnecessary_cast)] fn on_ret( &mut self, _emulator_modules: &mut EmulatorModules, @@ -587,7 +588,7 @@ impl FullBacktraceCollector { } impl CallTraceCollector for FullBacktraceCollector { - #[allow(clippy::unnecessary_cast)] + #[allow(clippy::unnecessary_cast)] // dependent on the target instruction size fn on_call( &mut self, _emulator_modules: &mut EmulatorModules, @@ -606,7 +607,7 @@ impl CallTraceCollector for FullBacktraceCollector { } } - #[allow(clippy::unnecessary_cast)] + #[allow(clippy::unnecessary_cast)] // dependent on the target instruction size fn on_ret( &mut self, _emulator_modules: &mut EmulatorModules, diff --git a/libafl_qemu/src/modules/cmplog.rs b/libafl_qemu/src/modules/cmplog.rs index b595971374..cdc4247510 100644 --- a/libafl_qemu/src/modules/cmplog.rs +++ b/libafl_qemu/src/modules/cmplog.rs @@ -202,6 +202,7 @@ where })) } +#[allow(clippy::needless_pass_by_value)] // no longer a problem with nightly pub fn gen_hashed_cmp_ids( emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, @@ -295,6 +296,7 @@ impl CmpLogRoutinesModule { } } + #[allow(clippy::needless_pass_by_value)] // no longer a problem with nightly fn gen_blocks_calls( emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, @@ -321,7 +323,7 @@ impl CmpLogRoutinesModule { let qemu = emulator_modules.qemu(); if let Some(h) = emulator_modules.get::() { - #[allow(unused_mut)] + #[allow(unused_mut)] // cfg dependent let mut code = { #[cfg(feature = "usermode")] unsafe { diff --git a/libafl_qemu/src/modules/drcov.rs b/libafl_qemu/src/modules/drcov.rs index e40d3dda0e..299cbffbcd 100644 --- a/libafl_qemu/src/modules/drcov.rs +++ b/libafl_qemu/src/modules/drcov.rs @@ -120,7 +120,7 @@ impl DrCovModule { } impl DrCovModule { #[must_use] - #[allow(clippy::let_underscore_untyped)] + #[expect(clippy::let_underscore_untyped)] pub fn new( filter: F, filename: PathBuf, @@ -168,7 +168,7 @@ impl DrCovModule { continue 'pcs_full; } if *idm == *id { - #[allow(clippy::unnecessary_cast)] // for GuestAddr -> u64 + #[expect(clippy::unnecessary_cast)] // for GuestAddr -> u64 match lengths.get(pc) { Some(block_length) => { drcov_vec.push(DrCovBasicBlock::new( @@ -217,7 +217,7 @@ impl DrCovModule { continue 'pcs; } - #[allow(clippy::unnecessary_cast)] // for GuestAddr -> u64 + #[expect(clippy::unnecessary_cast)] // for GuestAddr -> u64 match lengths.get(pc) { Some(block_length) => { drcov_vec.push(DrCovBasicBlock::new( @@ -287,7 +287,7 @@ where let mut module_mapping: RangeMap = RangeMap::new(); - #[allow(clippy::unnecessary_cast)] // for GuestAddr -> u64 + #[expect(clippy::unnecessary_cast)] // for GuestAddr -> u64 for (i, (r, p)) in qemu .mappings() .filter_map(|m| { @@ -398,7 +398,7 @@ where meta.current_id = id + 1; if drcov_module.full_trace { // GuestAddress is u32 for 32 bit guests - #[allow(clippy::unnecessary_cast)] + #[expect(clippy::unnecessary_cast)] Some(id as u64) } else { None @@ -407,6 +407,7 @@ where } } +#[allow(clippy::needless_pass_by_value)] // no longer a problem with nightly pub fn gen_block_lengths( emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, @@ -429,6 +430,7 @@ pub fn gen_block_lengths( .insert(pc, block_length); } +#[allow(clippy::needless_pass_by_value)] // no longer a problem with nightly pub fn exec_trace_block( emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, diff --git a/libafl_qemu/src/modules/edges/helpers.rs b/libafl_qemu/src/modules/edges/helpers.rs index 760fce7272..c3cadf508c 100644 --- a/libafl_qemu/src/modules/edges/helpers.rs +++ b/libafl_qemu/src/modules/edges/helpers.rs @@ -149,13 +149,13 @@ mod generators { } } // GuestAddress is u32 for 32 bit guests - #[allow(clippy::unnecessary_cast)] + #[expect(clippy::unnecessary_cast)] Some(id as u64) } } } - #[allow(clippy::unnecessary_cast)] + #[allow(clippy::needless_pass_by_value)] // no longer a problem with nightly pub fn gen_hashed_edge_ids( emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, @@ -193,7 +193,7 @@ mod generators { let mask = get_mask::() as u64; - #[allow(clippy::unnecessary_cast)] + #[expect(clippy::unnecessary_cast)] let id = (hash_me(src as u64) ^ hash_me(dest as u64)) & mask; if !IS_CONST_MAP { @@ -209,7 +209,8 @@ mod generators { } } - #[allow(clippy::unnecessary_cast)] + #[expect(clippy::unnecessary_cast)] + #[allow(clippy::needless_pass_by_value)] // no longer a problem with nightly pub fn gen_hashed_block_ids( emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, @@ -255,8 +256,6 @@ mod generators { } } - // GuestAddress is u32 for 32 bit guests - #[allow(clippy::unnecessary_cast)] Some(id) } } diff --git a/libafl_qemu/src/modules/edges/mod.rs b/libafl_qemu/src/modules/edges/mod.rs index db2538ca7e..35e4a0fcc9 100644 --- a/libafl_qemu/src/modules/edges/mod.rs +++ b/libafl_qemu/src/modules/edges/mod.rs @@ -380,7 +380,7 @@ mod tests { /// /// StdEdgeCoverageModule::builder().build().unwrap(); /// ``` - #[allow(unused)] + #[expect(unused)] pub fn does_not_build() {} #[test] diff --git a/libafl_qemu/src/modules/mod.rs b/libafl_qemu/src/modules/mod.rs index 04b80a84ee..b2fc689d79 100644 --- a/libafl_qemu/src/modules/mod.rs +++ b/libafl_qemu/src/modules/mod.rs @@ -14,7 +14,7 @@ pub use usermode::*; #[cfg(feature = "systemmode")] pub mod systemmode; #[cfg(feature = "systemmode")] -#[allow(unused_imports)] +#[expect(unused_imports)] pub use systemmode::*; pub mod edges; @@ -328,8 +328,8 @@ where #[cfg(feature = "systemmode")] fn allow_page_id_all(&mut self, page_id: GuestPhysAddr) { - self.0.page_filter_mut().register(page_id.clone()); - self.1.allow_page_id_all(page_id) + self.0.page_filter_mut().register(page_id); + self.1.allow_page_id_all(page_id); } } diff --git a/libafl_qemu/src/modules/usermode/asan.rs b/libafl_qemu/src/modules/usermode/asan.rs index 45ee1e8626..96674a899d 100644 --- a/libafl_qemu/src/modules/usermode/asan.rs +++ b/libafl_qemu/src/modules/usermode/asan.rs @@ -1,5 +1,5 @@ #![allow(clippy::cast_possible_wrap)] - +#![allow(clippy::needless_pass_by_value)] // default compiler complains about Option<&mut T> otherwise, and this is used extensively. use std::{borrow::Cow, env, fs, path::PathBuf, sync::Mutex}; use hashbrown::{HashMap, HashSet}; @@ -328,7 +328,7 @@ impl AsanGiovese { #[inline] #[must_use] - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] pub fn is_invalid_access(qemu: Qemu, addr: GuestAddr, n: usize) -> bool { unsafe { if n == 0 { @@ -380,7 +380,7 @@ impl AsanGiovese { } #[inline] - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] pub fn poison(&mut self, qemu: Qemu, addr: GuestAddr, n: usize, poison_byte: i8) -> bool { unsafe { if n == 0 { @@ -425,8 +425,8 @@ impl AsanGiovese { } #[inline] - #[allow(clippy::must_use_candidate)] - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::must_use_candidate)] + #[expect(clippy::cast_sign_loss)] pub fn unpoison(qemu: Qemu, addr: GuestAddr, n: usize) -> bool { unsafe { let n = n as isize; @@ -453,7 +453,7 @@ impl AsanGiovese { } #[inline] - #[allow(clippy::mut_from_ref)] + #[expect(clippy::mut_from_ref)] fn get_shadow_page(qemu: &Qemu, page: GuestAddr) -> &mut [i8] { unsafe { let h = qemu.g2h::<*const c_void>(page) as isize; @@ -840,7 +840,6 @@ impl AsanModule { self.rt.deallocation(qemu, pc, addr); } - #[allow(clippy::unused_self)] #[must_use] pub fn is_poisoned(&self, qemu: Qemu, addr: GuestAddr, size: usize) -> bool { AsanGiovese::is_invalid_access(qemu, addr, size) @@ -912,7 +911,6 @@ impl AsanModule { self.rt.poison(qemu, addr, size, poison.into()); } - #[allow(clippy::unused_self)] pub fn unpoison(&mut self, qemu: Qemu, addr: GuestAddr, size: usize) { AsanGiovese::unpoison(qemu, addr, size); } @@ -1296,7 +1294,7 @@ pub fn trace_write_n_asan_snapshot( h.access(addr, size); } -#[allow(clippy::too_many_arguments)] +#[expect(clippy::too_many_arguments)] pub fn qasan_fake_syscall( emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, @@ -1534,8 +1532,8 @@ mod addr2line_legacy { /// # Safety /// Will access the global [`FullBacktraceCollector`]. /// Calling this function concurrently might be racey. -#[allow(clippy::unnecessary_cast)] -#[allow(clippy::too_many_lines)] +#[expect(clippy::unnecessary_cast)] +#[expect(clippy::too_many_lines)] pub unsafe fn asan_report(rt: &AsanGiovese, qemu: Qemu, pc: GuestAddr, err: &AsanError) { let mut regions = HashMap::new(); for region in qemu.mappings() { diff --git a/libafl_qemu/src/modules/usermode/asan_guest.rs b/libafl_qemu/src/modules/usermode/asan_guest.rs index 567d98048e..eb03668685 100644 --- a/libafl_qemu/src/modules/usermode/asan_guest.rs +++ b/libafl_qemu/src/modules/usermode/asan_guest.rs @@ -205,6 +205,7 @@ where } } +#[allow(clippy::needless_pass_by_value)] // no longer a problem with nightly fn gen_readwrite_guest_asan( emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, @@ -240,9 +241,10 @@ where } #[cfg(feature = "clippy")] -#[allow(unused_variables)] +#[expect(unused_variables)] unsafe fn libafl_tcg_gen_asan(addr: *mut TCGTemp, size: usize) {} +#[allow(clippy::needless_pass_by_value)] // no longer a problem with nightly fn guest_trace_error_asan( _emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, @@ -255,6 +257,7 @@ fn guest_trace_error_asan( panic!("I really shouldn't be here"); } +#[allow(clippy::needless_pass_by_value)] // no longer a problem with nightly fn guest_trace_error_n_asan( _emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, diff --git a/libafl_qemu/src/modules/usermode/injections.rs b/libafl_qemu/src/modules/usermode/injections.rs index 9d62e7b017..086e293c6f 100644 --- a/libafl_qemu/src/modules/usermode/injections.rs +++ b/libafl_qemu/src/modules/usermode/injections.rs @@ -343,7 +343,8 @@ where } } -#[allow(clippy::too_many_arguments)] +#[expect(clippy::too_many_arguments)] +#[allow(clippy::needless_pass_by_value)] // no longer a problem with nightly fn syscall_hook( // Our instantiated [`EmulatorModules`] emulator_modules: &mut EmulatorModules, diff --git a/libafl_qemu/src/modules/usermode/snapshot.rs b/libafl_qemu/src/modules/usermode/snapshot.rs index d887f8e1ef..776fc749da 100644 --- a/libafl_qemu/src/modules/usermode/snapshot.rs +++ b/libafl_qemu/src/modules/usermode/snapshot.rs @@ -1,3 +1,4 @@ +#![allow(clippy::needless_pass_by_value)] // default compiler complains about Option<&mut T> otherwise, and this is used extensively. use std::{cell::UnsafeCell, mem::MaybeUninit, sync::Mutex}; use hashbrown::{HashMap, HashSet}; @@ -191,7 +192,6 @@ impl SnapshotModule { false } - #[allow(clippy::uninit_assumed_init)] pub fn snapshot(&mut self, qemu: Qemu) { log::info!("Start snapshot"); self.brk = qemu.get_brk(); @@ -753,8 +753,7 @@ pub fn trace_write_n_snapshot( h.access(addr, size); } -#[allow(clippy::too_many_arguments)] -#[allow(non_upper_case_globals)] +#[expect(clippy::too_many_arguments)] pub fn filter_mmap_snapshot( emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, @@ -781,8 +780,8 @@ where SyscallHookResult::new(None) } -#[allow(clippy::too_many_arguments, clippy::too_many_lines)] -#[allow(non_upper_case_globals)] +#[expect(clippy::too_many_arguments)] +#[expect(non_upper_case_globals)] pub fn trace_mmap_snapshot( emulator_modules: &mut EmulatorModules, _state: Option<&mut S>, diff --git a/libafl_qemu/src/qemu/hooks.rs b/libafl_qemu/src/qemu/hooks.rs index 4165742d17..ea59e6d3e0 100644 --- a/libafl_qemu/src/qemu/hooks.rs +++ b/libafl_qemu/src/qemu/hooks.rs @@ -755,7 +755,6 @@ impl QemuHooks { } // TODO set T lifetime to be like Emulator - #[allow(clippy::missing_transmute_annotations)] pub fn add_instruction_hooks>( &self, data: T, @@ -786,7 +785,6 @@ impl QemuHooks { } } - #[allow(clippy::missing_transmute_annotations)] pub fn add_edge_hooks>( &self, data: T, @@ -803,7 +801,6 @@ impl QemuHooks { } } - #[allow(clippy::missing_transmute_annotations)] pub fn add_block_hooks>( &self, data: T, @@ -822,7 +819,6 @@ impl QemuHooks { } } - #[allow(clippy::missing_transmute_annotations)] pub fn add_cpu_run_hooks>( &self, data: T, @@ -850,7 +846,6 @@ impl QemuHooks { /// /// If there is no specialized hook for a given read width, the `exec_n` will be /// called and its last argument will specify the access width - #[allow(clippy::missing_transmute_annotations)] pub fn add_read_hooks>( &self, data: T, @@ -885,7 +880,6 @@ impl QemuHooks { } // TODO add MemOp info - #[allow(clippy::missing_transmute_annotations)] pub fn add_write_hooks>( &self, data: T, @@ -919,7 +913,6 @@ impl QemuHooks { } } - #[allow(clippy::missing_transmute_annotations)] pub fn add_cmp_hooks>( &self, data: T, @@ -941,7 +934,6 @@ impl QemuHooks { } } - #[allow(clippy::missing_transmute_annotations)] pub fn add_backdoor_hook>( &self, data: T, @@ -971,7 +963,6 @@ impl QemuHooks { #[cfg(feature = "usermode")] impl QemuHooks { - #[allow(clippy::type_complexity)] pub fn add_pre_syscall_hook>( &self, data: T, @@ -1007,7 +998,6 @@ impl QemuHooks { } } - #[allow(clippy::type_complexity)] pub fn add_post_syscall_hook>( &self, data: T, @@ -1045,8 +1035,7 @@ impl QemuHooks { } } - #[allow(clippy::type_complexity)] - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] pub(crate) fn set_crash_hook(self, callback: extern "C" fn(i32)) { unsafe { libafl_dump_core_hook = Some(callback); diff --git a/libafl_qemu/src/qemu/mod.rs b/libafl_qemu/src/qemu/mod.rs index d9fc7ce657..52916c38fb 100644 --- a/libafl_qemu/src/qemu/mod.rs +++ b/libafl_qemu/src/qemu/mod.rs @@ -41,7 +41,6 @@ pub use usermode::*; #[cfg(feature = "systemmode")] mod systemmode; #[cfg(feature = "systemmode")] -#[allow(unused_imports)] pub use systemmode::*; mod hooks; @@ -112,7 +111,7 @@ pub enum QemuRWErrorCause { } #[derive(Debug, Clone)] -#[allow(dead_code)] +#[expect(dead_code)] pub struct QemuRWError { kind: QemuRWErrorKind, cause: QemuRWErrorCause, @@ -180,7 +179,7 @@ pub struct QemuMemoryChunk { cpu: Option, } -#[allow(clippy::vec_box)] +#[expect(clippy::vec_box)] static mut GDB_COMMANDS: Vec> = Vec::new(); unsafe extern "C" fn gdb_cmd(data: *mut c_void, buf: *mut u8, len: usize) -> bool { @@ -339,10 +338,9 @@ pub trait ArchExtras { T: Into; } -#[allow(clippy::unused_self)] impl CPU { #[must_use] - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] pub fn index(&self) -> usize { unsafe { libafl_qemu_cpu_index(self.ptr) as usize } } @@ -572,7 +570,6 @@ impl From for HookData { } } -#[allow(clippy::unused_self)] impl Qemu { /// For more details about the parameters check /// [the QEMU documentation](https://www.qemu.org/docs/master/about/). @@ -580,7 +577,7 @@ impl Qemu { QemuConfig::builder() } - #[allow(clippy::must_use_candidate, clippy::similar_names)] + #[expect(clippy::similar_names)] pub fn init(args: &[String]) -> Result { if args.is_empty() { return Err(QemuInitError::EmptyArgs); @@ -598,7 +595,7 @@ impl Qemu { QEMU_IS_INITIALIZED = true; } - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_possible_wrap)] let argc = argc as i32; let args: Vec = args @@ -733,8 +730,8 @@ impl Qemu { } #[must_use] - #[allow(clippy::cast_possible_wrap)] - #[allow(clippy::cast_sign_loss)] + #[allow(clippy::cast_possible_wrap)] // platform dependent + #[expect(clippy::cast_sign_loss)] pub fn num_cpus(&self) -> usize { unsafe { libafl_qemu_num_cpus() as usize } } @@ -750,7 +747,7 @@ impl Qemu { } #[must_use] - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_possible_wrap)] pub fn cpu_from_index(&self, index: usize) -> CPU { unsafe { CPU { @@ -883,7 +880,7 @@ impl Qemu { /// # Safety /// /// Calling this multiple times concurrently will access static variables and is unsafe. - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] pub unsafe fn add_gdb_cmd(&self, callback: Box bool>) { let fat: Box = Box::new(transmute::< Box FnMut(&'a Qemu, &'b str) -> bool>, @@ -1118,7 +1115,7 @@ pub mod pybind { #[pymethods] impl Qemu { - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] #[new] fn new(args: Vec) -> PyResult { let qemu = diff --git a/libafl_qemu/src/qemu/systemmode.rs b/libafl_qemu/src/qemu/systemmode.rs index c481ecd16f..c76898a293 100644 --- a/libafl_qemu/src/qemu/systemmode.rs +++ b/libafl_qemu/src/qemu/systemmode.rs @@ -16,8 +16,8 @@ use libc::EXIT_SUCCESS; use num_traits::Zero; use crate::{ - FastSnapshotPtr, GuestAddrKind, MemAccessInfo, Qemu, QemuMemoryChunk, QemuRWError, - QemuRWErrorCause, QemuRWErrorKind, QemuSnapshotCheckResult, CPU, + FastSnapshotPtr, GuestAddrKind, MemAccessInfo, Qemu, QemuMemoryChunk, QemuSnapshotCheckResult, + CPU, }; pub(super) extern "C" fn qemu_cleanup_atexit() { @@ -33,7 +33,7 @@ pub enum DeviceSnapshotFilter { } #[derive(Debug, Clone)] -#[allow(dead_code)] +#[expect(dead_code)] pub struct PhysMemoryChunk { addr: GuestPhysAddr, size: usize, @@ -48,7 +48,7 @@ pub struct PhysMemoryIter { cpu: CPU, } -#[allow(dead_code)] +#[expect(dead_code)] pub struct HostMemoryIter<'a> { addr: GuestPhysAddr, // This address is correct when the iterator enters next, except if the remaining len is 0 remaining_len: usize, @@ -96,6 +96,7 @@ impl CPU { page as GuestVirtAddr, attrs.as_mut_ptr(), ); + #[expect(clippy::cast_sign_loss)] if paddr == (-1i64 as GuestPhysAddr) { None } else { @@ -147,15 +148,13 @@ impl CPU { /// if a problem occurred during the operation, there will be no feedback pub unsafe fn read_mem_unchecked(&self, addr: GuestAddr, buf: &mut [u8]) { // TODO use gdbstub's target_cpu_memory_rw_debug - unsafe { - libafl_qemu_sys::cpu_memory_rw_debug( - self.ptr, - addr as GuestVirtAddr, - buf.as_mut_ptr() as *mut _, - buf.len(), - false, - ) - }; + libafl_qemu_sys::cpu_memory_rw_debug( + self.ptr, + addr as GuestVirtAddr, + buf.as_mut_ptr() as *mut _, + buf.len(), + false, + ); } /// Write a value to a guest address, taking into account the potential MMU / MPU. @@ -163,22 +162,21 @@ impl CPU { /// # Safety /// no check is done on the correctness of the operation. /// if a problem occurred during the operation, there will be no feedback - pub fn write_mem_unchecked(&self, addr: GuestAddr, buf: &[u8]) { + pub unsafe fn write_mem_unchecked(&self, addr: GuestAddr, buf: &[u8]) { // TODO use gdbstub's target_cpu_memory_rw_debug - unsafe { - libafl_qemu_sys::cpu_memory_rw_debug( - self.ptr, - addr as GuestVirtAddr, - buf.as_ptr() as *mut _, - buf.len(), - true, - ) - }; + libafl_qemu_sys::cpu_memory_rw_debug( + self.ptr, + addr as GuestVirtAddr, + buf.as_ptr() as *mut _, + buf.len(), + true, + ); } } -#[allow(clippy::unused_self)] +#[expect(clippy::unused_self)] impl Qemu { + #[must_use] pub fn guest_page_size(&self) -> usize { 4096 } @@ -215,6 +213,7 @@ impl Qemu { ); } + #[expect(clippy::trivially_copy_pass_by_ref)] pub(super) unsafe fn run_inner(&self) { vm_start(); qemu_main_loop(); @@ -222,12 +221,12 @@ impl Qemu { pub fn save_snapshot(&self, name: &str, sync: bool) { let s = CString::new(name).expect("Invalid snapshot name"); - unsafe { libafl_save_qemu_snapshot(s.as_ptr() as *mut i8, sync) }; + unsafe { libafl_save_qemu_snapshot(s.as_ptr().cast_mut(), sync) }; } pub fn load_snapshot(&self, name: &str, sync: bool) { let s = CString::new(name).expect("Invalid snapshot name"); - unsafe { libafl_load_qemu_snapshot(s.as_ptr() as *mut i8, sync) }; + unsafe { libafl_load_qemu_snapshot(s.as_ptr().cast_mut(), sync) }; } #[must_use] @@ -259,10 +258,13 @@ impl Qemu { } } + #[expect(clippy::missing_safety_doc)] pub unsafe fn restore_fast_snapshot(&self, snapshot: FastSnapshotPtr) { - libafl_qemu_sys::syx_snapshot_root_restore(snapshot) + libafl_qemu_sys::syx_snapshot_root_restore(snapshot); } + #[allow(clippy::missing_safety_doc)] + #[must_use] pub unsafe fn check_fast_snapshot( &self, ref_snapshot: FastSnapshotPtr, @@ -272,6 +274,7 @@ impl Qemu { QemuSnapshotCheckResult::new(check_result.nb_inconsistencies) } + #[must_use] pub fn list_devices(&self) -> Vec { let mut r = vec![]; unsafe { @@ -301,6 +304,7 @@ impl Qemu { } impl QemuMemoryChunk { + #[must_use] pub fn phys_iter(&self, qemu: Qemu) -> PhysMemoryIter { PhysMemoryIter { addr: self.addr, @@ -314,7 +318,8 @@ impl QemuMemoryChunk { } } - #[allow(clippy::map_flatten)] + #[expect(clippy::map_flatten)] + #[must_use] pub fn host_iter(&self, qemu: Qemu) -> Box> { Box::new( self.phys_iter(qemu) @@ -330,12 +335,14 @@ impl QemuMemoryChunk { ) } + #[must_use] pub fn to_host_segmented_buf(&self, qemu: Qemu) -> SegmentedBuf<&[u8]> { self.host_iter(qemu).collect() } } impl PhysMemoryChunk { + #[must_use] pub fn new(addr: GuestPhysAddr, size: usize, qemu: Qemu, cpu: CPU) -> Self { Self { addr, diff --git a/libafl_qemu/src/qemu/usermode.rs b/libafl_qemu/src/qemu/usermode.rs index 619202db02..e621adaf09 100644 --- a/libafl_qemu/src/qemu/usermode.rs +++ b/libafl_qemu/src/qemu/usermode.rs @@ -40,7 +40,6 @@ impl GuestMaps { impl Iterator for GuestMaps { type Item = MapInfo; - #[allow(clippy::uninit_assumed_init)] fn next(&mut self) -> Option { unsafe { let mut ret = MaybeUninit::uninit(); @@ -123,7 +122,7 @@ impl CPU { } } -#[allow(clippy::unused_self)] +#[expect(clippy::unused_self)] impl Qemu { #[must_use] pub fn mappings(&self) -> GuestMaps { @@ -195,7 +194,7 @@ impl Qemu { unsafe { mmap_next_start = start }; } - #[allow(clippy::cast_sign_loss)] + #[expect(clippy::cast_sign_loss)] fn mmap( self, addr: GuestAddr, diff --git a/libafl_sugar/src/forkserver.rs b/libafl_sugar/src/forkserver.rs index 07541cf847..59e62f0651 100644 --- a/libafl_sugar/src/forkserver.rs +++ b/libafl_sugar/src/forkserver.rs @@ -76,10 +76,9 @@ pub struct ForkserverBytesCoverageSugar<'a> { iterations: Option, } -#[allow(clippy::similar_names)] impl ForkserverBytesCoverageSugar<'_> { /// Runs the fuzzer. - #[allow(clippy::too_many_lines, clippy::similar_names)] + #[expect(clippy::too_many_lines)] pub fn run(&mut self) { // a large initial map size that should be enough // to house all potential coverage maps for our targets @@ -336,7 +335,7 @@ pub mod pybind { impl ForkserverBytesCoverageSugar { /// Create a new [`ForkserverBytesCoverageSugar`] #[new] - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] #[pyo3(signature = ( input_dirs, output_dir, @@ -370,7 +369,7 @@ pub mod pybind { } /// Run the fuzzer - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn run(&self, program: String, arguments: Vec) { forkserver::ForkserverBytesCoverageSugar::builder() .input_dirs(&self.input_dirs) diff --git a/libafl_sugar/src/inmemory.rs b/libafl_sugar/src/inmemory.rs index dfac4dd2d6..d1eb465d2d 100644 --- a/libafl_sugar/src/inmemory.rs +++ b/libafl_sugar/src/inmemory.rs @@ -109,13 +109,12 @@ where } } -#[allow(clippy::similar_names)] impl InMemoryBytesCoverageSugar<'_, H> where H: FnMut(&[u8]), { /// Run the fuzzer - #[allow(clippy::too_many_lines, clippy::similar_names)] + #[expect(clippy::too_many_lines)] pub fn run(&mut self) { let conf = match self.configuration.as_ref() { Some(name) => EventConfig::from_name(name), @@ -393,7 +392,7 @@ pub mod pybind { impl InMemoryBytesCoverageSugar { /// Create a new [`InMemoryBytesCoverageSugar`] #[new] - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] #[pyo3(signature = ( input_dirs, output_dir, @@ -427,7 +426,7 @@ pub mod pybind { } /// Run the fuzzer - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn run(&self, harness: PyObject) { inmemory::InMemoryBytesCoverageSugar::builder() .input_dirs(&self.input_dirs) diff --git a/libafl_sugar/src/lib.rs b/libafl_sugar/src/lib.rs index aefb6e0224..c9839203f8 100644 --- a/libafl_sugar/src/lib.rs +++ b/libafl_sugar/src/lib.rs @@ -41,18 +41,15 @@ ) )] -#[allow(clippy::ignored_unit_patterns)] pub mod inmemory; pub use inmemory::InMemoryBytesCoverageSugar; #[cfg(target_os = "linux")] -#[allow(clippy::ignored_unit_patterns)] pub mod qemu; #[cfg(target_os = "linux")] pub use qemu::QemuBytesCoverageSugar; #[cfg(target_family = "unix")] -#[allow(clippy::ignored_unit_patterns)] pub mod forkserver; #[cfg(target_family = "unix")] pub use forkserver::ForkserverBytesCoverageSugar; diff --git a/libafl_sugar/src/qemu.rs b/libafl_sugar/src/qemu.rs index e0126c3b01..124342d999 100644 --- a/libafl_sugar/src/qemu.rs +++ b/libafl_sugar/src/qemu.rs @@ -117,7 +117,7 @@ where H: FnMut(&[u8]), { /// Run the fuzzer - #[allow(clippy::too_many_lines, clippy::similar_names)] + #[expect(clippy::too_many_lines)] pub fn run(&mut self, qemu: Qemu) { let conf = match self.configuration.as_ref() { Some(name) => EventConfig::from_name(name), @@ -498,7 +498,7 @@ pub mod pybind { impl QemuBytesCoverageSugar { /// Create a new [`QemuBytesCoverageSugar`] #[new] - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] #[pyo3(signature = ( input_dirs, output_dir, @@ -532,7 +532,7 @@ pub mod pybind { } /// Run the fuzzer - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn run(&self, qemu: &Qemu, harness: PyObject) { qemu::QemuBytesCoverageSugar::builder() .input_dirs(&self.input_dirs) diff --git a/libafl_targets/build.rs b/libafl_targets/build.rs index 3f92a0004c..4f78848682 100644 --- a/libafl_targets/build.rs +++ b/libafl_targets/build.rs @@ -13,14 +13,14 @@ fn enable_nightly() { #[rustversion::not(nightly)] fn enable_nightly() {} -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] fn main() { println!("cargo:rustc-check-cfg=cfg(nightly)"); enable_nightly(); let out_dir = env::var_os("OUT_DIR").unwrap(); let out_dir = out_dir.to_string_lossy().to_string(); //let out_dir_path = Path::new(&out_dir); - #[allow(unused_variables)] + #[allow(unused_variables)] // feature dependent let src_dir = Path::new("src"); let dest_path = Path::new(&out_dir).join("constants.rs"); diff --git a/libafl_targets/src/cmps/mod.rs b/libafl_targets/src/cmps/mod.rs index 5ebe68ccce..21818e9368 100644 --- a/libafl_targets/src/cmps/mod.rs +++ b/libafl_targets/src/cmps/mod.rs @@ -63,7 +63,7 @@ pub use libafl_cmplog_map_ptr as CMPLOG_MAP_PTR; /// Value indicating if cmplog is enabled. #[no_mangle] -#[allow(non_upper_case_globals)] +#[allow(non_upper_case_globals)] // expect breaks here for some reason pub static mut libafl_cmplog_enabled: u8 = 0; pub use libafl_cmplog_enabled as CMPLOG_ENABLED; @@ -424,8 +424,7 @@ impl CmpMap for CmpLogMap { /// The global `CmpLog` map for the current `LibAFL` run. #[no_mangle] -#[allow(clippy::large_stack_arrays)] -#[allow(non_upper_case_globals)] +#[allow(non_upper_case_globals)] // expect breaks here for some reason pub static mut libafl_cmplog_map: CmpLogMap = CmpLogMap { headers: [CmpLogHeader { hits: 0, @@ -440,7 +439,6 @@ pub static mut libafl_cmplog_map: CmpLogMap = CmpLogMap { /// The globale `CmpLog` map, aflpp style #[no_mangle] #[cfg(feature = "cmplog_extended_instrumentation")] -#[allow(clippy::large_stack_arrays)] pub static mut libafl_cmplog_map_extended: AFLppCmpLogMap = AFLppCmpLogMap { headers: [AFLppCmpLogHeader::new_with_raw_value(0); CMPLOG_MAP_W], vals: AFLppCmpLogVals { @@ -478,7 +476,7 @@ impl HasLen for AFLppCmpLogMap { impl AFLppCmpLogMap { #[must_use] - #[allow(clippy::cast_ptr_alignment)] + #[expect(clippy::cast_ptr_alignment)] /// Instantiate a new boxed zeroed `AFLppCmpLogMap`. This should be used to create a new /// map, because it is so large it cannot be allocated on the stack with default /// runtime configuration. @@ -525,7 +523,7 @@ impl Serialize for AFLppCmpLogMap { } impl<'de> Deserialize<'de> for AFLppCmpLogMap { - #[allow(clippy::cast_ptr_alignment)] + #[expect(clippy::cast_ptr_alignment)] fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, diff --git a/libafl_targets/src/cmps/observers/aflpp.rs b/libafl_targets/src/cmps/observers/aflpp.rs index c07df26968..28efe97849 100644 --- a/libafl_targets/src/cmps/observers/aflpp.rs +++ b/libafl_targets/src/cmps/observers/aflpp.rs @@ -174,7 +174,7 @@ impl<'a> AFLppCmpLogObserver<'a> { where S: HasMetadata, { - #[allow(clippy::option_if_let_else)] // we can't mutate state in a closure + #[expect(clippy::option_if_let_else)] // we can't mutate state in a closure let meta = if let Some(meta) = state.metadata_map_mut().get_mut::() { meta diff --git a/libafl_targets/src/cmps/stages/aflpptracing.rs b/libafl_targets/src/cmps/stages/aflpptracing.rs index 99f37ffb12..7d20d04e3f 100644 --- a/libafl_targets/src/cmps/stages/aflpptracing.rs +++ b/libafl_targets/src/cmps/stages/aflpptracing.rs @@ -23,7 +23,6 @@ pub struct AFLppCmplogTracingStage<'a, EM, TE, S, Z> { name: Cow<'static, str>, tracer_executor: TE, cmplog_observer_handle: Handle>, - #[allow(clippy::type_complexity)] phantom: PhantomData<(EM, TE, S, Z)>, } /// The name for aflpp tracing stage diff --git a/libafl_targets/src/coverage.rs b/libafl_targets/src/coverage.rs index c93e5f3a4e..d272348deb 100644 --- a/libafl_targets/src/coverage.rs +++ b/libafl_targets/src/coverage.rs @@ -16,19 +16,19 @@ use crate::{ACCOUNTING_MAP_SIZE, DDG_MAP_SIZE, EDGES_MAP_ALLOCATED_SIZE, EDGES_M /// The map for edges. #[no_mangle] -#[allow(non_upper_case_globals)] +#[allow(non_upper_case_globals)] // expect breaks here for some reason pub static mut __afl_area_ptr_local: [u8; EDGES_MAP_ALLOCATED_SIZE] = [0; EDGES_MAP_ALLOCATED_SIZE]; pub use __afl_area_ptr_local as EDGES_MAP; /// The map for data dependency #[no_mangle] -#[allow(non_upper_case_globals)] +#[allow(non_upper_case_globals)] // expect breaks here for some reason pub static mut __ddg_area_ptr_local: [u8; DDG_MAP_SIZE] = [0; DDG_MAP_SIZE]; pub use __ddg_area_ptr_local as DDG_MAP; /// The map for accounting mem writes. #[no_mangle] -#[allow(non_upper_case_globals)] +#[allow(non_upper_case_globals)] // expect breaks here for some reason pub static mut __afl_acc_memop_ptr_local: [u32; ACCOUNTING_MAP_SIZE] = [0; ACCOUNTING_MAP_SIZE]; pub use __afl_acc_memop_ptr_local as ACCOUNTING_MEMOP_MAP; @@ -78,7 +78,7 @@ pub fn autotokens() -> Result { /// The actual size we use for the map of edges. /// This is used for forkserver backend -#[allow(non_upper_case_globals)] +#[allow(non_upper_case_globals)] // expect breaks here for some reason #[no_mangle] pub static mut __afl_map_size: usize = EDGES_MAP_DEFAULT_SIZE; @@ -221,7 +221,7 @@ mod swap { /// Observer to be used with `DiffExecutor`s when executing a differential target that shares /// the AFL map in order to swap out the maps (and thus allow for map observing the two targets /// separately). - #[allow(clippy::unsafe_derive_deserialize)] + #[expect(clippy::unsafe_derive_deserialize)] #[derive(Debug, Serialize, Deserialize)] pub struct DifferentialAFLMapSwapObserver<'a, 'b> { first_map: OwnedMutSlice<'a, u8>, diff --git a/libafl_targets/src/lib.rs b/libafl_targets/src/lib.rs index 74a6c5fce4..43fc18b731 100644 --- a/libafl_targets/src/lib.rs +++ b/libafl_targets/src/lib.rs @@ -45,7 +45,8 @@ #[cfg(feature = "std")] #[macro_use] extern crate std; -#[allow(unused_imports)] + +#[allow(unused_imports)] // for no-std #[macro_use] extern crate alloc; @@ -75,7 +76,6 @@ pub use sancov_cmp::*; /// Module containing bindings to the various sanitizer interface headers #[cfg(feature = "sanitizer_interfaces")] -#[allow(clippy::mixed_attributes_style)] pub mod sanitizer_ifaces { #![allow(non_snake_case)] #![allow(non_camel_case_types)] diff --git a/libafl_targets/src/libfuzzer/mod.rs b/libafl_targets/src/libfuzzer/mod.rs index 31bae56d35..f5d9d41bdb 100644 --- a/libafl_targets/src/libfuzzer/mod.rs +++ b/libafl_targets/src/libfuzzer/mod.rs @@ -26,13 +26,13 @@ extern "C" { /// /// # Safety /// Calls the libfuzzer-style init function which is native code. -#[allow(clippy::similar_names)] -#[allow(clippy::must_use_candidate)] // nobody uses that return code... +#[expect(clippy::similar_names)] +#[expect(clippy::must_use_candidate)] // nobody uses that return code... pub unsafe fn libfuzzer_initialize(args: &[String]) -> i32 { let args: Vec = args.iter().map(|x| x.clone() + "\0").collect(); let argv: Vec<*const u8> = args.iter().map(|x| x.as_bytes().as_ptr()).collect(); assert!(argv.len() < i32::MAX as usize); - #[allow(clippy::cast_possible_wrap)] + #[expect(clippy::cast_possible_wrap)] let argc = argv.len() as i32; unsafe { let argv_ptr = argv.as_ptr(); @@ -44,7 +44,7 @@ pub unsafe fn libfuzzer_initialize(args: &[String]) -> i32 { /// /// # Safety /// Calls the libfuzzer harness. We actually think the target is unsafe and crashes eventually, that's why we do all this fuzzing. -#[allow(clippy::must_use_candidate)] +#[expect(clippy::must_use_candidate)] pub unsafe fn libfuzzer_test_one_input(buf: &[u8]) -> i32 { unsafe { LLVMFuzzerTestOneInput(buf.as_ptr(), buf.len()) } } diff --git a/libafl_targets/src/libfuzzer/mutators.rs b/libafl_targets/src/libfuzzer/mutators.rs index 95f01443e8..a57b7fa751 100644 --- a/libafl_targets/src/libfuzzer/mutators.rs +++ b/libafl_targets/src/libfuzzer/mutators.rs @@ -67,7 +67,7 @@ thread_local! { /// Mutator which is available for user-defined mutator/crossover /// See: [Structure-Aware Fuzzing with libFuzzer](https://github.com/google/fuzzing/blob/master/docs/structure-aware-fuzzing.md) -#[allow(non_snake_case)] +#[allow(non_snake_case)] // expect breaks here for some reason #[no_mangle] pub extern "C" fn LLVMFuzzerMutate(data: *mut u8, size: usize, max_size: usize) -> usize { MUTATOR.with(|mutator| { @@ -110,7 +110,7 @@ impl<'a, M, S> MutatorProxy<'a, M, S> { /// Create a weak version of the proxy, which will become unusable when the custom mutator /// is no longer permitted to be executed. - #[allow(clippy::type_complexity)] + #[allow(clippy::type_complexity)] // no longer a problem in nightly fn weak(&self) -> WeakMutatorProxy FnMut(&'b mut S)) -> bool, M, S> { let state = Rc::downgrade(&self.state); WeakMutatorProxy { diff --git a/libafl_targets/src/sancov_8bit.rs b/libafl_targets/src/sancov_8bit.rs index b4ef07bcde..ae1e916af8 100644 --- a/libafl_targets/src/sancov_8bit.rs +++ b/libafl_targets/src/sancov_8bit.rs @@ -40,8 +40,7 @@ pub unsafe fn extra_counters() -> Vec> { /// # Safety /// Start and stop are being dereferenced. #[no_mangle] -#[allow(clippy::cast_sign_loss)] -#[allow(clippy::not_unsafe_ptr_arg_deref)] +#[expect(clippy::cast_sign_loss)] pub unsafe extern "C" fn __sanitizer_cov_8bit_counters_init(start: *mut u8, stop: *mut u8) { unsafe { let counter_maps = &mut *counter_maps_ptr_mut(); @@ -129,7 +128,7 @@ mod observers { /// The [`CountersMultiMapObserver`] observes all the counters that may be set by /// `SanitizerCoverage` in [`super::COUNTERS_MAPS`] #[derive(Serialize, Deserialize, Debug)] - #[allow(clippy::unsafe_derive_deserialize)] + #[expect(clippy::unsafe_derive_deserialize)] pub struct CountersMultiMapObserver { intervals: IntervalTree, len: usize, diff --git a/libafl_targets/src/sancov_pcguard.rs b/libafl_targets/src/sancov_pcguard.rs index 3fc2e63adc..cb7aa2a142 100644 --- a/libafl_targets/src/sancov_pcguard.rs +++ b/libafl_targets/src/sancov_pcguard.rs @@ -23,7 +23,7 @@ use libafl::executors::{hooks::ExecutorHook, HasObservers}; use crate::coverage::EDGES_MAP; use crate::coverage::MAX_EDGES_FOUND; #[cfg(any(feature = "sancov_ngram4", feature = "sancov_ngram8"))] -#[allow(unused)] +#[allow(unused_imports)] // only used in an unused function use crate::EDGES_MAP_DEFAULT_SIZE; #[cfg(feature = "pointer_maps")] use crate::{coverage::EDGES_MAP_PTR, EDGES_MAP_ALLOCATED_SIZE}; @@ -35,7 +35,7 @@ compile_error!( ); #[cfg(any(feature = "sancov_ngram4", feature = "sancov_ngram8"))] -#[allow(unused)] +#[allow(unused_imports)] // only used in an unused function use core::ops::ShlAssign; #[cfg(feature = "sancov_ngram4")] @@ -180,7 +180,7 @@ where } #[rustversion::nightly] -#[allow(unused)] +#[expect(unused)] #[inline] #[cfg(any(feature = "sancov_ngram4", feature = "sancov_ngram8"))] unsafe fn update_ngram(pos: usize) -> usize { @@ -224,9 +224,9 @@ extern "C" { /// Dereferences `guard`, reads the position from there, then dereferences the [`EDGES_MAP`] at that position. /// Should usually not be called directly. #[no_mangle] -#[allow(unused_assignments)] +#[allow(unused_assignments)] // cfg dependent pub unsafe extern "C" fn __sanitizer_cov_trace_pc_guard(guard: *mut u32) { - #[allow(unused_mut)] + #[allow(unused_mut)] // cfg dependent let mut pos = *guard as usize; #[cfg(any(feature = "sancov_ngram4", feature = "sancov_ngram8"))] diff --git a/libafl_tinyinst/src/executor.rs b/libafl_tinyinst/src/executor.rs index b4b22d58fe..f699ab337d 100644 --- a/libafl_tinyinst/src/executor.rs +++ b/libafl_tinyinst/src/executor.rs @@ -82,7 +82,7 @@ where } } - #[allow(unused_assignments)] + #[expect(unused_assignments)] let mut status = RunResult::OK; unsafe { status = self.tinyinst.run(); diff --git a/scripts/dummy.rs b/scripts/dummy.rs index 7a0f064f28..464dee6f2e 100644 --- a/scripts/dummy.rs +++ b/scripts/dummy.rs @@ -1,5 +1,5 @@ /// Dummy file for Docker build caching /// Just here as dummy in docker -#[allow(dead_code)] +#[expect(dead_code)] fn main() { panic!("This is the CI dummy file - it should never run!") } \ No newline at end of file diff --git a/scripts/parallellize_cargo_clippy_on_fuzzers.py b/scripts/parallellize_cargo_clippy_on_fuzzers.py new file mode 100644 index 0000000000..8122d06d5c --- /dev/null +++ b/scripts/parallellize_cargo_clippy_on_fuzzers.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 + +import os +import subprocess +import sys +import argparse +from pathlib import Path +from concurrent.futures import ThreadPoolExecutor, as_completed +import multiprocessing +import logging + + +def main(): + # Parse command-line arguments + parser = argparse.ArgumentParser(description="Run Clippy on fuzzers in parallel.") + parser.add_argument( + "--dry-run", action="store_true", help="Show commands without executing." + ) + parser.add_argument( + "--pedantic", action="store_true", help="Activate all clippy warnings" + ) + args = parser.parse_args() + + # Setup logging + logging.basicConfig( + level=logging.DEBUG, + format="%(asctime)s - %(levelname)s - %(message)s", + handlers=[logging.StreamHandler(sys.stdout)], + ) + if args.dry_run: + logging.info("Dry-run mode enabled. Commands will not be executed.") + + # Set directories + script_dir = Path(__file__).resolve().parent + libafl_dir = script_dir.parent + os.chdir(libafl_dir) + logging.debug(f"Changed directory to {libafl_dir}") + + # Initialize git submodules + cmd = "git submodule update --init" + logging.info(f"Running: {cmd}") + if not args.dry_run: + subprocess.run(cmd, shell=True, check=True) + + # Find fuzzer directories + fuzzers = list((libafl_dir / "fuzzers").glob("*/*")) + fuzzers.extend(list((libafl_dir / "fuzzers/baby/backtrace_baby_fuzzers").glob("*"))) + + fuzzers = [f for f in fuzzers if "nyx_" not in f.name and f.is_dir()] + logging.debug(f"Found {len(fuzzers)} fuzzers.") + + # Function to run commands + def run_clippy(fuzzer: Path): + if not (fuzzer / "Cargo.toml").is_file(): + logging.info(f"No Cargo.toml for {fuzzer}, skipping…") + return True + + options = "-D clippy::pedantic" if args.pedantic else "" + + cmd_default = f"cargo clippy -- -D warnings {options}" + cmd_nightly = f"cargo +nightly clippy -- -D warnings {options}" + for cmd in [cmd_default, cmd_nightly]: + logging.info(f"[{fuzzer}] Running: {cmd}") + if args.dry_run: + continue + result = subprocess.run( + cmd, + shell=True, + cwd=fuzzer, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + ) + if result.returncode != 0: + logging.error( + f"[{fuzzer}] Command failed: cd {fuzzer}; {cmd}\n{result.stderr}" + ) + return False + else: + logging.info(f"[{fuzzer}] Clippy passed.") + + return True + + # Run Clippy in parallel + with ThreadPoolExecutor(max_workers=multiprocessing.cpu_count()) as executor: + futures = {executor.submit(run_clippy, fuzzer): fuzzer for fuzzer in fuzzers} + success = True + for future in as_completed(futures): + if not future.result(): + success = False + + if success: + logging.info("All fuzzers passed Clippy.") + sys.exit(0) + else: + logging.error("Some fuzzers failed Clippy.") + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/utils/build_and_test_fuzzers/src/diffing.rs b/utils/build_and_test_fuzzers/src/diffing.rs index 8b770e38cb..707ca3690f 100644 --- a/utils/build_and_test_fuzzers/src/diffing.rs +++ b/utils/build_and_test_fuzzers/src/diffing.rs @@ -35,7 +35,7 @@ pub fn get_diffing_files(commits: &[String]) -> HashSet { files } -#[allow(clippy::implicit_hasher)] +#[expect(clippy::implicit_hasher)] #[must_use] pub fn get_diffing_crates(diffing_files: &HashSet) -> HashSet { // TODO maybe consider using a combination of this and https://docs.rs/cargo/0.28.0/cargo/sources/path/struct.PathSource.html @@ -99,7 +99,7 @@ pub fn find_all_crates() -> HashSet { crates } -#[allow(clippy::implicit_hasher)] +#[expect(clippy::implicit_hasher)] pub fn extend_diffing_crates_with_deps( diffing_crates: &mut HashSet, all_crates: &HashSet, diff --git a/utils/desyscall/src/file.rs b/utils/desyscall/src/file.rs index 0e146d9396..9a0ffaa17e 100644 --- a/utils/desyscall/src/file.rs +++ b/utils/desyscall/src/file.rs @@ -11,7 +11,7 @@ extern "C" { /// # Safety /// Call to functions using syscalls -#[allow(clippy::cast_possible_wrap)] +#[expect(clippy::cast_possible_wrap)] #[no_mangle] pub unsafe extern "C" fn write(fd: c_int, buf: Pointer, count: size_t) -> ssize_t { let ctx = Context::get(); diff --git a/utils/desyscall/src/mmap.rs b/utils/desyscall/src/mmap.rs index 948d425cf0..f101ec18e7 100644 --- a/utils/desyscall/src/mmap.rs +++ b/utils/desyscall/src/mmap.rs @@ -42,7 +42,7 @@ extern "C" { /// # Safety /// Call to functions using syscalls #[no_mangle] -#[allow(clippy::too_many_lines)] +#[expect(clippy::too_many_lines)] #[cfg(not(windows))] pub unsafe extern "C" fn mmap( addr: Pointer, @@ -162,7 +162,7 @@ pub unsafe extern "C" fn mmap( } let mut reminder_next = None; - #[allow(clippy::comparison_chain)] + #[expect(clippy::comparison_chain)] if let Some(p) = prev.take() { if p.0 < end { fail = true; diff --git a/utils/drcov_utils/src/bin/drcov_dump_addrs.rs b/utils/drcov_utils/src/bin/drcov_dump_addrs.rs index 533dea3186..262cdaf6b1 100644 --- a/utils/drcov_utils/src/bin/drcov_dump_addrs.rs +++ b/utils/drcov_utils/src/bin/drcov_dump_addrs.rs @@ -9,7 +9,6 @@ use libafl_targets::drcov::DrCovReader; #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] -#[allow(clippy::module_name_repetitions)] #[command( name = "drcov_dump_addrs", about, diff --git a/utils/drcov_utils/src/bin/drcov_merge.rs b/utils/drcov_utils/src/bin/drcov_merge.rs index 6069cd451d..13d3d4a4d3 100644 --- a/utils/drcov_utils/src/bin/drcov_merge.rs +++ b/utils/drcov_utils/src/bin/drcov_merge.rs @@ -1,11 +1,10 @@ use std::path::PathBuf; -use clap::{ArgAction, Parser}; +use clap::Parser; use libafl_targets::drcov::DrCovReader; #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] -#[allow(clippy::module_name_repetitions)] #[command( name = "drcov_merge", about, diff --git a/utils/libafl_fmt/src/main.rs b/utils/libafl_fmt/src/main.rs index 336a409c00..b716c5a78a 100644 --- a/utils/libafl_fmt/src/main.rs +++ b/utils/libafl_fmt/src/main.rs @@ -352,7 +352,7 @@ async fn get_version_string(path: &str, args: &[&str]) -> Result ! { #[cfg(feature = "std")] println!("Hex: {addr:#x}"); - #[allow(clippy::cast_possible_truncation)] + #[expect(clippy::cast_possible_truncation)] let addr = addr as usize; let entrypoint = addr as *mut c_void;