* Fix docs (follow-up to #2385) * More fix * fix fuzzer * More docs
This commit is contained in:
parent
3c93b96b70
commit
7feeb00546
@ -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.
|
||||
|
@ -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:
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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::{
|
||||
|
@ -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>,
|
||||
|
@ -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(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user