puffin/fuzzer/
mod.rs

1//! The fuzzer module setups the fuzzing loop. It also is responsible for gathering feedback from
2//! runs and restarting processes if they crash.
3
4use std::hash::{BuildHasher, Hash, Hasher};
5
6use chrono::Utc;
7use libafl::inputs::Input;
8use libafl_bolts::HasLen;
9
10use crate::protocol::ProtocolTypes;
11use crate::trace::Trace;
12
13pub mod harness;
14mod libafl_setup;
15pub mod sanitizer;
16pub mod stages;
17mod stats_monitor;
18pub mod stats_stage;
19pub mod term_zoo;
20// Public for benchmarks
21pub mod bit_mutations;
22pub mod config;
23pub mod feedback;
24pub mod mutations;
25pub mod utils;
26
27pub use libafl_setup::start;
28
29// LibAFL support
30impl<PT: ProtocolTypes> Input for Trace<PT> {
31    fn generate_name(&self, _idx: Option<libafl::corpus::CorpusId>) -> String {
32        let now = Utc::now();
33        let mut hasher = ahash::RandomState::with_seeds(0, 0, 0, 0).build_hasher();
34        self.hash(&mut hasher);
35        format!(
36            "{time}-{hash:016x}.trace",
37            hash = hasher.finish(),
38            time = now.format("%Y%m%d-%H%M%S%3f")
39        )
40    }
41}
42
43impl<PT: ProtocolTypes> HasLen for Trace<PT> {
44    fn len(&self) -> usize {
45        self.steps.len()
46    }
47}