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; use std::path::PathBuf;
#[cfg(windows)] #[cfg(windows)]
use std::ptr::write_volatile; 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)] #[cfg(windows)]
use std::ptr::write_volatile; use std::ptr::write_volatile;
use std::{
fs,
io::{BufReader, Read},
path::{Path, PathBuf},
};
use libafl::{ use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list}, 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)] #[cfg(windows)]
use std::ptr::write_volatile; use std::ptr::write_volatile;
use std::{fs, io::Read, path::PathBuf};
use libafl::{ use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice}, bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,10 @@
use std::path::PathBuf; use std::path::PathBuf;
use libafl::bolts::AsSlice;
use libafl::executors::InProcessExecutor;
use libafl::observers::ConstMapObserver;
use libafl::{ use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list}, bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},
corpus::{InMemoryCorpus, OnDiskCorpus}, corpus::{InMemoryCorpus, OnDiskCorpus},
events::SimpleEventManager, events::SimpleEventManager,
executors::InProcessExecutor,
feedback_and, feedback_and,
feedbacks::{CrashFeedback, MaxMapFeedback, NewHashFeedback}, feedbacks::{CrashFeedback, MaxMapFeedback, NewHashFeedback},
fuzzer::{Fuzzer, StdFuzzer}, fuzzer::{Fuzzer, StdFuzzer},
@ -14,7 +12,7 @@ use libafl::{
inputs::{BytesInput, HasTargetBytes}, inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor, monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator}, mutators::scheduled::{havoc_mutations, StdScheduledMutator},
observers::BacktraceObserver, observers::{BacktraceObserver, ConstMapObserver},
schedulers::QueueScheduler, schedulers::QueueScheduler,
stages::mutational::StdMutationalStage, stages::mutational::StdMutationalStage,
state::StdState, 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::{ use libafl::{
bolts::{ bolts::{
current_nanos, current_nanos,
@ -22,13 +30,6 @@ use libafl::{
state::StdState, state::StdState,
Error, Error,
}; };
#[cfg(windows)]
use std::ptr::write_volatile;
use std::{
io::Write,
path::PathBuf,
process::{Child, Command, Stdio},
};
#[allow(clippy::similar_names)] #[allow(clippy::similar_names)]
pub fn main() { pub fn main() {

View File

@ -1,6 +1,8 @@
use std::env; use std::{
use std::path::Path; env,
use std::process::{exit, Command}; path::Path,
process::{exit, Command},
};
const AFL_URL: &str = "https://github.com/AFLplusplus/AFLplusplus"; 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::{ use libafl::{
bolts::{ bolts::{
current_nanos, current_nanos,
@ -21,12 +27,6 @@ use libafl::{
stages::mutational::StdMutationalStage, stages::mutational::StdMutationalStage,
state::StdState, 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)] #[allow(clippy::similar_names)]
pub fn main() { pub fn main() {

View File

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

View File

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

View File

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

View File

@ -1,5 +1,11 @@
use clap::{Arg, Command};
use core::time::Duration; 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::{ use libafl::{
bolts::{ bolts::{
current_nanos, current_nanos,
@ -23,13 +29,6 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState}, state::{HasCorpus, HasMetadata, StdState},
}; };
use nix::sys::signal::Signal; 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)] #[allow(clippy::similar_names)]
pub fn main() { pub fn main() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,11 +3,8 @@ use mimalloc::MiMalloc;
#[global_allocator] #[global_allocator]
static GLOBAL: MiMalloc = MiMalloc; static GLOBAL: MiMalloc = MiMalloc;
use clap::{Arg, Command};
use core::{cell::RefCell, time::Duration}; use core::{cell::RefCell, time::Duration};
#[cfg(unix)] #[cfg(unix)]
use nix::{self, unistd::dup};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd}; use std::os::unix::io::{AsRawFd, FromRawFd};
use std::{ use std::{
env, env,
@ -17,6 +14,7 @@ use std::{
process, process,
}; };
use clap::{Arg, Command};
use libafl::{ use libafl::{
bolts::{ bolts::{
current_nanos, current_time, current_nanos, current_time,
@ -49,13 +47,14 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState}, state::{HasCorpus, HasMetadata, StdState},
Error, Error,
}; };
#[cfg(target_os = "linux")]
use libafl_targets::autotokens;
use libafl_targets::{ use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, CmpLogObserver, CMPLOG_MAP, EDGES_MAP, libfuzzer_initialize, libfuzzer_test_one_input, CmpLogObserver, CMPLOG_MAP, EDGES_MAP,
MAX_EDGES_NUM, MAX_EDGES_NUM,
}; };
#[cfg(unix)]
#[cfg(target_os = "linux")] use nix::{self, unistd::dup};
use libafl_targets::autotokens;
/// The fuzzer main (as `no_mangle` C function) /// The fuzzer main (as `no_mangle` C function)
#[no_mangle] #[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) //! This is the drop-in replacement for libfuzzer, to be used together with [`Atheris`](https://github.com/google/atheris)
//! for python instrumentation and fuzzing. //! for python instrumentation and fuzzing.
use clap::{AppSettings, Arg, Command};
use core::{convert::TryInto, ffi::c_void, slice, time::Duration}; use core::{convert::TryInto, ffi::c_void, slice, time::Duration};
use std::{ use std::{
env, env,
@ -11,6 +10,7 @@ use std::{
path::PathBuf, path::PathBuf,
}; };
use clap::{AppSettings, Arg, Command};
use libafl::{ use libafl::{
bolts::{ bolts::{
core_affinity::Cores, core_affinity::Cores,
@ -30,8 +30,10 @@ use libafl::{
generators::RandBytesGenerator, generators::RandBytesGenerator,
inputs::{BytesInput, HasTargetBytes}, inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor, monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator}, mutators::{
mutators::token_mutations::{I2SRandReplace, Tokens}, scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::{I2SRandReplace, Tokens},
},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver}, observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
schedulers::{IndexesLenTimeMinimizerScheduler, QueueScheduler}, schedulers::{IndexesLenTimeMinimizerScheduler, QueueScheduler},
stages::{StdMutationalStage, TracingStage}, stages::{StdMutationalStage, TracingStage},

View File

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

View File

@ -21,15 +21,16 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer}, fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes}, inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor, monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator}, mutators::{
mutators::token_mutations::Tokens, scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::Tokens,
},
observers::StdMapObserver, observers::StdMapObserver,
schedulers::RandScheduler, schedulers::RandScheduler,
stages::mutational::StdMutationalStage, stages::mutational::StdMutationalStage,
state::{HasCorpus, HasMetadata, StdState}, state::{HasCorpus, HasMetadata, StdState},
Error, Error,
}; };
use libafl_targets::{ use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, CMP_MAP, EDGES_MAP, MAX_EDGES_NUM, 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 std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper};
pub fn main() { pub fn main() {
let args: Vec<String> = env::args().collect(); let args: Vec<String> = env::args().collect();
if args.len() > 1 { if args.len() > 1 {

View File

@ -24,8 +24,10 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer}, fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes}, inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor, monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator}, mutators::{
mutators::token_mutations::Tokens, scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::Tokens,
},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver}, observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
schedulers::{ schedulers::{
powersched::PowerSchedule, IndexesLenTimeMinimizerScheduler, StdWeightedScheduler, powersched::PowerSchedule, IndexesLenTimeMinimizerScheduler, StdWeightedScheduler,
@ -34,7 +36,6 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState}, state::{HasCorpus, HasMetadata, StdState},
Error, Error,
}; };
use libafl_targets::{libfuzzer_initialize, libfuzzer_test_one_input, EDGES_MAP, MAX_EDGES_NUM}; 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 /// 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 std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
const GRANULARITY: &str = "FUNC"; const GRANULARITY: &str = "FUNC";
pub fn main() { pub fn main() {

View File

@ -6,10 +6,10 @@ use mimalloc::MiMalloc;
#[global_allocator] #[global_allocator]
static GLOBAL: MiMalloc = MiMalloc; static GLOBAL: MiMalloc = MiMalloc;
use clap::{self, StructOpt};
use core::time::Duration; use core::time::Duration;
use std::{env, net::SocketAddr, path::PathBuf}; use std::{env, net::SocketAddr, path::PathBuf};
use clap::{self, StructOpt};
use libafl::{ use libafl::{
bolts::{ bolts::{
core_affinity::Cores, core_affinity::Cores,
@ -28,15 +28,16 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer}, fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes}, inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor, monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator}, mutators::{
mutators::token_mutations::Tokens, scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::Tokens,
},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver}, observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
schedulers::{CoverageAccountingScheduler, QueueScheduler}, schedulers::{CoverageAccountingScheduler, QueueScheduler},
stages::mutational::StdMutationalStage, stages::mutational::StdMutationalStage,
state::{HasCorpus, HasMetadata, StdState}, state::{HasCorpus, HasMetadata, StdState},
Error, Error,
}; };
use libafl_targets::{ use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, ACCOUNTING_MEMOP_MAP, EDGES_MAP, MAX_EDGES_NUM, 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 std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
pub fn main() { pub fn main() {
let args: Vec<String> = env::args().collect(); let args: Vec<String> = env::args().collect();
if args.len() > 1 { if args.len() > 1 {

View File

@ -6,10 +6,10 @@ use mimalloc::MiMalloc;
#[global_allocator] #[global_allocator]
static GLOBAL: MiMalloc = MiMalloc; static GLOBAL: MiMalloc = MiMalloc;
use clap::{self, StructOpt};
use core::time::Duration; use core::time::Duration;
use std::{env, net::SocketAddr, path::PathBuf}; use std::{env, net::SocketAddr, path::PathBuf};
use clap::{self, StructOpt};
use libafl::{ use libafl::{
bolts::{ bolts::{
core_affinity::Cores, core_affinity::Cores,
@ -38,7 +38,6 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState}, state::{HasCorpus, HasMetadata, StdState},
Error, Error,
}; };
use libafl_targets::{edges_map_from_ptr, libfuzzer_initialize, libfuzzer_test_one_input}; use libafl_targets::{edges_map_from_ptr, libfuzzer_initialize, libfuzzer_test_one_input};
fn timeout_from_millis_str(time: &str) -> Result<Duration, Error> { 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 std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper};
pub fn main() { pub fn main() {
let args: Vec<String> = env::args().collect(); let args: Vec<String> = env::args().collect();
if args.len() > 1 { if args.len() > 1 {

View File

@ -6,10 +6,10 @@ use mimalloc::MiMalloc;
#[global_allocator] #[global_allocator]
static GLOBAL: MiMalloc = MiMalloc; static GLOBAL: MiMalloc = MiMalloc;
use clap::{self, StructOpt};
use core::time::Duration; use core::time::Duration;
use std::{env, net::SocketAddr, path::PathBuf}; use std::{env, net::SocketAddr, path::PathBuf};
use clap::{self, StructOpt};
use libafl::{ use libafl::{
bolts::{ bolts::{
core_affinity::Cores, core_affinity::Cores,
@ -28,15 +28,16 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer}, fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes}, inputs::{BytesInput, HasTargetBytes},
monitors::{MultiMonitor, OnDiskTOMLMonitor}, monitors::{MultiMonitor, OnDiskTOMLMonitor},
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator}, mutators::{
mutators::token_mutations::Tokens, scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::Tokens,
},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver}, observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
schedulers::{IndexesLenTimeMinimizerScheduler, QueueScheduler}, schedulers::{IndexesLenTimeMinimizerScheduler, QueueScheduler},
stages::mutational::StdMutationalStage, stages::mutational::StdMutationalStage,
state::{HasCorpus, HasMetadata, StdState}, state::{HasCorpus, HasMetadata, StdState},
Error, Error,
}; };
use libafl_targets::{libfuzzer_initialize, libfuzzer_test_one_input, EDGES_MAP, MAX_EDGES_NUM}; 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. /// 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 std::env;
use libafl_cc::{ClangWrapper, CompilerWrapper};
pub fn main() { pub fn main() {
let args: Vec<String> = env::args().collect(); let args: Vec<String> = env::args().collect();
if args.len() > 1 { if args.len() > 1 {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -147,9 +147,10 @@ impl Drop for InputFile {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::bolts::fs::{write_file_atomic, InputFile};
use std::fs; use std::fs;
use crate::bolts::fs::{write_file_atomic, InputFile};
#[test] #[test]
fn test_atomic_file_write() { fn test_atomic_file_write() {
let path = "test_atomic_file_write.tmp"; 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`. //! 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. //! 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"))))] #[cfg(all(feature = "std", any(windows, not(feature = "fork"))))]
use crate::bolts::os::startable_self; use crate::bolts::os::startable_self;
#[cfg(all(unix, feature = "std", feature = "fork"))] #[cfg(all(unix, feature = "std", feature = "fork"))]
@ -24,24 +43,6 @@ use crate::{
Error, 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. /// The (internal) `env` that indicates we're running as client.
const _AFL_LAUNCHER_CLIENT: &str = "AFL_LAUNCHER_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 /// 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}; use alloc::{string::String, vec::Vec};
#[cfg(not(target_pointer_width = "64"))] #[cfg(not(target_pointer_width = "64"))]
use core::sync::atomic::AtomicU32; use core::sync::atomic::AtomicU32;
@ -71,10 +73,8 @@ use core::{
sync::atomic::{fence, AtomicU16, Ordering}, sync::atomic::{fence, AtomicU16, Ordering},
time::Duration, time::Duration,
}; };
use serde::{Deserialize, Serialize}; #[cfg(all(unix, feature = "std"))]
use std::os::unix::io::AsRawFd;
#[cfg(feature = "std")]
use alloc::string::ToString;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::{ use std::{
env, env,
@ -86,6 +86,9 @@ use std::{
#[cfg(all(debug_assertions, feature = "llmp_debug", feature = "std"))] #[cfg(all(debug_assertions, feature = "llmp_debug", feature = "std"))]
use backtrace::Backtrace; use backtrace::Backtrace;
#[cfg(all(unix, feature = "std"))]
use nix::sys::socket::{self, sockopt::ReusePort};
use serde::{Deserialize, Serialize};
#[cfg(unix)] #[cfg(unix)]
use crate::bolts::os::unix_signals::{ use crate::bolts::os::unix_signals::{
@ -95,10 +98,6 @@ use crate::{
bolts::shmem::{ShMem, ShMemDescription, ShMemId, ShMemProvider}, bolts::shmem::{ShMem, ShMemDescription, ShMemId, ShMemProvider},
Error, 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`] /// 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. /// 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, LlmpMsgHookResult::ForwardToClients,
Tag, Tag,
}; };
use crate::bolts::shmem::{ShMemProvider, StdShMemProvider}; use crate::bolts::shmem::{ShMemProvider, StdShMemProvider};
#[test] #[test]

View File

@ -3,9 +3,10 @@
//! You may use the [`crate::bolts::os::unix_signals::ucontext`] //! You may use the [`crate::bolts::os::unix_signals::ucontext`]
//! function to get a [`ucontext_t`]. //! function to get a [`ucontext_t`].
use libc::siginfo_t;
use std::io::{BufWriter, Write}; use std::io::{BufWriter, Write};
use libc::siginfo_t;
use crate::bolts::os::unix_signals::{ucontext_t, Signal}; use crate::bolts::os::unix_signals::{ucontext_t, Signal};
/// Write the content of all important registers /// 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. /// The purpose of this module is to alleviate imports of the bolts by adding a glob import.
pub mod bolts_prelude { pub mod bolts_prelude {
pub use super::anymap::*;
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub use super::build_id::*; pub use super::build_id::*;
#[cfg(all( #[cfg(all(
@ -166,20 +165,15 @@ pub mod bolts_prelude {
pub use super::compress::*; pub use super::compress::*;
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub use super::core_affinity::*; pub use super::core_affinity::*;
pub use super::cpu::*;
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub use super::fs::*; pub use super::fs::*;
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub use super::launcher::*; pub use super::launcher::*;
pub use super::llmp::*;
#[cfg(all(feature = "std", unix))] #[cfg(all(feature = "std", unix))]
pub use super::minibsod::*; 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")] #[cfg(feature = "std")]
pub use super::staterestore::*; 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 //! Operating System specific abstractions
//! //!
#[cfg(any(unix, all(windows, feature = "std")))]
use crate::Error;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::{env, process::Command}; use std::{env, process::Command};
#[cfg(any(unix, all(windows, feature = "std")))]
use crate::Error;
#[cfg(all(unix, feature = "std"))] #[cfg(all(unix, feature = "std"))]
pub mod unix_shmem_server; pub mod unix_shmem_server;

View File

@ -1,13 +1,15 @@
//! Unix `pipe` wrapper for `LibAFL` //! Unix `pipe` wrapper for `LibAFL`
use crate::Error;
#[cfg(feature = "std")]
use nix::unistd::{close, pipe, read, write};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::{ use std::{
io::{self, ErrorKind, Read, Write}, io::{self, ErrorKind, Read, Write},
os::unix::io::RawFd, os::unix::io::RawFd,
}; };
#[cfg(feature = "std")]
use nix::unistd::{close, pipe, read, write};
use crate::Error;
/// A unix pipe wrapper for `LibAFL` /// A unix pipe wrapper for `LibAFL`
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[derive(Debug, Clone)] #[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. and forwards them over unix domain sockets.
*/ */
use crate::{
bolts::{
shmem::{ShMem, ShMemDescription, ShMemId, ShMemProvider},
AsMutSlice, AsSlice,
},
Error,
};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use alloc::{ use alloc::{
string::{String, ToString}, string::{String, ToString},
vec::Vec, vec::Vec,
}; };
use core::{mem::ManuallyDrop, ptr::addr_of}; use core::{mem::ManuallyDrop, ptr::addr_of};
use hashbrown::HashMap; #[cfg(target_vendor = "apple")]
use serde::{Deserialize, Serialize}; use std::fs;
use std::{ use std::{
borrow::BorrowMut, borrow::BorrowMut,
cell::RefCell, cell::RefCell,
@ -31,13 +23,6 @@ use std::{
sync::{Arc, Condvar, Mutex}, sync::{Arc, Condvar, Mutex},
thread::JoinHandle, 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))] #[cfg(all(feature = "std", unix))]
use std::{ use std::{
os::unix::{ os::unix::{
@ -47,9 +32,21 @@ use std::{
thread, thread,
}; };
use hashbrown::HashMap;
#[cfg(all(feature = "std", unix))]
use nix::poll::{poll, PollFd, PollFlags};
use serde::{Deserialize, Serialize};
#[cfg(all(unix, feature = "std"))] #[cfg(all(unix, feature = "std"))]
use uds::{UnixListenerExt, UnixSocketAddr, UnixStreamExt}; 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 /// The default server name for our abstract shmem server
#[cfg(all(unix, not(target_vendor = "apple")))] #[cfg(all(unix, not(target_vendor = "apple")))]
const UNIX_SERVER_NAME: &str = "@libafl_unix_shmem_server"; const UNIX_SERVER_NAME: &str = "@libafl_unix_shmem_server";

View File

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

View File

@ -1,14 +1,5 @@
//! Exception handling for Windows //! 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 alloc::vec::Vec;
use core::{ use core::{
cell::UnsafeCell, cell::UnsafeCell,
@ -17,8 +8,15 @@ use core::{
ptr::write_volatile, ptr::write_volatile,
sync::atomic::{compiler_fence, Ordering}, sync::atomic::{compiler_fence, Ordering},
}; };
use std::os::raw::{c_long, c_void};
use num_enum::TryFromPrimitive; 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_EXECUTION: c_long = -1;
//const EXCEPTION_CONTINUE_SEARCH: c_long = 0; //const EXCEPTION_CONTINUE_SEARCH: c_long = 0;

View File

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

View File

@ -1,14 +1,14 @@
//! The random number generators of `LibAFL` //! The random number generators of `LibAFL`
use core::{debug_assert, fmt::Debug}; 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 serde::{de::DeserializeOwned, Deserialize, Serialize};
use xxhash_rust::xxh3::xxh3_64_with_seed; use xxhash_rust::xxh3::xxh3_64_with_seed;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use crate::bolts::current_nanos; use crate::bolts::current_nanos;
#[cfg(feature = "rand_trait")]
use rand_core::{self, impls::fill_bytes_via_next, RngCore};
const HASH_CONST: u64 = 0xa5b35705; const HASH_CONST: u64 = 0xa5b35705;
/// The standard rand implementation for `LibAFL`. /// The standard rand implementation for `LibAFL`.
@ -417,8 +417,9 @@ mod tests {
#[test] #[test]
#[cfg(feature = "rand_trait")] #[cfg(feature = "rand_trait")]
fn test_rgn_core_support() { fn test_rgn_core_support() {
use crate::bolts::rands::StdRand;
use rand_core::RngCore; use rand_core::RngCore;
use crate::bolts::rands::StdRand;
pub struct Mutator<R: RngCore> { pub struct Mutator<R: RngCore> {
rng: R, rng: R,
} }
@ -435,11 +436,12 @@ mod tests {
#[allow(missing_docs)] #[allow(missing_docs)]
/// `Rand` Python bindings /// `Rand` Python bindings
pub mod pybind { pub mod pybind {
use super::Rand;
use crate::bolts::{current_nanos, rands::StdRand};
use pyo3::prelude::*; use pyo3::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::Rand;
use crate::bolts::{current_nanos, rands::StdRand};
#[pyclass(unsendable, name = "StdRand")] #[pyclass(unsendable, name = "StdRand")]
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone)]
/// Python class for StdRand /// 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) //! 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 alloc::boxed::Box;
use core::{any::Any, fmt::Debug}; use core::{any::Any, fmt::Debug};
use serde::{de::DeserializeSeed, Deserialize, Deserializer, Serialize, Serializer};
/// A (de)serializable Any trait /// A (de)serializable Any trait
pub trait SerdeAny: Any + erased_serde::Serialize + Debug { pub trait SerdeAny: Any + erased_serde::Serialize + Debug {
/// returns this as Any trait /// returns this as Any trait
@ -69,19 +69,21 @@ macro_rules! create_serde_registry_for_trait {
pub mod $mod_name { pub mod $mod_name {
use alloc::boxed::Box; use alloc::boxed::Box;
use core::any::TypeId; use core::{any::TypeId, fmt};
use core::fmt;
use hashbrown::{
hash_map::{Keys, Values, ValuesMut},
HashMap,
};
use postcard; use postcard;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use $crate::{
use hashbrown::hash_map::{Keys, Values, ValuesMut}; bolts::{
use hashbrown::HashMap;
use $crate::bolts::{
anymap::{pack_type_id, unpack_type_id}, anymap::{pack_type_id, unpack_type_id},
serdeany::{DeserializeCallback, DeserializeCallbackSeed}, serdeany::{DeserializeCallback, DeserializeCallbackSeed},
},
Error,
}; };
use $crate::Error;
/// Visitor object used internally for the [`SerdeAny`] registry. /// Visitor object used internally for the [`SerdeAny`] registry.
#[derive(Debug)] #[derive(Debug)]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,23 @@
//! LLMP-backed event manager for scalable multi-processed fuzzing //! 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")] #[cfg(feature = "std")]
use crate::bolts::core_affinity::CoreId; use crate::bolts::core_affinity::CoreId;
#[cfg(all(feature = "std", any(windows, not(feature = "fork"))))] #[cfg(all(feature = "std", any(windows, not(feature = "fork"))))]
@ -29,23 +47,6 @@ use crate::{
observers::ObserversTuple, observers::ObserversTuple,
Error, 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 /// Forward this to the client
const _LLMP_TAG_EVENT_TO_CLIENT: Tag = 0x2C11E471; const _LLMP_TAG_EVENT_TO_CLIENT: Tag = 0x2C11E471;
@ -990,6 +991,8 @@ where
#[cfg(test)] #[cfg(test)]
#[cfg(feature = "std")] #[cfg(feature = "std")]
mod tests { mod tests {
use core::sync::atomic::{compiler_fence, Ordering};
use serial_test::serial; use serial_test::serial;
use crate::{ use crate::{
@ -1010,7 +1013,6 @@ mod tests {
state::StdState, state::StdState,
Fuzzer, StdFuzzer, Fuzzer, StdFuzzer,
}; };
use core::sync::atomic::{compiler_fence, Ordering};
#[test] #[test]
#[serial] #[serial]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,8 +31,11 @@ pub use with_observers::WithObservers;
#[cfg(all(feature = "std", unix))] #[cfg(all(feature = "std", unix))]
pub mod command; pub mod command;
use core::fmt::Debug;
#[cfg(all(feature = "std", unix))] #[cfg(all(feature = "std", unix))]
pub use command::CommandExecutor; pub use command::CommandExecutor;
use serde::{Deserialize, Serialize};
use crate::{ use crate::{
bolts::AsSlice, bolts::AsSlice,
@ -41,9 +44,6 @@ use crate::{
Error, Error,
}; };
use core::fmt::Debug;
use serde::{Deserialize, Serialize};
/// How an execution finished. /// How an execution finished.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub enum ExitKind { pub enum ExitKind {
@ -189,17 +189,21 @@ mod test {
#[allow(missing_docs)] #[allow(missing_docs)]
/// `Executor` Python bindings /// `Executor` Python bindings
pub mod pybind { 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 pyo3::prelude::*;
use serde::{Deserialize, Serialize}; 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")] #[pyclass(unsendable, name = "ExitKind")]
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PythonExitKind { pub struct PythonExitKind {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,10 @@
//! The `Fuzzer` is the main struct for a fuzz campaign. //! 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::{ use crate::{
bolts::current_time, bolts::current_time,
corpus::{Corpus, Testcase}, corpus::{Corpus, Testcase},
@ -16,12 +21,6 @@ use crate::{
Error, 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 /// Send a monitor update all 15 (or more) seconds
const STATS_TIMEOUT_DEFAULT: Duration = Duration::from_secs(15); const STATS_TIMEOUT_DEFAULT: Duration = Duration::from_secs(15);
@ -672,19 +671,23 @@ where
#[allow(missing_docs)] #[allow(missing_docs)]
/// `Fuzzer` Python bindings /// `Fuzzer` Python bindings
pub mod pybind { 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 alloc::{boxed::Box, vec::Vec};
use pyo3::prelude::*; 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 /// `StdFuzzer` with fixed generics
pub type PythonStdFuzzer = StdFuzzer< pub type PythonStdFuzzer = StdFuzzer<
QueueScheduler, QueueScheduler,

View File

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

View File

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

View File

@ -1,15 +1,16 @@
//! Generators for the [`Nautilus`](https://github.com/RUB-SysSec/nautilus) grammar fuzzer //! Generators for the [`Nautilus`](https://github.com/RUB-SysSec/nautilus) grammar fuzzer
use crate::{generators::Generator, inputs::nautilus::NautilusInput, Error};
use alloc::{ use alloc::{
string::{String, ToString}, string::{String, ToString},
vec::Vec, vec::Vec,
}; };
use core::fmt::Debug; use core::fmt::Debug;
use grammartec::context::Context;
use std::{fs, io::BufReader, path::Path}; use std::{fs, io::BufReader, path::Path};
use grammartec::context::Context;
pub use grammartec::newtypes::NTermID; pub use grammartec::newtypes::NTermID;
use crate::{generators::Generator, inputs::nautilus::NautilusInput, Error};
/// The nautilus context for a generator /// The nautilus context for a generator
pub struct NautilusContext { pub struct NautilusContext {
/// The nautilus context for a generator /// 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 //! 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) //! (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 alloc::{borrow::ToOwned, rc::Rc, string::String, vec::Vec};
use core::hash::Hasher; use core::{cell::RefCell, convert::From, hash::Hasher};
use core::{cell::RefCell, convert::From};
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::{fs::File, io::Read, path::Path}; use std::{fs::File, io::Read, path::Path};
use ahash::AHasher;
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use crate::{bolts::fs::write_file_atomic, Error}; use crate::{bolts::fs::write_file_atomic, Error};
use crate::{ use crate::{

View File

@ -2,15 +2,14 @@
//! (As opposed to other, more abstract, inputs, like an Grammar-Based AST Input) //! (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) //! 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")] #[cfg(feature = "std")]
use alloc::string::ToString; use alloc::string::ToString;
use alloc::{borrow::ToOwned, rc::Rc, string::String, vec::Vec}; use alloc::{borrow::ToOwned, rc::Rc, string::String, vec::Vec};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use core::str::from_utf8; 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; use hashbrown::HashMap;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use regex::Regex; use regex::Regex;
@ -259,11 +258,11 @@ impl EncodedInput {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use alloc::borrow::ToOwned; use alloc::borrow::ToOwned;
use core::str::from_utf8;
use crate::inputs::encoded::{ use crate::inputs::encoded::{
InputDecoder, InputEncoder, NaiveTokenizer, TokenInputEncoderDecoder, InputDecoder, InputEncoder, NaiveTokenizer, TokenInputEncoderDecoder,
}; };
use core::str::from_utf8;
#[test] #[test]
fn test_input() { 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 //! 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 alloc::{borrow::ToOwned, rc::Rc, string::String, vec::Vec};
use core::hash::Hasher; use core::{cell::RefCell, convert::From, hash::Hasher};
use core::{cell::RefCell, convert::From}; #[cfg(feature = "std")]
use std::{fs::File, io::Read, path::Path};
use ahash::AHasher;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use crate::Error; use crate::Error;
#[cfg(feature = "std")]
use std::{fs::File, io::Read, path::Path};
use crate::{ use crate::{
bolts::{ownedref::OwnedSlice, HasLen}, bolts::{ownedref::OwnedSlice, HasLen},
inputs::{HasBytesVec, HasTargetBytes, Input}, inputs::{HasBytesVec, HasTargetBytes, Input},

View File

@ -1,9 +1,8 @@
//! The gramatron grammar fuzzer //! The gramatron grammar fuzzer
use ahash::AHasher;
use core::hash::Hasher;
use alloc::{rc::Rc, string::String, vec::Vec}; 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 serde::{Deserialize, Serialize};
use crate::{bolts::HasLen, inputs::Input, Error}; use crate::{bolts::HasLen, inputs::Input, Error};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,14 +1,6 @@
//! Monitor based on tui-rs //! Monitor based on tui-rs
use crossterm::{ use alloc::boxed::Box;
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 std::{ use std::{
collections::VecDeque, collections::VecDeque,
fmt::Write, fmt::Write,
@ -21,16 +13,22 @@ use std::{
vec::Vec, 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")] #[cfg(feature = "introspection")]
use super::{ClientPerfMonitor, PerfFeature}; use super::{ClientPerfMonitor, PerfFeature};
use crate::{ use crate::{
bolts::{current_time, format_duration_hms}, bolts::{current_time, format_duration_hms},
monitors::{ClientStats, Monitor, UserStats}, monitors::{ClientStats, Monitor, UserStats},
}; };
use alloc::boxed::Box;
mod ui; mod ui;
use ui::TuiUI; 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 alloc::vec::Vec;
use std::{
cmp::{max, min},
sync::{Arc, RwLock},
};
use tui::{ use tui::{
backend::Backend, backend::Backend,
layout::{Alignment, Constraint, Direction, Layout, Rect}, layout::{Alignment, Constraint, Direction, Layout, Rect},
@ -13,10 +16,7 @@ use tui::{
Frame, Frame,
}; };
use std::{ use super::{current_time, format_duration_hms, Duration, String, TimedStats, TuiContext};
cmp::{max, min},
sync::{Arc, RwLock},
};
#[derive(Default)] #[derive(Default)]
pub struct TuiUI { pub struct TuiUI {

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