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": [
|
||||
"cargo",
|
||||
"check",
|
||||
|
@ -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")]
|
||||
|
@ -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;
|
||||
|
@ -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};
|
||||
|
||||
|
@ -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};
|
||||
|
||||
|
@ -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};
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//! A systemmode linux kernel example
|
||||
//!
|
||||
#[cfg(target_os = "linux")]
|
||||
mod fuzzer;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//! A systemmode linux kernel example
|
||||
//!
|
||||
#[cfg(target_os = "linux")]
|
||||
mod fuzzer;
|
||||
|
||||
|
@ -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)]
|
||||
|
@ -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);
|
||||
|
@ -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())
|
||||
|
@ -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,
|
||||
|
@ -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};
|
||||
|
@ -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
|
||||
|
||||
@ -760,7 +759,7 @@ macro_rules! feedback_or_fast {
|
||||
/// Variadic macro to create a [`NotFeedback`]
|
||||
#[macro_export]
|
||||
macro_rules! feedback_not {
|
||||
( $last:expr ) => {
|
||||
($last:expr) => {
|
||||
$crate::feedbacks::NotFeedback::new($last)
|
||||
};
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -27,7 +27,7 @@ use crate::inputs::{HasMutatorBytes, ResizableMutator};
|
||||
/// # #[no_mangle]
|
||||
/// # pub extern "C" fn external_current_millis() -> u64 { 0 }
|
||||
///
|
||||
/// let mut bytes_input = BytesInput::new(vec![1,2,3]);
|
||||
/// let mut bytes_input = BytesInput::new(vec![1, 2, 3]);
|
||||
/// let mut sub_input = bytes_input.sub_input(1..);
|
||||
///
|
||||
/// // Run any mutations on the sub input.
|
||||
|
@ -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};
|
||||
|
@ -1,5 +1,4 @@
|
||||
//! Mutations for [`EncodedInput`]s
|
||||
//!
|
||||
use alloc::{borrow::Cow, vec::Vec};
|
||||
use core::{
|
||||
cmp::{max, min},
|
||||
|
@ -403,7 +403,7 @@ add_mutator_impl!(QwordAddMutator, u64);
|
||||
///////////////////////////
|
||||
|
||||
macro_rules! interesting_mutator_impl {
|
||||
($name: ident, $size: ty, $interesting: ident) => {
|
||||
($name:ident, $size:ty, $interesting:ident) => {
|
||||
/// Inserts an interesting value at a random place in the input vector
|
||||
#[derive(Default, Debug)]
|
||||
pub struct $name;
|
||||
|
@ -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")
|
||||
|
@ -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};
|
||||
|
@ -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;
|
||||
|
@ -59,7 +59,7 @@
|
||||
//!
|
||||
//! log::info!("{:?}", parsed);
|
||||
//! }
|
||||
//!```
|
||||
//! ```
|
||||
|
||||
#[cfg(feature = "frida_cli")]
|
||||
use alloc::{boxed::Box, string::ToString};
|
||||
|
@ -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(()),
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*!
|
||||
* Welcome to `LibAFL_bolts`
|
||||
*/
|
||||
* Welcome to `LibAFL_bolts`
|
||||
*/
|
||||
#![doc = include_str!("../README.md")]
|
||||
/*! */
|
||||
#![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
|
||||
|
@ -1,5 +1,4 @@
|
||||
//! Operating System specific abstractions
|
||||
//!
|
||||
|
||||
#[cfg(any(unix, all(windows, feature = "std")))]
|
||||
use crate::Error;
|
||||
|
@ -173,7 +173,7 @@ pub struct arm_neon_state64 {
|
||||
/// _STRUCT_ARM_EXCEPTION_STATE64 es;
|
||||
/// _STRUCT_ARM_THREAD_STATE64 ss;
|
||||
/// _STRUCT_ARM_NEON_STATE64 ns;
|
||||
///};
|
||||
/// };
|
||||
/// ```
|
||||
#[cfg(all(target_vendor = "apple", target_arch = "aarch64"))]
|
||||
#[derive(Debug)]
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ pub trait Rand: Debug + Serialize + DeserializeOwned {
|
||||
}
|
||||
|
||||
macro_rules! impl_default_new {
|
||||
($rand: ty) => {
|
||||
($rand:ty) => {
|
||||
impl Default for $rand {
|
||||
/// Creates a generator seeded with [`random_seed`].
|
||||
fn default() -> Self {
|
||||
@ -249,7 +249,7 @@ impl_default_new!(RomuDuoJrRand);
|
||||
impl_default_new!(Sfc64Rand);
|
||||
|
||||
macro_rules! impl_rng_core {
|
||||
($rand: ty) => {
|
||||
($rand:ty) => {
|
||||
#[cfg(feature = "rand_trait")]
|
||||
impl rand_core::RngCore for $rand {
|
||||
fn next_u32(&mut self) -> u32 {
|
||||
|
@ -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;
|
||||
|
@ -124,10 +124,10 @@ macro_rules! make_symexpr_optional {
|
||||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! unwrap_option {
|
||||
($param_name:ident: RSymExpr) => {
|
||||
($param_name:ident : RSymExpr) => {
|
||||
$param_name?
|
||||
};
|
||||
($param_name:ident: $($type:tt)+) => {
|
||||
($param_name:ident : $($type:tt)+) => {
|
||||
$param_name
|
||||
};
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ impl FridaInstrumentationHelperBuilder {
|
||||
/// # Example
|
||||
/// Instrument all modules in `/usr/lib` as well as `libfoo.so`:
|
||||
/// ```
|
||||
///# use libafl_frida::helper::FridaInstrumentationHelper;
|
||||
/// # use libafl_frida::helper::FridaInstrumentationHelper;
|
||||
/// let builder = FridaInstrumentationHelper::builder()
|
||||
/// .instrument_module_if(|module| module.name() == "libfoo.so")
|
||||
/// .instrument_module_if(|module| module.path().starts_with("/usr/lib"));
|
||||
@ -376,7 +376,7 @@ impl FridaInstrumentationHelperBuilder {
|
||||
/// Instrument all modules in `/usr/lib`, but exclude `libfoo.so`.
|
||||
///
|
||||
/// ```
|
||||
///# use libafl_frida::helper::FridaInstrumentationHelper;
|
||||
/// # use libafl_frida::helper::FridaInstrumentationHelper;
|
||||
/// let builder = FridaInstrumentationHelper::builder()
|
||||
/// .instrument_module_if(|module| module.path().starts_with("/usr/lib"))
|
||||
/// .skip_module_if(|module| module.name() == "libfoo.so");
|
||||
|
@ -131,18 +131,24 @@ impl From<EventType> for libc::c_uint {
|
||||
/// Set a `pthread_introspection` hook.
|
||||
/// # Example
|
||||
/// ```
|
||||
///# use libafl_frida::pthread_hook;
|
||||
///# use std::time::Duration;
|
||||
///# use std::thread;
|
||||
/// # use libafl_frida::pthread_hook;
|
||||
/// # use std::time::Duration;
|
||||
/// # 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(|| {
|
||||
///# thread::sleep(Duration::from_millis(1));
|
||||
///# });
|
||||
///# thread::sleep(Duration::from_millis(50));
|
||||
/// # thread::spawn(|| {
|
||||
/// # thread::sleep(Duration::from_millis(1));
|
||||
/// # });
|
||||
/// # thread::sleep(Duration::from_millis(50));
|
||||
/// ```
|
||||
/// This should output the thread IDs, lifecycle events, addresses and sizes of the corresponding events.
|
||||
/// ```no_test
|
||||
@ -174,9 +180,9 @@ where
|
||||
/// Restore a previously set `pthread_introspection` hook.
|
||||
/// # Example
|
||||
/// ```
|
||||
///# use libafl_frida::pthread_hook;
|
||||
///# use std::time::Duration;
|
||||
///# use std::thread;
|
||||
/// # use libafl_frida::pthread_hook;
|
||||
/// # use std::time::Duration;
|
||||
/// # use std::thread;
|
||||
/// unsafe { pthread_hook::reset() };
|
||||
/// ```
|
||||
///
|
||||
|
@ -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());
|
||||
/// ```
|
||||
|
@ -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,
|
||||
|
@ -380,7 +380,7 @@ macro_rules! create_exec_wrapper {
|
||||
}
|
||||
|
||||
macro_rules! create_hook_id {
|
||||
($name:ident, $sys:ident, true) => {
|
||||
($name:ident, $sys:ident,true) => {
|
||||
paste::paste! {
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
pub struct [<$name HookId>](pub(crate) usize);
|
||||
@ -397,7 +397,7 @@ macro_rules! create_hook_id {
|
||||
}
|
||||
}
|
||||
};
|
||||
($name:ident, $sys:ident, false) => {
|
||||
($name:ident, $sys:ident,false) => {
|
||||
paste::paste! {
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
pub struct [<$name HookId>](pub(crate) usize);
|
||||
|
@ -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};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user