Fix docs (follow-up to #2385) (#2388)

* Fix docs (follow-up to #2385)

* More fix

* fix fuzzer

* More docs
This commit is contained in:
Dominik Maier 2024-07-12 16:13:43 +02:00 committed by GitHub
parent 3c93b96b70
commit 7feeb00546
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 30 additions and 17 deletions

View File

@ -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.

View File

@ -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:

View File

@ -70,7 +70,6 @@ fn fuzz(
// let monitor = MultiMonitor::new(|s| println!("{s}"));
// Setup an Monitor with AFL-Style UI to display the stats
#[cfg(feature = "tui")]
let monitor = TuiMonitor::builder()
.title("Libfuzzer in LibAFL")
.version("0.0.1")

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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::{

View File

@ -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<F> PrometheusMonitor<F>
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::<Labels, Gauge>::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<Labels, Gauge>,
objectives: Family<Labels, Gauge>,
@ -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<Registry>,

View File

@ -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<Vec<(String, f64)>>,
/// 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(),