Renamed Stats to Monitors (#373)

* renamed stats to monitors

* added depreciation notices

* resorted generics alphaabetically

* added monitors

* fmt fuzzers

* added depreciation note for usermonitor

* fmt all fuzzers script

* more fmt

* renamed some monitor things back to stats

* fixed rename
This commit is contained in:
Dominik Maier 2021-11-12 11:01:08 +01:00 committed by GitHub
parent 9ab8663366
commit 62afed61e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 488 additions and 441 deletions

View File

@ -2,7 +2,7 @@
- [ ] Objective-Specific Corpuses (named per objective)
- [ ] Good documentation
- [ ] More informative outpus, deeper introspection (stats, what mutation did x, etc.)
- [ ] More informative outpus, deeper introspection (monitor, what mutation did x, etc.)
- [ ] Timeout handling for llmp clients (no ping for n seconds -> treat as disconnected)
- [ ] Heap for signal handling (bumpallo or llmp directly?)
- [x] Frida support for Windows

View File

@ -121,15 +121,15 @@ As the second parameter, it takes an instance of something implementing the Corp
We will discuss the last parameter later. The third parameter is another corpus, in this case, to store the testcases that are considered as "solutions" for the fuzzer. For our purpose, the solution is the input that triggers the panic. In this case, we want to store it to disk under the `crashes` directory, so we can inspect it.
Another required component is the EventManager. It handles some events such as the addition of a testcase to the corpus during the fuzzing process. For our purpose, we use the simplest one that just displays the information about these events to the user using a Stats instance.
Another required component is the EventManager. It handles some events such as the addition of a testcase to the corpus during the fuzzing process. For our purpose, we use the simplest one that just displays the information about these events to the user using a `Monitor` instance.
```rust,ignore
// The Stats trait define how the fuzzer stats are reported to the user
let stats = SimpleStats::new(|s| println!("{}", s));
// The Monitor trait defines how the fuzzer stats are displayed to the user
let mon = SimpleMonitor::new(|s| println!("{}", s));
// The event manager handle the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mut mgr = SimpleEventManager::new(stats);
let mut mgr = SimpleEventManager::new(mon);
```
In addition, we have the Fuzzer, an entity that contains some actions that alter the State. One of these actions is the scheduling of the testcases to the fuzzer using a CorpusScheduler.
@ -190,8 +190,8 @@ use libafl::{
fuzzer::StdFuzzer,
generators::RandPrintablesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
state::StdState,
stats::SimpleStats,
};
```

View File

@ -27,7 +27,7 @@ An example may look like this:
Launcher::builder()
.configuration(EventConfig::from_name(&configuration))
.shmem_provider(shmem_provider)
.stats(stats)
.monitor(mon)
.run_client(&mut run_client)
.cores(cores)
.broker_port(broker_port)

View File

@ -12,11 +12,11 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
generators::RandPrintablesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
observers::StdMapObserver,
stages::mutational::StdMutationalStage,
state::StdState,
stats::SimpleStats,
};
/// Coverage map with explicit assignments due to the lack of instrumentation
@ -82,12 +82,12 @@ pub fn main() {
tuple_list!(feedback_state),
);
// The Stats trait define how the fuzzer stats are reported to the user
let stats = SimpleStats::new(|s| println!("{}", s));
// The Monitor trait define how the fuzzer stats are displayed to the user
let mon = SimpleMonitor::new(|s| println!("{}", s));
// The event manager handle the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mut mgr = SimpleEventManager::new(stats);
let mut mgr = SimpleEventManager::new(mon);
// A queue policy to get testcasess from the corpus
let scheduler = QueueCorpusScheduler::new();

View File

@ -17,6 +17,7 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
generators::{Automaton, GramatronGenerator},
inputs::GramatronInput,
monitors::SimpleMonitor,
mutators::{
GramatronRandomMutator, GramatronRecursionMutator, GramatronSpliceMutator,
StdScheduledMutator,
@ -24,7 +25,6 @@ use libafl::{
observers::StdMapObserver,
stages::mutational::StdMutationalStage,
state::StdState,
stats::SimpleStats,
};
/// Coverage map with explicit assignments due to the lack of instrumentation
@ -83,12 +83,12 @@ pub fn main() {
tuple_list!(feedback_state),
);
// The Stats trait define how the fuzzer stats are reported to the user
let stats = SimpleStats::new(|s| println!("{}", s));
// The Monitor trait define how the fuzzer stats are reported to the user
let monitor = SimpleMonitor::new(|s| println!("{}", s));
// The event manager handle the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mut mgr = SimpleEventManager::new(stats);
let mut mgr = SimpleEventManager::new(monitor);
// A queue policy to get testcasess from the corpus
let scheduler = QueueCorpusScheduler::new();

View File

@ -15,13 +15,13 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
generators::{NautilusContext, NautilusGenerator},
inputs::NautilusInput,
monitors::SimpleMonitor,
mutators::{
NautilusRandomMutator, NautilusRecursionMutator, NautilusSpliceMutator, StdScheduledMutator,
},
observers::StdMapObserver,
stages::mutational::StdMutationalStage,
state::{HasMetadata, StdState},
stats::SimpleStats,
};
/// Coverage map with explicit assignments due to the lack of instrumentation
@ -80,12 +80,12 @@ pub fn main() {
state.add_metadata(NautilusChunksMetadata::new("/tmp/".into()));
}
// The Stats trait define how the fuzzer stats are reported to the user
let stats = SimpleStats::new(|s| println!("{}", s));
// The Monitor trait define how the fuzzer stats are reported to the user
let monitor = SimpleMonitor::new(|s| println!("{}", s));
// The event manager handle the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mut mgr = SimpleEventManager::new(stats);
let mut mgr = SimpleEventManager::new(monitor);
// A queue policy to get testcasess from the corpus
let scheduler = QueueCorpusScheduler::new();

View File

@ -12,11 +12,11 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback},
fuzzer::{Evaluator, Fuzzer, StdFuzzer},
inputs::{EncodedInput, InputDecoder, InputEncoder, NaiveTokenizer, TokenInputEncoderDecoder},
monitors::SimpleMonitor,
mutators::{encoded_mutations::encoded_mutations, scheduled::StdScheduledMutator},
observers::StdMapObserver,
stages::mutational::StdMutationalStage,
state::StdState,
stats::SimpleStats,
};
/// Coverage map with explicit assignments due to the lack of instrumentation
@ -91,12 +91,12 @@ pub fn main() {
tuple_list!(feedback_state),
);
// The Stats trait define how the fuzzer stats are reported to the user
let stats = SimpleStats::new(|s| println!("{}", s));
// The Monitor trait define how the fuzzer stats are reported to the user
let monitor = SimpleMonitor::new(|s| println!("{}", s));
// The event manager handle the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mut mgr = SimpleEventManager::new(stats);
let mut mgr = SimpleEventManager::new(monitor);
// A queue policy to get testcasess from the corpus
let scheduler = QueueCorpusScheduler::new();

View File

@ -13,11 +13,11 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
generators::RandPrintablesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
observers::StdMapObserver,
stages::mutational::StdMutationalStage,
state::StdState,
stats::SimpleStats,
};
#[cfg(any(windows, unix))]
@ -99,8 +99,8 @@ pub fn main() {
tuple_list!(feedback_state),
);
// The Stats trait define how the fuzzer stats are reported to the user
let stats = SimpleStats::new(|s| {
// The Monitor trait define how the fuzzer stats are reported to the user
let monitor = SimpleMonitor::new(|s| {
// TODO: Print `s` here, if your target permits it.
#[cfg(any(windows, unix))]
unsafe {
@ -113,7 +113,7 @@ pub fn main() {
// The event manager handle the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mut mgr = SimpleEventManager::new(stats);
let mut mgr = SimpleEventManager::new(monitor);
// A queue policy to get testcasess from the corpus
let scheduler = QueueCorpusScheduler::new();

View File

@ -16,11 +16,11 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback},
fuzzer::{Fuzzer, StdFuzzer},
inputs::BytesInput,
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
observers::{ConstMapObserver, HitcountsMapObserver, TimeObserver},
stages::mutational::StdMutationalStage,
state::{HasCorpus, StdState},
stats::SimpleStats,
};
use std::path::PathBuf;
@ -83,12 +83,12 @@ pub fn main() {
tuple_list!(feedback_state, objective_state),
);
// The Stats trait define how the fuzzer stats are reported to the user
let stats = SimpleStats::new(|s| println!("{}", s));
// The Monitor trait define how the fuzzer stats are reported to the user
let monitor = SimpleMonitor::new(|s| println!("{}", s));
// The event manager handle the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mut mgr = SimpleEventManager::new(stats);
let mut mgr = SimpleEventManager::new(monitor);
// A minimization+queue policy to get testcasess from the corpus
let scheduler = IndexesLenTimeMinimizerCorpusScheduler::new(QueueCorpusScheduler::new());

View File

@ -25,6 +25,7 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback, TimeoutFeedback},
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes, Input},
monitors::MultiMonitor,
mutators::{
scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::I2SRandReplace,
@ -33,7 +34,6 @@ use libafl::{
observers::{HitcountsMapObserver, ObserversTuple, StdMapObserver, TimeObserver},
stages::{ShadowTracingStage, StdMutationalStage},
state::{HasCorpus, HasMetadata, StdState},
stats::MultiStats,
Error,
};
@ -277,7 +277,7 @@ unsafe fn fuzz(
configuration: String,
) -> Result<(), Error> {
// 'While the stats are state, they are usually used in the broker - which is likely never restarted
let stats = MultiStats::new(|s| println!("{}", s));
let monitor = MultiMonitor::new(|s| println!("{}", s));
let shmem_provider = StdShMemProvider::new()?;
@ -458,7 +458,7 @@ unsafe fn fuzz(
Launcher::builder()
.configuration(EventConfig::from_name(&configuration))
.shmem_provider(shmem_provider)
.stats(stats)
.monitor(monitor)
.run_client(&mut run_client)
.cores(cores)
.broker_port(broker_port)

View File

@ -29,6 +29,7 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback},
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::{
scheduled::{havoc_mutations, StdScheduledMutator},
token_mutations::I2SRandReplace,
@ -37,7 +38,6 @@ use libafl::{
observers::{StdMapObserver, TimeObserver},
stages::{StdMutationalStage, TracingStage},
state::{HasCorpus, HasMetadata, StdState},
stats::SimpleStats,
Error,
};
use libafl_targets::{
@ -171,7 +171,7 @@ fn fuzz(
let file_null = File::open("/dev/null")?;
// 'While the stats are state, they are usually used in the broker - which is likely never restarted
let stats = SimpleStats::new(|s| {
let monitor = SimpleMonitor::new(|s| {
#[cfg(unix)]
writeln!(&mut stdout_cpy, "{}", s).unwrap();
#[cfg(windows)]
@ -183,7 +183,8 @@ fn fuzz(
// This way, we are able to continue fuzzing afterwards.
let mut shmem_provider = StdShMemProvider::new()?;
let (state, mut mgr) = match SimpleRestartingEventManager::launch(stats, &mut shmem_provider) {
let (state, mut mgr) = match SimpleRestartingEventManager::launch(monitor, &mut shmem_provider)
{
// The restarting state will spawn the same process again as child, then restarted it each time it crashes.
Ok(res) => res,
Err(err) => match err {

View File

@ -31,6 +31,7 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback},
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::{
scheduled::havoc_mutations, token_mutations::I2SRandReplace, tokens_mutations,
StdMOptMutator, Tokens,
@ -42,7 +43,6 @@ use libafl::{
TracingStage,
},
state::{HasCorpus, HasMetadata, StdState},
stats::SimpleStats,
Error,
};
use libafl_targets::{
@ -175,8 +175,8 @@ fn fuzz(
#[cfg(unix)]
let file_null = File::open("/dev/null")?;
// 'While the stats are state, they are usually used in the broker - which is likely never restarted
let stats = SimpleStats::new(|s| {
// 'While the monitor are state, they are usually used in the broker - which is likely never restarted
let monitor = SimpleMonitor::new(|s| {
#[cfg(unix)]
writeln!(&mut stdout_cpy, "{}", s).unwrap();
#[cfg(windows)]
@ -188,7 +188,8 @@ fn fuzz(
// This way, we are able to continue fuzzing afterwards.
let mut shmem_provider = StdShMemProvider::new()?;
let (state, mut mgr) = match SimpleRestartingEventManager::launch(stats, &mut shmem_provider) {
let (state, mut mgr) = match SimpleRestartingEventManager::launch(monitor, &mut shmem_provider)
{
// The restarting state will spawn the same process again as child, then restarted it each time it crashes.
Ok(res) => res,
Err(err) => match err {

View File

@ -29,6 +29,7 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback, TimeoutFeedback},
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::{
scheduled::{havoc_mutations, StdScheduledMutator},
tokens_mutations, I2SRandReplace, Tokens,
@ -36,7 +37,6 @@ use libafl::{
observers::{HitcountsMapObserver, TimeObserver, VariableMapObserver},
stages::{ShadowTracingStage, StdMutationalStage},
state::{HasCorpus, HasMetadata, StdState},
stats::SimpleStats,
Error,
};
use libafl_qemu::{
@ -205,7 +205,7 @@ fn fuzz(
let file_null = File::open("/dev/null")?;
// 'While the stats are state, they are usually used in the broker - which is likely never restarted
let stats = SimpleStats::new(|s| {
let monitor = SimpleMonitor::new(|s| {
#[cfg(unix)]
writeln!(&mut stdout_cpy, "{}", s).unwrap();
#[cfg(windows)]
@ -215,7 +215,8 @@ fn fuzz(
let mut shmem_provider = StdShMemProvider::new()?;
let (state, mut mgr) = match SimpleRestartingEventManager::launch(stats, &mut shmem_provider) {
let (state, mut mgr) = match SimpleRestartingEventManager::launch(monitor, &mut shmem_provider)
{
// The restarting state will spawn the same process again as child, then restarted it each time it crashes.
Ok(res) => res,
Err(err) => match err {

View File

@ -25,12 +25,12 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
generators::RandBytesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::{I2SRandReplace, Tokens},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
stages::{StdMutationalStage, TracingStage},
state::{HasCorpus, HasMetadata, StdState},
stats::MultiStats,
Error,
};
@ -82,7 +82,7 @@ pub fn libafl_main() {
let shmem_provider = StdShMemProvider::new().expect("Failed to init shared memory");
let stats = MultiStats::new(|s| println!("{}", s));
let monitor = MultiMonitor::new(|s| println!("{}", s));
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr, _core_id| {
// Create an observation channel using the coverage map
@ -234,7 +234,7 @@ pub fn libafl_main() {
match Launcher::builder()
.shmem_provider(shmem_provider)
.configuration(EventConfig::from_name("default"))
.stats(stats)
.monitor(monitor)
.run_client(&mut run_client)
.cores(&cores)
.broker_port(broker_port)

View File

@ -31,12 +31,12 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
generators::RandBytesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::{I2SRandReplace, Tokens},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
stages::{StdMutationalStage, TracingStage},
state::{HasCorpus, HasMetadata, StdState},
stats::MultiStats,
Error,
};
use libafl_targets::{
@ -210,7 +210,7 @@ pub fn LLVMFuzzerRunDriver(
let shmem_provider = StdShMemProvider::new().expect("Failed to init shared memory");
let stats = MultiStats::new(|s| println!("{}", s));
let monitor = MultiMonitor::new(|s| println!("{}", s));
// TODO: we need to handle Atheris calls to `exit` on errors somhow.
@ -359,7 +359,7 @@ pub fn LLVMFuzzerRunDriver(
match Launcher::builder()
.shmem_provider(shmem_provider)
.configuration(EventConfig::from_name("default"))
.stats(stats)
.monitor(monitor)
.run_client(&mut run_client)
.cores(&cores)
.broker_port(broker_port)

View File

@ -16,12 +16,12 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback},
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::Tokens,
observers::StdMapObserver,
stages::mutational::StdMutationalStage,
state::{HasCorpus, HasMetadata, StdState},
stats::SimpleStats,
Error,
};
@ -56,11 +56,11 @@ pub fn libafl_main() {
/// The actual fuzzer
fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Result<(), Error> {
// 'While the stats are state, they are usually used in the broker - which is likely never restarted
let stats = SimpleStats::new(|s| println!("{}", s));
let monitor = SimpleMonitor::new(|s| println!("{}", s));
// The restarting state will spawn the same process again as child, then restarted it each time it crashes.
let (state, mut restarting_mgr) =
match setup_restarting_mgr_std(stats, broker_port, EventConfig::from_name("default")) {
match setup_restarting_mgr_std(monitor, broker_port, EventConfig::from_name("default")) {
Ok(tuple) => tuple,
Err(Error::ShuttingDown) => {
println!("\nFinished fuzzing. Good bye.");

View File

@ -20,6 +20,7 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback, TimeoutFeedback},
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::Tokens,
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
@ -28,7 +29,6 @@ use libafl::{
power::{PowerMutationalStage, PowerSchedule},
},
state::{HasCorpus, HasMetadata, StdState},
stats::MultiStats,
Error,
};
@ -57,11 +57,11 @@ pub fn libafl_main() {
/// The actual fuzzer
fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Result<(), Error> {
// 'While the stats are state, they are usually used in the broker - which is likely never restarted
let stats = MultiStats::new(|s| println!("{}", s));
let monitor = MultiMonitor::new(|s| println!("{}", s));
// The restarting state will spawn the same process again as child, then restarted it each time it crashes.
let (state, mut restarting_mgr) =
match setup_restarting_mgr_std(stats, broker_port, EventConfig::AlwaysUnique) {
match setup_restarting_mgr_std(monitor, broker_port, EventConfig::AlwaysUnique) {
Ok(res) => res,
Err(err) => match err {
Error::ShuttingDown => {

View File

@ -26,12 +26,12 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback, TimeoutFeedback},
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::Tokens,
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
stages::mutational::StdMutationalStage,
state::{HasCorpus, HasMetadata, StdState},
stats::MultiStats,
Error,
};
@ -58,7 +58,7 @@ pub fn libafl_main() {
let shmem_provider = StdShMemProvider::new().expect("Failed to init shared memory");
let stats = MultiStats::new(|s| println!("{}", s));
let monitor = MultiMonitor::new(|s| println!("{}", s));
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut restarting_mgr, _core_id| {
let corpus_dirs = &[PathBuf::from("./corpus")];
@ -168,7 +168,7 @@ pub fn libafl_main() {
match Launcher::builder()
.shmem_provider(shmem_provider)
.configuration(EventConfig::from_name("default"))
.stats(stats)
.monitor(monitor)
.run_client(&mut run_client)
.cores(&cores)
.broker_port(broker_port)

View File

@ -11,11 +11,11 @@ use libafl::{
feedbacks::{MapFeedbackState, MaxMapFeedback, ReachabilityFeedback},
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
observers::{HitcountsMapObserver, StdMapObserver},
stages::mutational::StdMutationalStage,
state::{HasCorpus, StdState},
stats::SimpleStats,
Error,
};
use libafl_targets::{libfuzzer_initialize, libfuzzer_test_one_input, EDGES_MAP, MAX_EDGES_NUM};
@ -48,11 +48,11 @@ pub fn libafl_main() {
/// The actual fuzzer
fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Result<(), Error> {
// 'While the stats are state, they are usually used in the broker - which is likely never restarted
let stats = SimpleStats::new(|s| println!("{}", s));
let monitor = SimpleMonitor::new(|s| println!("{}", s));
// The restarting state will spawn the same process again as child, then restarted it each time it crashes.
let (state, mut restarting_mgr) =
match setup_restarting_mgr_std(stats, broker_port, EventConfig::AlwaysUnique) {
match setup_restarting_mgr_std(monitor, broker_port, EventConfig::AlwaysUnique) {
Ok(res) => res,
Err(err) => match err {
Error::ShuttingDown => {

View File

@ -15,12 +15,12 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback},
fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
mutators::token_mutations::I2SRandReplace,
observers::{StdMapObserver, TimeObserver},
stages::{ShadowTracingStage, StdMutationalStage},
state::{HasCorpus, StdState},
stats::MultiStats,
Error,
};
@ -49,11 +49,11 @@ pub fn main() {
/// The actual fuzzer
fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Result<(), Error> {
// 'While the stats are state, they are usually used in the broker - which is likely never restarted
let stats = MultiStats::new(|s| println!("{}", s));
let monitor = MultiMonitor::new(|s| println!("{}", s));
// The restarting state will spawn the same process again as child, then restarted it each time it crashes.
let (state, mut restarting_mgr) =
match setup_restarting_mgr_std(stats, broker_port, EventConfig::from_name("default")) {
match setup_restarting_mgr_std(monitor, broker_port, EventConfig::from_name("default")) {
Ok(res) => res,
Err(err) => match err {
Error::ShuttingDown => {

View File

@ -38,7 +38,7 @@ use libafl::{
StdMutationalStage, TracingStage,
},
state::{HasCorpus, StdState},
stats::MultiStats,
monitors::MultiMonitor,
Error,
};
@ -84,11 +84,11 @@ fn fuzz(
concolic: bool,
) -> Result<(), Error> {
// 'While the stats are state, they are usually used in the broker - which is likely never restarted
let stats = MultiStats::new(|s| println!("{}", s));
let monitor = MultiMonitor::new(|s| println!("{}", s));
// The restarting state will spawn the same process again as child, then restarted it each time it crashes.
let (state, mut restarting_mgr) =
match setup_restarting_mgr_std(stats, broker_port, EventConfig::from_name("default")) {
match setup_restarting_mgr_std(monitor, broker_port, EventConfig::from_name("default")) {
Ok(res) => res,
Err(err) => match err {
Error::ShuttingDown => {

View File

@ -10,11 +10,11 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback},
fuzzer::{Fuzzer, StdFuzzer},
generators::RandPrintablesGenerator,
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
observers::StdMapObserver,
stages::mutational::StdMutationalStage,
state::StdState,
stats::SimpleStats,
};
use std::path::PathBuf;
@ -63,12 +63,12 @@ fn input_generator() {
tuple_list!(feedback_state),
);
// The Stats trait define how the fuzzer stats are reported to the user
let stats = SimpleStats::new(|s| println!("{}", s));
// The Monitor trait define how the fuzzer stats are reported to the user
let monitor = SimpleMonitor::new(|s| println!("{}", s));
// The event manager handle the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mut mgr = SimpleEventManager::new(stats);
let mut mgr = SimpleEventManager::new(monitor);
// A queue policy to get testcasess from the corpus
let scheduler = QueueCorpusScheduler::new();

View File

@ -17,11 +17,11 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback},
fuzzer::StdFuzzer,
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
observers::StdMapObserver,
stages::push::StdMutationalPushStage,
state::{HasCorpus, StdState},
stats::SimpleStats,
};
/// Coverage map with explicit assignments due to the lack of instrumentation
@ -60,12 +60,12 @@ pub fn main() {
tuple_list!(feedback_state),
);
// The Stats trait define how the fuzzer stats are reported to the user
let stats = SimpleStats::new(|s| println!("{}", s));
// The Monitor trait define how the fuzzer stats are reported to the user
let monitor = SimpleMonitor::new(|s| println!("{}", s));
// The event manager handle the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mgr = SimpleEventManager::new(stats);
let mgr = SimpleEventManager::new(monitor);
// A queue policy to get testcasess from the corpus
let scheduler = QueueCorpusScheduler::new();

View File

@ -15,13 +15,13 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback, TimeoutFeedback},
fuzzer::{Fuzzer, StdFuzzer},
inputs::HasTargetBytes,
monitors::MultiMonitor,
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
stages::{
calibrate::CalibrationStage,
power::{PowerMutationalStage, PowerSchedule},
},
state::{HasCorpus, StdState},
stats::MultiStats,
Error,
};
@ -67,11 +67,11 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
};
// 'While the stats are state, they are usually used in the broker - which is likely never restarted
let stats = MultiStats::new(|s| println!("{}", s));
let monitor = MultiMonitor::new(|s| println!("{}", s));
// The restarting state will spawn the same process again as child, then restarted it each time it crashes.
let (state, mut restarting_mgr) =
match setup_restarting_mgr_std(stats, broker_port, EventConfig::AlwaysUnique) {
match setup_restarting_mgr_std(monitor, broker_port, EventConfig::AlwaysUnique) {
Ok(res) => res,
Err(err) => match err {
Error::ShuttingDown => {

View File

@ -5,7 +5,7 @@ use libafl::{
executors::ExitKind,
feedbacks::{Feedback, MapIndexesMetadata},
observers::ObserversTuple,
state::{HasClientPerfStats, HasMetadata},
state::{HasClientPerfMonitor, HasMetadata},
Error, SerdeAny,
};
@ -39,7 +39,7 @@ pub struct PacketLenFeedback {
impl<S> Feedback<PacketData, S> for PacketLenFeedback
where
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn is_interesting<EM, OT>(
&mut self,

View File

@ -19,8 +19,8 @@ use crate::{
bolts::shmem::ShMemProvider,
events::{EventConfig, LlmpRestartingEventManager, ManagerKind, RestartingMgr},
inputs::Input,
monitors::Monitor,
observers::ObserversTuple,
stats::Stats,
Error,
};
@ -45,19 +45,19 @@ const _AFL_LAUNCHER_CLIENT: &str = "AFL_LAUNCHER_CLIENT";
#[cfg(feature = "std")]
#[derive(TypedBuilder)]
#[allow(clippy::type_complexity)]
pub struct Launcher<'a, CF, I, OT, S, SP, ST>
pub struct Launcher<'a, CF, I, MT, OT, S, SP>
where
CF: FnOnce(Option<S>, LlmpRestartingEventManager<I, OT, S, SP>, usize) -> Result<(), Error>,
I: Input + 'a,
ST: Stats,
MT: Monitor,
SP: ShMemProvider + 'static,
OT: ObserversTuple<I, S> + 'a,
S: DeserializeOwned + 'a,
{
/// The ShmemProvider to use
shmem_provider: SP,
/// The stats instance to use
stats: ST,
/// The monitor instance to use
monitor: MT,
/// The configuration
configuration: EventConfig,
/// The 'main' function to run for each client forked. This probably shouldn't return
@ -86,12 +86,12 @@ where
}
#[cfg(feature = "std")]
impl<'a, CF, I, OT, S, SP, ST> Launcher<'a, CF, I, OT, S, SP, ST>
impl<'a, CF, I, MT, OT, S, SP> Launcher<'a, CF, I, MT, OT, S, SP>
where
CF: FnOnce(Option<S>, LlmpRestartingEventManager<I, OT, S, SP>, usize) -> Result<(), Error>,
I: Input,
OT: ObserversTuple<I, S> + serde::de::DeserializeOwned,
ST: Stats + Clone,
MT: Monitor + Clone,
SP: ShMemProvider + 'static,
S: DeserializeOwned,
{
@ -138,7 +138,7 @@ where
dup2(file.as_raw_fd(), libc::STDERR_FILENO)?;
}
// Fuzzer client. keeps retrying the connection to broker till the broker starts
let (state, mgr) = RestartingMgr::<I, OT, S, SP, ST>::builder()
let (state, mgr) = RestartingMgr::<I, MT, OT, S, SP>::builder()
.shmem_provider(self.shmem_provider.clone())
.broker_port(self.broker_port)
.kind(ManagerKind::Client {
@ -161,9 +161,9 @@ where
println!("I am broker!!.");
// TODO we don't want always a broker here, think about using different laucher process to spawn different configurations
RestartingMgr::<I, OT, S, SP, ST>::builder()
RestartingMgr::<I, MT, OT, S, SP>::builder()
.shmem_provider(self.shmem_provider.clone())
.stats(Some(self.stats.clone()))
.monitor(Some(self.monitor.clone()))
.broker_port(self.broker_port)
.kind(ManagerKind::Broker)
.remote_broker_addr(self.remote_broker_addr)
@ -206,7 +206,7 @@ where
//todo: silence stdout and stderr for clients
// the actual client. do the fuzzing
let (state, mgr) = RestartingMgr::<I, OT, S, SP, ST>::builder()
let (state, mgr) = RestartingMgr::<I, MT, OT, S, SP>::builder()
.shmem_provider(self.shmem_provider.clone())
.broker_port(self.broker_port)
.kind(ManagerKind::Client {
@ -259,9 +259,9 @@ where
#[cfg(feature = "std")]
println!("I am broker!!.");
RestartingMgr::<I, OT, S, SP, ST>::builder()
RestartingMgr::<I, MT, OT, S, SP>::builder()
.shmem_provider(self.shmem_provider.clone())
.stats(Some(self.stats.clone()))
.monitor(Some(self.monitor.clone()))
.broker_port(self.broker_port)
.kind(ManagerKind::Broker)
.remote_broker_addr(self.remote_broker_addr)

View File

@ -31,8 +31,8 @@ use crate::{
executors::{Executor, HasObservers},
fuzzer::{EvaluatorObservers, ExecutionProcessor},
inputs::Input,
monitors::Monitor,
observers::ObserversTuple,
stats::Stats,
Error,
};
@ -66,30 +66,30 @@ const _LLMP_TAG_NO_RESTART: llmp::Tag = 0x57A7EE71;
const COMPRESS_THRESHOLD: usize = 1024;
#[derive(Debug)]
pub struct LlmpEventBroker<I, SP, ST>
pub struct LlmpEventBroker<I, MT, SP>
where
I: Input,
SP: ShMemProvider + 'static,
ST: Stats,
MT: Monitor,
//CE: CustomEvent<I>,
{
stats: ST,
monitor: MT,
llmp: llmp::LlmpBroker<SP>,
#[cfg(feature = "llmp_compression")]
compressor: GzipCompressor,
phantom: PhantomData<I>,
}
impl<I, SP, ST> LlmpEventBroker<I, SP, ST>
impl<I, MT, SP> LlmpEventBroker<I, MT, SP>
where
I: Input,
SP: ShMemProvider + 'static,
ST: Stats,
MT: Monitor,
{
/// Create an even broker from a raw broker.
pub fn new(llmp: llmp::LlmpBroker<SP>, stats: ST) -> Result<Self, Error> {
pub fn new(llmp: llmp::LlmpBroker<SP>, monitor: MT) -> Result<Self, Error> {
Ok(Self {
stats,
monitor,
llmp,
#[cfg(feature = "llmp_compression")]
compressor: GzipCompressor::new(COMPRESS_THRESHOLD),
@ -100,9 +100,9 @@ where
/// Create llmp on a port
/// The port must not be bound yet to have a broker.
#[cfg(feature = "std")]
pub fn new_on_port(shmem_provider: SP, stats: ST, port: u16) -> Result<Self, Error> {
pub fn new_on_port(shmem_provider: SP, monitor: MT, port: u16) -> Result<Self, Error> {
Ok(Self {
stats,
monitor,
llmp: llmp::LlmpBroker::create_attach_to_tcp(shmem_provider, port)?,
#[cfg(feature = "llmp_compression")]
compressor: GzipCompressor::new(COMPRESS_THRESHOLD),
@ -120,7 +120,7 @@ where
/// Run forever in the broker
pub fn broker_loop(&mut self) -> Result<(), Error> {
let stats = &mut self.stats;
let monitor = &mut self.monitor;
#[cfg(feature = "llmp_compression")]
let compressor = &self.compressor;
self.llmp.loop_forever(
@ -138,7 +138,7 @@ where
msg
};
let event: Event<I> = postcard::from_bytes(event_bytes)?;
match Self::handle_in_broker(stats, client_id, &event)? {
match Self::handle_in_broker(monitor, client_id, &event)? {
BrokerEventResult::Forward => Ok(llmp::LlmpMsgHookResult::ForwardToClients),
BrokerEventResult::Handled => Ok(llmp::LlmpMsgHookResult::Handled),
}
@ -155,7 +155,7 @@ where
/// Handle arriving events in the broker
#[allow(clippy::unnecessary_wraps)]
fn handle_in_broker(
stats: &mut ST,
monitor: &mut MT,
client_id: u32,
event: &Event<I>,
) -> Result<BrokerEventResult, Error> {
@ -169,21 +169,21 @@ where
time,
executions,
} => {
let client = stats.client_stats_mut_for(client_id);
let client = monitor.client_stats_mut_for(client_id);
client.update_corpus_size(*corpus_size as u64);
client.update_executions(*executions as u64, *time);
stats.display(event.name().to_string(), client_id);
monitor.display(event.name().to_string(), client_id);
Ok(BrokerEventResult::Forward)
}
Event::UpdateStats {
Event::UpdateExecutions {
time,
executions,
phantom: _,
} => {
// TODO: The stats buffer should be added on client add.
let client = stats.client_stats_mut_for(client_id);
// TODO: The monitor buffer should be added on client add.
let client = monitor.client_stats_mut_for(client_id);
client.update_executions(*executions as u64, *time);
stats.display(event.name().to_string(), client_id);
monitor.display(event.name().to_string(), client_id);
Ok(BrokerEventResult::Handled)
}
Event::UpdateUserStats {
@ -191,39 +191,39 @@ where
value,
phantom: _,
} => {
let client = stats.client_stats_mut_for(client_id);
let client = monitor.client_stats_mut_for(client_id);
client.update_user_stats(name.clone(), value.clone());
stats.display(event.name().to_string(), client_id);
monitor.display(event.name().to_string(), client_id);
Ok(BrokerEventResult::Handled)
}
#[cfg(feature = "introspection")]
Event::UpdatePerfStats {
Event::UpdatePerfMonitor {
time,
executions,
introspection_stats,
introspection_monitor,
phantom: _,
} => {
// TODO: The stats buffer should be added on client add.
// TODO: The monitor buffer should be added on client add.
// Get the client for the staterestorer ID
let client = stats.client_stats_mut_for(client_id);
let client = monitor.client_stats_mut_for(client_id);
// Update the normal stats for this client
// Update the normal monitor for this client
client.update_executions(*executions as u64, *time);
// Update the performance stats for this client
client.update_introspection_stats((**introspection_stats).clone());
// Update the performance monitor for this client
client.update_introspection_monitor((**introspection_monitor).clone());
// Display the stats via `.display` only on core #1
stats.display(event.name().to_string(), client_id);
// Display the monitor via `.display` only on core #1
monitor.display(event.name().to_string(), client_id);
// Correctly handled the event
Ok(BrokerEventResult::Handled)
}
Event::Objective { objective_size } => {
let client = stats.client_stats_mut_for(client_id);
let client = monitor.client_stats_mut_for(client_id);
client.update_objective_size(*objective_size as u64);
stats.display(event.name().to_string(), client_id);
monitor.display(event.name().to_string(), client_id);
Ok(BrokerEventResult::Handled)
}
Event::Log {
@ -232,7 +232,7 @@ where
phantom: _,
} => {
let (_, _) = (severity_level, message);
// TODO rely on Stats
// TODO rely on Monitor
#[cfg(feature = "std")]
println!("[LOG {}]: {}", severity_level, message);
Ok(BrokerEventResult::Handled)
@ -672,8 +672,8 @@ pub enum ManagerKind {
/// The restarter will spawn a new process each time the child crashes or timeouts.
#[cfg(feature = "std")]
#[allow(clippy::type_complexity)]
pub fn setup_restarting_mgr_std<I, OT, S, ST>(
stats: ST,
pub fn setup_restarting_mgr_std<I, MT, OT, S>(
monitor: MT,
broker_port: u16,
configuration: EventConfig,
) -> Result<
@ -686,13 +686,13 @@ pub fn setup_restarting_mgr_std<I, OT, S, ST>(
where
I: Input,
S: DeserializeOwned,
ST: Stats + Clone,
MT: Monitor + Clone,
OT: ObserversTuple<I, S> + serde::de::DeserializeOwned,
S: DeserializeOwned,
{
RestartingMgr::builder()
.shmem_provider(StdShMemProvider::new()?)
.stats(Some(stats))
.monitor(Some(monitor))
.broker_port(broker_port)
.configuration(configuration)
.build()
@ -705,13 +705,13 @@ where
#[cfg(feature = "std")]
#[allow(clippy::default_trait_access)]
#[derive(TypedBuilder, Debug)]
pub struct RestartingMgr<I, OT, S, SP, ST>
pub struct RestartingMgr<I, MT, OT, S, SP>
where
I: Input,
OT: ObserversTuple<I, S> + serde::de::DeserializeOwned,
S: DeserializeOwned,
SP: ShMemProvider + 'static,
ST: Stats,
MT: Monitor,
//CE: CustomEvent<I>,
{
/// The shared memory provider to use for the broker or client spawned by the restarting
@ -719,9 +719,9 @@ where
shmem_provider: SP,
/// The configuration
configuration: EventConfig,
/// The stats to use
/// The monitor to use
#[builder(default = None)]
stats: Option<ST>,
monitor: Option<MT>,
/// The broker port to use
#[builder(default = 1337_u16)]
broker_port: u16,
@ -737,13 +737,13 @@ where
#[cfg(feature = "std")]
#[allow(clippy::type_complexity, clippy::too_many_lines)]
impl<I, OT, S, SP, ST> RestartingMgr<I, OT, S, SP, ST>
impl<I, MT, OT, S, SP> RestartingMgr<I, MT, OT, S, SP>
where
I: Input,
OT: ObserversTuple<I, S> + serde::de::DeserializeOwned,
S: DeserializeOwned,
SP: ShMemProvider,
ST: Stats + Clone,
MT: Monitor + Clone,
{
/// Launch the restarting manager
pub fn launch(
@ -753,7 +753,7 @@ where
let (staterestorer, new_shmem_provider, core_id) = if std::env::var(_ENV_FUZZER_SENDER)
.is_err()
{
let broker_things = |mut broker: LlmpEventBroker<I, SP, ST>, remote_broker_addr| {
let broker_things = |mut broker: LlmpEventBroker<I, MT, SP>, remote_broker_addr| {
if let Some(remote_broker_addr) = remote_broker_addr {
println!("B2b: Connecting to {:?}", &remote_broker_addr);
broker.connect_b2b(remote_broker_addr)?;
@ -769,9 +769,9 @@ where
LlmpConnection::on_port(self.shmem_provider.clone(), self.broker_port)?;
match connection {
LlmpConnection::IsBroker { broker } => {
let event_broker = LlmpEventBroker::<I, SP, ST>::new(
let event_broker = LlmpEventBroker::<I, MT, SP>::new(
broker,
self.stats.take().unwrap(),
self.monitor.take().unwrap(),
)?;
// Yep, broker. Just loop here.
@ -791,9 +791,9 @@ where
}
}
ManagerKind::Broker => {
let event_broker = LlmpEventBroker::<I, SP, ST>::new_on_port(
let event_broker = LlmpEventBroker::<I, MT, SP>::new_on_port(
self.shmem_provider.clone(),
self.stats.take().unwrap(),
self.monitor.take().unwrap(),
self.broker_port,
)?;

View File

@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::{
executors::ExitKind, inputs::Input, observers::ObserversTuple, stats::UserStats, Error,
executors::ExitKind, inputs::Input, monitors::UserStats, observers::ObserversTuple, Error,
};
/// A per-fuzzer unique `ID`, usually starting with `0` and increasing
@ -26,7 +26,7 @@ pub struct EventManagerId {
}
#[cfg(feature = "introspection")]
use crate::stats::ClientPerfStats;
use crate::monitors::ClientPerfMonitor;
#[cfg(feature = "introspection")]
use alloc::boxed::Box;
@ -169,8 +169,8 @@ where
/// The executions of this client
executions: usize,
},
/// New stats.
UpdateStats {
/// New stats event to monitor.
UpdateExecutions {
/// The time of generation of the [`Event`]
time: Duration,
/// The executions of this client
@ -178,18 +178,18 @@ where
/// [`PhantomData`]
phantom: PhantomData<I>,
},
/// New stats.
/// New user stats event to monitor.
UpdateUserStats {
/// Custom user stats name
/// Custom user monitor name
name: String,
/// Custom user stats value
/// Custom user monitor value
value: UserStats,
/// [`PhantomData`]
phantom: PhantomData<I>,
},
/// New stats with performance stats.
/// New monitor with performance monitor.
#[cfg(feature = "introspection")]
UpdatePerfStats {
UpdatePerfMonitor {
/// The time of generation of the event
time: Duration,
@ -197,7 +197,7 @@ where
executions: usize,
/// Current performance statistics
introspection_stats: Box<ClientPerfStats>,
introspection_monitor: Box<ClientPerfMonitor>,
phantom: PhantomData<I>,
},
@ -237,7 +237,7 @@ where
time: _,
executions: _,
} => "Testcase",
Event::UpdateStats {
Event::UpdateExecutions {
time: _,
executions: _,
phantom: _,
@ -248,12 +248,12 @@ where
phantom: _,
} => "Stats",
#[cfg(feature = "introspection")]
Event::UpdatePerfStats {
Event::UpdatePerfMonitor {
time: _,
executions: _,
introspection_stats: _,
introspection_monitor: _,
phantom: _,
} => "PerfStats",
} => "PerfMonitor",
Event::Objective { objective_size: _ } => "Objective",
Event::Log {
severity_level: _,

View File

@ -6,7 +6,7 @@ use crate::{
EventRestarter, HasEventManagerId,
},
inputs::Input,
stats::Stats,
monitors::Monitor,
Error,
};
use alloc::{string::ToString, vec::Vec};
@ -37,24 +37,24 @@ const _ENV_FUZZER_BROKER_CLIENT_INITIAL: &str = "_AFL_ENV_FUZZER_BROKER_CLIENT";
/// A simple, single-threaded event manager that just logs
#[derive(Clone, Debug)]
pub struct SimpleEventManager<I, ST>
pub struct SimpleEventManager<I, MT>
where
I: Input,
ST: Stats, //CE: CustomEvent<I, OT>,
MT: Monitor, //CE: CustomEvent<I, OT>,
{
/// The stats
stats: ST,
/// The monitor
monitor: MT,
/// The events that happened since the last handle_in_broker
events: Vec<Event<I>>,
}
impl<I, S, ST> EventFirer<I, S> for SimpleEventManager<I, ST>
impl<I, MT, S> EventFirer<I, S> for SimpleEventManager<I, MT>
where
I: Input,
ST: Stats, //CE: CustomEvent<I, OT>,
MT: Monitor, //CE: CustomEvent<I, OT>,
{
fn fire(&mut self, _state: &mut S, event: Event<I>) -> Result<(), Error> {
match Self::handle_in_broker(&mut self.stats, &event)? {
match Self::handle_in_broker(&mut self.monitor, &event)? {
BrokerEventResult::Forward => self.events.push(event),
BrokerEventResult::Handled => (),
};
@ -62,17 +62,17 @@ where
}
}
impl<I, S, ST> EventRestarter<S> for SimpleEventManager<I, ST>
impl<I, MT, S> EventRestarter<S> for SimpleEventManager<I, MT>
where
I: Input,
ST: Stats, //CE: CustomEvent<I, OT>,
MT: Monitor, //CE: CustomEvent<I, OT>,
{
}
impl<E, I, S, ST, Z> EventProcessor<E, I, S, Z> for SimpleEventManager<I, ST>
impl<E, I, MT, S, Z> EventProcessor<E, I, S, Z> for SimpleEventManager<I, MT>
where
I: Input,
ST: Stats, //CE: CustomEvent<I, OT>,
MT: Monitor, //CE: CustomEvent<I, OT>,
{
fn process(
&mut self,
@ -89,39 +89,39 @@ where
}
}
impl<E, I, S, ST, Z> EventManager<E, I, S, Z> for SimpleEventManager<I, ST>
impl<E, I, MT, S, Z> EventManager<E, I, S, Z> for SimpleEventManager<I, MT>
where
I: Input,
ST: Stats, //CE: CustomEvent<I, OT>,
MT: Monitor, //CE: CustomEvent<I, OT>,
{
}
impl<I, ST> HasEventManagerId for SimpleEventManager<I, ST>
impl<I, MT> HasEventManagerId for SimpleEventManager<I, MT>
where
I: Input,
ST: Stats,
MT: Monitor,
{
fn mgr_id(&self) -> EventManagerId {
EventManagerId { id: 0 }
}
}
impl<I, ST> SimpleEventManager<I, ST>
impl<I, MT> SimpleEventManager<I, MT>
where
I: Input,
ST: Stats, //TODO CE: CustomEvent,
MT: Monitor, //TODO CE: CustomEvent,
{
/// Creates a new [`SimpleEventManager`].
pub fn new(stats: ST) -> Self {
pub fn new(monitor: MT) -> Self {
Self {
stats,
monitor,
events: vec![],
}
}
// Handle arriving events in the broker
#[allow(clippy::unnecessary_wraps)]
fn handle_in_broker(stats: &mut ST, event: &Event<I>) -> Result<BrokerEventResult, Error> {
fn handle_in_broker(monitor: &mut MT, event: &Event<I>) -> Result<BrokerEventResult, Error> {
match event {
Event::NewTestcase {
input: _,
@ -132,25 +132,25 @@ where
time,
executions,
} => {
stats
monitor
.client_stats_mut_for(0)
.update_corpus_size(*corpus_size as u64);
stats
monitor
.client_stats_mut_for(0)
.update_executions(*executions as u64, *time);
stats.display(event.name().to_string(), 0);
monitor.display(event.name().to_string(), 0);
Ok(BrokerEventResult::Handled)
}
Event::UpdateStats {
Event::UpdateExecutions {
time,
executions,
phantom: _,
} => {
// TODO: The stats buffer should be added on client add.
stats
// TODO: The monitor buffer should be added on client add.
monitor
.client_stats_mut_for(0)
.update_executions(*executions as u64, *time);
stats.display(event.name().to_string(), 0);
monitor.display(event.name().to_string(), 0);
Ok(BrokerEventResult::Handled)
}
Event::UpdateUserStats {
@ -158,31 +158,31 @@ where
value,
phantom: _,
} => {
stats
monitor
.client_stats_mut_for(0)
.update_user_stats(name.clone(), value.clone());
stats.display(event.name().to_string(), 0);
monitor.display(event.name().to_string(), 0);
Ok(BrokerEventResult::Handled)
}
#[cfg(feature = "introspection")]
Event::UpdatePerfStats {
Event::UpdatePerfMonitor {
time,
executions,
introspection_stats,
introspection_monitor,
phantom: _,
} => {
// TODO: The stats buffer should be added on client add.
stats.client_stats_mut()[0].update_executions(*executions as u64, *time);
stats.client_stats_mut()[0]
.update_introspection_stats((**introspection_stats).clone());
stats.display(event.name().to_string(), 0);
// TODO: The monitor buffer should be added on client add.
monitor.client_stats_mut()[0].update_executions(*executions as u64, *time);
monitor.client_stats_mut()[0]
.update_introspection_monitor((**introspection_monitor).clone());
monitor.display(event.name().to_string(), 0);
Ok(BrokerEventResult::Handled)
}
Event::Objective { objective_size } => {
stats
monitor
.client_stats_mut_for(0)
.update_objective_size(*objective_size as u64);
stats.display(event.name().to_string(), 0);
monitor.display(event.name().to_string(), 0);
Ok(BrokerEventResult::Handled)
}
Event::Log {
@ -213,16 +213,16 @@ where
/// `restarter` will start a new process each time the child crashes or times out.
#[cfg(feature = "std")]
#[allow(clippy::default_trait_access)]
pub struct SimpleRestartingEventManager<'a, C, I, S, SC, SP, ST>
pub struct SimpleRestartingEventManager<'a, C, I, MT, S, SC, SP>
where
C: Corpus<I>,
I: Input,
S: Serialize,
SP: ShMemProvider,
ST: Stats, //CE: CustomEvent<I, OT>,
MT: Monitor, //CE: CustomEvent<I, OT>,
{
/// The actual simple event mgr
simple_event_mgr: SimpleEventManager<I, ST>,
simple_event_mgr: SimpleEventManager<I, MT>,
/// [`StateRestorer`] for restarts
staterestorer: StateRestorer<SP>,
/// Phantom data
@ -230,14 +230,14 @@ where
}
#[cfg(feature = "std")]
impl<'a, C, I, S, SC, SP, ST> EventFirer<I, S>
for SimpleRestartingEventManager<'a, C, I, S, SC, SP, ST>
impl<'a, C, I, MT, S, SC, SP> EventFirer<I, S>
for SimpleRestartingEventManager<'a, C, I, MT, S, SC, SP>
where
C: Corpus<I>,
I: Input,
S: Serialize,
SP: ShMemProvider,
ST: Stats, //CE: CustomEvent<I, OT>,
MT: Monitor, //CE: CustomEvent<I, OT>,
{
fn fire(&mut self, _state: &mut S, event: Event<I>) -> Result<(), Error> {
self.simple_event_mgr.fire(_state, event)
@ -245,14 +245,14 @@ where
}
#[cfg(feature = "std")]
impl<'a, C, I, S, SC, SP, ST> EventRestarter<S>
for SimpleRestartingEventManager<'a, C, I, S, SC, SP, ST>
impl<'a, C, I, MT, S, SC, SP> EventRestarter<S>
for SimpleRestartingEventManager<'a, C, I, MT, S, SC, SP>
where
C: Corpus<I>,
I: Input,
S: Serialize,
SP: ShMemProvider,
ST: Stats, //CE: CustomEvent<I, OT>,
MT: Monitor, //CE: CustomEvent<I, OT>,
{
/// Reset the single page (we reuse it over and over from pos 0), then send the current state to the next runner.
fn on_restart(&mut self, state: &mut S) -> Result<(), Error> {
@ -263,14 +263,14 @@ where
}
#[cfg(feature = "std")]
impl<'a, C, E, I, S, SC, SP, ST, Z> EventProcessor<E, I, S, Z>
for SimpleRestartingEventManager<'a, C, I, S, SC, SP, ST>
impl<'a, C, E, I, S, SC, SP, MT, Z> EventProcessor<E, I, S, Z>
for SimpleRestartingEventManager<'a, C, I, MT, S, SC, SP>
where
C: Corpus<I>,
I: Input,
S: Serialize,
SP: ShMemProvider,
ST: Stats, //CE: CustomEvent<I, OT>,
MT: Monitor, //CE: CustomEvent<I, OT>,
{
fn process(&mut self, fuzzer: &mut Z, state: &mut S, executor: &mut E) -> Result<usize, Error> {
self.simple_event_mgr.process(fuzzer, state, executor)
@ -278,26 +278,26 @@ where
}
#[cfg(feature = "std")]
impl<'a, C, E, I, S, SC, SP, ST, Z> EventManager<E, I, S, Z>
for SimpleRestartingEventManager<'a, C, I, S, SC, SP, ST>
impl<'a, C, E, I, S, SC, SP, MT, Z> EventManager<E, I, S, Z>
for SimpleRestartingEventManager<'a, C, I, MT, S, SC, SP>
where
C: Corpus<I>,
I: Input,
S: Serialize,
SP: ShMemProvider,
ST: Stats, //CE: CustomEvent<I, OT>,
MT: Monitor, //CE: CustomEvent<I, OT>,
{
}
#[cfg(feature = "std")]
impl<'a, C, I, S, SC, SP, ST> HasEventManagerId
for SimpleRestartingEventManager<'a, C, I, S, SC, SP, ST>
impl<'a, C, I, MT, S, SC, SP> HasEventManagerId
for SimpleRestartingEventManager<'a, C, I, MT, S, SC, SP>
where
C: Corpus<I>,
I: Input,
S: Serialize,
SP: ShMemProvider,
ST: Stats,
MT: Monitor,
{
fn mgr_id(&self) -> EventManagerId {
self.simple_event_mgr.mgr_id()
@ -306,20 +306,20 @@ where
#[cfg(feature = "std")]
#[allow(clippy::type_complexity, clippy::too_many_lines)]
impl<'a, C, I, S, SC, SP, ST> SimpleRestartingEventManager<'a, C, I, S, SC, SP, ST>
impl<'a, C, I, MT, S, SC, SP> SimpleRestartingEventManager<'a, C, I, MT, S, SC, SP>
where
C: Corpus<I>,
I: Input,
S: DeserializeOwned + Serialize + HasCorpus<C, I> + HasSolutions<SC, I>,
SC: Corpus<I>,
SP: ShMemProvider,
ST: Stats, //TODO CE: CustomEvent,
MT: Monitor, //TODO CE: CustomEvent,
{
/// Creates a new [`SimpleEventManager`].
fn new_launched(stats: ST, staterestorer: StateRestorer<SP>) -> Self {
fn new_launched(monitor: MT, staterestorer: StateRestorer<SP>) -> Self {
Self {
staterestorer,
simple_event_mgr: SimpleEventManager::new(stats),
simple_event_mgr: SimpleEventManager::new(monitor),
_phantom: PhantomData {},
}
}
@ -328,7 +328,7 @@ where
/// This [`EventManager`] is simple and single threaded,
/// but can still used shared maps to recover from crashes and timeouts.
#[allow(clippy::similar_names)]
pub fn launch(mut stats: ST, shmem_provider: &mut SP) -> Result<(Option<S>, Self), Error> {
pub fn launch(mut monitor: MT, shmem_provider: &mut SP) -> Result<(Option<S>, Self), Error> {
// We start ourself as child process to actually fuzz
let mut staterestorer = if std::env::var(_ENV_FUZZER_SENDER).is_err() {
// First, create a place to store state in, for restarts.
@ -397,7 +397,7 @@ where
// Mgr to send and receive msgs from/to all other fuzzer instances
(
None,
SimpleRestartingEventManager::new_launched(stats, staterestorer),
SimpleRestartingEventManager::new_launched(monitor, staterestorer),
)
}
// Restoring from a previous run, deserialize state and corpus.
@ -406,14 +406,14 @@ where
// We reset the staterestorer, the next staterestorer and receiver (after crash) will reuse the page from the initial message.
staterestorer.reset();
// load the corpus size into stats to still display the correct numbers after restart.
let client_stats = stats.client_stats_mut_for(0);
// load the corpus size into monitor to still display the correct numbers after restart.
let client_stats = monitor.client_stats_mut_for(0);
client_stats.update_corpus_size(state.corpus().count().try_into()?);
client_stats.update_objective_size(state.solutions().count().try_into()?);
(
Some(state),
SimpleRestartingEventManager::new_launched(stats, staterestorer),
SimpleRestartingEventManager::new_launched(monitor, staterestorer),
)
}
};

View File

@ -33,7 +33,7 @@ use crate::{
fuzzer::HasObjective,
inputs::Input,
observers::ObserversTuple,
state::{HasClientPerfStats, HasSolutions},
state::{HasClientPerfMonitor, HasSolutions},
Error,
};
@ -166,7 +166,7 @@ where
EM: EventFirer<I, S> + EventRestarter<S>,
OC: Corpus<I>,
OF: Feedback<I, S>,
S: HasSolutions<OC, I> + HasClientPerfStats,
S: HasSolutions<OC, I> + HasClientPerfMonitor,
Z: HasObjective<I, OF, S>,
{
#[cfg(unix)]
@ -333,7 +333,7 @@ mod unix_signal_handler {
fuzzer::HasObjective,
inputs::Input,
observers::ObserversTuple,
state::{HasClientPerfStats, HasMetadata, HasSolutions},
state::{HasClientPerfMonitor, HasMetadata, HasSolutions},
};
pub type HandlerFuncPtr =
@ -397,7 +397,7 @@ mod unix_signal_handler {
OT: ObserversTuple<I, S>,
OC: Corpus<I>,
OF: Feedback<I, S>,
S: HasSolutions<OC, I> + HasClientPerfStats,
S: HasSolutions<OC, I> + HasClientPerfMonitor,
I: Input,
Z: HasObjective<I, OF, S>,
{
@ -475,7 +475,7 @@ mod unix_signal_handler {
OT: ObserversTuple<I, S>,
OC: Corpus<I>,
OF: Feedback<I, S>,
S: HasSolutions<OC, I> + HasClientPerfStats,
S: HasSolutions<OC, I> + HasClientPerfMonitor,
I: Input,
Z: HasObjective<I, OF, S>,
{
@ -608,7 +608,7 @@ mod windows_exception_handler {
fuzzer::HasObjective,
inputs::Input,
observers::ObserversTuple,
state::{HasClientPerfStats, HasMetadata, HasSolutions},
state::{HasClientPerfMonitor, HasMetadata, HasSolutions},
};
pub type HandlerFuncPtr =
@ -647,7 +647,7 @@ mod windows_exception_handler {
OT: ObserversTuple<I, S>,
OC: Corpus<I>,
OF: Feedback<I, S>,
S: HasSolutions<OC, I> + HasClientPerfStats,
S: HasSolutions<OC, I> + HasClientPerfMonitor,
I: Input,
Z: HasObjective<I, OF, S>,
{
@ -723,7 +723,7 @@ mod windows_exception_handler {
OT: ObserversTuple<I, S>,
OC: Corpus<I>,
OF: Feedback<I, S>,
S: HasSolutions<OC, I> + HasClientPerfStats,
S: HasSolutions<OC, I> + HasClientPerfMonitor,
I: Input,
Z: HasObjective<I, OF, S>,
{
@ -920,7 +920,7 @@ where
EM: EventFirer<I, S> + EventRestarter<S>,
OC: Corpus<I>,
OF: Feedback<I, S>,
S: HasSolutions<OC, I> + HasClientPerfStats,
S: HasSolutions<OC, I> + HasClientPerfMonitor,
Z: HasObjective<I, OF, S>,
{
Ok(Self {

View File

@ -9,7 +9,7 @@ use crate::{
concolic::{ConcolicMetadata, ConcolicObserver},
ObserversTuple,
},
state::{HasClientPerfStats, HasMetadata},
state::{HasClientPerfMonitor, HasMetadata},
Error,
};
@ -42,7 +42,7 @@ impl Named for ConcolicFeedback {
impl<I, S> Feedback<I, S> for ConcolicFeedback
where
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn is_interesting<EM, OT>(
&mut self,

View File

@ -15,9 +15,9 @@ use crate::{
executors::ExitKind,
feedbacks::{Feedback, FeedbackState, FeedbackStatesTuple},
inputs::Input,
monitors::UserStats,
observers::{MapObserver, ObserversTuple},
state::{HasClientPerfStats, HasFeedbackStates, HasMetadata},
stats::UserStats,
state::{HasClientPerfMonitor, HasFeedbackStates, HasMetadata},
Error,
};
@ -324,7 +324,7 @@ where
O: MapObserver<T>,
MF: MapFindFilter<T>,
I: Input,
S: HasFeedbackStates<FT> + HasClientPerfStats,
S: HasFeedbackStates<FT> + HasClientPerfMonitor,
FT: FeedbackStatesTuple,
{
fn is_interesting<EM, OT>(
@ -552,7 +552,7 @@ impl<I, O, S> Feedback<I, S> for ReachabilityFeedback<O>
where
I: Input,
O: MapObserver<usize>,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn is_interesting<EM, OT>(
&mut self,

View File

@ -24,7 +24,7 @@ use crate::{
executors::ExitKind,
inputs::Input,
observers::{ObserversTuple, TimeObserver},
state::HasClientPerfStats,
state::HasClientPerfMonitor,
Error,
};
@ -36,7 +36,7 @@ use core::{marker::PhantomData, time::Duration};
pub trait Feedback<I, S>: Named
where
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
/// `is_interesting ` return if an input is worth the addition to the corpus
fn is_interesting<EM, OT>(
@ -76,7 +76,7 @@ where
// Add this stat to the feedback metrics
state
.introspection_stats_mut()
.introspection_monitor_mut()
.update_feedback(self.name(), elapsed);
ret
@ -136,7 +136,7 @@ where
B: Feedback<I, S>,
FL: FeedbackLogic<A, B, I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
pub first: A,
pub second: B,
@ -150,7 +150,7 @@ where
B: Feedback<I, S>,
FL: FeedbackLogic<A, B, I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn name(&self) -> &str {
self.name.as_ref()
@ -163,7 +163,7 @@ where
B: Feedback<I, S>,
FL: FeedbackLogic<A, B, I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
pub fn new(first: A, second: B) -> Self {
let name = format!("{} ({},{})", FL::name(), first.name(), second.name());
@ -182,7 +182,7 @@ where
B: Feedback<I, S>,
FL: FeedbackLogic<A, B, I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn is_interesting<EM, OT>(
&mut self,
@ -249,7 +249,7 @@ where
A: Feedback<I, S>,
B: Feedback<I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn name() -> &'static str;
@ -292,7 +292,7 @@ where
A: Feedback<I, S>,
B: Feedback<I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn name() -> &'static str {
"Eager OR"
@ -343,7 +343,7 @@ where
A: Feedback<I, S>,
B: Feedback<I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn name() -> &'static str {
"Fast OR"
@ -400,7 +400,7 @@ where
A: Feedback<I, S>,
B: Feedback<I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn name() -> &'static str {
"Eager AND"
@ -451,7 +451,7 @@ where
A: Feedback<I, S>,
B: Feedback<I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn name() -> &'static str {
"Fast AND"
@ -526,7 +526,7 @@ pub struct NotFeedback<A, I, S>
where
A: Feedback<I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
/// The feedback to invert
pub first: A,
@ -539,7 +539,7 @@ impl<A, I, S> Feedback<I, S> for NotFeedback<A, I, S>
where
A: Feedback<I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn is_interesting<EM, OT>(
&mut self,
@ -573,7 +573,7 @@ impl<A, I, S> Named for NotFeedback<A, I, S>
where
A: Feedback<I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
#[inline]
fn name(&self) -> &str {
@ -585,7 +585,7 @@ impl<A, I, S> NotFeedback<A, I, S>
where
A: Feedback<I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
/// Creates a new [`NotFeedback`].
pub fn new(first: A) -> Self {
@ -653,7 +653,7 @@ macro_rules! feedback_not {
impl<I, S> Feedback<I, S> for ()
where
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn is_interesting<EM, OT>(
&mut self,
@ -685,7 +685,7 @@ pub struct CrashFeedback {}
impl<I, S> Feedback<I, S> for CrashFeedback
where
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn is_interesting<EM, OT>(
&mut self,
@ -735,7 +735,7 @@ pub struct TimeoutFeedback {}
impl<I, S> Feedback<I, S> for TimeoutFeedback
where
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn is_interesting<EM, OT>(
&mut self,
@ -790,7 +790,7 @@ pub struct TimeFeedback {
impl<I, S> Feedback<I, S> for TimeFeedback
where
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn is_interesting<EM, OT>(
&mut self,

View File

@ -11,7 +11,7 @@ use crate::{
generators::NautilusContext,
inputs::NautilusInput,
observers::ObserversTuple,
state::{HasClientPerfStats, HasMetadata},
state::{HasClientPerfMonitor, HasMetadata},
Error,
};
@ -52,7 +52,7 @@ impl<'a> Named for NautilusFeedback<'a> {
impl<'a, S> Feedback<NautilusInput, S> for NautilusFeedback<'a>
where
S: HasMetadata + HasClientPerfStats,
S: HasMetadata + HasClientPerfMonitor,
{
fn is_interesting<EM, OT>(
&mut self,

View File

@ -11,19 +11,19 @@ use crate::{
observers::ObserversTuple,
stages::StagesTuple,
start_timer,
state::{HasClientPerfStats, HasCorpus, HasExecutions, HasSolutions},
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasSolutions},
Error,
};
#[cfg(feature = "introspection")]
use crate::stats::PerfFeature;
use crate::monitors::PerfFeature;
#[cfg(feature = "introspection")]
use alloc::boxed::Box;
use alloc::string::ToString;
use core::{marker::PhantomData, time::Duration};
/// Send a stats update all 15 (or more) seconds
/// Send a monitor update all 15 (or more) seconds
const STATS_TIMEOUT_DEFAULT: Duration = Duration::from_secs(15);
/// Holds a scheduler
@ -44,7 +44,7 @@ pub trait HasFeedback<F, I, S>
where
F: Feedback<I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
/// The feedback
fn feedback(&self) -> &F;
@ -58,7 +58,7 @@ pub trait HasObjective<I, OF, S>
where
OF: Feedback<I, S>,
I: Input,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
/// The objective feedback
fn objective(&self) -> &OF;
@ -172,10 +172,10 @@ pub trait Fuzzer<E, EM, I, S, ST> {
manager: &mut EM,
) -> Result<usize, Error> {
let mut last = current_time();
let stats_timeout = STATS_TIMEOUT_DEFAULT;
let monitor_timeout = STATS_TIMEOUT_DEFAULT;
loop {
self.fuzz_one(stages, executor, state, manager)?;
last = Self::maybe_report_stats(state, manager, last, stats_timeout)?;
last = Self::maybe_report_monitor(state, manager, last, monitor_timeout)?;
}
}
@ -201,11 +201,11 @@ pub trait Fuzzer<E, EM, I, S, ST> {
let mut ret = 0;
let mut last = current_time();
let stats_timeout = STATS_TIMEOUT_DEFAULT;
let monitor_timeout = STATS_TIMEOUT_DEFAULT;
for _ in 0..iters {
ret = self.fuzz_one(stages, executor, state, manager)?;
last = Self::maybe_report_stats(state, manager, last, stats_timeout)?;
last = Self::maybe_report_monitor(state, manager, last, monitor_timeout)?;
}
// If we would assume the fuzzer loop will always exit after this, we could do this here:
@ -216,14 +216,14 @@ pub trait Fuzzer<E, EM, I, S, ST> {
Ok(ret)
}
/// Given the last time, if `stats_timeout` seconds passed, send off an info/stats/heartbeat message to the broker.
/// Returns the new `last` time (so the old one, unless `stats_timeout` time has passed and stats have been sent)
/// Will return an [`crate::Error`], if the stats could not be sent.
fn maybe_report_stats(
/// Given the last time, if `monitor_timeout` seconds passed, send off an info/monitor/heartbeat message to the broker.
/// Returns the new `last` time (so the old one, unless `monitor_timeout` time has passed and monitor have been sent)
/// Will return an [`crate::Error`], if the monitor could not be sent.
fn maybe_report_monitor(
state: &mut S,
manager: &mut EM,
last: Duration,
stats_timeout: Duration,
monitor_timeout: Duration,
) -> Result<Duration, Error>;
}
@ -242,7 +242,7 @@ where
F: Feedback<I, S>,
I: Input,
OF: Feedback<I, S>,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
scheduler: CS,
feedback: F,
@ -257,7 +257,7 @@ where
F: Feedback<I, S>,
I: Input,
OF: Feedback<I, S>,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn scheduler(&self) -> &CS {
&self.scheduler
@ -274,7 +274,7 @@ where
F: Feedback<I, S>,
I: Input,
OF: Feedback<I, S>,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn feedback(&self) -> &F {
&self.feedback
@ -291,7 +291,7 @@ where
F: Feedback<I, S>,
I: Input,
OF: Feedback<I, S>,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn objective(&self) -> &OF {
&self.objective
@ -312,7 +312,7 @@ where
I: Input,
OF: Feedback<I, S>,
OT: ObserversTuple<I, S> + serde::Serialize + serde::de::DeserializeOwned,
S: HasCorpus<C, I> + HasSolutions<SC, I> + HasClientPerfStats + HasExecutions,
S: HasCorpus<C, I> + HasSolutions<SC, I> + HasClientPerfMonitor + HasExecutions,
{
/// Evaluate if a set of observation channels has an interesting state
fn process_execution<EM>(
@ -428,7 +428,7 @@ where
F: Feedback<I, S>,
I: Input,
OF: Feedback<I, S>,
S: HasExecutions + HasCorpus<C, I> + HasSolutions<SC, I> + HasClientPerfStats,
S: HasExecutions + HasCorpus<C, I> + HasSolutions<SC, I> + HasClientPerfMonitor,
SC: Corpus<I>,
{
/// Process one input, adding to the respective corpuses if needed and firing the right events
@ -462,7 +462,7 @@ where
F: Feedback<I, S>,
I: Input,
OF: Feedback<I, S>,
S: HasExecutions + HasCorpus<C, I> + HasSolutions<SC, I> + HasClientPerfStats,
S: HasExecutions + HasCorpus<C, I> + HasSolutions<SC, I> + HasClientPerfMonitor,
SC: Corpus<I>,
{
/// Process one input, adding to the respective corpuses if needed and firing the right events
@ -527,46 +527,46 @@ where
EM: EventManager<E, I, S, Self>,
F: Feedback<I, S>,
I: Input,
S: HasExecutions + HasClientPerfStats,
S: HasExecutions + HasClientPerfMonitor,
OF: Feedback<I, S>,
ST: StagesTuple<E, EM, S, Self>,
{
#[inline]
fn maybe_report_stats(
fn maybe_report_monitor(
state: &mut S,
manager: &mut EM,
last: Duration,
stats_timeout: Duration,
monitor_timeout: Duration,
) -> Result<Duration, Error> {
let cur = current_time();
// default to 0 here to avoid crashes on clock skew
if cur.checked_sub(last).unwrap_or_default() > stats_timeout {
if cur.checked_sub(last).unwrap_or_default() > monitor_timeout {
// Default no introspection implmentation
#[cfg(not(feature = "introspection"))]
manager.fire(
state,
Event::UpdateStats {
Event::UpdateExecutions {
executions: *state.executions(),
time: cur,
phantom: PhantomData,
},
)?;
// If performance stats are requested, fire the `UpdatePerfStats` event
// If performance monitor are requested, fire the `UpdatePerfMonitor` event
#[cfg(feature = "introspection")]
{
state
.introspection_stats_mut()
.introspection_monitor_mut()
.set_current_time(crate::bolts::cpu::read_time_counter());
// Send the current stats over to the manager. This `.clone` shouldn't be
// costly as `ClientPerfStats` impls `Copy` since it only contains `u64`s
// Send the current monitor over to the manager. This `.clone` shouldn't be
// costly as `ClientPerfMonitor` impls `Copy` since it only contains `u64`s
manager.fire(
state,
Event::UpdatePerfStats {
Event::UpdatePerfMonitor {
executions: *state.executions(),
time: cur,
introspection_stats: Box::new(state.introspection_stats().clone()),
introspection_monitor: Box::new(state.introspection_monitor().clone()),
phantom: PhantomData,
},
)?;
@ -588,32 +588,32 @@ where
) -> Result<usize, Error> {
// Init timer for scheduler
#[cfg(feature = "introspection")]
state.introspection_stats_mut().start_timer();
state.introspection_monitor_mut().start_timer();
// Get the next index from the scheduler
let idx = self.scheduler.next(state)?;
// Mark the elapsed time for the scheduler
#[cfg(feature = "introspection")]
state.introspection_stats_mut().mark_scheduler_time();
state.introspection_monitor_mut().mark_scheduler_time();
// Mark the elapsed time for the scheduler
#[cfg(feature = "introspection")]
state.introspection_stats_mut().reset_stage_index();
state.introspection_monitor_mut().reset_stage_index();
// Execute all stages
stages.perform_all(self, executor, state, manager, idx)?;
// Init timer for manager
#[cfg(feature = "introspection")]
state.introspection_stats_mut().start_timer();
state.introspection_monitor_mut().start_timer();
// Execute the manager
manager.process(self, state, executor)?;
// Mark the elapsed time for the manager
#[cfg(feature = "introspection")]
state.introspection_stats_mut().mark_manager_time();
state.introspection_monitor_mut().mark_manager_time();
Ok(idx)
}
@ -625,7 +625,7 @@ where
F: Feedback<I, S>,
I: Input,
OF: Feedback<I, S>,
S: HasExecutions + HasClientPerfStats,
S: HasExecutions + HasClientPerfMonitor,
{
/// Create a new `StdFuzzer` with standard behavior.
pub fn new(scheduler: CS, feedback: F, objective: OF) -> Self {

View File

@ -31,15 +31,36 @@ pub mod executors;
pub mod feedbacks;
pub mod generators;
pub mod inputs;
pub mod monitors;
pub mod mutators;
pub mod observers;
pub mod stages;
pub mod state;
pub mod stats;
pub mod fuzzer;
pub use fuzzer::*;
/// The `stats` module got renamed to [`monitors`].
/// It monitors and displays the statistics of the fuzzing process.
#[deprecated(since = "0.6.0", note = "The `stats` module got renamed to `monitors`")]
pub mod stats {
#[deprecated(
since = "0.6.0",
note = "Use monitors::MultiMonitor instead of stats::MultiStats!"
)]
pub use crate::monitors::MultiMonitor as MultiStats;
#[deprecated(
since = "0.6.0",
note = "Use monitors::SimpleMonitor instead of stats::SimpleStats!"
)]
pub use crate::monitors::SimpleMonitor as SimpleStats;
#[deprecated(
since = "0.6.0",
note = "Use monitors::UserMonitor instead of stats::SimpleStats!"
)]
pub use crate::monitors::UserStats;
}
use alloc::string::String;
use core::fmt;
@ -173,10 +194,10 @@ mod tests {
corpus::{Corpus, InMemoryCorpus, RandCorpusScheduler, Testcase},
executors::{ExitKind, InProcessExecutor},
inputs::BytesInput,
monitors::SimpleMonitor,
mutators::{mutations::BitFlipMutator, StdScheduledMutator},
stages::StdMutationalStage,
state::{HasCorpus, StdState},
stats::SimpleStats,
Fuzzer, StdFuzzer,
};
@ -199,10 +220,10 @@ mod tests {
tuple_list!(),
);
let stats = SimpleStats::new(|s| {
let monitor = SimpleMonitor::new(|s| {
println!("{}", s);
});
let mut event_manager = SimpleEventManager::new(stats);
let mut event_manager = SimpleEventManager::new(monitor);
let scheduler = RandCorpusScheduler::new();
let mut fuzzer = StdFuzzer::new(scheduler, (), ());

View File

@ -1,7 +1,7 @@
//! Keep stats, and dispaly them to the user. Usually used in a broker, or main node, of some sort.
pub mod multi;
pub use multi::MultiStats;
pub use multi::MultiMonitor;
use serde::{Deserialize, Serialize};
@ -17,7 +17,7 @@ use crate::bolts::current_time;
const CLIENT_STATS_TIME_WINDOW_SECS: u64 = 5; // 5 seconds
/// User-defined stats types
/// User-defined stat types
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum UserStats {
Number(u64),
@ -41,10 +41,10 @@ impl fmt::Display for UserStats {
}
}
/// A simple struct to keep track of client stats
/// A simple struct to keep track of client monitor
#[derive(Debug, Clone, Default)]
pub struct ClientStats {
// stats (maybe we need a separated struct?)
// monitor (maybe we need a separated struct?)
/// The corpus size for this client
pub corpus_size: u64,
/// The total executions for this client
@ -57,12 +57,12 @@ pub struct ClientStats {
pub last_window_time: time::Duration,
/// The last executions per sec
pub last_execs_per_sec: f32,
/// User-defined stats
pub user_stats: HashMap<String, UserStats>,
/// User-defined monitor
pub user_monitor: HashMap<String, UserStats>,
/// Client performance statistics
#[cfg(feature = "introspection")]
pub introspection_stats: ClientPerfStats,
pub introspection_monitor: ClientPerfMonitor,
}
impl ClientStats {
@ -121,33 +121,33 @@ impl ClientStats {
/// Update the user-defined stat with name and value
pub fn update_user_stats(&mut self, name: String, value: UserStats) {
self.user_stats.insert(name, value);
self.user_monitor.insert(name, value);
}
/// Get a user-defined stat using the name
pub fn get_user_stats(&mut self, name: &str) -> Option<&UserStats> {
self.user_stats.get(name)
self.user_monitor.get(name)
}
/// Update the current [`ClientPerfStats`] with the given [`ClientPerfStats`]
/// Update the current [`ClientPerfMonitor`] with the given [`ClientPerfMonitor`]
#[cfg(feature = "introspection")]
pub fn update_introspection_stats(&mut self, introspection_stats: ClientPerfStats) {
self.introspection_stats = introspection_stats;
pub fn update_introspection_monitor(&mut self, introspection_monitor: ClientPerfMonitor) {
self.introspection_monitor = introspection_monitor;
}
}
/// The stats trait keeps track of all the client's stats, and offers methods to dispaly them.
pub trait Stats {
/// the client stats (mut)
/// The monitor trait keeps track of all the client's monitor, and offers methods to dispaly them.
pub trait Monitor {
/// the client monitor (mut)
fn client_stats_mut(&mut self) -> &mut Vec<ClientStats>;
/// the client stats
/// the client monitor
fn client_stats(&self) -> &[ClientStats];
/// creation time
fn start_time(&mut self) -> time::Duration;
/// show the stats to the user
/// show the monitor to the user
fn display(&mut self, event_msg: String, sender_id: u32);
/// Amount of elements in the corpus (combined for all children)
@ -181,7 +181,7 @@ pub trait Stats {
.fold(0_u64, |acc, x| acc + x.execs_per_sec(cur_time))
}
/// The client stats for a specific id, creating new if it doesn't exist
/// The client monitor for a specific id, creating new if it doesn't exist
fn client_stats_mut_for(&mut self, client_id: u32) -> &mut ClientStats {
let client_stat_count = self.client_stats().len();
for _ in client_stat_count..(client_id + 1) as usize {
@ -194,20 +194,20 @@ pub trait Stats {
}
}
/// Stats that print exactly nothing.
/// Monitor that print exactly nothing.
/// Not good for debuging, very good for speed.
pub struct NopStats {
pub struct NopMonitor {
start_time: Duration,
client_stats: Vec<ClientStats>,
}
impl Stats for NopStats {
/// the client stats, mutable
impl Monitor for NopMonitor {
/// the client monitor, mutable
fn client_stats_mut(&mut self) -> &mut Vec<ClientStats> {
&mut self.client_stats
}
/// the client stats
/// the client monitor
fn client_stats(&self) -> &[ClientStats] {
&self.client_stats
}
@ -220,8 +220,8 @@ impl Stats for NopStats {
fn display(&mut self, _event_msg: String, _sender_id: u32) {}
}
impl NopStats {
/// Create new [`NopStats`]
impl NopMonitor {
/// Create new [`NopMonitor`]
#[must_use]
pub fn new() -> Self {
Self {
@ -231,15 +231,15 @@ impl NopStats {
}
}
impl Default for NopStats {
impl Default for NopMonitor {
fn default() -> Self {
Self::new()
}
}
/// Tracking stats during fuzzing.
/// Tracking monitor during fuzzing.
#[derive(Clone, Debug)]
pub struct SimpleStats<F>
pub struct SimpleMonitor<F>
where
F: FnMut(String),
{
@ -248,16 +248,16 @@ where
client_stats: Vec<ClientStats>,
}
impl<F> Stats for SimpleStats<F>
impl<F> Monitor for SimpleMonitor<F>
where
F: FnMut(String),
{
/// the client stats, mutable
/// the client monitor, mutable
fn client_stats_mut(&mut self) -> &mut Vec<ClientStats> {
&mut self.client_stats
}
/// the client stats
/// the client monitor
fn client_stats(&self) -> &[ClientStats] {
&self.client_stats
}
@ -269,7 +269,8 @@ where
fn display(&mut self, event_msg: String, sender_id: u32) {
let fmt = format!(
"[{} #{}] clients: {}, corpus: {}, objectives: {}, executions: {}, exec/sec: {}",
"{}: [{} #{}] clients: {}, corpus: {}, objectives: {}, executions: {}, exec/sec: {}",
(current_time() - self.start_time).as_millis(),
event_msg,
sender_id,
self.client_stats().len(),
@ -280,13 +281,13 @@ where
);
(self.print_fn)(fmt);
// Only print perf stats if the feature is enabled
// Only print perf monitor if the feature is enabled
#[cfg(feature = "introspection")]
{
// Print the client performance stats.
// Print the client performance monitor.
let fmt = format!(
"Client {:03}:\n{}",
sender_id, self.client_stats[sender_id as usize].introspection_stats
sender_id, self.client_stats[sender_id as usize].introspection_monitor
);
(self.print_fn)(fmt);
@ -296,11 +297,11 @@ where
}
}
impl<F> SimpleStats<F>
impl<F> SimpleMonitor<F>
where
F: FnMut(String),
{
/// Creates the stats, using the `current_time` as `start_time`.
/// Creates the monitor, using the `current_time` as `start_time`.
pub fn new(print_fn: F) -> Self {
Self {
print_fn,
@ -309,7 +310,7 @@ where
}
}
/// Creates the stats with a given `start_time`.
/// Creates the monitor with a given `start_time`.
pub fn with_time(print_fn: F, start_time: time::Duration) -> Self {
Self {
print_fn,
@ -324,7 +325,7 @@ macro_rules! start_timer {
($state:expr) => {{
// Start the timer
#[cfg(feature = "introspection")]
$state.introspection_stats_mut().start_timer();
$state.introspection_monitor_mut().start_timer();
}};
}
@ -333,7 +334,9 @@ macro_rules! mark_feature_time {
($state:expr, $feature:expr) => {{
// Mark the elapsed time for the given feature
#[cfg(feature = "introspection")]
$state.introspection_stats_mut().mark_feature_time($feature);
$state
.introspection_monitor_mut()
.mark_feature_time($feature);
}};
}
@ -342,13 +345,13 @@ macro_rules! mark_feedback_time {
($state:expr) => {{
// Mark the elapsed time for the given feature
#[cfg(feature = "introspection")]
$state.introspection_stats_mut().mark_feedback_time();
$state.introspection_monitor_mut().mark_feedback_time();
}};
}
/// Client performance statistics
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ClientPerfStats {
pub struct ClientPerfMonitor {
/// Starting counter (in clock cycles from `read_time_counter`)
start_time: u64,
@ -465,8 +468,8 @@ impl From<usize> for PerfFeature {
pub const NUM_PERF_FEATURES: usize = PerfFeature::Count as usize;
#[cfg(feature = "introspection")]
impl ClientPerfStats {
/// Create a blank [`ClientPerfStats`] with the `start_time` and `current_time` with
impl ClientPerfMonitor {
/// Create a blank [`ClientPerfMonitor`] with the `start_time` and `current_time` with
/// the current clock counter
#[must_use]
pub fn new() -> Self {
@ -497,13 +500,13 @@ impl ClientPerfStats {
self.timer_start = Some(crate::bolts::cpu::read_time_counter());
}
/// Update the current [`ClientPerfStats`] with the given [`ClientPerfStats`]
pub fn update(&mut self, stats: &ClientPerfStats) {
self.set_current_time(stats.current_time);
self.update_scheduler(stats.scheduler);
self.update_manager(stats.manager);
self.update_stages(&stats.stages);
self.update_feedbacks(&stats.feedbacks);
/// Update the current [`ClientPerfMonitor`] with the given [`ClientPerfMonitor`]
pub fn update(&mut self, monitor: &ClientPerfMonitor) {
self.set_current_time(monitor.current_time);
self.update_scheduler(monitor.scheduler);
self.update_manager(monitor.manager);
self.update_stages(&monitor.stages);
self.update_feedbacks(&monitor.feedbacks);
}
/// Gets the elapsed time since the internal timer started. Resets the timer when
@ -562,7 +565,7 @@ impl ClientPerfStats {
self.update_feature(feature, elapsed);
}
/// Add the given `time` to the `scheduler` stats
/// Add the given `time` to the `scheduler` monitor
#[inline]
pub fn update_scheduler(&mut self, time: u64) {
self.scheduler = self
@ -571,7 +574,7 @@ impl ClientPerfStats {
.expect("update_scheduler overflow");
}
/// Add the given `time` to the `manager` stats
/// Add the given `time` to the `manager` monitor
#[inline]
pub fn update_manager(&mut self, time: u64) {
self.manager = self
@ -689,10 +692,10 @@ impl ClientPerfStats {
}
#[cfg(feature = "introspection")]
impl core::fmt::Display for ClientPerfStats {
impl core::fmt::Display for ClientPerfMonitor {
#[allow(clippy::cast_precision_loss)]
fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
// Calculate the elapsed time from the stats
// Calculate the elapsed time from the monitor
let elapsed: f64 = self.elapsed_cycles() as f64;
// Calculate the percentages for each benchmark
@ -762,7 +765,7 @@ impl core::fmt::Display for ClientPerfStats {
}
#[cfg(feature = "introspection")]
impl Default for ClientPerfStats {
impl Default for ClientPerfMonitor {
#[must_use]
fn default() -> Self {
Self::new()

View File

@ -1,4 +1,4 @@
//! Stats to disply both cumulative and per-client stats
//! Monitor to disply both cumulative and per-client monitor
use alloc::{string::String, vec::Vec};
use core::{time, time::Duration};
@ -8,12 +8,12 @@ use alloc::string::ToString;
use crate::{
bolts::current_time,
stats::{ClientStats, Stats},
monitors::{ClientStats, Monitor},
};
/// Tracking stats during fuzzing and display both per-client and cumulative info.
/// Tracking monitor during fuzzing and display both per-client and cumulative info.
#[derive(Clone, Debug)]
pub struct MultiStats<F>
pub struct MultiMonitor<F>
where
F: FnMut(String),
{
@ -22,16 +22,16 @@ where
client_stats: Vec<ClientStats>,
}
impl<F> Stats for MultiStats<F>
impl<F> Monitor for MultiMonitor<F>
where
F: FnMut(String),
{
/// the client stats, mutable
/// the client monitor, mutable
fn client_stats_mut(&mut self) -> &mut Vec<ClientStats> {
&mut self.client_stats
}
/// the client stats
/// the client monitor
fn client_stats(&self) -> &[ClientStats] {
&self.client_stats
}
@ -69,17 +69,17 @@ where
" {} (CLIENT) corpus: {}, objectives: {}, executions: {}, exec/sec: {}",
pad, client.corpus_size, client.objective_size, client.executions, exec_sec
);
for (key, val) in &client.user_stats {
for (key, val) in &client.user_monitor {
fmt += &format!(", {}: {}", key, val);
}
(self.print_fn)(fmt);
// Only print perf stats if the feature is enabled
// Only print perf monitor if the feature is enabled
#[cfg(feature = "introspection")]
{
// Print the client performance stats. Skip the Client 0 which is the broker
// Print the client performance monitor. Skip the Client 0 which is the broker
for (i, client) in self.client_stats.iter().skip(1).enumerate() {
let fmt = format!("Client {:03}:\n{}", i + 1, client.introspection_stats);
let fmt = format!("Client {:03}:\n{}", i + 1, client.introspection_monitor);
(self.print_fn)(fmt);
}
@ -89,11 +89,11 @@ where
}
}
impl<F> MultiStats<F>
impl<F> MultiMonitor<F>
where
F: FnMut(String),
{
/// Creates the stats, using the `current_time` as `start_time`.
/// Creates the monitor, using the `current_time` as `start_time`.
pub fn new(print_fn: F) -> Self {
Self {
print_fn,
@ -102,7 +102,7 @@ where
}
}
/// Creates the stats with a given `start_time`.
/// Creates the monitor with a given `start_time`.
pub fn with_time(print_fn: F, start_time: time::Duration) -> Self {
Self {
print_fn,

View File

@ -9,7 +9,7 @@ use crate::{
executors::{Executor, HasObservers},
inputs::Input,
observers::{concolic::ConcolicObserver, ObserversTuple},
state::{HasClientPerfStats, HasCorpus, HasExecutions, HasMetadata},
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasMetadata},
Error,
};
@ -23,7 +23,7 @@ where
C: Corpus<I>,
TE: Executor<EM, I, S, Z> + HasObservers<I, OT, S>,
OT: ObserversTuple<I, S>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
S: HasClientPerfMonitor + HasExecutions + HasCorpus<C, I>,
{
inner: TracingStage<C, EM, I, OT, S, TE, Z>,
observer_name: String,
@ -35,7 +35,7 @@ where
C: Corpus<I>,
TE: Executor<EM, I, S, Z> + HasObservers<I, OT, S>,
OT: ObserversTuple<I, S>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
S: HasClientPerfMonitor + HasExecutions + HasCorpus<C, I>,
{
#[inline]
fn perform(
@ -73,7 +73,7 @@ where
C: Corpus<I>,
TE: Executor<EM, I, S, Z> + HasObservers<I, OT, S>,
OT: ObserversTuple<I, S>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
S: HasClientPerfMonitor + HasExecutions + HasCorpus<C, I>,
{
/// Creates a new default tracing stage using the given [`Executor`], observing traces from a [`ConcolicObserver`] with the given name.
pub fn new(inner: TracingStage<C, EM, I, OT, S, TE, Z>, observer_name: String) -> Self {
@ -93,7 +93,7 @@ use crate::{
};
#[cfg(all(feature = "concolic_mutation", feature = "introspection"))]
use crate::stats::PerfFeature;
use crate::monitors::PerfFeature;
#[cfg(feature = "concolic_mutation")]
#[allow(clippy::too_many_lines)]
@ -348,7 +348,7 @@ pub struct SimpleConcolicMutationalStage<C, EM, I, S, Z>
where
I: Input,
C: Corpus<I>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
S: HasClientPerfMonitor + HasExecutions + HasCorpus<C, I>,
{
_phantom: PhantomData<(C, EM, I, S, Z)>,
}
@ -358,7 +358,7 @@ impl<E, C, EM, I, S, Z> Stage<E, EM, S, Z> for SimpleConcolicMutationalStage<C,
where
I: Input + HasBytesVec,
C: Corpus<I>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
S: HasClientPerfMonitor + HasExecutions + HasCorpus<C, I>,
Z: Evaluator<E, EM, I, S>,
{
#[inline]
@ -402,7 +402,7 @@ impl<C, EM, I, S, Z> Default for SimpleConcolicMutationalStage<C, EM, I, S, Z>
where
I: Input,
C: Corpus<I>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
S: HasClientPerfMonitor + HasExecutions + HasCorpus<C, I>,
{
fn default() -> Self {
Self {

View File

@ -12,12 +12,12 @@ use crate::{
mutators::Mutator,
stages::Stage,
start_timer,
state::{HasClientPerfStats, HasCorpus, HasRand},
state::{HasClientPerfMonitor, HasCorpus, HasRand},
Error,
};
#[cfg(feature = "introspection")]
use crate::stats::PerfFeature;
use crate::monitors::PerfFeature;
// TODO multi mutators stage
@ -29,7 +29,7 @@ where
C: Corpus<I>,
M: Mutator<I, S>,
I: Input,
S: HasClientPerfStats + HasCorpus<C, I>,
S: HasClientPerfMonitor + HasCorpus<C, I>,
Z: Evaluator<E, EM, I, S>,
{
/// The mutator registered for this stage
@ -90,7 +90,7 @@ where
M: Mutator<I, S>,
I: Input,
R: Rand,
S: HasClientPerfStats + HasCorpus<C, I> + HasRand<R>,
S: HasClientPerfMonitor + HasCorpus<C, I> + HasRand<R>,
Z: Evaluator<E, EM, I, S>,
{
mutator: M,
@ -105,7 +105,7 @@ where
M: Mutator<I, S>,
I: Input,
R: Rand,
S: HasClientPerfStats + HasCorpus<C, I> + HasRand<R>,
S: HasClientPerfMonitor + HasCorpus<C, I> + HasRand<R>,
Z: Evaluator<E, EM, I, S>,
{
/// The mutator, added to this stage
@ -132,7 +132,7 @@ where
M: Mutator<I, S>,
I: Input,
R: Rand,
S: HasClientPerfStats + HasCorpus<C, I> + HasRand<R>,
S: HasClientPerfMonitor + HasCorpus<C, I> + HasRand<R>,
Z: Evaluator<E, EM, I, S>,
{
#[inline]
@ -148,7 +148,7 @@ where
let ret = self.perform_mutational(fuzzer, executor, state, manager, corpus_idx);
#[cfg(feature = "introspection")]
state.introspection_stats_mut().finish_stage();
state.introspection_monitor_mut().finish_stage();
ret
}
@ -160,7 +160,7 @@ where
M: Mutator<I, S>,
I: Input,
R: Rand,
S: HasClientPerfStats + HasCorpus<C, I> + HasRand<R>,
S: HasClientPerfMonitor + HasCorpus<C, I> + HasRand<R>,
Z: Evaluator<E, EM, I, S>,
{
/// Creates a new default mutational stage

View File

@ -12,7 +12,7 @@ use crate::{
mutators::Mutator,
observers::{MapObserver, ObserversTuple},
stages::{MutationalStage, PowerScheduleMetadata, Stage},
state::{HasClientPerfStats, HasCorpus, HasMetadata},
state::{HasClientPerfMonitor, HasCorpus, HasMetadata},
Error,
};
@ -41,7 +41,7 @@ where
M: Mutator<I, S>,
O: MapObserver<T>,
OT: ObserversTuple<I, S>,
S: HasClientPerfStats + HasCorpus<C, I> + HasMetadata,
S: HasClientPerfMonitor + HasCorpus<C, I> + HasMetadata,
Z: Evaluator<E, EM, I, S>,
{
map_observer_name: String,
@ -62,7 +62,7 @@ where
M: Mutator<I, S>,
O: MapObserver<T>,
OT: ObserversTuple<I, S>,
S: HasClientPerfStats + HasCorpus<C, I> + HasMetadata,
S: HasClientPerfMonitor + HasCorpus<C, I> + HasMetadata,
Z: Evaluator<E, EM, I, S>,
{
/// The mutator, added to this stage
@ -163,7 +163,7 @@ where
M: Mutator<I, S>,
O: MapObserver<T>,
OT: ObserversTuple<I, S>,
S: HasClientPerfStats + HasCorpus<C, I> + HasMetadata,
S: HasClientPerfMonitor + HasCorpus<C, I> + HasMetadata,
Z: Evaluator<E, EM, I, S>,
{
#[inline]
@ -190,7 +190,7 @@ where
M: Mutator<I, S>,
O: MapObserver<T>,
OT: ObserversTuple<I, S>,
S: HasClientPerfStats + HasCorpus<C, I> + HasMetadata,
S: HasClientPerfMonitor + HasCorpus<C, I> + HasMetadata,
Z: Evaluator<E, EM, I, S>,
{
pub fn new(mutator: M, strat: PowerSchedule, map_observer_name: &O) -> Self {

View File

@ -19,14 +19,14 @@ use crate::{
mutators::Mutator,
observers::ObserversTuple,
start_timer,
state::{HasClientPerfStats, HasCorpus, HasRand},
state::{HasClientPerfMonitor, HasCorpus, HasRand},
Error, EvaluatorObservers, ExecutionProcessor, Fuzzer, HasCorpusScheduler,
};
#[cfg(feature = "introspection")]
use crate::stats::PerfFeature;
use crate::monitors::PerfFeature;
/// Send a stats update all 15 (or more) seconds
/// Send a monitor update all 15 (or more) seconds
const STATS_TIMEOUT_DEFAULT: Duration = Duration::from_secs(15);
pub static DEFAULT_MUTATIONAL_MAX_ITERATIONS: u64 = 128;
@ -50,7 +50,7 @@ where
M: Mutator<I, S>,
OT: ObserversTuple<I, S>,
R: Rand,
S: HasClientPerfStats + HasCorpus<C, I> + HasRand<R>,
S: HasClientPerfMonitor + HasCorpus<C, I> + HasRand<R>,
Z: ExecutionProcessor<I, OT, S>
+ EvaluatorObservers<I, OT, S>
+ Fuzzer<(), EM, I, S, ()>
@ -73,7 +73,7 @@ where
mutator: M,
#[allow(clippy::type_complexity)]
phantom: PhantomData<(C, CS, (), EM, I, R, OT, S, Z)>,
last_stats_time: Duration,
last_monitor_time: Duration,
observers: Rc<RefCell<OT>>,
exit_kind: Rc<Cell<Option<ExitKind>>>,
}
@ -87,7 +87,7 @@ where
M: Mutator<I, S>,
OT: ObserversTuple<I, S>,
R: Rand,
S: HasClientPerfStats + HasCorpus<C, I> + HasRand<R>,
S: HasClientPerfMonitor + HasCorpus<C, I> + HasRand<R>,
Z: ExecutionProcessor<I, OT, S>
+ EvaluatorObservers<I, OT, S>
+ Fuzzer<(), EM, I, S, ()>
@ -188,7 +188,7 @@ where
M: Mutator<I, S>,
OT: ObserversTuple<I, S>,
R: Rand,
S: HasClientPerfStats + HasCorpus<C, I> + HasRand<R>,
S: HasClientPerfMonitor + HasCorpus<C, I> + HasRand<R>,
Z: ExecutionProcessor<I, OT, S>
+ EvaluatorObservers<I, OT, S>
+ Fuzzer<(), EM, I, S, ()>
@ -219,14 +219,14 @@ where
//let fuzzer: &mut Z = &mut (*self.fuzzer).borrow_mut();
let event_mgr: &mut EM = &mut (*self.event_mgr).borrow_mut();
self.last_stats_time = Z::maybe_report_stats(
self.last_monitor_time = Z::maybe_report_monitor(
state,
event_mgr,
self.last_stats_time,
self.last_monitor_time,
STATS_TIMEOUT_DEFAULT,
)
.unwrap();
//self.fuzzer.maybe_report_stats();
//self.fuzzer.maybe_report_monitor();
} else {
self.exit_kind.replace(None);
}
@ -243,7 +243,7 @@ where
M: Mutator<I, S>,
OT: ObserversTuple<I, S>,
R: Rand,
S: HasClientPerfStats + HasCorpus<C, I> + HasRand<R>,
S: HasClientPerfMonitor + HasCorpus<C, I> + HasRand<R>,
Z: ExecutionProcessor<I, OT, S>
+ EvaluatorObservers<I, OT, S>
+ Fuzzer<(), EM, I, S, ()>
@ -274,7 +274,7 @@ where
event_mgr,
observers,
exit_kind,
last_stats_time: current_time(),
last_monitor_time: current_time(),
}
}
}

View File

@ -10,12 +10,12 @@ use crate::{
observers::ObserversTuple,
stages::Stage,
start_timer,
state::{HasClientPerfStats, HasCorpus, HasExecutions},
state::{HasClientPerfMonitor, HasCorpus, HasExecutions},
Error,
};
#[cfg(feature = "introspection")]
use crate::stats::PerfFeature;
use crate::monitors::PerfFeature;
/// A stage that runs a tracer executor
#[derive(Clone, Debug)]
@ -25,7 +25,7 @@ where
C: Corpus<I>,
TE: Executor<EM, I, S, Z> + HasObservers<I, OT, S>,
OT: ObserversTuple<I, S>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
S: HasClientPerfMonitor + HasExecutions + HasCorpus<C, I>,
{
tracer_executor: TE,
#[allow(clippy::type_complexity)]
@ -38,7 +38,7 @@ where
C: Corpus<I>,
TE: Executor<EM, I, S, Z> + HasObservers<I, OT, S>,
OT: ObserversTuple<I, S>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
S: HasClientPerfMonitor + HasExecutions + HasCorpus<C, I>,
{
#[inline]
fn perform(
@ -88,7 +88,7 @@ where
C: Corpus<I>,
TE: Executor<EM, I, S, Z> + HasObservers<I, OT, S>,
OT: ObserversTuple<I, S>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
S: HasClientPerfMonitor + HasExecutions + HasCorpus<C, I>,
{
/// Creates a new default stage
pub fn new(tracer_executor: TE) -> Self {
@ -118,7 +118,7 @@ where
E: Executor<EM, I, S, Z> + HasObservers<I, OT, S>,
OT: ObserversTuple<I, S>,
SOT: ObserversTuple<I, S>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
S: HasClientPerfMonitor + HasExecutions + HasCorpus<C, I>,
{
#[inline]
fn perform(
@ -169,7 +169,7 @@ where
E: Executor<EM, I, S, Z> + HasObservers<I, OT, S>,
OT: ObserversTuple<I, S>,
SOT: ObserversTuple<I, S>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
S: HasClientPerfMonitor + HasExecutions + HasCorpus<C, I>,
{
/// Creates a new default stage
pub fn new(_executor: &mut ShadowExecutor<E, I, S, SOT>) -> Self {

View File

@ -19,7 +19,7 @@ use crate::{
fuzzer::{Evaluator, ExecuteInputResult},
generators::Generator,
inputs::Input,
stats::ClientPerfStats,
monitors::ClientPerfMonitor,
Error,
};
@ -71,13 +71,13 @@ where
fn rand_mut(&mut self) -> &mut R;
}
/// Trait for offering a [`ClientPerfStats`]
pub trait HasClientPerfStats {
/// [`ClientPerfStats`] itself
fn introspection_stats(&self) -> &ClientPerfStats;
/// Trait for offering a [`ClientPerfMonitor`]
pub trait HasClientPerfMonitor {
/// [`ClientPerfMonitor`] itself
fn introspection_monitor(&self) -> &ClientPerfMonitor;
/// Mutatable ref to [`ClientPerfStats`]
fn introspection_stats_mut(&mut self) -> &mut ClientPerfStats;
/// Mutatable ref to [`ClientPerfMonitor`]
fn introspection_monitor_mut(&mut self) -> &mut ClientPerfMonitor;
}
/// Trait for elements offering metadata
@ -166,7 +166,7 @@ where
/// Performance statistics for this fuzzer
#[cfg(feature = "introspection")]
introspection_stats: ClientPerfStats,
introspection_monitor: ClientPerfMonitor,
phantom: PhantomData<I>,
}
@ -559,14 +559,14 @@ where
solutions,
max_size: DEFAULT_MAX_SIZE,
#[cfg(feature = "introspection")]
introspection_stats: ClientPerfStats::new(),
introspection_monitor: ClientPerfMonitor::new(),
phantom: PhantomData,
}
}
}
#[cfg(feature = "introspection")]
impl<C, FT, I, R, SC> HasClientPerfStats for StdState<C, FT, I, R, SC>
impl<C, FT, I, R, SC> HasClientPerfMonitor for StdState<C, FT, I, R, SC>
where
C: Corpus<I>,
I: Input,
@ -574,17 +574,17 @@ where
FT: FeedbackStatesTuple,
SC: Corpus<I>,
{
fn introspection_stats(&self) -> &ClientPerfStats {
&self.introspection_stats
fn introspection_monitor(&self) -> &ClientPerfMonitor {
&self.introspection_monitor
}
fn introspection_stats_mut(&mut self) -> &mut ClientPerfStats {
&mut self.introspection_stats
fn introspection_monitor_mut(&mut self) -> &mut ClientPerfMonitor {
&mut self.introspection_monitor
}
}
#[cfg(not(feature = "introspection"))]
impl<C, FT, I, R, SC> HasClientPerfStats for StdState<C, FT, I, R, SC>
impl<C, FT, I, R, SC> HasClientPerfMonitor for StdState<C, FT, I, R, SC>
where
C: Corpus<I>,
I: Input,
@ -592,11 +592,11 @@ where
FT: FeedbackStatesTuple,
SC: Corpus<I>,
{
fn introspection_stats(&self) -> &ClientPerfStats {
fn introspection_monitor(&self) -> &ClientPerfMonitor {
unimplemented!()
}
fn introspection_stats_mut(&mut self) -> &mut ClientPerfStats {
fn introspection_monitor_mut(&mut self) -> &mut ClientPerfMonitor {
unimplemented!()
}
}

View File

@ -13,7 +13,7 @@ use libafl::{
feedbacks::Feedback,
inputs::{HasTargetBytes, Input},
observers::{Observer, ObserversTuple},
state::{HasClientPerfStats, HasMetadata},
state::{HasClientPerfMonitor, HasMetadata},
Error, SerdeAny,
};
use serde::{Deserialize, Serialize};
@ -614,7 +614,7 @@ pub struct AsanErrorsFeedback {
impl<I, S> Feedback<I, S> for AsanErrorsFeedback
where
I: Input + HasTargetBytes,
S: HasClientPerfStats,
S: HasClientPerfMonitor,
{
fn is_interesting<EM, OT>(
&mut self,

View File

@ -10,7 +10,7 @@ use libafl::{
fuzzer::HasObjective,
inputs::Input,
observers::ObserversTuple,
state::{HasClientPerfStats, HasSolutions},
state::{HasClientPerfMonitor, HasSolutions},
Error,
};
@ -386,7 +386,7 @@ where
EM: EventFirer<I, S> + EventRestarter<S>,
OC: Corpus<I>,
OF: Feedback<I, S>,
S: HasSolutions<OC, I> + HasClientPerfStats,
S: HasSolutions<OC, I> + HasClientPerfMonitor,
Z: HasObjective<I, OF, S>,
{
let slf = Self {

View File

@ -20,12 +20,12 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback, TimeoutFeedback},
fuzzer::{Fuzzer, StdFuzzer},
generators::RandBytesGenerator,
monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::Tokens,
observers::{ConstMapObserver, HitcountsMapObserver, TimeObserver},
stages::StdMutationalStage,
state::{HasCorpus, HasMetadata, StdState},
stats::MultiStats,
Error,
};
@ -97,7 +97,7 @@ impl<'a> ForkserverBytesCoverageSugar<'a> {
let shmem_provider = StdShMemProvider::new().expect("Failed to init shared memory");
let stats = MultiStats::new(|s| println!("{}", s));
let monitor = MultiMonitor::new(|s| println!("{}", s));
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr, _core_id| {
// Coverage map shared between target and fuzzer
@ -233,7 +233,7 @@ impl<'a> ForkserverBytesCoverageSugar<'a> {
let launcher = Launcher::builder()
.shmem_provider(shmem_provider)
.configuration(conf)
.stats(stats)
.monitor(monitor)
.run_client(&mut run_client)
.cores(self.cores)
.broker_port(self.broker_port)

View File

@ -21,12 +21,12 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
generators::RandBytesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::{I2SRandReplace, Tokens},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
stages::{ShadowTracingStage, StdMutationalStage},
state::{HasCorpus, HasMetadata, StdState},
stats::MultiStats,
Error,
};
@ -99,7 +99,7 @@ where
let shmem_provider = StdShMemProvider::new().expect("Failed to init shared memory");
let stats = MultiStats::new(|s| println!("{}", s));
let monitor = MultiMonitor::new(|s| println!("{}", s));
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr, _core_id| {
// Create an observation channel using the coverage map
@ -254,7 +254,7 @@ where
let launcher = Launcher::builder()
.shmem_provider(shmem_provider)
.configuration(conf)
.stats(stats)
.monitor(monitor)
.run_client(&mut run_client)
.cores(self.cores)
.broker_port(self.broker_port)

View File

@ -21,12 +21,12 @@ use libafl::{
fuzzer::{Fuzzer, StdFuzzer},
generators::RandBytesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::MultiMonitor,
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::{token_mutations::Tokens, I2SRandReplace},
observers::{HitcountsMapObserver, TimeObserver, VariableMapObserver},
stages::{ShadowTracingStage, StdMutationalStage},
state::{HasCorpus, HasMetadata, StdState},
stats::MultiStats,
};
pub use libafl_qemu::emu;
@ -99,7 +99,7 @@ where
let shmem_provider = StdShMemProvider::new().expect("Failed to init shared memory");
let stats = MultiStats::new(|s| println!("{}", s));
let monitor = MultiMonitor::new(|s| println!("{}", s));
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr, _core_id| {
// Create an observation channel using the coverage map
@ -316,7 +316,7 @@ where
let launcher = Launcher::builder()
.shmem_provider(shmem_provider)
.configuration(conf)
.stats(stats)
.monitor(monitor)
.run_client(&mut run_client)
.cores(self.cores)
.broker_port(self.broker_port)

20
scripts/fmt_all.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$SCRIPT_DIR/.."
# TODO: This should be rewritten in rust, a Makefile, or some platform-independent language
echo "Welcome to the happy fmt script. :)"
echo "[*] Running fmt for the main crates"
cargo fmt
cd fuzzers
for fuzzer in *;
do
cd $fuzzer
echo "[*] Running fmt for $fuzzer"
cargo fmt --all
cd ..
done