Add auto format to settings.json.default, format documentation and macros (#3019)

* Add auto format to settings.json.default

* Add more nightly rustfmt features
This commit is contained in:
Dominik Maier 2025-02-21 13:31:31 +01:00 committed by GitHub
parent 14eee111c2
commit 7c83be2408
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
38 changed files with 87 additions and 71 deletions

View File

@ -1,4 +1,11 @@
{
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true
},
"rust-analyzer.rustfmt.extraArgs": [
"+nightly"
],
"rust-analyzer.cargo.buildScripts.overrideCommand": [
"cargo",
"check",

View File

@ -1,5 +1,4 @@
//! A libfuzzer-like fuzzer using qemu for binary-only coverage
//!
#[cfg(feature = "i386")]
use core::mem::size_of;
#[cfg(feature = "snapshot")]

View File

@ -1,5 +1,4 @@
//! A libfuzzer-like fuzzer using qemu for binary-only coverage
//!
#[cfg(feature = "i386")]
use core::mem::size_of;
use core::time::Duration;

View File

@ -1,5 +1,4 @@
//! A fuzzer using qemu in systemmode for binary-only coverage of kernels
//!
use core::time::Duration;
use std::{env, path::PathBuf, process};

View File

@ -1,5 +1,4 @@
//! A fuzzer using qemu in systemmode for binary-only coverage of kernels
//!
use core::time::Duration;
use std::{env, path::PathBuf, process};

View File

@ -1,5 +1,4 @@
//! A fuzzer using qemu in systemmode for binary-only coverage of kernels
//!
use core::time::Duration;
use std::{env, path::PathBuf, process};

View File

@ -1,5 +1,4 @@
//! A systemmode linux kernel example
//!
#[cfg(target_os = "linux")]
mod fuzzer;

View File

@ -1,5 +1,4 @@
//! A systemmode linux kernel example
//!
#[cfg(target_os = "linux")]
mod fuzzer;

View File

@ -1,5 +1,4 @@
//! LibAFL version of the [`Nautilus`](https://github.com/nautilus-fuzz/nautilus) grammar fuzzer
//!
#![doc = include_str!("README.md")]
#[allow(missing_docs)]

View File

@ -33,7 +33,6 @@ pub(crate) const _LLMP_TAG_EVENT_TO_CLIENT: Tag = Tag(0x2C11E471);
/// Only handle this in the broker
pub(crate) const _LLMP_TAG_EVENT_TO_BROKER: Tag = Tag(0x2B80438);
/// Handle in both
///
pub(crate) const LLMP_TAG_EVENT_TO_BOTH: Tag = Tag(0x2B0741);
pub(crate) const _LLMP_TAG_RESTART: Tag = Tag(0x8357A87);
pub(crate) const _LLMP_TAG_NO_RESTART: Tag = Tag(0x57A7EE71);

View File

@ -739,17 +739,25 @@ impl CommandExecutorBuilder {
/// A `CommandConfigurator` takes care of creating and spawning a [`Command`] for the [`CommandExecutor`].
/// # Example
/// ```
/// use std::{io::Write, process::{Stdio, Command, Child}, time::Duration};
/// use libafl::{Error, corpus::Corpus, inputs::{BytesInput, HasTargetBytes, Input}, executors::{Executor, command::CommandConfigurator}, state::{HasExecutions}};
/// use std::{
/// io::Write,
/// process::{Child, Command, Stdio},
/// time::Duration,
/// };
///
/// use libafl::{
/// corpus::Corpus,
/// executors::{command::CommandConfigurator, Executor},
/// inputs::{BytesInput, HasTargetBytes, Input},
/// state::HasExecutions,
/// Error,
/// };
/// use libafl_bolts::AsSlice;
/// #[derive(Debug)]
/// struct MyExecutor;
///
/// impl CommandConfigurator<BytesInput> for MyExecutor {
/// fn spawn_child(
/// &mut self,
/// input: &BytesInput,
/// ) -> Result<Child, Error> {
/// fn spawn_child(&mut self, input: &BytesInput) -> Result<Child, Error> {
/// let mut command = Command::new("../if");
/// command
/// .stdin(Stdio::piped())

View File

@ -2,7 +2,6 @@
//!
//! It wraps two executors that will be run after each other with the same input.
//! In comparison to the [`crate::executors::CombinedExecutor`] it also runs the secondary executor in `run_target`.
//!
use core::{
cell::UnsafeCell,
fmt::Debug,

View File

@ -1,5 +1,4 @@
//! Diff Feedback, comparing the content of two observers of the same type.
//!
use alloc::borrow::Cow;
use core::fmt::{self, Debug, Formatter};

View File

@ -1,6 +1,5 @@
//! The feedbacks reduce observer state after each run to a single `is_interesting`-value.
//! If a testcase is interesting, it may be added to a Corpus.
//!
// TODO: make S of Feedback<S> an associated type when specialisation + AT is stable

View File

@ -1,5 +1,4 @@
//! The [`ValueBloomFeedback`] checks if a value has already been observed in a [`BloomFilter`] and returns `true` if the value is new, adding it to the bloom filter.
//!
use alloc::borrow::Cow;
use core::hash::Hash;

View File

@ -1,6 +1,4 @@
//! Input for the [`Nautilus`](https://github.com/RUB-SysSec/nautilus) grammar fuzzer methods
//!
//!
use alloc::{rc::Rc, vec::Vec};
use core::cell::RefCell;
use std::hash::{Hash, Hasher};

View File

@ -1,5 +1,4 @@
//! Mutations for [`EncodedInput`]s
//!
use alloc::{borrow::Cow, vec::Vec};
use core::{
cmp::{max, min},

View File

@ -219,7 +219,11 @@ pub mod macros {
/// # phantom: PhantomData<(C, O)>,
/// # }
/// #
/// impl<C, O> MyCustomScheduler<C, O> where O: MapObserver, C: CanTrack + AsRef<O> {
/// impl<C, O> MyCustomScheduler<C, O>
/// where
/// O: MapObserver,
/// C: CanTrack + AsRef<O>,
/// {
/// pub fn new(obs: &C) -> Self {
/// require_index_tracking!("MyCustomScheduler", C);
/// todo!("Construct your type")
@ -282,7 +286,11 @@ pub mod macros {
/// # phantom: PhantomData<(C, O)>,
/// # }
/// #
/// impl<C, O> MyCustomScheduler<C, O> where O: MapObserver, C: CanTrack + AsRef<O> {
/// impl<C, O> MyCustomScheduler<C, O>
/// where
/// O: MapObserver,
/// C: CanTrack + AsRef<O>,
/// {
/// pub fn new(obs: &C) -> Self {
/// require_novelties_tracking!("MyCustomScheduler", C);
/// todo!("Construct your type")

View File

@ -1,6 +1,5 @@
//! This module contains the `concolic` stages, which can trace a target using symbolic execution
//! and use the results for fuzzer input and mutations.
//!
use alloc::borrow::{Cow, ToOwned};
#[cfg(feature = "concolic_mutation")]
use alloc::{string::ToString, vec::Vec};

View File

@ -4,7 +4,6 @@
//! A push stage instead returns an iterator that generates a new result for each time it gets called.
//! With the new testcase, you will have to take care about testcase execution, manually.
//! The push stage relies on internal mutability of the supplied `Observers`.
//!
/// Mutational stage is the normal fuzzing stage.
pub mod mutational;

View File

@ -14,19 +14,21 @@
//!
//! // Create a thread for each active CPU core.
//! # #[cfg(not(miri))]
//! let handles = core_ids.into_iter().map(|id| {
//! let handles = core_ids
//! .into_iter()
//! .map(|id| {
//! thread::spawn(move || {
//! // Pin this thread to a single CPU core.
//! id.set_affinity();
//! // Do more work after this.
//! })
//! }).collect::<Vec<_>>();
//! })
//! .collect::<Vec<_>>();
//!
//! # #[cfg(not(miri))]
//! for handle in handles.into_iter() {
//! handle.join().unwrap();
//! }
//!
//! ```
//!
//! *This file is a fork of <https://github.com/Elzair/core_affinity_rs>*
@ -60,7 +62,6 @@ impl CoreId {
/// Note: This will *_not_* fail if the target platform does not support core affinity.
/// (only on error cases for supported platforms)
/// If you really need to fail for unsupported platforms (like `aarch64` on `macOS`), use [`CoreId::set_affinity_forced`] instead.
///
pub fn set_affinity(&self) -> Result<(), Error> {
match set_for_current_helper(*self) {
Ok(()) | Err(Error::Unsupported(_, _)) => Ok(()),

View File

@ -1,5 +1,4 @@
//! Operating System specific abstractions
//!
#[cfg(any(unix, all(windows, feature = "std")))]
use crate::Error;

View File

@ -271,7 +271,6 @@ use crate::Error;
extern "C" {
/// The `libc` `getcontext`
/// For some reason, it's not available on `MacOS`.
///
fn getcontext(ucp: *mut ucontext_t) -> c_int;
}

View File

@ -809,7 +809,7 @@ macro_rules! tuple_for_each_mut {
/// ```rust
/// use libafl_bolts::{
/// map_tuple_list_type,
/// tuples::{MappingFunctor, Map, tuple_list, tuple_list_type}
/// tuples::{tuple_list, tuple_list_type, Map, MappingFunctor},
/// };
///
/// struct Wrapper<T>(T);
@ -842,7 +842,10 @@ macro_rules! map_tuple_list_type {
/// Merges the types of two merged [`tuple_list!`]s
///
/// ```rust
/// use libafl_bolts::{merge_tuple_list_type, tuples::{Merge, tuple_list, tuple_list_type}};
/// use libafl_bolts::{
/// merge_tuple_list_type,
/// tuples::{tuple_list, tuple_list_type, Merge},
/// };
///
/// struct A;
/// struct B;

View File

@ -136,7 +136,13 @@ impl From<EventType> for libc::c_uint {
/// # use std::thread;
/// unsafe {
/// pthread_hook::install(|event, pthread, addr, size| {
/// log::trace!("thread id=0x{:x} event={:?} addr={:?} size={:x}", pthread, event, addr, size);
/// log::trace!(
/// "thread id=0x{:x} event={:?} addr={:?} size={:x}",
/// pthread,
/// event,
/// addr,
/// size
/// );
/// });
/// };
/// # thread::spawn(|| {

View File

@ -538,8 +538,10 @@ impl Default for IntelPTBuilder {
/// .exclude_kernel(true)
/// .exclude_hv(true)
/// .inherit(false)
/// .perf_buffer_size(128 * PAGE_SIZE + PAGE_SIZE).unwrap()
/// .perf_aux_buffer_size(2 * 1024 * 1024).unwrap()
/// .perf_buffer_size(128 * PAGE_SIZE + PAGE_SIZE)
/// .unwrap()
/// .perf_aux_buffer_size(2 * 1024 * 1024)
/// .unwrap()
/// .ip_filters(&[]);
/// assert_eq!(builder, IntelPTBuilder::default());
/// ```

View File

@ -73,7 +73,6 @@
//! This crate links to a (separately built) internal crate which affords the actual functionality.
//! The internal crate must be built separately to ensure flags from dependent crates are not leaked
//! to the runtime (e.g., to prevent coverage being collected on the runtime).
//!
#![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
#![cfg_attr(not(test), warn(
missing_debug_implementations,

View File

@ -1,5 +1,4 @@
//! In-memory fuzzer with `QEMU`-based binary-only instrumentation
//!
use core::fmt::{self, Debug, Formatter};
use std::{fs, net::SocketAddr, path::PathBuf, time::Duration};

View File

@ -1,6 +1,5 @@
//! `CmpLog` logs and reports back values touched during fuzzing.
//! The values will then be used in subsequent mutations.
//!
use alloc::borrow::Cow;
use core::fmt::Debug;

View File

@ -1,2 +1,6 @@
group_imports = "StdExternalCrate"
imports_granularity = "Crate"
newline_style = "Unix"
format_code_in_doc_comments = true
format_macro_bodies = true
format_macro_matchers = true