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:
parent
14eee111c2
commit
7c83be2408
7
.vscode/settings.json.default
vendored
7
.vscode/settings.json.default
vendored
@ -1,4 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"[rust]": {
|
||||||
|
"editor.defaultFormatter": "rust-lang.rust-analyzer",
|
||||||
|
"editor.formatOnSave": true
|
||||||
|
},
|
||||||
|
"rust-analyzer.rustfmt.extraArgs": [
|
||||||
|
"+nightly"
|
||||||
|
],
|
||||||
"rust-analyzer.cargo.buildScripts.overrideCommand": [
|
"rust-analyzer.cargo.buildScripts.overrideCommand": [
|
||||||
"cargo",
|
"cargo",
|
||||||
"check",
|
"check",
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//! A libfuzzer-like fuzzer using qemu for binary-only coverage
|
//! A libfuzzer-like fuzzer using qemu for binary-only coverage
|
||||||
//!
|
|
||||||
#[cfg(feature = "i386")]
|
#[cfg(feature = "i386")]
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
#[cfg(feature = "snapshot")]
|
#[cfg(feature = "snapshot")]
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//! A libfuzzer-like fuzzer using qemu for binary-only coverage
|
//! A libfuzzer-like fuzzer using qemu for binary-only coverage
|
||||||
//!
|
|
||||||
#[cfg(feature = "i386")]
|
#[cfg(feature = "i386")]
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//! A fuzzer using qemu in systemmode for binary-only coverage of kernels
|
//! A fuzzer using qemu in systemmode for binary-only coverage of kernels
|
||||||
//!
|
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use std::{env, path::PathBuf, process};
|
use std::{env, path::PathBuf, process};
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//! A fuzzer using qemu in systemmode for binary-only coverage of kernels
|
//! A fuzzer using qemu in systemmode for binary-only coverage of kernels
|
||||||
//!
|
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use std::{env, path::PathBuf, process};
|
use std::{env, path::PathBuf, process};
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//! A fuzzer using qemu in systemmode for binary-only coverage of kernels
|
//! A fuzzer using qemu in systemmode for binary-only coverage of kernels
|
||||||
//!
|
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use std::{env, path::PathBuf, process};
|
use std::{env, path::PathBuf, process};
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//! A systemmode linux kernel example
|
//! A systemmode linux kernel example
|
||||||
//!
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
mod fuzzer;
|
mod fuzzer;
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//! A systemmode linux kernel example
|
//! A systemmode linux kernel example
|
||||||
//!
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
mod fuzzer;
|
mod fuzzer;
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//! LibAFL version of the [`Nautilus`](https://github.com/nautilus-fuzz/nautilus) grammar fuzzer
|
//! LibAFL version of the [`Nautilus`](https://github.com/nautilus-fuzz/nautilus) grammar fuzzer
|
||||||
//!
|
|
||||||
#![doc = include_str!("README.md")]
|
#![doc = include_str!("README.md")]
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
|
@ -33,7 +33,6 @@ pub(crate) const _LLMP_TAG_EVENT_TO_CLIENT: Tag = Tag(0x2C11E471);
|
|||||||
/// Only handle this in the broker
|
/// Only handle this in the broker
|
||||||
pub(crate) const _LLMP_TAG_EVENT_TO_BROKER: Tag = Tag(0x2B80438);
|
pub(crate) const _LLMP_TAG_EVENT_TO_BROKER: Tag = Tag(0x2B80438);
|
||||||
/// Handle in both
|
/// Handle in both
|
||||||
///
|
|
||||||
pub(crate) const LLMP_TAG_EVENT_TO_BOTH: Tag = Tag(0x2B0741);
|
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_RESTART: Tag = Tag(0x8357A87);
|
||||||
pub(crate) const _LLMP_TAG_NO_RESTART: Tag = Tag(0x57A7EE71);
|
pub(crate) const _LLMP_TAG_NO_RESTART: Tag = Tag(0x57A7EE71);
|
||||||
|
@ -739,17 +739,25 @@ impl CommandExecutorBuilder {
|
|||||||
/// A `CommandConfigurator` takes care of creating and spawning a [`Command`] for the [`CommandExecutor`].
|
/// A `CommandConfigurator` takes care of creating and spawning a [`Command`] for the [`CommandExecutor`].
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::{io::Write, process::{Stdio, Command, Child}, time::Duration};
|
/// use std::{
|
||||||
/// use libafl::{Error, corpus::Corpus, inputs::{BytesInput, HasTargetBytes, Input}, executors::{Executor, command::CommandConfigurator}, state::{HasExecutions}};
|
/// 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;
|
/// use libafl_bolts::AsSlice;
|
||||||
/// #[derive(Debug)]
|
/// #[derive(Debug)]
|
||||||
/// struct MyExecutor;
|
/// struct MyExecutor;
|
||||||
///
|
///
|
||||||
/// impl CommandConfigurator<BytesInput> for MyExecutor {
|
/// impl CommandConfigurator<BytesInput> for MyExecutor {
|
||||||
/// fn spawn_child(
|
/// fn spawn_child(&mut self, input: &BytesInput) -> Result<Child, Error> {
|
||||||
/// &mut self,
|
|
||||||
/// input: &BytesInput,
|
|
||||||
/// ) -> Result<Child, Error> {
|
|
||||||
/// let mut command = Command::new("../if");
|
/// let mut command = Command::new("../if");
|
||||||
/// command
|
/// command
|
||||||
/// .stdin(Stdio::piped())
|
/// .stdin(Stdio::piped())
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
//!
|
//!
|
||||||
//! It wraps two executors that will be run after each other with the same input.
|
//! 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`.
|
//! In comparison to the [`crate::executors::CombinedExecutor`] it also runs the secondary executor in `run_target`.
|
||||||
//!
|
|
||||||
use core::{
|
use core::{
|
||||||
cell::UnsafeCell,
|
cell::UnsafeCell,
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//! Diff Feedback, comparing the content of two observers of the same type.
|
//! Diff Feedback, comparing the content of two observers of the same type.
|
||||||
//!
|
|
||||||
|
|
||||||
use alloc::borrow::Cow;
|
use alloc::borrow::Cow;
|
||||||
use core::fmt::{self, Debug, Formatter};
|
use core::fmt::{self, Debug, Formatter};
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
//! The feedbacks reduce observer state after each run to a single `is_interesting`-value.
|
//! 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.
|
//! 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
|
// TODO: make S of Feedback<S> an associated type when specialisation + AT is stable
|
||||||
|
|
||||||
|
@ -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.
|
//! 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 alloc::borrow::Cow;
|
||||||
use core::hash::Hash;
|
use core::hash::Hash;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
//! Input for the [`Nautilus`](https://github.com/RUB-SysSec/nautilus) grammar fuzzer methods
|
//! Input for the [`Nautilus`](https://github.com/RUB-SysSec/nautilus) grammar fuzzer methods
|
||||||
//!
|
|
||||||
//!
|
|
||||||
use alloc::{rc::Rc, vec::Vec};
|
use alloc::{rc::Rc, vec::Vec};
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//! Mutations for [`EncodedInput`]s
|
//! Mutations for [`EncodedInput`]s
|
||||||
//!
|
|
||||||
use alloc::{borrow::Cow, vec::Vec};
|
use alloc::{borrow::Cow, vec::Vec};
|
||||||
use core::{
|
use core::{
|
||||||
cmp::{max, min},
|
cmp::{max, min},
|
||||||
|
@ -219,7 +219,11 @@ pub mod macros {
|
|||||||
/// # phantom: PhantomData<(C, O)>,
|
/// # 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 {
|
/// pub fn new(obs: &C) -> Self {
|
||||||
/// require_index_tracking!("MyCustomScheduler", C);
|
/// require_index_tracking!("MyCustomScheduler", C);
|
||||||
/// todo!("Construct your type")
|
/// todo!("Construct your type")
|
||||||
@ -282,7 +286,11 @@ pub mod macros {
|
|||||||
/// # phantom: PhantomData<(C, O)>,
|
/// # 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 {
|
/// pub fn new(obs: &C) -> Self {
|
||||||
/// require_novelties_tracking!("MyCustomScheduler", C);
|
/// require_novelties_tracking!("MyCustomScheduler", C);
|
||||||
/// todo!("Construct your type")
|
/// todo!("Construct your type")
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
//! This module contains the `concolic` stages, which can trace a target using symbolic execution
|
//! This module contains the `concolic` stages, which can trace a target using symbolic execution
|
||||||
//! and use the results for fuzzer input and mutations.
|
//! and use the results for fuzzer input and mutations.
|
||||||
//!
|
|
||||||
use alloc::borrow::{Cow, ToOwned};
|
use alloc::borrow::{Cow, ToOwned};
|
||||||
#[cfg(feature = "concolic_mutation")]
|
#[cfg(feature = "concolic_mutation")]
|
||||||
use alloc::{string::ToString, vec::Vec};
|
use alloc::{string::ToString, vec::Vec};
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
//! A push stage instead returns an iterator that generates a new result for each time it gets called.
|
//! 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.
|
//! 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`.
|
//! The push stage relies on internal mutability of the supplied `Observers`.
|
||||||
//!
|
|
||||||
|
|
||||||
/// Mutational stage is the normal fuzzing stage.
|
/// Mutational stage is the normal fuzzing stage.
|
||||||
pub mod mutational;
|
pub mod mutational;
|
||||||
|
@ -14,19 +14,21 @@
|
|||||||
//!
|
//!
|
||||||
//! // Create a thread for each active CPU core.
|
//! // Create a thread for each active CPU core.
|
||||||
//! # #[cfg(not(miri))]
|
//! # #[cfg(not(miri))]
|
||||||
//! let handles = core_ids.into_iter().map(|id| {
|
//! let handles = core_ids
|
||||||
|
//! .into_iter()
|
||||||
|
//! .map(|id| {
|
||||||
//! thread::spawn(move || {
|
//! thread::spawn(move || {
|
||||||
//! // Pin this thread to a single CPU core.
|
//! // Pin this thread to a single CPU core.
|
||||||
//! id.set_affinity();
|
//! id.set_affinity();
|
||||||
//! // Do more work after this.
|
//! // Do more work after this.
|
||||||
//! })
|
//! })
|
||||||
//! }).collect::<Vec<_>>();
|
//! })
|
||||||
|
//! .collect::<Vec<_>>();
|
||||||
//!
|
//!
|
||||||
//! # #[cfg(not(miri))]
|
//! # #[cfg(not(miri))]
|
||||||
//! for handle in handles.into_iter() {
|
//! for handle in handles.into_iter() {
|
||||||
//! handle.join().unwrap();
|
//! handle.join().unwrap();
|
||||||
//! }
|
//! }
|
||||||
//!
|
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! *This file is a fork of <https://github.com/Elzair/core_affinity_rs>*
|
//! *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.
|
/// Note: This will *_not_* fail if the target platform does not support core affinity.
|
||||||
/// (only on error cases for supported platforms)
|
/// (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.
|
/// 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> {
|
pub fn set_affinity(&self) -> Result<(), Error> {
|
||||||
match set_for_current_helper(*self) {
|
match set_for_current_helper(*self) {
|
||||||
Ok(()) | Err(Error::Unsupported(_, _)) => Ok(()),
|
Ok(()) | Err(Error::Unsupported(_, _)) => Ok(()),
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//! Operating System specific abstractions
|
//! Operating System specific abstractions
|
||||||
//!
|
|
||||||
|
|
||||||
#[cfg(any(unix, all(windows, feature = "std")))]
|
#[cfg(any(unix, all(windows, feature = "std")))]
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
@ -271,7 +271,6 @@ use crate::Error;
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
/// The `libc` `getcontext`
|
/// The `libc` `getcontext`
|
||||||
/// For some reason, it's not available on `MacOS`.
|
/// For some reason, it's not available on `MacOS`.
|
||||||
///
|
|
||||||
fn getcontext(ucp: *mut ucontext_t) -> c_int;
|
fn getcontext(ucp: *mut ucontext_t) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,7 +809,7 @@ macro_rules! tuple_for_each_mut {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// use libafl_bolts::{
|
/// use libafl_bolts::{
|
||||||
/// map_tuple_list_type,
|
/// map_tuple_list_type,
|
||||||
/// tuples::{MappingFunctor, Map, tuple_list, tuple_list_type}
|
/// tuples::{tuple_list, tuple_list_type, Map, MappingFunctor},
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
/// struct Wrapper<T>(T);
|
/// struct Wrapper<T>(T);
|
||||||
@ -842,7 +842,10 @@ macro_rules! map_tuple_list_type {
|
|||||||
/// Merges the types of two merged [`tuple_list!`]s
|
/// Merges the types of two merged [`tuple_list!`]s
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```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 A;
|
||||||
/// struct B;
|
/// struct B;
|
||||||
|
@ -136,7 +136,13 @@ impl From<EventType> for libc::c_uint {
|
|||||||
/// # use std::thread;
|
/// # use std::thread;
|
||||||
/// unsafe {
|
/// unsafe {
|
||||||
/// pthread_hook::install(|event, pthread, addr, size| {
|
/// 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(|| {
|
/// # thread::spawn(|| {
|
||||||
|
@ -538,8 +538,10 @@ impl Default for IntelPTBuilder {
|
|||||||
/// .exclude_kernel(true)
|
/// .exclude_kernel(true)
|
||||||
/// .exclude_hv(true)
|
/// .exclude_hv(true)
|
||||||
/// .inherit(false)
|
/// .inherit(false)
|
||||||
/// .perf_buffer_size(128 * PAGE_SIZE + PAGE_SIZE).unwrap()
|
/// .perf_buffer_size(128 * PAGE_SIZE + PAGE_SIZE)
|
||||||
/// .perf_aux_buffer_size(2 * 1024 * 1024).unwrap()
|
/// .unwrap()
|
||||||
|
/// .perf_aux_buffer_size(2 * 1024 * 1024)
|
||||||
|
/// .unwrap()
|
||||||
/// .ip_filters(&[]);
|
/// .ip_filters(&[]);
|
||||||
/// assert_eq!(builder, IntelPTBuilder::default());
|
/// assert_eq!(builder, IntelPTBuilder::default());
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -73,7 +73,6 @@
|
|||||||
//! This crate links to a (separately built) internal crate which affords the actual functionality.
|
//! 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
|
//! 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).
|
//! 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(feature = "document-features", doc = document_features::document_features!())]
|
||||||
#![cfg_attr(not(test), warn(
|
#![cfg_attr(not(test), warn(
|
||||||
missing_debug_implementations,
|
missing_debug_implementations,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//! In-memory fuzzer with `QEMU`-based binary-only instrumentation
|
//! In-memory fuzzer with `QEMU`-based binary-only instrumentation
|
||||||
//!
|
|
||||||
use core::fmt::{self, Debug, Formatter};
|
use core::fmt::{self, Debug, Formatter};
|
||||||
use std::{fs, net::SocketAddr, path::PathBuf, time::Duration};
|
use std::{fs, net::SocketAddr, path::PathBuf, time::Duration};
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
//! `CmpLog` logs and reports back values touched during fuzzing.
|
//! `CmpLog` logs and reports back values touched during fuzzing.
|
||||||
//! The values will then be used in subsequent mutations.
|
//! The values will then be used in subsequent mutations.
|
||||||
//!
|
|
||||||
|
|
||||||
use alloc::borrow::Cow;
|
use alloc::borrow::Cow;
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
|
@ -1,2 +1,6 @@
|
|||||||
group_imports = "StdExternalCrate"
|
group_imports = "StdExternalCrate"
|
||||||
imports_granularity = "Crate"
|
imports_granularity = "Crate"
|
||||||
|
newline_style = "Unix"
|
||||||
|
format_code_in_doc_comments = true
|
||||||
|
format_macro_bodies = true
|
||||||
|
format_macro_matchers = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user