Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use #[expect(…)] instead of #[allow(…)], remove unnecessary allows #2784

Merged
merged 28 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
01836cf
Use expect instead of allow, remove unnecessary allows
riesentoaster Dec 19, 2024
e17230b
Remove more whitelist lint warnings
riesentoaster Dec 19, 2024
5c0c8d8
tranisitioning more subprojects
riesentoaster Dec 19, 2024
6509b51
Re-add some necessary allows
riesentoaster Dec 19, 2024
fbea9b2
Re-add more required allows
riesentoaster Dec 19, 2024
4de58ff
Some more windows clippy fixes
riesentoaster Dec 19, 2024
d03fefd
Re-add more whitelist items for expect
riesentoaster Dec 19, 2024
a44564e
More clippy whitelist fun
riesentoaster Dec 19, 2024
d1e3def
Reset changes to generated files
riesentoaster Dec 19, 2024
ae5a8dd
Reset generated files to correct version
riesentoaster Dec 19, 2024
7f7fbc7
Move libafl_concolic to expect instead of allow
riesentoaster Dec 19, 2024
0d68d92
Move libafl_frida to expect from allow
riesentoaster Dec 19, 2024
6a41e10
Move libafl_libfuzzer to expect from allow
riesentoaster Dec 19, 2024
6c93faa
Remove more whitelist items for macOS
riesentoaster Dec 19, 2024
b0e9a88
Fix unknown clippy allow
riesentoaster Dec 19, 2024
f369f65
Remove more unnecessary allow statements
riesentoaster Dec 19, 2024
f2265c6
moving fuzzers
riesentoaster Dec 20, 2024
22ab683
Remove mistakenly added subdirs
riesentoaster Dec 20, 2024
ac9a126
fixing imports
riesentoaster Dec 20, 2024
0827c85
Remove more unnecessary whitelisted lints
riesentoaster Dec 20, 2024
be4f51e
Fix test for /home/ubuntu/LibAFL/fuzzers/inprocess/libfuzzer_libpng_a…
riesentoaster Dec 20, 2024
ffc1510
More clippy improvements for libafl_qemu
riesentoaster Dec 20, 2024
5ea6c78
fmt
riesentoaster Dec 20, 2024
1d7f6fc
Some pedantic options
riesentoaster Dec 20, 2024
3a0f3b2
Fix more stuff
riesentoaster Dec 20, 2024
2ecd5a4
Remove Little-CMS again
riesentoaster Dec 20, 2024
848d453
Add note to static_mut_refs
riesentoaster Dec 20, 2024
54dcc4d
Reset the changed testing routine since it is unnecessary
riesentoaster Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion fuzzers/baby/baby_fuzzer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case these allows have to go

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or otherwise leave a biiiiiig TODO comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created an issue (#2786) and added a comment to the code with a link to it.

static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() };

/// 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| {
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions fuzzers/baby/baby_fuzzer_custom_executor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) };
Expand Down
5 changes: 4 additions & 1 deletion fuzzers/baby/baby_fuzzer_minimizing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ 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
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| {
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions fuzzers/baby/baby_fuzzer_swap_differential/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions fuzzers/baby/baby_fuzzer_unicode/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ extern "C" {

}

#[allow(clippy::similar_names)]
pub fn main() {
let mut shmem_provider = StdShMemProvider::new().unwrap();
unsafe { create_shmem_array() };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ extern "C" {

}

#[allow(clippy::similar_names)]
pub fn main() {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
Expand Down
7 changes: 4 additions & 3 deletions fuzzers/baby/backtrace_baby_fuzzers/command_executor/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -81,13 +80,16 @@ 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,
timeout: Duration,
}

impl CommandConfigurator<BytesInput> 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<Child, Error> {
let mut command = Command::new("./test_command");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use libafl_bolts::{
AsSliceMut,
};

#[allow(clippy::similar_names)]
pub fn main() {
const MAP_SIZE: usize = 65536;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ 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
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| {
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions fuzzers/baby/tutorial/src/input.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![expect(unexpected_cfgs)] // deriving NewFuzzed etc. introduces these
use std::hash::Hash;

use lain::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/binary_only/frida_executable_libpng/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion fuzzers/binary_only/frida_executable_libpng/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/binary_only/frida_libpng/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");

Expand Down
2 changes: 1 addition & 1 deletion fuzzers/binary_only/frida_windows_gdiplus/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"));
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/binary_only/fuzzbench_fork_qemu/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<libafl_qemu::modules::cmplog::CmpLogMap>();
Expand Down
3 changes: 2 additions & 1 deletion fuzzers/binary_only/intel_pt_baby_fuzzer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion fuzzers/binary_only/intel_pt_command_executor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion fuzzers/binary_only/qemu_cmin/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|| {
Expand Down
2 changes: 0 additions & 2 deletions fuzzers/binary_only/qemu_coverage/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|| {
Expand Down
6 changes: 3 additions & 3 deletions fuzzers/binary_only/qemu_launcher/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{
options::FuzzerOptions,
};

#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub type ClientState =
StdState<BytesInput, InMemoryOnDiskCorpus<BytesInput>, StdRand, OnDiskCorpus<BytesInput>>;

Expand All @@ -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::<Vec<(String, String)>>()
}

#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub fn run<M: Monitor>(
&self,
state: Option<ClientState>,
Expand Down
6 changes: 3 additions & 3 deletions fuzzers/binary_only/qemu_launcher/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>) {}

/// Helper function to find the function we want to fuzz.
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions fuzzers/binary_only/qemu_launcher/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ pub struct Instance<'a, M: Monitor> {
}

impl<M: Monitor> Instance<'_, M> {
#[allow(clippy::similar_names)] // elf != self
fn coverage_filter(&self, qemu: Qemu) -> Result<StdAddressFilter, Error> {
/* Conversion is required on 32-bit targets, but not on 64-bit ones */
if let Some(includes) = &self.options.include {
Expand Down Expand Up @@ -106,7 +105,7 @@ impl<M: Monitor> Instance<'_, M> {
}
}

#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub fn run<ET>(&mut self, modules: ET, state: Option<ClientState>) -> Result<(), Error>
where
ET: EmulatorModuleTuple<ClientState> + Debug,
Expand Down
1 change: 0 additions & 1 deletion fuzzers/binary_only/qemu_launcher/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Loading
Loading