diff --git a/docs/src/core_concepts/mutator.md b/docs/src/core_concepts/mutator.md index 8406de7918..1956befd7c 100644 --- a/docs/src/core_concepts/mutator.md +++ b/docs/src/core_concepts/mutator.md @@ -6,6 +6,6 @@ Mutators can be composed, and they are generally linked to a specific Input type There can be, for instance, a Mutator that applies more than a single type of mutation to the input. Consider a generic Mutator for a byte stream, bit flip is just one of the possible mutations but not the only one, there is also, for instance, the random replacement of a byte of the copy of a chunk. -There are also mutators that always produce valid inputs, say a mutator that generates valid Json or code, but these grammar based mutators need a grammar to work. +There are also mutators that always produce valid inputs, say a mutator that generates valid JSON or code, but these grammar based mutators need a grammar to work. In LibAFL, [`Mutator`](https://docs.rs/libafl/latest/libafl/mutators/trait.Mutator.html) is a trait. diff --git a/fuzzers/dynamic_analysis/concatenator.py b/fuzzers/dynamic_analysis/concatenator.py index 0948167628..72f09f56c6 100755 --- a/fuzzers/dynamic_analysis/concatenator.py +++ b/fuzzers/dynamic_analysis/concatenator.py @@ -25,7 +25,7 @@ def concatenate_json_files(input_dir): with open(output_file, 'w') as file: json.dump([data], file) - print(f"Json files concatenated successfully! Output file: {output_file}") + print(f"JSON files concatenated successfully! Output file: {output_file}") if __name__ == '__main__': if len(sys.argv) != 2: diff --git a/fuzzers/libfuzzer_libpng_aflpp_ui/src/lib.rs b/fuzzers/libfuzzer_libpng_aflpp_ui/src/lib.rs index c4d80c7adf..af8a885aa8 100644 --- a/fuzzers/libfuzzer_libpng_aflpp_ui/src/lib.rs +++ b/fuzzers/libfuzzer_libpng_aflpp_ui/src/lib.rs @@ -69,8 +69,7 @@ fn fuzz( // 'While the stats are state, they are usually used in the broker - which is likely never restarted // let monitor = MultiMonitor::new(|s| println!("{s}")); - //Setup an Monitor with AFL-Style UI to display the stats - #[cfg(feature = "tui")] + // Setup an Monitor with AFL-Style UI to display the stats let monitor = TuiMonitor::builder() .title("Libfuzzer in LibAFL") .version("0.0.1") diff --git a/libafl/src/corpus/ondisk.rs b/libafl/src/corpus/ondisk.rs index 221d218411..273700d2ed 100644 --- a/libafl/src/corpus/ondisk.rs +++ b/libafl/src/corpus/ondisk.rs @@ -24,9 +24,9 @@ use crate::{ pub enum OnDiskMetadataFormat { /// A binary-encoded postcard Postcard, - /// Json + /// JSON Json, - /// Json formatted for readability + /// JSON formatted for readability #[default] JsonPretty, /// The same as [`OnDiskMetadataFormat::JsonPretty`], but compressed diff --git a/libafl/src/monitors/disk.rs b/libafl/src/monitors/disk.rs index baaeb4d30b..ed745ae07b 100644 --- a/libafl/src/monitors/disk.rs +++ b/libafl/src/monitors/disk.rs @@ -1,4 +1,4 @@ -//! Monitors that wrap a base monitor and also log to disk using different formats. +//! Monitors that wrap a base monitor and also log to disk using different formats like `JSON` and `TOML`. use alloc::{string::String, vec::Vec}; use core::time::Duration; diff --git a/libafl/src/monitors/mod.rs b/libafl/src/monitors/mod.rs index 5800539463..9a4ede5348 100644 --- a/libafl/src/monitors/mod.rs +++ b/libafl/src/monitors/mod.rs @@ -7,7 +7,6 @@ pub use multi::MultiMonitor; pub mod tui; #[cfg(all(feature = "prometheus_monitor", feature = "std"))] -#[allow(missing_docs)] pub mod prometheus; use alloc::string::ToString; diff --git a/libafl/src/monitors/multi.rs b/libafl/src/monitors/multi.rs index cf338781f3..e5a3e56c0e 100644 --- a/libafl/src/monitors/multi.rs +++ b/libafl/src/monitors/multi.rs @@ -1,4 +1,4 @@ -//! Monitor to display both cumulative and per-client monitor +//! The [`MultiMonitor`] displays both cumulative and per-client stats. use alloc::{string::String, vec::Vec}; use core::{ diff --git a/libafl/src/monitors/prometheus.rs b/libafl/src/monitors/prometheus.rs index 4eaf567209..cdaa27b587 100644 --- a/libafl/src/monitors/prometheus.rs +++ b/libafl/src/monitors/prometheus.rs @@ -1,16 +1,16 @@ -//! Prometheus Monitor to log to a prometheus endpoint. +//! The [`PrometheusMonitor`] logs fuzzer progress to a prometheus endpoint. //! //! ## Overview //! //! The client (i.e., the fuzzer) sets up an HTTP endpoint (/metrics). //! The endpoint contains metrics such as execution rate. //! -//! A prometheus server (can use a precompiled binary or docker) then scrapes \ +//! A prometheus server (can use a precompiled binary or docker) then scrapes //! the endpoint at regular intervals (configurable via prometheus.yml file). //! //! ## How to use it //! -//! This monitor should plug into any fuzzer similar to other monitors. +//! Create a [`PrometheusMonitor`] and plug it into any fuzzer similar to other monitors. //! In your fuzzer: //! //! ```rust @@ -199,6 +199,9 @@ impl PrometheusMonitor where F: FnMut(&str), { + /// Create a new [`PrometheusMonitor`]. + /// The `listener` is the address to send logs to. + /// The `print_fn` is the printing function that can output the logs otherwise. pub fn new(listener: String, print_fn: F) -> Self { // Gauge's implementation of clone uses Arc let corpus_count = Family::::default(); @@ -290,9 +293,9 @@ where } } -// set up an HTTP endpoint /metrics +/// Set up an HTTP endpoint /metrics #[allow(clippy::too_many_arguments)] -pub async fn serve_metrics( +pub(crate) async fn serve_metrics( listener: String, corpus: Family, objectives: Family, @@ -354,12 +357,16 @@ pub async fn serve_metrics( Ok(()) } +/// Struct used to define the labels in `prometheus`. #[derive(Clone, Hash, PartialEq, Eq, EncodeLabelSet, Debug)] pub struct Labels { - client: u32, // sender_id: u32, to differentiate between clients when multiple are spawned. - stat: Cow<'static, str>, // for custom_stat filtering. + /// The `sender_id` helps to differentiate between clients when multiple are spawned. + client: u32, + /// Used for `custom_stat` filtering. + stat: Cow<'static, str>, } +/// The state for this monitor. #[derive(Clone)] struct State { registry: Arc, diff --git a/libafl/src/monitors/tui/mod.rs b/libafl/src/monitors/tui/mod.rs index 6e5944f322..77cbbe0ee9 100644 --- a/libafl/src/monitors/tui/mod.rs +++ b/libafl/src/monitors/tui/mod.rs @@ -1,4 +1,6 @@ -//! Fancy-looking terminal UI monitor, similar to AFL, based on [ratatui](https://ratatui.rs/) +//! [`TuiMonitor`] is a fancy-looking TUI monitor similar to `AFL`. +//! +//! It's based on [ratatui](https://ratatui.rs/) use alloc::{borrow::Cow, boxed::Box, string::ToString}; use core::cmp; @@ -126,10 +128,15 @@ impl TimedStats { #[cfg(feature = "introspection")] #[derive(Debug, Default, Clone)] pub struct PerfTuiContext { + /// Time spent in the scheduler pub scheduler: f64, + /// Time spent in the event manager pub manager: f64, + /// Additional time pub unmeasured: f64, + /// Time spent in each individual stage pub stages: Vec>, + /// Time spent in each individual feedback pub feedbacks: Vec<(String, f64)>, } @@ -234,6 +241,7 @@ pub struct ItemGeometry { } impl ItemGeometry { + /// Create a new [`ItemGeometry`] fn new() -> Self { Self { stability: "0%".to_string(),