From 08a32c3856c12bc2bef49bef6633e0c7404fba71 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Wed, 5 May 2021 14:32:47 +0200 Subject: [PATCH] more docs --- libafl/src/bolts/tuples.rs | 6 ++++++ libafl/src/corpus/minimizer.rs | 1 + libafl/src/corpus/queue.rs | 1 + libafl/src/events/mod.rs | 1 + libafl/src/executors/mod.rs | 6 ++++++ libafl/src/executors/timeout.rs | 3 +++ libafl/src/fuzzer.rs | 1 + 7 files changed, 19 insertions(+) diff --git a/libafl/src/bolts/tuples.rs b/libafl/src/bolts/tuples.rs index 6fcd58c13f..64ec061bc8 100644 --- a/libafl/src/bolts/tuples.rs +++ b/libafl/src/bolts/tuples.rs @@ -212,9 +212,12 @@ where } } +/// Allows prepending of values to a tuple pub trait Prepend: TupleList { type PreprendResult: TupleList; + /// Prepend a value to this tuple, returning a new tuple with prepended value. + #[must_use] fn prepend(self, value: T) -> (T, Self::PreprendResult); } @@ -230,9 +233,12 @@ where } } +/// Append to a `TupeList` pub trait Append: TupleList { type AppendResult: TupleList; + /// Append Value and return the tuple + #[must_use] fn append(self, value: T) -> Self::AppendResult; } diff --git a/libafl/src/corpus/minimizer.rs b/libafl/src/corpus/minimizer.rs index e4f12f95a1..861505dffc 100644 --- a/libafl/src/corpus/minimizer.rs +++ b/libafl/src/corpus/minimizer.rs @@ -15,6 +15,7 @@ use core::marker::PhantomData; use hashbrown::{HashMap, HashSet}; use serde::{Deserialize, Serialize}; +/// Default probability to skip the non-favored values pub const DEFAULT_SKIP_NOT_FAV_PROB: u64 = 95; /// A testcase metadata saying if a testcase is favored diff --git a/libafl/src/corpus/queue.rs b/libafl/src/corpus/queue.rs index 89b10b945f..e54eb7a581 100644 --- a/libafl/src/corpus/queue.rs +++ b/libafl/src/corpus/queue.rs @@ -53,6 +53,7 @@ where C: Corpus, I: Input, { + /// Creates a new `QueueCorpusScheduler` pub fn new() -> Self { Self { phantom: PhantomData, diff --git a/libafl/src/events/mod.rs b/libafl/src/events/mod.rs index b2c089a699..e332630d2f 100644 --- a/libafl/src/events/mod.rs +++ b/libafl/src/events/mod.rs @@ -108,6 +108,7 @@ where severity_level: LogSeverity, /// The message message: String, + /// `PhantomData` phantom: PhantomData, }, /*/// A custom type diff --git a/libafl/src/executors/mod.rs b/libafl/src/executors/mod.rs index b79dc5b259..b7c67e3b5a 100644 --- a/libafl/src/executors/mod.rs +++ b/libafl/src/executors/mod.rs @@ -16,15 +16,21 @@ use crate::{ use alloc::boxed::Box; +/// A `CustomExitKind` for exits that do not fit the default `ExitKind` pub trait CustomExitKind: core::fmt::Debug + SerdeAny + 'static {} /// How an execution finished. #[derive(Debug)] pub enum ExitKind { + /// The run exited normally. Ok, + /// The run resulted in a target crash. Crash, + /// The run hit an out of memory error. Oom, + /// The run timed out Timeout, + /// The run resulted in a custom `ExitKind`. Custom(Box), } diff --git a/libafl/src/executors/timeout.rs b/libafl/src/executors/timeout.rs index cc90cfabe3..4ecf9dc8ff 100644 --- a/libafl/src/executors/timeout.rs +++ b/libafl/src/executors/timeout.rs @@ -54,6 +54,8 @@ where E: Executor, I: Input, { + /// Create a new `TimeoutExecutor`, wrapping the given `executor` and checking for timeouts. + /// This should usually be used for `InProcess` fuzzing. pub fn new(executor: E, exec_tmout: Duration) -> Self { Self { executor, @@ -62,6 +64,7 @@ where } } + /// Retrieve the inner `Executor` that is wrapped by this `TimeoutExecutor`. pub fn inner(&mut self) -> &mut E { &mut self.executor } diff --git a/libafl/src/fuzzer.rs b/libafl/src/fuzzer.rs index e1eeb08c06..49de40bca5 100644 --- a/libafl/src/fuzzer.rs +++ b/libafl/src/fuzzer.rs @@ -237,6 +237,7 @@ where EM: EventManager, I: Input, { + /// Create a new `StdFuzzer` with standard behavior. pub fn new(stages: ST) -> Self { Self { stages,