Add rustfmt.toml (#722)

* add `rustfmt.toml`

* format fix

Co-authored-by: syheliel <syheliel@gmail.com>
This commit is contained in:
syheliel 2022-08-12 08:28:32 +08:00 committed by GitHub
parent faca7b9ac7
commit 2504b6dae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
165 changed files with 933 additions and 864 deletions

View File

@ -1,5 +1,4 @@
use std::path::PathBuf;
#[cfg(windows)]
use std::ptr::write_volatile;

View File

@ -1,12 +1,10 @@
use std::io::Read;
use std::{
fs,
io::BufReader,
path::{Path, PathBuf},
};
#[cfg(windows)]
use std::ptr::write_volatile;
use std::{
fs,
io::{BufReader, Read},
path::{Path, PathBuf},
};
use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list},

View File

@ -1,8 +1,6 @@
use std::io::Read;
use std::{fs, path::PathBuf};
#[cfg(windows)]
use std::ptr::write_volatile;
use std::{fs, io::Read, path::PathBuf};
use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},

View File

@ -1,5 +1,4 @@
use std::path::PathBuf;
#[cfg(windows)]
use std::ptr::write_volatile;

View File

@ -1,8 +1,6 @@
use std::io::Read;
use std::{fs, path::PathBuf};
#[cfg(windows)]
use std::ptr::write_volatile;
use std::{fs, io::Read, path::PathBuf};
use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list},

View File

@ -1,5 +1,4 @@
use std::path::PathBuf;
#[cfg(windows)]
use std::ptr::write_volatile;

View File

@ -4,6 +4,11 @@
// Embedded needs alloc error handlers which only work on nightly right now...
#![cfg_attr(not(any(windows, unix)), feature(default_alloc_error_handler))]
#[cfg(not(any(windows, unix)))]
use core::panic::PanicInfo;
#[cfg(any(windows, unix))]
use cstr_core::CString;
use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},
corpus::InMemoryCorpus,
@ -20,14 +25,8 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::StdState,
};
#[cfg(any(windows, unix))]
use cstr_core::CString;
#[cfg(any(windows, unix))]
use libc::{c_char, printf};
#[cfg(not(any(windows, unix)))]
use core::panic::PanicInfo;
use static_alloc::Bump;
#[global_allocator]

View File

@ -1,14 +1,12 @@
use std::path::PathBuf;
use libafl::bolts::shmem::ShMemProvider;
use libafl::bolts::AsSlice;
use libafl::observers::ConstMapObserver;
use libafl::{
bolts::{
current_nanos,
rands::StdRand,
shmem::{ShMem, StdShMemProvider},
shmem::{ShMem, ShMemProvider, StdShMemProvider},
tuples::tuple_list,
AsSlice,
},
corpus::{InMemoryCorpus, OnDiskCorpus},
events::SimpleEventManager,
@ -20,13 +18,12 @@ use libafl::{
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
observers::BacktraceObserver,
observers::{BacktraceObserver, ConstMapObserver},
schedulers::QueueScheduler,
stages::mutational::StdMutationalStage,
state::StdState,
};
use libc::c_int;
use libc::c_uchar;
use libc::{c_int, c_uchar};
extern crate libc;
extern "C" {

View File

@ -1,12 +1,10 @@
use std::path::PathBuf;
use libafl::bolts::AsSlice;
use libafl::executors::InProcessExecutor;
use libafl::observers::ConstMapObserver;
use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list},
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},
corpus::{InMemoryCorpus, OnDiskCorpus},
events::SimpleEventManager,
executors::InProcessExecutor,
feedback_and,
feedbacks::{CrashFeedback, MaxMapFeedback, NewHashFeedback},
fuzzer::{Fuzzer, StdFuzzer},
@ -14,7 +12,7 @@ use libafl::{
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
observers::BacktraceObserver,
observers::{BacktraceObserver, ConstMapObserver},
schedulers::QueueScheduler,
stages::mutational::StdMutationalStage,
state::StdState,

View File

@ -1,3 +1,11 @@
#[cfg(windows)]
use std::ptr::write_volatile;
use std::{
io::Write,
path::PathBuf,
process::{Child, Command, Stdio},
};
use libafl::{
bolts::{
current_nanos,
@ -22,13 +30,6 @@ use libafl::{
state::StdState,
Error,
};
#[cfg(windows)]
use std::ptr::write_volatile;
use std::{
io::Write,
path::PathBuf,
process::{Child, Command, Stdio},
};
#[allow(clippy::similar_names)]
pub fn main() {

View File

@ -1,6 +1,8 @@
use std::env;
use std::path::Path;
use std::process::{exit, Command};
use std::{
env,
path::Path,
process::{exit, Command},
};
const AFL_URL: &str = "https://github.com/AFLplusplus/AFLplusplus";

View File

@ -1,3 +1,9 @@
use std::path::PathBuf;
#[cfg(not(target_vendor = "apple"))]
use libafl::bolts::shmem::StdShMemProvider;
#[cfg(target_vendor = "apple")]
use libafl::bolts::shmem::UnixShMemProvider;
use libafl::{
bolts::{
current_nanos,
@ -21,12 +27,6 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::StdState,
};
use std::path::PathBuf;
#[cfg(not(target_vendor = "apple"))]
use libafl::bolts::shmem::StdShMemProvider;
#[cfg(target_vendor = "apple")]
use libafl::bolts::shmem::UnixShMemProvider;
#[allow(clippy::similar_names)]
pub fn main() {

View File

@ -1,5 +1,4 @@
use std::path::PathBuf;
#[cfg(windows)]
use std::ptr::write_volatile;

View File

@ -1,5 +1,4 @@
use std::path::PathBuf;
#[cfg(windows)]
use std::ptr::write_volatile;

View File

@ -1,6 +1,8 @@
use std::env;
use std::path::Path;
use std::process::{exit, Command};
use std::{
env,
path::Path,
process::{exit, Command},
};
const AFL_URL: &str = "https://github.com/AFLplusplus/AFLplusplus";

View File

@ -1,5 +1,11 @@
use clap::{Arg, Command};
use core::time::Duration;
use std::path::PathBuf;
use clap::{Arg, Command};
#[cfg(not(target_vendor = "apple"))]
use libafl::bolts::shmem::StdShMemProvider;
#[cfg(target_vendor = "apple")]
use libafl::bolts::shmem::UnixShMemProvider;
use libafl::{
bolts::{
current_nanos,
@ -23,13 +29,6 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState},
};
use nix::sys::signal::Signal;
use std::path::PathBuf;
#[cfg(target_vendor = "apple")]
use libafl::bolts::shmem::UnixShMemProvider;
#[cfg(not(target_vendor = "apple"))]
use libafl::bolts::shmem::StdShMemProvider;
#[allow(clippy::similar_names)]
pub fn main() {

View File

@ -4,9 +4,9 @@ use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
use frida_gum::Gum;
use std::path::PathBuf;
use frida_gum::Gum;
use libafl::{
bolts::{
cli::{parse_args, FuzzerOptions},
@ -27,8 +27,7 @@ use libafl::{
monitors::MultiMonitor,
mutators::{
scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::I2SRandReplace,
token_mutations::Tokens,
token_mutations::{I2SRandReplace, Tokens},
},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
schedulers::{IndexesLenTimeMinimizerScheduler, QueueScheduler},
@ -36,19 +35,17 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState},
Error,
};
use libafl_frida::{
coverage_rt::CoverageRuntime, coverage_rt::MAP_SIZE, executor::FridaInProcessExecutor,
helper::FridaInstrumentationHelper,
};
#[cfg(unix)]
use libafl_frida::asan::asan_rt::AsanRuntime;
use libafl_targets::cmplog::{CmpLogObserver, CMPLOG_MAP};
#[cfg(unix)]
use libafl_frida::asan::errors::{AsanErrorsFeedback, AsanErrorsObserver, ASAN_ERRORS};
use libafl_frida::cmplog_rt::CmpLogRuntime;
use libafl_frida::{
cmplog_rt::CmpLogRuntime,
coverage_rt::{CoverageRuntime, MAP_SIZE},
executor::FridaInProcessExecutor,
helper::FridaInstrumentationHelper,
};
use libafl_targets::cmplog::{CmpLogObserver, CMPLOG_MAP};
/// The main fn, usually parsing parameters, and starting the fuzzer
pub fn main() {

View File

@ -1,6 +1,7 @@
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
use std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
pub fn main() {
let mut args: Vec<String> = env::args().collect();
if args.len() > 1 {

View File

@ -3,11 +3,8 @@ use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
use clap::{Arg, Command};
use core::{cell::RefCell, time::Duration};
#[cfg(unix)]
use nix::{self, unistd::dup};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::{
env,
@ -17,6 +14,7 @@ use std::{
process,
};
use clap::{Arg, Command};
use libafl::{
bolts::{
current_nanos, current_time,
@ -49,13 +47,14 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState},
Error,
};
#[cfg(target_os = "linux")]
use libafl_targets::autotokens;
use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, CmpLogObserver, CMPLOG_MAP, EDGES_MAP,
MAX_EDGES_NUM,
};
#[cfg(target_os = "linux")]
use libafl_targets::autotokens;
#[cfg(unix)]
use nix::{self, unistd::dup};
/// The fuzzer main (as `no_mangle` C function)
#[no_mangle]

View File

@ -1,10 +1,7 @@
//! A singlethreaded QEMU fuzzer that can auto-restart.
use clap::{Arg, Command};
use core::cell::RefCell;
#[cfg(unix)]
use nix::{self, unistd::dup};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::{
env,
@ -14,6 +11,7 @@ use std::{
process,
};
use clap::{Arg, Command};
use libafl::{
bolts::{
current_nanos, current_time,
@ -55,6 +53,8 @@ use libafl_qemu::{
hooks::QemuHooks,
MmapPerms, QemuForkExecutor, Regs,
};
#[cfg(unix)]
use nix::{self, unistd::dup};
/// The fuzzer main
pub fn main() {

View File

@ -1,10 +1,7 @@
//! A singlethreaded QEMU fuzzer that can auto-restart.
use clap::{Arg, Command};
use core::{cell::RefCell, time::Duration};
#[cfg(unix)]
use nix::{self, unistd::dup};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::{
env,
@ -14,6 +11,7 @@ use std::{
process,
};
use clap::{Arg, Command};
use libafl::{
bolts::{
current_nanos, current_time,
@ -61,6 +59,8 @@ use libafl_qemu::{
QemuExecutor,
Regs,
};
#[cfg(unix)]
use nix::{self, unistd::dup};
/// The fuzzer main
pub fn main() {

View File

@ -1,6 +1,7 @@
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
use std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
pub fn main() {
let args: Vec<String> = env::args().collect();
if args.len() > 1 {

View File

@ -3,12 +3,8 @@ use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
use clap::{Arg, Command};
use content_inspector::inspect;
use core::{cell::RefCell, time::Duration};
#[cfg(unix)]
use nix::{self, unistd::dup};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::{
env,
@ -18,6 +14,8 @@ use std::{
process,
};
use clap::{Arg, Command};
use content_inspector::inspect;
use libafl::{
bolts::{
current_nanos, current_time,
@ -55,13 +53,14 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState},
Error,
};
#[cfg(target_os = "linux")]
use libafl_targets::autotokens;
use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, CmpLogObserver, CMPLOG_MAP, EDGES_MAP,
MAX_EDGES_NUM,
};
#[cfg(target_os = "linux")]
use libafl_targets::autotokens;
#[cfg(unix)]
use nix::{self, unistd::dup};
/// The fuzzer main (as `no_mangle` C function)
#[no_mangle]

View File

@ -1,6 +1,7 @@
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
use std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
pub fn main() {
let mut args: Vec<String> = env::args().collect();
if args.len() > 1 {

View File

@ -3,11 +3,8 @@ use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
use clap::{Arg, Command};
use core::{cell::RefCell, time::Duration};
#[cfg(unix)]
use nix::{self, unistd::dup};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::{
env,
@ -17,6 +14,7 @@ use std::{
process,
};
use clap::{Arg, Command};
use libafl::{
bolts::{
current_nanos, current_time,
@ -49,13 +47,14 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState},
Error,
};
#[cfg(target_os = "linux")]
use libafl_targets::autotokens;
use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, CmpLogObserver, CMPLOG_MAP, EDGES_MAP,
MAX_EDGES_NUM,
};
#[cfg(target_os = "linux")]
use libafl_targets::autotokens;
#[cfg(unix)]
use nix::{self, unistd::dup};
/// The fuzzer main (as `no_mangle` C function)
#[no_mangle]

View File

@ -3,7 +3,6 @@
//! This is the drop-in replacement for libfuzzer, to be used together with [`Atheris`](https://github.com/google/atheris)
//! for python instrumentation and fuzzing.
use clap::{AppSettings, Arg, Command};
use core::{convert::TryInto, ffi::c_void, slice, time::Duration};
use std::{
env,
@ -11,6 +10,7 @@ use std::{
path::PathBuf,
};
use clap::{AppSettings, Arg, Command};
use libafl::{
bolts::{
core_affinity::Cores,
@ -30,8 +30,10 @@ use libafl::{
generators::RandBytesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::{I2SRandReplace, Tokens},
mutators::{
scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::{I2SRandReplace, Tokens},
},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
schedulers::{IndexesLenTimeMinimizerScheduler, QueueScheduler},
stages::{StdMutationalStage, TracingStage},

View File

@ -1,6 +1,7 @@
use libafl_cc::{ClangWrapper, CompilerWrapper};
use std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper};
pub fn main() {
let args: Vec<String> = env::args().collect();
if args.len() > 1 {

View File

@ -21,15 +21,16 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::Tokens,
mutators::{
scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::Tokens,
},
observers::StdMapObserver,
schedulers::RandScheduler,
stages::mutational::StdMutationalStage,
state::{HasCorpus, HasMetadata, StdState},
Error,
};
use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, CMP_MAP, EDGES_MAP, MAX_EDGES_NUM,
};

View File

@ -1,6 +1,7 @@
use libafl_cc::{ClangWrapper, CompilerWrapper};
use std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper};
pub fn main() {
let args: Vec<String> = env::args().collect();
if args.len() > 1 {

View File

@ -24,8 +24,10 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::Tokens,
mutators::{
scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::Tokens,
},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
schedulers::{
powersched::PowerSchedule, IndexesLenTimeMinimizerScheduler, StdWeightedScheduler,
@ -34,7 +36,6 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState},
Error,
};
use libafl_targets::{libfuzzer_initialize, libfuzzer_test_one_input, EDGES_MAP, MAX_EDGES_NUM};
/// The main fn, `no_mangle` as it is a C main

View File

@ -1,6 +1,7 @@
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
use std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
const GRANULARITY: &str = "FUNC";
pub fn main() {

View File

@ -6,10 +6,10 @@ use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
use clap::{self, StructOpt};
use core::time::Duration;
use std::{env, net::SocketAddr, path::PathBuf};
use clap::{self, StructOpt};
use libafl::{
bolts::{
core_affinity::Cores,
@ -28,15 +28,16 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::Tokens,
mutators::{
scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::Tokens,
},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
schedulers::{CoverageAccountingScheduler, QueueScheduler},
stages::mutational::StdMutationalStage,
state::{HasCorpus, HasMetadata, StdState},
Error,
};
use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, ACCOUNTING_MEMOP_MAP, EDGES_MAP, MAX_EDGES_NUM,
};

View File

@ -1,6 +1,7 @@
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
use std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
pub fn main() {
let args: Vec<String> = env::args().collect();
if args.len() > 1 {

View File

@ -6,10 +6,10 @@ use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
use clap::{self, StructOpt};
use core::time::Duration;
use std::{env, net::SocketAddr, path::PathBuf};
use clap::{self, StructOpt};
use libafl::{
bolts::{
core_affinity::Cores,
@ -38,7 +38,6 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState},
Error,
};
use libafl_targets::{edges_map_from_ptr, libfuzzer_initialize, libfuzzer_test_one_input};
fn timeout_from_millis_str(time: &str) -> Result<Duration, Error> {

View File

@ -1,6 +1,7 @@
use libafl_cc::{ClangWrapper, CompilerWrapper};
use std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper};
pub fn main() {
let args: Vec<String> = env::args().collect();
if args.len() > 1 {

View File

@ -6,10 +6,10 @@ use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
use clap::{self, StructOpt};
use core::time::Duration;
use std::{env, net::SocketAddr, path::PathBuf};
use clap::{self, StructOpt};
use libafl::{
bolts::{
core_affinity::Cores,
@ -28,15 +28,16 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::{MultiMonitor, OnDiskTOMLMonitor},
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::Tokens,
mutators::{
scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::Tokens,
},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
schedulers::{IndexesLenTimeMinimizerScheduler, QueueScheduler},
stages::mutational::StdMutationalStage,
state::{HasCorpus, HasMetadata, StdState},
Error,
};
use libafl_targets::{libfuzzer_initialize, libfuzzer_test_one_input, EDGES_MAP, MAX_EDGES_NUM};
/// Parse a millis string to a [`Duration`]. Used for arg parsing.

View File

@ -1,6 +1,7 @@
use libafl_cc::{ClangWrapper, CompilerWrapper};
use std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper};
pub fn main() {
let args: Vec<String> = env::args().collect();
if args.len() > 1 {

View File

@ -16,15 +16,16 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
mutators::token_mutations::I2SRandReplace,
mutators::{
scheduled::{havoc_mutations, StdScheduledMutator},
token_mutations::I2SRandReplace,
},
observers::{StdMapObserver, TimeObserver},
schedulers::{IndexesLenTimeMinimizerScheduler, QueueScheduler},
stages::{ShadowTracingStage, StdMutationalStage},
state::{HasCorpus, StdState},
Error,
};
use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, CmpLogObserver, CMPLOG_MAP, EDGES_MAP,
MAX_EDGES_NUM,

View File

@ -1,7 +1,8 @@
//! [`Klo-routines`](https://github.com/andreafioraldi/klo-routines/) based fuzzer.
//! The target loops and the harness pulls inputs out of `LibAFL`, instead of being called by `LibAFL`.
use std::path::PathBuf;
use klo_routines::*;
use libafl::inputs::{BytesInput, HasTargetBytes};
use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},
corpus::{InMemoryCorpus, OnDiskCorpus},
@ -10,6 +11,7 @@ use libafl::{
feedbacks::{CrashFeedback, MaxMapFeedback},
fuzzer::{Fuzzer, StdFuzzer},
generators::RandPrintablesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
observers::StdMapObserver,
@ -17,7 +19,6 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::StdState,
};
use std::path::PathBuf;
/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];

View File

@ -1,6 +1,7 @@
use libafl_cc::{ClangWrapper, CompilerWrapper};
use std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper};
pub fn main() {
let args: Vec<String> = env::args().collect();
if args.len() > 1 {

View File

@ -1,12 +1,11 @@
use std::hash::Hash;
use lain::prelude::*;
use libafl::{
bolts::{ownedref::OwnedSlice, HasLen},
inputs::{HasTargetBytes, Input},
};
use lain::prelude::*;
use serde::{Deserialize, Serialize};
use std::hash::Hash;
#[derive(
Serialize,

View File

@ -22,7 +22,6 @@ use libafl::{
state::{HasCorpus, StdState},
Error, Fuzzer,
};
use libafl_targets::{libfuzzer_initialize, libfuzzer_test_one_input, EDGES_MAP, MAX_EDGES_NUM};
mod input;

View File

@ -9,11 +9,10 @@ use libafl::{
state::{HasClientPerfMonitor, HasCorpus, HasMetadata},
Error, SerdeAny,
};
use serde::{Deserialize, Serialize};
use crate::input::PacketData;
use serde::{Deserialize, Serialize};
#[derive(Debug, SerdeAny, Serialize, Deserialize)]
pub struct PacketLenMetadata {
pub length: u64,

View File

@ -1,3 +1,4 @@
use lain::traits::Mutatable;
use libafl::{
bolts::{
rands::{Rand, StdRand},
@ -10,8 +11,6 @@ use libafl::{
use crate::input::PacketData;
use lain::traits::Mutatable;
pub struct LainMutator {
inner: lain::mutator::Mutator<StdRand>,
}

View File

@ -1,7 +1,6 @@
//! Based on <https://github.com/alecmocatta/build_id>
//! (C) Alec Mocatta <alec@mocatta.net> under license MIT or Apache 2
use once_cell::sync::Lazy;
use std::{
any::TypeId,
env,
@ -9,6 +8,8 @@ use std::{
hash::{Hash, Hasher},
io,
};
use once_cell::sync::Lazy;
use uuid::Uuid;
static BUILD_ID: Lazy<Uuid> = Lazy::new(calculate);

View File

@ -69,15 +69,15 @@ use alloc::{
string::{String, ToString},
vec::Vec,
};
use clap::{Command, CommandFactory, Parser};
use serde::{Deserialize, Serialize};
#[cfg(feature = "frida_cli")]
use std::error;
use std::{net::SocketAddr, path::PathBuf, time::Duration};
use crate::Error;
use clap::{Command, CommandFactory, Parser};
use serde::{Deserialize, Serialize};
use super::core_affinity::Cores;
use crate::Error;
/// helper function to go from a parsed cli string to a `Duration`
fn parse_timeout(src: &str) -> Result<Duration, Error> {
@ -371,10 +371,11 @@ pub fn parse_args() -> FuzzerOptions {
any(feature = "cli", feature = "qemu_cli", feature = "frida_cli")
))]
mod tests {
use super::*;
#[cfg(feature = "frida_cli")]
use alloc::string::String;
use super::*;
/// pass a standard option and `--` followed by some options that `FuzzerOptions` doesn't know
/// about; expect the standard option to work normally, and everything after `--` to be
/// collected into `qemu_args`

View File

@ -1,13 +1,16 @@
//! Compression of events passed between a broker and clients.
//! Currently we use the gzip compression algorithm for its fast decompression performance.
use crate::Error;
use alloc::vec::Vec;
use core::fmt::Debug;
use miniz_oxide::{
deflate::compress_to_vec, deflate::CompressionLevel, inflate::decompress_to_vec,
deflate::{compress_to_vec, CompressionLevel},
inflate::decompress_to_vec,
};
use crate::Error;
/// Compression for your stream compression needs.
#[derive(Debug)]
pub struct GzipCompressor {

View File

@ -33,6 +33,7 @@ use alloc::{
string::{String, ToString},
vec::Vec,
};
use serde::{Deserialize, Serialize};
use crate::Error;
@ -206,11 +207,12 @@ fn set_for_current_helper(core_id: CoreId) -> Result<(), Error> {
#[cfg(any(target_os = "android", target_os = "linux"))]
mod linux {
use super::CoreId;
use alloc::{string::ToString, vec::Vec};
use libc::{cpu_set_t, sched_getaffinity, sched_setaffinity, CPU_ISSET, CPU_SET, CPU_SETSIZE};
use std::mem;
use libc::{cpu_set_t, sched_getaffinity, sched_setaffinity, CPU_ISSET, CPU_SET, CPU_SETSIZE};
use super::CoreId;
use crate::Error;
#[allow(trivial_numeric_casts)]
@ -331,10 +333,14 @@ fn set_for_current_helper(core_id: CoreId) -> Result<(), Error> {
#[cfg(target_os = "windows")]
mod windows {
use crate::bolts::core_affinity::{CoreId, Error};
use alloc::vec::Vec;
use windows::Win32::System::SystemInformation::GROUP_AFFINITY;
use windows::Win32::System::Threading::{GetCurrentThread, SetThreadGroupAffinity};
use windows::Win32::System::{
SystemInformation::GROUP_AFFINITY,
Threading::{GetCurrentThread, SetThreadGroupAffinity},
};
use crate::bolts::core_affinity::{CoreId, Error};
pub fn get_core_ids() -> Result<Vec<CoreId>, Error> {
let mut core_ids: Vec<CoreId> = Vec::new();
@ -386,8 +392,7 @@ mod windows {
#[allow(clippy::cast_ptr_alignment)]
#[allow(clippy::cast_possible_wrap)]
pub fn get_num_logical_cpus_ex_windows() -> Option<usize> {
use std::ptr;
use std::slice;
use std::{ptr, slice};
#[allow(non_upper_case_globals)]
const RelationProcessorCore: u32 = 0;
@ -517,19 +522,19 @@ fn set_for_current_helper(core_id: CoreId) -> Result<(), Error> {
#[cfg(target_vendor = "apple")]
mod apple {
use alloc::vec::Vec;
use core::ptr::addr_of_mut;
use std::thread::available_parallelism;
use crate::Error;
use super::CoreId;
use alloc::vec::Vec;
use libc::{
integer_t, kern_return_t, mach_msg_type_number_t, pthread_mach_thread_np, pthread_self,
thread_policy_flavor_t, thread_policy_t, thread_t, KERN_NOT_SUPPORTED, KERN_SUCCESS,
THREAD_AFFINITY_POLICY, THREAD_AFFINITY_POLICY_COUNT,
};
use super::CoreId;
use crate::Error;
#[repr(C)]
struct thread_affinity_policy_data_t {
affinity_tag: integer_t,

View File

@ -147,9 +147,10 @@ impl Drop for InputFile {
#[cfg(test)]
mod test {
use crate::bolts::fs::{write_file_atomic, InputFile};
use std::fs;
use crate::bolts::fs::{write_file_atomic, InputFile};
#[test]
fn test_atomic_file_write() {
let path = "test_atomic_file_write.tmp";

View File

@ -10,6 +10,25 @@
//! On `Unix` systems, the [`Launcher`] will use `fork` if the `fork` feature is used for `LibAFL`.
//! Else, it will start subsequent nodes with the same commandline, and will set special `env` variables accordingly.
#[cfg(all(feature = "std"))]
use alloc::string::ToString;
use core::fmt::{self, Debug, Formatter};
#[cfg(feature = "std")]
use core::marker::PhantomData;
#[cfg(feature = "std")]
use std::net::SocketAddr;
#[cfg(all(feature = "std", any(windows, not(feature = "fork"))))]
use std::process::Stdio;
#[cfg(all(unix, feature = "std", feature = "fork"))]
use std::{fs::File, os::unix::io::AsRawFd};
#[cfg(feature = "std")]
use serde::de::DeserializeOwned;
#[cfg(feature = "std")]
use typed_builder::TypedBuilder;
#[cfg(all(feature = "std", any(windows, not(feature = "fork"))))]
use crate::bolts::core_affinity::CoreId;
#[cfg(all(feature = "std", any(windows, not(feature = "fork"))))]
use crate::bolts::os::startable_self;
#[cfg(all(unix, feature = "std", feature = "fork"))]
@ -24,24 +43,6 @@ use crate::{
Error,
};
#[cfg(all(feature = "std", any(windows, not(feature = "fork"))))]
use crate::bolts::core_affinity::CoreId;
#[cfg(all(feature = "std"))]
use alloc::string::ToString;
use core::fmt::{self, Debug, Formatter};
#[cfg(feature = "std")]
use core::marker::PhantomData;
#[cfg(feature = "std")]
use serde::de::DeserializeOwned;
#[cfg(feature = "std")]
use std::net::SocketAddr;
#[cfg(all(feature = "std", any(windows, not(feature = "fork"))))]
use std::process::Stdio;
#[cfg(all(unix, feature = "std", feature = "fork"))]
use std::{fs::File, os::unix::io::AsRawFd};
#[cfg(feature = "std")]
use typed_builder::TypedBuilder;
/// The (internal) `env` that indicates we're running as client.
const _AFL_LAUNCHER_CLIENT: &str = "AFL_LAUNCHER_CLIENT";
/// Provides a Launcher, which can be used to launch a fuzzing run on a specified list of cores

View File

@ -57,6 +57,8 @@ Check out the `llmp_test` example in ./examples, or build it with `cargo run --e
*/
#[cfg(feature = "std")]
use alloc::string::ToString;
use alloc::{string::String, vec::Vec};
#[cfg(not(target_pointer_width = "64"))]
use core::sync::atomic::AtomicU32;
@ -71,10 +73,8 @@ use core::{
sync::atomic::{fence, AtomicU16, Ordering},
time::Duration,
};
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use alloc::string::ToString;
#[cfg(all(unix, feature = "std"))]
use std::os::unix::io::AsRawFd;
#[cfg(feature = "std")]
use std::{
env,
@ -86,6 +86,9 @@ use std::{
#[cfg(all(debug_assertions, feature = "llmp_debug", feature = "std"))]
use backtrace::Backtrace;
#[cfg(all(unix, feature = "std"))]
use nix::sys::socket::{self, sockopt::ReusePort};
use serde::{Deserialize, Serialize};
#[cfg(unix)]
use crate::bolts::os::unix_signals::{
@ -95,10 +98,6 @@ use crate::{
bolts::shmem::{ShMem, ShMemDescription, ShMemId, ShMemProvider},
Error,
};
#[cfg(all(unix, feature = "std"))]
use nix::sys::socket::{self, sockopt::ReusePort};
#[cfg(all(unix, feature = "std"))]
use std::os::unix::io::AsRawFd;
/// The max number of pages a [`client`] may have mapped that were not yet read by the [`broker`]
/// Usually, this value should not exceed `1`, else the broker cannot keep up with the amount of incoming messages.
@ -2740,7 +2739,6 @@ mod tests {
LlmpMsgHookResult::ForwardToClients,
Tag,
};
use crate::bolts::shmem::{ShMemProvider, StdShMemProvider};
#[test]

View File

@ -3,9 +3,10 @@
//! You may use the [`crate::bolts::os::unix_signals::ucontext`]
//! function to get a [`ucontext_t`].
use libc::siginfo_t;
use std::io::{BufWriter, Write};
use libc::siginfo_t;
use crate::bolts::os::unix_signals::{ucontext_t, Signal};
/// Write the content of all important registers

View File

@ -154,7 +154,6 @@ pub fn format_duration_hms(duration: &time::Duration) -> String {
/// The purpose of this module is to alleviate imports of the bolts by adding a glob import.
pub mod bolts_prelude {
pub use super::anymap::*;
#[cfg(feature = "std")]
pub use super::build_id::*;
#[cfg(all(
@ -166,20 +165,15 @@ pub mod bolts_prelude {
pub use super::compress::*;
#[cfg(feature = "std")]
pub use super::core_affinity::*;
pub use super::cpu::*;
#[cfg(feature = "std")]
pub use super::fs::*;
#[cfg(feature = "std")]
pub use super::launcher::*;
pub use super::llmp::*;
#[cfg(all(feature = "std", unix))]
pub use super::minibsod::*;
pub use super::os::*;
pub use super::ownedref::*;
pub use super::rands::*;
pub use super::serdeany::*;
pub use super::shmem::*;
#[cfg(feature = "std")]
pub use super::staterestore::*;
pub use super::tuples::*;
pub use super::{
anymap::*, cpu::*, llmp::*, os::*, ownedref::*, rands::*, serdeany::*, shmem::*, tuples::*,
};
}

View File

@ -1,12 +1,12 @@
//! Operating System specific abstractions
//!
#[cfg(any(unix, all(windows, feature = "std")))]
use crate::Error;
#[cfg(feature = "std")]
use std::{env, process::Command};
#[cfg(any(unix, all(windows, feature = "std")))]
use crate::Error;
#[cfg(all(unix, feature = "std"))]
pub mod unix_shmem_server;

View File

@ -1,13 +1,15 @@
//! Unix `pipe` wrapper for `LibAFL`
use crate::Error;
#[cfg(feature = "std")]
use nix::unistd::{close, pipe, read, write};
#[cfg(feature = "std")]
use std::{
io::{self, ErrorKind, Read, Write},
os::unix::io::RawFd,
};
#[cfg(feature = "std")]
use nix::unistd::{close, pipe, read, write};
use crate::Error;
/// A unix pipe wrapper for `LibAFL`
#[cfg(feature = "std")]
#[derive(Debug, Clone)]

View File

@ -5,22 +5,14 @@ Hence, the `unix_shmem_server` keeps track of existing maps, creates new maps fo
and forwards them over unix domain sockets.
*/
use crate::{
bolts::{
shmem::{ShMem, ShMemDescription, ShMemId, ShMemProvider},
AsMutSlice, AsSlice,
},
Error,
};
#[cfg(feature = "std")]
use alloc::{
string::{String, ToString},
vec::Vec,
};
use core::{mem::ManuallyDrop, ptr::addr_of};
use hashbrown::HashMap;
use serde::{Deserialize, Serialize};
#[cfg(target_vendor = "apple")]
use std::fs;
use std::{
borrow::BorrowMut,
cell::RefCell,
@ -31,13 +23,6 @@ use std::{
sync::{Arc, Condvar, Mutex},
thread::JoinHandle,
};
#[cfg(target_vendor = "apple")]
use std::fs;
#[cfg(all(feature = "std", unix))]
use nix::poll::{poll, PollFd, PollFlags};
#[cfg(all(feature = "std", unix))]
use std::{
os::unix::{
@ -47,9 +32,21 @@ use std::{
thread,
};
use hashbrown::HashMap;
#[cfg(all(feature = "std", unix))]
use nix::poll::{poll, PollFd, PollFlags};
use serde::{Deserialize, Serialize};
#[cfg(all(unix, feature = "std"))]
use uds::{UnixListenerExt, UnixSocketAddr, UnixStreamExt};
use crate::{
bolts::{
shmem::{ShMem, ShMemDescription, ShMemId, ShMemProvider},
AsMutSlice, AsSlice,
},
Error,
};
/// The default server name for our abstract shmem server
#[cfg(all(unix, not(target_vendor = "apple")))]
const UNIX_SERVER_NAME: &str = "@libafl_unix_shmem_server";

View File

@ -7,15 +7,14 @@ use core::{
ptr::{addr_of_mut, write_volatile},
sync::atomic::{compiler_fence, Ordering},
};
#[cfg(feature = "std")]
use nix::errno::{errno, Errno};
#[cfg(feature = "std")]
use std::ffi::CString;
/// armv7 `libc` does not feature a `uncontext_t` implementation
#[cfg(target_arch = "arm")]
pub use libc::c_ulong;
#[cfg(feature = "std")]
use nix::errno::{errno, Errno};
/// ARMv7-specific representation of a saved context
#[cfg(target_arch = "arm")]
@ -234,21 +233,19 @@ pub struct ucontext_t {
pub mcontext_data: mcontext64,
}
pub use libc::{c_void, siginfo_t};
#[cfg(all(target_vendor = "apple", target_arch = "aarch64"))]
use libc::ssize_t;
#[cfg(not(any(
all(target_os = "linux", target_arch = "arm"),
all(target_vendor = "apple", target_arch = "aarch64")
)))]
pub use libc::ucontext_t;
#[cfg(all(target_vendor = "apple", target_arch = "aarch64"))]
use libc::ssize_t;
use libc::{
c_int, malloc, sigaction, sigaddset, sigaltstack, sigemptyset, stack_t, SA_NODEFER, SA_ONSTACK,
SA_SIGINFO, SIGABRT, SIGALRM, SIGBUS, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGKILL, SIGPIPE,
SIGQUIT, SIGSEGV, SIGTERM, SIGTRAP, SIGUSR2,
};
pub use libc::{c_void, siginfo_t};
use num_enum::{IntoPrimitive, TryFromPrimitive};
use crate::Error;

View File

@ -1,14 +1,5 @@
//! Exception handling for Windows
pub use windows::Win32::System::Diagnostics::Debug::{
AddVectoredExceptionHandler, EXCEPTION_POINTERS,
};
pub use windows::Win32::Foundation::NTSTATUS;
use crate::Error;
use std::os::raw::{c_long, c_void};
use alloc::vec::Vec;
use core::{
cell::UnsafeCell,
@ -17,8 +8,15 @@ use core::{
ptr::write_volatile,
sync::atomic::{compiler_fence, Ordering},
};
use std::os::raw::{c_long, c_void};
use num_enum::TryFromPrimitive;
pub use windows::Win32::{
Foundation::NTSTATUS,
System::Diagnostics::Debug::{AddVectoredExceptionHandler, EXCEPTION_POINTERS},
};
use crate::Error;
//const EXCEPTION_CONTINUE_EXECUTION: c_long = -1;
//const EXCEPTION_CONTINUE_SEARCH: c_long = 0;

View File

@ -1,15 +1,17 @@
//! Wrappers that abstracts references (or pointers) and owned data accesses.
// The serialization is towards owned, allowing to serialize pointers without troubles.
use crate::bolts::{AsMutSlice, AsSlice};
use alloc::{
boxed::Box,
slice::{Iter, IterMut},
vec::Vec,
};
use core::{clone::Clone, fmt::Debug, slice};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use crate::bolts::{AsMutSlice, AsSlice};
/// Trait to convert into an Owned type
pub trait IntoOwned {
/// Returns if the current type is an owned type.

View File

@ -1,14 +1,14 @@
//! The random number generators of `LibAFL`
use core::{debug_assert, fmt::Debug};
#[cfg(feature = "rand_trait")]
use rand_core::{self, impls::fill_bytes_via_next, RngCore};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use xxhash_rust::xxh3::xxh3_64_with_seed;
#[cfg(feature = "std")]
use crate::bolts::current_nanos;
#[cfg(feature = "rand_trait")]
use rand_core::{self, impls::fill_bytes_via_next, RngCore};
const HASH_CONST: u64 = 0xa5b35705;
/// The standard rand implementation for `LibAFL`.
@ -417,8 +417,9 @@ mod tests {
#[test]
#[cfg(feature = "rand_trait")]
fn test_rgn_core_support() {
use crate::bolts::rands::StdRand;
use rand_core::RngCore;
use crate::bolts::rands::StdRand;
pub struct Mutator<R: RngCore> {
rng: R,
}
@ -435,11 +436,12 @@ mod tests {
#[allow(missing_docs)]
/// `Rand` Python bindings
pub mod pybind {
use super::Rand;
use crate::bolts::{current_nanos, rands::StdRand};
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
use super::Rand;
use crate::bolts::{current_nanos, rands::StdRand};
#[pyclass(unsendable, name = "StdRand")]
#[derive(Serialize, Deserialize, Debug, Clone)]
/// Python class for StdRand

View File

@ -1,10 +1,10 @@
//! Poor-rust-man's downcasts for stuff we send over the wire (or shared maps)
use serde::{de::DeserializeSeed, Deserialize, Deserializer, Serialize, Serializer};
use alloc::boxed::Box;
use core::{any::Any, fmt::Debug};
use serde::{de::DeserializeSeed, Deserialize, Deserializer, Serialize, Serializer};
/// A (de)serializable Any trait
pub trait SerdeAny: Any + erased_serde::Serialize + Debug {
/// returns this as Any trait
@ -69,19 +69,21 @@ macro_rules! create_serde_registry_for_trait {
pub mod $mod_name {
use alloc::boxed::Box;
use core::any::TypeId;
use core::fmt;
use core::{any::TypeId, fmt};
use hashbrown::{
hash_map::{Keys, Values, ValuesMut},
HashMap,
};
use postcard;
use serde::{Deserialize, Serialize};
use hashbrown::hash_map::{Keys, Values, ValuesMut};
use hashbrown::HashMap;
use $crate::bolts::{
anymap::{pack_type_id, unpack_type_id},
serdeany::{DeserializeCallback, DeserializeCallbackSeed},
use $crate::{
bolts::{
anymap::{pack_type_id, unpack_type_id},
serdeany::{DeserializeCallback, DeserializeCallbackSeed},
},
Error,
};
use $crate::Error;
/// Visitor object used internally for the [`SerdeAny`] registry.
#[derive(Debug)]

View File

@ -1,19 +1,12 @@
//! A generic shared memory region to be used by any functions (queues or feedbacks
//! too.)
#[cfg(all(unix, feature = "std"))]
use crate::bolts::os::pipes::Pipe;
use crate::{
bolts::{AsMutSlice, AsSlice},
Error,
};
use alloc::{rc::Rc, string::ToString};
use core::{
cell::RefCell,
fmt::{self, Debug, Display},
mem::ManuallyDrop,
};
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use std::env;
#[cfg(all(unix, feature = "std"))]
@ -21,17 +14,22 @@ use std::io::Read;
#[cfg(feature = "std")]
use std::io::Write;
use serde::{Deserialize, Serialize};
#[cfg(all(feature = "std", unix, not(target_os = "android")))]
pub use unix_shmem::{MmapShMem, MmapShMemProvider};
#[cfg(all(feature = "std", unix))]
pub use unix_shmem::{UnixShMem, UnixShMemProvider};
#[cfg(all(windows, feature = "std"))]
pub use win32_shmem::{Win32ShMem, Win32ShMemProvider};
#[cfg(all(unix, feature = "std"))]
use crate::bolts::os::pipes::Pipe;
#[cfg(all(feature = "std", unix))]
pub use crate::bolts::os::unix_shmem_server::{ServedShMemProvider, ShMemService};
use crate::{
bolts::{AsMutSlice, AsSlice},
Error,
};
/// The standard sharedmem provider
#[cfg(all(windows, feature = "std"))]
@ -541,11 +539,12 @@ pub mod unix_shmem {
use alloc::string::ToString;
use core::{ptr, slice};
use std::{io::Write, process};
use libc::{
c_int, c_long, c_uchar, c_uint, c_ulong, c_ushort, close, ftruncate, mmap, munmap,
perror, shm_open, shm_unlink, shmat, shmctl, shmget,
};
use std::{io::Write, process};
use crate::{
bolts::{
@ -922,11 +921,12 @@ pub mod unix_shmem {
pub mod ashmem {
use alloc::string::ToString;
use core::{ptr, slice};
use std::ffi::CString;
use libc::{
c_uint, c_ulong, c_void, close, ioctl, mmap, open, MAP_SHARED, O_RDWR, PROT_READ,
PROT_WRITE,
};
use std::ffi::CString;
use crate::{
bolts::{
@ -1146,6 +1146,15 @@ pub mod unix_shmem {
#[cfg(all(feature = "std", windows))]
pub mod win32_shmem {
use alloc::string::String;
use core::{
ffi::c_void,
fmt::{self, Debug, Formatter},
ptr, slice,
};
use uuid::Uuid;
use crate::{
bolts::{
shmem::{ShMem, ShMemId, ShMemProvider},
@ -1154,22 +1163,16 @@ pub mod win32_shmem {
Error,
};
use alloc::string::String;
use core::{
ffi::c_void,
fmt::{self, Debug, Formatter},
ptr, slice,
};
use uuid::Uuid;
const INVALID_HANDLE_VALUE: isize = -1;
use windows::{
core::PCSTR,
Win32::Foundation::{CloseHandle, BOOL, HANDLE},
Win32::System::Memory::{
CreateFileMappingA, MapViewOfFile, OpenFileMappingA, UnmapViewOfFile,
FILE_MAP_ALL_ACCESS, PAGE_READWRITE,
Win32::{
Foundation::{CloseHandle, BOOL, HANDLE},
System::Memory::{
CreateFileMappingA, MapViewOfFile, OpenFileMappingA, UnmapViewOfFile,
FILE_MAP_ALL_ACCESS, PAGE_READWRITE,
},
},
};

View File

@ -1,9 +1,7 @@
//! Stores and restores state when a client needs to relaunch.
//! Uses a [`ShMem`] up to a threshold, then write to disk.
use ahash::AHasher;
use alloc::string::{String, ToString};
use core::{hash::Hasher, marker::PhantomData, mem::size_of, ptr, slice};
use serde::{de::DeserializeOwned, Serialize};
use std::{
env::temp_dir,
fs::{self, File},
@ -12,6 +10,9 @@ use std::{
ptr::read_volatile,
};
use ahash::AHasher;
use serde::{de::DeserializeOwned, Serialize};
use crate::{
bolts::{
shmem::{ShMem, ShMemProvider},
@ -246,6 +247,7 @@ mod tests {
string::{String, ToString},
vec::Vec,
};
use serial_test::serial;
use crate::bolts::{

View File

@ -1,12 +1,11 @@
//! Compiletime lists/tuples used throughout the `LibAFL` universe
pub use tuple_list::{tuple_list, tuple_list_type, TupleList};
use core::{
any::TypeId,
ptr::{addr_of, addr_of_mut},
};
pub use tuple_list::{tuple_list, tuple_list_type, TupleList};
use xxhash_rust::xxh3::xxh3_64;
/// Returns if the type `T` is equal to `U`

View File

@ -2,9 +2,10 @@
use alloc::collections::vec_deque::VecDeque;
use core::cell::RefCell;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
use crate::{
corpus::{
ondisk::{OnDiskCorpus, OnDiskMetadataFormat},
@ -137,11 +138,16 @@ where
/// ``CachedOnDiskCorpus`` Python bindings
#[cfg(feature = "python")]
pub mod pybind {
use crate::{corpus::pybind::PythonCorpus, corpus::CachedOnDiskCorpus, inputs::BytesInput};
use alloc::string::String;
use std::path::PathBuf;
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use crate::{
corpus::{pybind::PythonCorpus, CachedOnDiskCorpus},
inputs::BytesInput,
};
#[pyclass(unsendable, name = "CachedOnDiskCorpus")]
#[derive(Serialize, Deserialize, Debug, Clone)]

View File

@ -2,9 +2,14 @@
use alloc::vec::Vec;
use core::cell::RefCell;
use serde::{Deserialize, Serialize};
use crate::{corpus::Corpus, corpus::Testcase, inputs::Input, Error};
use crate::{
corpus::{Corpus, Testcase},
inputs::Input,
Error,
};
/// A corpus handling all in memory.
#[derive(Default, Serialize, Deserialize, Clone, Debug)]
@ -91,12 +96,13 @@ where
/// `InMemoryCorpus` Python bindings
#[cfg(feature = "python")]
pub mod pybind {
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
use crate::{
corpus::{pybind::PythonCorpus, InMemoryCorpus},
inputs::BytesInput,
};
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
#[pyclass(unsendable, name = "InMemoryCorpus")]
#[derive(Serialize, Deserialize, Debug, Clone)]

View File

@ -13,11 +13,11 @@ pub use ondisk::OnDiskCorpus;
#[cfg(feature = "std")]
pub mod cached;
use core::cell::RefCell;
#[cfg(feature = "std")]
pub use cached::CachedOnDiskCorpus;
use core::cell::RefCell;
use crate::{inputs::Input, Error};
/// Corpus with all current testcases
@ -56,6 +56,11 @@ where
#[cfg(feature = "python")]
#[allow(missing_docs)]
pub mod pybind {
use std::cell::RefCell;
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
use crate::{
corpus::{
cached::pybind::PythonCachedOnDiskCorpus, inmemory::pybind::PythonInMemoryCorpus,
@ -65,9 +70,6 @@ pub mod pybind {
inputs::BytesInput,
Error,
};
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
use std::cell::RefCell;
#[derive(Serialize, Deserialize, Debug, Clone)]
enum PythonCorpusWrapper {

View File

@ -2,18 +2,21 @@
use alloc::vec::Vec;
use core::{cell::RefCell, time::Duration};
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use std::{fs, fs::File, io::Write};
use std::{
fs::OpenOptions,
path::{Path, PathBuf},
};
#[cfg(feature = "std")]
use std::{fs, fs::File, io::Write};
use serde::{Deserialize, Serialize};
use crate::{
bolts::serdeany::SerdeAnyMap, corpus::Corpus, corpus::Testcase, inputs::Input,
state::HasMetadata, Error,
bolts::serdeany::SerdeAnyMap,
corpus::{Corpus, Testcase},
inputs::Input,
state::HasMetadata,
Error,
};
/// Options for the the format of the on-disk metadata
@ -208,14 +211,16 @@ where
#[cfg(feature = "python")]
/// `OnDiskCorpus` Python bindings
pub mod pybind {
use alloc::string::String;
use std::path::PathBuf;
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
use crate::{
corpus::{pybind::PythonCorpus, OnDiskCorpus},
inputs::BytesInput,
};
use alloc::string::String;
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[pyclass(unsendable, name = "OnDiskCorpus")]
#[derive(Serialize, Deserialize, Debug, Clone)]

View File

@ -3,6 +3,7 @@
use alloc::string::String;
use core::{convert::Into, default::Default, option::Option, time::Duration};
use serde::{Deserialize, Serialize};
use crate::{
@ -350,14 +351,16 @@ crate::impl_serdeany!(SchedulerTestcaseMetaData);
#[allow(missing_docs)]
/// `Testcase` Python bindings
pub mod pybind {
use alloc::{boxed::Box, vec::Vec};
use pyo3::{prelude::*, types::PyDict};
use super::{HasMetadata, Testcase};
use crate::{
bolts::ownedref::OwnedPtrMut,
inputs::{BytesInput, HasBytesVec},
pybind::PythonMetadata,
};
use alloc::{boxed::Box, vec::Vec};
use pyo3::{prelude::*, types::PyDict};
/// `PythonTestcase` with fixed generics
pub type PythonTestcase = Testcase<BytesInput>;

View File

@ -1,5 +1,23 @@
//! LLMP-backed event manager for scalable multi-processed fuzzing
use alloc::{
boxed::Box,
string::{String, ToString},
vec::Vec,
};
#[cfg(feature = "std")]
use core::sync::atomic::{compiler_fence, Ordering};
use core::{marker::PhantomData, time::Duration};
#[cfg(feature = "std")]
use std::net::{SocketAddr, ToSocketAddrs};
use serde::de::DeserializeOwned;
#[cfg(feature = "std")]
use serde::Serialize;
#[cfg(feature = "std")]
use typed_builder::TypedBuilder;
use super::{CustomBufEventResult, CustomBufHandlerFn};
#[cfg(feature = "std")]
use crate::bolts::core_affinity::CoreId;
#[cfg(all(feature = "std", any(windows, not(feature = "fork"))))]
@ -29,23 +47,6 @@ use crate::{
observers::ObserversTuple,
Error,
};
use alloc::{
boxed::Box,
string::{String, ToString},
vec::Vec,
};
#[cfg(feature = "std")]
use core::sync::atomic::{compiler_fence, Ordering};
use core::{marker::PhantomData, time::Duration};
use serde::de::DeserializeOwned;
#[cfg(feature = "std")]
use serde::Serialize;
#[cfg(feature = "std")]
use std::net::{SocketAddr, ToSocketAddrs};
#[cfg(feature = "std")]
use typed_builder::TypedBuilder;
use super::{CustomBufEventResult, CustomBufHandlerFn};
/// Forward this to the client
const _LLMP_TAG_EVENT_TO_CLIENT: Tag = 0x2C11E471;
@ -990,6 +991,8 @@ where
#[cfg(test)]
#[cfg(feature = "std")]
mod tests {
use core::sync::atomic::{compiler_fence, Ordering};
use serial_test::serial;
use crate::{
@ -1010,7 +1013,6 @@ mod tests {
state::StdState,
Fuzzer, StdFuzzer,
};
use core::sync::atomic::{compiler_fence, Ordering};
#[test]
#[serial]

View File

@ -3,17 +3,16 @@
pub mod simple;
pub use simple::*;
pub mod llmp;
pub use llmp::*;
use ahash::AHasher;
use alloc::{
boxed::Box,
string::{String, ToString},
vec::Vec,
};
use core::{fmt, hash::Hasher, marker::PhantomData, time::Duration};
use serde::{Deserialize, Serialize};
use ahash::AHasher;
pub use llmp::*;
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use uuid::Uuid;
@ -582,6 +581,8 @@ mod tests {
#[cfg(feature = "python")]
#[allow(missing_docs)]
pub mod pybind {
use pyo3::prelude::*;
use crate::{
events::{
simple::pybind::PythonSimpleEventManager, Event, EventFirer, EventManager,
@ -593,7 +594,6 @@ pub mod pybind {
state::pybind::PythonStdState,
Error,
};
use pyo3::prelude::*;
#[derive(Debug, Clone)]
pub enum PythonEventManagerWrapper {

View File

@ -1,14 +1,5 @@
//! A very simple event manager, that just supports log outputs, but no multiprocessing
use crate::{
events::{
BrokerEventResult, Event, EventFirer, EventManager, EventManagerId, EventProcessor,
EventRestarter, HasEventManagerId,
},
inputs::Input,
monitors::Monitor,
Error,
};
use alloc::{
boxed::Box,
string::{String, ToString},
@ -17,9 +8,11 @@ use alloc::{
#[cfg(feature = "std")]
use core::sync::atomic::{compiler_fence, Ordering};
use core::{fmt::Debug, marker::PhantomData};
#[cfg(feature = "std")]
use serde::{de::DeserializeOwned, Serialize};
use super::{CustomBufEventResult, CustomBufHandlerFn, HasCustomBufHandlers, ProgressReporter};
#[cfg(all(feature = "std", any(windows, not(feature = "fork"))))]
use crate::bolts::os::startable_self;
#[cfg(all(feature = "std", feature = "fork", unix))]
@ -31,8 +24,15 @@ use crate::{
executors::Executor,
state::{HasCorpus, HasSolutions},
};
use super::{CustomBufEventResult, CustomBufHandlerFn, HasCustomBufHandlers, ProgressReporter};
use crate::{
events::{
BrokerEventResult, Event, EventFirer, EventManager, EventManagerId, EventProcessor,
EventRestarter, HasEventManagerId,
},
inputs::Input,
monitors::Monitor,
Error,
};
/// The llmp connection from the actual fuzzer to the process supervising it
const _ENV_FUZZER_SENDER: &str = "_AFL_ENV_FUZZER_SENDER";
@ -494,12 +494,15 @@ where
#[cfg(feature = "python")]
#[allow(missing_docs)]
pub mod pybind {
use crate::{
events::pybind::PythonEventManager, events::SimpleEventManager, inputs::BytesInput,
monitors::pybind::PythonMonitor, state::pybind::PythonStdState,
};
use pyo3::prelude::*;
use crate::{
events::{pybind::PythonEventManager, SimpleEventManager},
inputs::BytesInput,
monitors::pybind::PythonMonitor,
state::pybind::PythonStdState,
};
#[pyclass(unsendable, name = "SimpleEventManager")]
#[derive(Debug)]
/// Python class for SimpleEventManager

View File

@ -1,13 +1,14 @@
//! A `CombinedExecutor` wraps a primary executor and a secondary one
//! In comparison to the [`crate::executors::DiffExecutor`] it does not run the secondary executor in `run_target`.
use core::fmt::Debug;
use crate::{
executors::{Executor, ExitKind, HasObservers},
inputs::Input,
observers::ObserversTuple,
Error,
};
use core::fmt::Debug;
/// A [`CombinedExecutor`] wraps a primary executor, forwarding its methods, and a secondary one
#[derive(Debug)]

View File

@ -1,15 +1,16 @@
//! The command executor executes a sub program for each run
#[cfg(feature = "std")]
use alloc::{borrow::ToOwned, string::String, vec::Vec};
use core::{
fmt::{self, Debug, Formatter},
marker::PhantomData,
};
#[cfg(feature = "std")]
use alloc::{borrow::ToOwned, string::String, vec::Vec};
#[cfg(unix)]
use std::os::unix::ffi::OsStrExt;
#[cfg(feature = "std")]
use std::process::Child;
#[cfg(all(feature = "std", unix))]
use std::time::Duration;
use std::{
ffi::{OsStr, OsString},
io::{Read, Write},
@ -17,6 +18,9 @@ use std::{
process::{Command, Stdio},
};
use super::HasObservers;
#[cfg(all(feature = "std", unix))]
use crate::executors::{Executor, ExitKind};
use crate::{
bolts::{
fs::{InputFile, INPUTFILE_STD},
@ -29,14 +33,6 @@ use crate::{
#[cfg(feature = "std")]
use crate::{inputs::Input, Error};
#[cfg(all(feature = "std", unix))]
use crate::executors::{Executor, ExitKind};
#[cfg(all(feature = "std", unix))]
use std::time::Duration;
use super::HasObservers;
/// How to deliver input to an external program
/// `StdIn`: The traget reads from stdin
/// `File`: The target reads from the specified [`InputFile`]
@ -320,6 +316,7 @@ where
input: &I,
) -> Result<ExitKind, Error> {
use std::os::unix::prelude::ExitStatusExt;
use wait_timeout::ChildExt;
let mut child = self.configurer.spawn_child(input)?;

View File

@ -2,13 +2,14 @@
//! It wraps two exeutors 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::fmt::Debug;
use crate::{
executors::{Executor, ExitKind, HasObservers},
inputs::Input,
observers::ObserversTuple,
Error,
};
use core::fmt::Debug;
/// A [`DiffExecutor`] wraps a primary executor, forwarding its methods, and a secondary one
#[derive(Debug)]

View File

@ -1,5 +1,6 @@
//! Expose an `Executor` based on a `Forkserver` in order to execute AFL/AFL++ binaries
use alloc::{borrow::ToOwned, string::ToString, vec::Vec};
use core::{
fmt::{self, Debug, Formatter},
marker::PhantomData,
@ -13,6 +14,15 @@ use std::{
process::{Command, Stdio},
};
use nix::{
sys::{
select::{pselect, FdSet},
signal::{kill, SigSet, Signal},
time::{TimeSpec, TimeValLike},
},
unistd::Pid,
};
use crate::{
bolts::{
fs::{InputFile, INPUTFILE_STD},
@ -27,16 +37,6 @@ use crate::{
Error,
};
use alloc::{borrow::ToOwned, string::ToString, vec::Vec};
use nix::{
sys::{
select::{pselect, FdSet},
signal::{kill, SigSet, Signal},
time::{TimeSpec, TimeValLike},
},
unistd::Pid,
};
const FORKSRV_FD: i32 = 198;
#[allow(clippy::cast_possible_wrap)]
const FS_OPT_ENABLED: i32 = 0x80000001_u32 as i32;
@ -1011,6 +1011,10 @@ where
#[cfg(test)]
mod tests {
use std::ffi::OsString;
use serial_test::serial;
use crate::{
bolts::{
shmem::{ShMem, ShMemProvider, StdShMemProvider},
@ -1022,8 +1026,6 @@ mod tests {
observers::{ConstMapObserver, HitcountsMapObserver},
Error,
};
use serial_test::serial;
use std::ffi::OsString;
#[test]
#[serial]
fn test_forkserver() {

View File

@ -3,6 +3,9 @@
//!
//! Needs the `fork` feature flag.
use alloc::boxed::Box;
#[cfg(all(unix, feature = "std"))]
use alloc::vec::Vec;
use core::{
borrow::BorrowMut,
ffi::c_void,
@ -10,42 +13,32 @@ use core::{
marker::PhantomData,
ptr,
};
#[cfg(any(unix, all(windows, feature = "std")))]
use core::{
ptr::write_volatile,
sync::atomic::{compiler_fence, Ordering},
};
use alloc::boxed::Box;
#[cfg(all(unix, feature = "std"))]
use alloc::vec::Vec;
#[cfg(all(feature = "std", unix))]
use std::intrinsics::transmute;
#[cfg(all(feature = "std", unix))]
use libc::siginfo_t;
#[cfg(all(feature = "std", unix))]
use nix::{
sys::wait::{waitpid, WaitStatus},
unistd::{fork, ForkResult},
};
#[cfg(windows)]
use windows::Win32::System::Threading::SetThreadStackGuarantee;
#[cfg(unix)]
use crate::bolts::os::unix_signals::setup_signal_handler;
#[cfg(all(feature = "std", unix))]
use crate::bolts::os::unix_signals::{ucontext_t, Handler, Signal};
#[cfg(all(windows, feature = "std"))]
use crate::bolts::os::windows_exceptions::setup_exception_handler;
#[cfg(all(feature = "std", unix))]
use crate::bolts::shmem::ShMemProvider;
#[cfg(windows)]
use windows::Win32::System::Threading::SetThreadStackGuarantee;
#[cfg(all(feature = "std", unix))]
use crate::bolts::os::unix_signals::{ucontext_t, Handler, Signal};
use crate::{
events::{EventFirer, EventRestarter},
executors::{Executor, ExitKind, HasObservers},
@ -512,13 +505,14 @@ mod unix_signal_handler {
#[cfg(feature = "std")]
use alloc::{boxed::Box, string::String};
use core::mem::transmute;
use libc::siginfo_t;
#[cfg(feature = "std")]
use std::{
io::{stdout, Write},
panic,
};
use libc::siginfo_t;
use crate::{
bolts::os::unix_signals::{ucontext_t, Handler, Signal},
corpus::{Corpus, Testcase},
@ -860,16 +854,21 @@ mod unix_signal_handler {
mod windows_exception_handler {
#[cfg(feature = "std")]
use alloc::boxed::Box;
use alloc::string::String;
use alloc::vec::Vec;
use core::ffi::c_void;
use core::{mem::transmute, ptr};
use alloc::{string::String, vec::Vec};
use core::{
ffi::c_void,
mem::transmute,
ptr,
sync::atomic::{compiler_fence, Ordering},
};
#[cfg(feature = "std")]
use std::{
io::{stdout, Write},
panic,
};
use windows::Win32::System::Threading::ExitProcess;
use crate::{
bolts::os::windows_exceptions::{
ExceptionCode, Handler, CRASH_EXCEPTIONS, EXCEPTION_POINTERS,
@ -887,9 +886,6 @@ mod windows_exception_handler {
state::{HasClientPerfMonitor, HasMetadata, HasSolutions},
};
use core::sync::atomic::{compiler_fence, Ordering};
use windows::Win32::System::Threading::ExitProcess;
pub(crate) type HandlerFuncPtr =
unsafe fn(*mut EXCEPTION_POINTERS, &mut InProcessExecutorHandlerData);
@ -1560,12 +1556,11 @@ where
#[cfg(all(feature = "std", unix))]
pub mod child_signal_handlers {
use alloc::boxed::Box;
use libc::siginfo_t;
use std::panic;
use super::InProcessForkExecutorGlobalData;
use libc::siginfo_t;
use super::FORK_EXECUTOR_GLOBAL_DATA;
use super::{InProcessForkExecutorGlobalData, FORK_EXECUTOR_GLOBAL_DATA};
use crate::{
bolts::os::unix_signals::{ucontext_t, Signal},
executors::{ExitKind, HasObservers},
@ -1633,6 +1628,7 @@ pub mod child_signal_handlers {
#[cfg(test)]
mod tests {
use core::marker::PhantomData;
use serial_test::serial;
#[cfg(all(feature = "std", feature = "fork", unix))]
@ -1689,6 +1685,10 @@ mod tests {
#[allow(missing_docs)]
/// `InProcess` Python bindings
pub mod pybind {
use alloc::boxed::Box;
use pyo3::{prelude::*, types::PyBytes};
use crate::{
events::pybind::PythonEventManager,
executors::{inprocess::OwnedInProcessExecutor, pybind::PythonExecutor, ExitKind},
@ -1697,8 +1697,6 @@ pub mod pybind {
observers::pybind::PythonObserversTuple,
state::pybind::{PythonStdState, PythonStdStateWrapper},
};
use alloc::boxed::Box;
use pyo3::{prelude::*, types::PyBytes};
#[pyclass(unsendable, name = "InProcessExecutor")]
#[derive(Debug)]

View File

@ -31,8 +31,11 @@ pub use with_observers::WithObservers;
#[cfg(all(feature = "std", unix))]
pub mod command;
use core::fmt::Debug;
#[cfg(all(feature = "std", unix))]
pub use command::CommandExecutor;
use serde::{Deserialize, Serialize};
use crate::{
bolts::AsSlice,
@ -41,9 +44,6 @@ use crate::{
Error,
};
use core::fmt::Debug;
use serde::{Deserialize, Serialize};
/// How an execution finished.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub enum ExitKind {
@ -189,17 +189,21 @@ mod test {
#[allow(missing_docs)]
/// `Executor` Python bindings
pub mod pybind {
use crate::events::pybind::PythonEventManager;
use crate::executors::inprocess::pybind::PythonOwnedInProcessExecutor;
use crate::executors::{Executor, ExitKind, HasObservers};
use crate::fuzzer::pybind::{PythonStdFuzzer, PythonStdFuzzerWrapper};
use crate::inputs::{BytesInput, HasBytesVec};
use crate::observers::pybind::PythonObserversTuple;
use crate::state::pybind::{PythonStdState, PythonStdStateWrapper};
use crate::Error;
use pyo3::prelude::*;
use serde::{Deserialize, Serialize};
use crate::{
events::pybind::PythonEventManager,
executors::{
inprocess::pybind::PythonOwnedInProcessExecutor, Executor, ExitKind, HasObservers,
},
fuzzer::pybind::{PythonStdFuzzer, PythonStdFuzzerWrapper},
inputs::{BytesInput, HasBytesVec},
observers::pybind::PythonObserversTuple,
state::pybind::{PythonStdState, PythonStdStateWrapper},
Error,
};
#[pyclass(unsendable, name = "ExitKind")]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PythonExitKind {

View File

@ -1,30 +1,24 @@
//! A `TimeoutExecutor` sets a timeout before each target run
#[cfg(target_os = "linux")]
use core::ptr::{addr_of, addr_of_mut};
#[cfg(all(windows, feature = "std"))]
use core::{ffi::c_void, ptr::write_volatile};
#[cfg(any(windows, unix))]
use core::{
fmt::{self, Debug, Formatter},
time::Duration,
};
use crate::{
executors::{Executor, ExitKind, HasObservers},
inputs::Input,
observers::ObserversTuple,
Error,
};
#[cfg(all(windows, feature = "std"))]
use crate::executors::inprocess::{HasInProcessHandlers, GLOBAL_STATE};
#[cfg(unix)]
use core::{mem::zeroed, ptr::null_mut};
#[cfg(target_os = "linux")]
use core::ptr::{addr_of, addr_of_mut};
#[cfg(windows)]
use core::{
ptr::addr_of_mut,
sync::atomic::{compiler_fence, Ordering},
};
#[cfg(all(unix, not(target_os = "linux")))]
use libc::c_int;
#[cfg(all(windows, feature = "std"))]
use windows::Win32::{
Foundation::FILETIME,
@ -36,12 +30,12 @@ use windows::Win32::{
};
#[cfg(all(windows, feature = "std"))]
use core::{ffi::c_void, ptr::write_volatile};
#[cfg(windows)]
use core::{
ptr::addr_of_mut,
sync::atomic::{compiler_fence, Ordering},
use crate::executors::inprocess::{HasInProcessHandlers, GLOBAL_STATE};
use crate::{
executors::{Executor, ExitKind, HasObservers},
inputs::Input,
observers::ObserversTuple,
Error,
};
#[repr(C)]

View File

@ -6,6 +6,7 @@ use core::{
fmt::{self, Debug, Formatter},
marker::PhantomData,
};
use serde::{Deserialize, Serialize};
use crate::{
@ -153,6 +154,8 @@ where
#[cfg(test)]
mod tests {
use alloc::string::{String, ToString};
use crate::{
bolts::{
serdeany::SerdeAnyMap,
@ -166,7 +169,6 @@ mod tests {
observers::Observer,
state::{HasClientPerfMonitor, HasMetadata},
};
use alloc::string::{String, ToString};
#[derive(Debug)]
struct NopObserver {

View File

@ -4,8 +4,12 @@ use alloc::{
string::{String, ToString},
vec::Vec,
};
use core::ops::{BitAnd, BitOr};
use core::{fmt::Debug, marker::PhantomData};
use core::{
fmt::Debug,
marker::PhantomData,
ops::{BitAnd, BitOr},
};
use num_traits::PrimInt;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
@ -837,13 +841,14 @@ mod tests {
#[cfg(feature = "python")]
#[allow(missing_docs)]
pub mod pybind {
use super::{Debug, HasObserverName, MaxMapFeedback};
use crate::feedbacks::pybind::PythonFeedback;
use crate::inputs::BytesInput;
use crate::state::pybind::PythonStdState;
use concat_idents::concat_idents;
use pyo3::prelude::*;
use super::{Debug, HasObserverName, MaxMapFeedback};
use crate::{
feedbacks::pybind::PythonFeedback, inputs::BytesInput, state::pybind::PythonStdState,
};
macro_rules! define_python_map_feedback {
($struct_name:ident, $py_name:tt, $datatype:ty, $map_observer_type_name: ident, $my_std_state_type_name: ident) => {
use crate::observers::map::pybind::$map_observer_type_name;

View File

@ -20,10 +20,15 @@ pub use new_hash_feedback::NewHashFeedbackMetadata;
#[cfg(feature = "nautilus")]
pub mod nautilus;
use alloc::string::{String, ToString};
use core::{
fmt::{self, Debug, Formatter},
marker::PhantomData,
time::Duration,
};
#[cfg(feature = "nautilus")]
pub use nautilus::*;
use alloc::string::{String, ToString};
use serde::{Deserialize, Serialize};
use crate::{
@ -37,12 +42,6 @@ use crate::{
Error,
};
use core::{
fmt::{self, Debug, Formatter},
marker::PhantomData,
time::Duration,
};
/// Feedbacks evaluate the observers.
/// Basically, they reduce the information provided by an observer to a value,
/// indicating the "interestingness" of the last run.
@ -1040,27 +1039,32 @@ impl From<bool> for ConstFeedback {
#[cfg(feature = "python")]
#[allow(missing_docs)]
pub mod pybind {
use std::cell::UnsafeCell;
use pyo3::prelude::*;
use super::{
ConstFeedback, CrashFeedback, Debug, EagerAndFeedback, EagerOrFeedback, FastAndFeedback,
FastOrFeedback, Feedback, NotFeedback, String, ToString,
};
use crate::corpus::testcase::pybind::{PythonTestcase, PythonTestcaseWrapper};
use crate::events::pybind::PythonEventManager;
use crate::executors::pybind::PythonExitKind;
use crate::feedbacks::map::pybind::{
PythonMaxMapFeedbackI16, PythonMaxMapFeedbackI32, PythonMaxMapFeedbackI64,
PythonMaxMapFeedbackI8, PythonMaxMapFeedbackU16, PythonMaxMapFeedbackU32,
PythonMaxMapFeedbackU64, PythonMaxMapFeedbackU8,
};
use crate::inputs::HasBytesVec;
use crate::observers::pybind::PythonObserversTuple;
use crate::state::pybind::{PythonStdState, PythonStdStateWrapper};
use crate::{
bolts::tuples::Named, corpus::Testcase, events::EventFirer, executors::ExitKind,
inputs::BytesInput, observers::ObserversTuple, Error,
bolts::tuples::Named,
corpus::{
testcase::pybind::{PythonTestcase, PythonTestcaseWrapper},
Testcase,
},
events::{pybind::PythonEventManager, EventFirer},
executors::{pybind::PythonExitKind, ExitKind},
feedbacks::map::pybind::{
PythonMaxMapFeedbackI16, PythonMaxMapFeedbackI32, PythonMaxMapFeedbackI64,
PythonMaxMapFeedbackI8, PythonMaxMapFeedbackU16, PythonMaxMapFeedbackU32,
PythonMaxMapFeedbackU64, PythonMaxMapFeedbackU8,
},
inputs::{BytesInput, HasBytesVec},
observers::{pybind::PythonObserversTuple, ObserversTuple},
state::pybind::{PythonStdState, PythonStdStateWrapper},
Error,
};
use pyo3::prelude::*;
use std::cell::UnsafeCell;
#[derive(Debug)]
pub struct PyObjectFeedback {

View File

@ -1,10 +1,11 @@
//! Nautilus grammar mutator, see <https://github.com/nautilus-fuzz/nautilus>
use alloc::string::String;
use core::fmt::Debug;
use std::fs::create_dir_all;
use grammartec::{chunkstore::ChunkStore, context::Context};
use serde::{Deserialize, Serialize};
use serde_json;
use std::fs::create_dir_all;
use crate::{
bolts::tuples::Named,

View File

@ -1,8 +1,8 @@
//! The ``NewHashFeedback`` uses the backtrace hash and a hashset to only keep novel cases
use alloc::string::{String, ToString};
use std::{fmt::Debug, marker::PhantomData};
use alloc::string::{String, ToString};
use hashbrown::HashSet;
use serde::{Deserialize, Serialize};

View File

@ -1,5 +1,10 @@
//! The `Fuzzer` is the main struct for a fuzz campaign.
use alloc::string::ToString;
use core::{marker::PhantomData, time::Duration};
#[cfg(feature = "introspection")]
use crate::monitors::PerfFeature;
use crate::{
bolts::current_time,
corpus::{Corpus, Testcase},
@ -16,12 +21,6 @@ use crate::{
Error,
};
#[cfg(feature = "introspection")]
use crate::monitors::PerfFeature;
use alloc::string::ToString;
use core::{marker::PhantomData, time::Duration};
/// Send a monitor update all 15 (or more) seconds
const STATS_TIMEOUT_DEFAULT: Duration = Duration::from_secs(15);
@ -672,19 +671,23 @@ where
#[allow(missing_docs)]
/// `Fuzzer` Python bindings
pub mod pybind {
use crate::bolts::ownedref::OwnedPtrMut;
use crate::events::pybind::PythonEventManager;
use crate::executors::pybind::PythonExecutor;
use crate::feedbacks::pybind::PythonFeedback;
use crate::fuzzer::{Evaluator, Fuzzer, StdFuzzer};
use crate::inputs::BytesInput;
use crate::observers::pybind::PythonObserversTuple;
use crate::schedulers::QueueScheduler;
use crate::stages::pybind::PythonStagesTuple;
use crate::state::pybind::{PythonStdState, PythonStdStateWrapper};
use alloc::{boxed::Box, vec::Vec};
use pyo3::prelude::*;
use crate::{
bolts::ownedref::OwnedPtrMut,
events::pybind::PythonEventManager,
executors::pybind::PythonExecutor,
feedbacks::pybind::PythonFeedback,
fuzzer::{Evaluator, Fuzzer, StdFuzzer},
inputs::BytesInput,
observers::pybind::PythonObserversTuple,
schedulers::QueueScheduler,
stages::pybind::PythonStagesTuple,
state::pybind::{PythonStdState, PythonStdStateWrapper},
};
/// `StdFuzzer` with fixed generics
pub type PythonStdFuzzer = StdFuzzer<
QueueScheduler,

View File

@ -1,6 +1,7 @@
//! Gramatron generator
use alloc::{string::String, vec::Vec};
use core::marker::PhantomData;
use serde::{Deserialize, Serialize};
use crate::{

View File

@ -130,13 +130,17 @@ where
#[allow(missing_docs)]
#[cfg(feature = "python")]
pub mod pybind {
use crate::generators::{Generator, RandBytesGenerator, RandPrintablesGenerator};
use crate::inputs::{BytesInput, HasBytesVec};
use crate::state::pybind::{PythonStdState, PythonStdStateWrapper};
use crate::Error;
use alloc::vec::Vec;
use pyo3::prelude::*;
use crate::{
generators::{Generator, RandBytesGenerator, RandPrintablesGenerator},
inputs::{BytesInput, HasBytesVec},
state::pybind::{PythonStdState, PythonStdStateWrapper},
Error,
};
#[derive(Clone, Debug)]
pub struct PyObjectGenerator {
inner: PyObject,

View File

@ -1,15 +1,16 @@
//! Generators for the [`Nautilus`](https://github.com/RUB-SysSec/nautilus) grammar fuzzer
use crate::{generators::Generator, inputs::nautilus::NautilusInput, Error};
use alloc::{
string::{String, ToString},
vec::Vec,
};
use core::fmt::Debug;
use grammartec::context::Context;
use std::{fs, io::BufReader, path::Path};
use grammartec::context::Context;
pub use grammartec::newtypes::NTermID;
use crate::{generators::Generator, inputs::nautilus::NautilusInput, Error};
/// The nautilus context for a generator
pub struct NautilusContext {
/// The nautilus context for a generator

View File

@ -1,14 +1,14 @@
//! The `BytesInput` is the "normal" input, a map of bytes, that can be sent directly to the client
//! (As opposed to other, more abstract, inputs, like an Grammar-Based AST Input)
use ahash::AHasher;
use alloc::{borrow::ToOwned, rc::Rc, string::String, vec::Vec};
use core::hash::Hasher;
use core::{cell::RefCell, convert::From};
use serde::{Deserialize, Serialize};
use core::{cell::RefCell, convert::From, hash::Hasher};
#[cfg(feature = "std")]
use std::{fs::File, io::Read, path::Path};
use ahash::AHasher;
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use crate::{bolts::fs::write_file_atomic, Error};
use crate::{

View File

@ -2,15 +2,14 @@
//! (As opposed to other, more abstract, inputs, like an Grammar-Based AST Input)
//! See also [the paper on token-level fuzzing](https://www.usenix.org/system/files/sec21-salls.pdf)
use ahash::AHasher;
use core::hash::Hasher;
#[cfg(feature = "std")]
use alloc::string::ToString;
use alloc::{borrow::ToOwned, rc::Rc, string::String, vec::Vec};
#[cfg(feature = "std")]
use core::str::from_utf8;
use core::{cell::RefCell, convert::From};
use core::{cell::RefCell, convert::From, hash::Hasher};
use ahash::AHasher;
use hashbrown::HashMap;
#[cfg(feature = "std")]
use regex::Regex;
@ -259,11 +258,11 @@ impl EncodedInput {
#[cfg(test)]
mod tests {
use alloc::borrow::ToOwned;
use core::str::from_utf8;
use crate::inputs::encoded::{
InputDecoder, InputEncoder, NaiveTokenizer, TokenInputEncoderDecoder,
};
use core::str::from_utf8;
#[test]
fn test_input() {

View File

@ -1,16 +1,15 @@
//! The `GeneralizedInput` is an input that ca be generalized to represent a rule, used by Grimoire
use ahash::AHasher;
use alloc::{borrow::ToOwned, rc::Rc, string::String, vec::Vec};
use core::hash::Hasher;
use core::{cell::RefCell, convert::From};
use core::{cell::RefCell, convert::From, hash::Hasher};
#[cfg(feature = "std")]
use std::{fs::File, io::Read, path::Path};
use ahash::AHasher;
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use crate::Error;
#[cfg(feature = "std")]
use std::{fs::File, io::Read, path::Path};
use crate::{
bolts::{ownedref::OwnedSlice, HasLen},
inputs::{HasBytesVec, HasTargetBytes, Input},

View File

@ -1,9 +1,8 @@
//! The gramatron grammar fuzzer
use ahash::AHasher;
use core::hash::Hasher;
use alloc::{rc::Rc, string::String, vec::Vec};
use core::{cell::RefCell, convert::From};
use core::{cell::RefCell, convert::From, hash::Hasher};
use ahash::AHasher;
use serde::{Deserialize, Serialize};
use crate::{bolts::HasLen, inputs::Input, Error};

View File

@ -14,18 +14,18 @@ pub use generalized::*;
#[cfg(feature = "nautilus")]
pub mod nautilus;
#[cfg(feature = "nautilus")]
pub use nautilus::*;
use alloc::{
string::{String, ToString},
vec::Vec,
};
use core::{clone::Clone, fmt::Debug};
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use std::{fs::File, hash::Hash, io::Read, path::Path};
#[cfg(feature = "nautilus")]
pub use nautilus::*;
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use crate::bolts::fs::write_file_atomic;
use crate::{bolts::ownedref::OwnedSlice, Error};

View File

@ -6,17 +6,16 @@
use alloc::{rc::Rc, string::String, vec::Vec};
use core::{cell::RefCell, convert::From};
use serde::{Deserialize, Serialize};
use crate::{bolts::HasLen, generators::nautilus::NautilusContext, inputs::Input};
use std::hash::{Hash, Hasher};
use grammartec::{
newtypes::NodeID,
rule::RuleIDOrCustom,
tree::{Tree, TreeLike},
};
use serde::{Deserialize, Serialize};
use std::hash::{Hash, Hasher};
use crate::{bolts::HasLen, generators::nautilus::NautilusContext, inputs::Input};
/// An [`Input`] implementation for `Nautilus` grammar.
#[derive(Serialize, Deserialize, Clone, Debug)]

View File

@ -109,12 +109,16 @@ pub mod state;
pub mod fuzzer;
use alloc::string::{FromUtf8Error, String};
use core::{array::TryFromSliceError, fmt, num::ParseIntError, num::TryFromIntError};
pub use fuzzer::*;
use core::{
array::TryFromSliceError,
fmt,
num::{ParseIntError, TryFromIntError},
};
#[cfg(feature = "std")]
use std::{env::VarError, io};
pub use fuzzer::*;
#[cfg(feature = "errors_backtrace")]
/// Error Backtrace type when `errors_backtrace` feature is enabled (== [`backtrace::Backtrace`])
pub type ErrorBacktrace = backtrace::Backtrace;
@ -425,28 +429,31 @@ impl std::error::Error for Error {}
/// The purpose of this module is to alleviate imports of many components by adding a glob import.
pub mod prelude {
pub use super::bolts::bolts_prelude::*;
pub use super::bolts::*;
pub use super::corpus::*;
pub use super::events::*;
pub use super::executors::*;
pub use super::feedbacks::*;
pub use super::fuzzer::*;
pub use super::generators::*;
pub use super::inputs::*;
pub use super::monitors::*;
pub use super::mutators::*;
pub use super::observers::*;
pub use super::schedulers::*;
pub use super::stages::*;
pub use super::state::*;
pub use super::*;
pub use super::{
bolts::{bolts_prelude::*, *},
corpus::*,
events::*,
executors::*,
feedbacks::*,
fuzzer::*,
generators::*,
inputs::*,
monitors::*,
mutators::*,
observers::*,
schedulers::*,
stages::*,
state::*,
*,
};
}
// TODO: no_std test
#[cfg(feature = "std")]
#[cfg(test)]
mod tests {
#[cfg(feature = "std")]
use crate::events::SimpleEventManager;
use crate::{
bolts::{rands::StdRand, tuples::tuple_list},
corpus::{Corpus, InMemoryCorpus, Testcase},
@ -460,9 +467,6 @@ mod tests {
Fuzzer, StdFuzzer,
};
#[cfg(feature = "std")]
use crate::events::SimpleEventManager;
#[test]
#[allow(clippy::similar_names)]
fn test_fuzzer() {
@ -535,11 +539,12 @@ pub extern "C" fn external_current_millis() -> u64 {
#[cfg(feature = "python")]
#[allow(missing_docs)]
pub mod pybind {
use pyo3::prelude::*;
use super::{
bolts, corpus, events, executors, feedbacks, fuzzer, generators, monitors, mutators,
observers, stages, state,
};
use pyo3::prelude::*;
#[derive(Debug, Clone)]
pub struct PythonMetadata {
@ -627,6 +632,7 @@ pub mod pybind {
($struct_name:ident, $inner:tt) => {
const _: () = {
use alloc::vec::Vec;
use pyo3::prelude::*;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

View File

@ -2,14 +2,13 @@
use alloc::{string::String, vec::Vec};
use core::time::Duration;
use std::{fs::File, io::Write, path::PathBuf};
use crate::{
bolts::{current_time, format_duration_hms},
monitors::{ClientStats, Monitor, NopMonitor},
};
use std::{fs::File, io::Write, path::PathBuf};
/// Wrap a monitor and log the current state of the monitor into a TOML file.
#[derive(Debug, Clone)]
pub struct OnDiskTOMLMonitor<M>

View File

@ -9,15 +9,13 @@ pub mod tui;
#[cfg(feature = "std")]
pub mod disk;
#[cfg(feature = "std")]
pub use disk::OnDiskTOMLMonitor;
use alloc::{fmt::Debug, string::String, vec::Vec};
#[cfg(feature = "introspection")]
use alloc::string::ToString;
use alloc::{fmt::Debug, string::String, vec::Vec};
use core::{fmt, time::Duration};
#[cfg(feature = "std")]
pub use disk::OnDiskTOMLMonitor;
use hashbrown::HashMap;
use serde::{Deserialize, Serialize};
@ -834,14 +832,14 @@ impl Default for ClientPerfMonitor {
#[cfg(feature = "python")]
#[allow(missing_docs)]
pub mod pybind {
use crate::monitors::{Monitor, SimpleMonitor};
use pyo3::prelude::*;
use pyo3::types::PyUnicode;
use super::ClientStats;
use alloc::{boxed::Box, string::String, vec::Vec};
use core::time::Duration;
use pyo3::{prelude::*, types::PyUnicode};
use super::ClientStats;
use crate::monitors::{Monitor, SimpleMonitor};
// TODO create a PyObjectFnMut to pass, track stabilization of https://github.com/rust-lang/rust/issues/29625
#[pyclass(unsendable, name = "SimpleMonitor")]

View File

@ -1,10 +1,9 @@
//! Monitor to display both cumulative and per-client monitor
use alloc::{string::String, vec::Vec};
use core::{fmt::Write, time::Duration};
#[cfg(feature = "introspection")]
use alloc::string::ToString;
use alloc::{string::String, vec::Vec};
use core::{fmt::Write, time::Duration};
use crate::{
bolts::{current_time, format_duration_hms},

View File

@ -1,14 +1,6 @@
//! Monitor based on tui-rs
use crossterm::{
cursor::{EnableBlinking, Show},
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use hashbrown::HashMap;
use tui::{backend::CrosstermBackend, Terminal};
use alloc::boxed::Box;
use std::{
collections::VecDeque,
fmt::Write,
@ -21,16 +13,22 @@ use std::{
vec::Vec,
};
use crossterm::{
cursor::{EnableBlinking, Show},
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use hashbrown::HashMap;
use tui::{backend::CrosstermBackend, Terminal};
#[cfg(feature = "introspection")]
use super::{ClientPerfMonitor, PerfFeature};
use crate::{
bolts::{current_time, format_duration_hms},
monitors::{ClientStats, Monitor, UserStats},
};
use alloc::boxed::Box;
mod ui;
use ui::TuiUI;

View File

@ -1,6 +1,9 @@
use super::{current_time, format_duration_hms, Duration, String, TimedStats, TuiContext};
use alloc::vec::Vec;
use std::{
cmp::{max, min},
sync::{Arc, RwLock},
};
use tui::{
backend::Backend,
layout::{Alignment, Constraint, Direction, Layout, Rect},
@ -13,10 +16,7 @@ use tui::{
Frame,
};
use std::{
cmp::{max, min},
sync::{Arc, RwLock},
};
use super::{current_time, format_duration_hms, Duration, String, TimedStats, TuiContext};
#[derive(Default)]
pub struct TuiUI {

Some files were not shown because too many files have changed in this diff Show More