pub struct Corpus { /* private fields */ }Expand description
The corpus containing testcases shared between all fuzzing workers.
Role of the Corpus in the Fuzzer.
Our mutation-based fuzzer needs an initial set of testcases to start running. These testcases
are stored in the corpus and can be loaded from a directory using Corpus::load_from_dir.
The fuzzer currently does not implement corpus minimization, a process that removes as many
testcases as possible without reducing coverage. While implementing such a system would
distill the current corpus to its essence, we would effectively lose out on information that
might have been useful for later iterations (e.g. a testcase that sets up an internal state
that would trigger a bug after being mutated for a few times). Instead, this fuzzer keeps all
testcases, but favors the least used ones when picking the next testcase using
Corpus::get_testcase.
Implementations
sourceimpl Corpus
impl Corpus
sourcepub fn new(
rand: Random,
corpus_path: impl AsRef<Path>,
work_dir: impl AsRef<Path>,
load_corpus: bool
) -> Result<Self>
pub fn new(
rand: Random,
corpus_path: impl AsRef<Path>,
work_dir: impl AsRef<Path>,
load_corpus: bool
) -> Result<Self>
Creates a new shared corpus.
sourcepub fn load_from_dir(&mut self, max_size: usize) -> Result<()>
pub fn load_from_dir(&mut self, max_size: usize) -> Result<()>
Loads all testcases stored in the path directory.
sourcepub fn add_testcase(&mut self, testcase: Testcase) -> Result<()>
pub fn add_testcase(&mut self, testcase: Testcase) -> Result<()>
Adds a testcase to the shared corpus.
sourcepub fn get_testcase(&mut self) -> Testcase
pub fn get_testcase(&mut self) -> Testcase
Gets one testcase from the shared corpus (the least used are more likely to be selected next).
sourcepub fn nb_entries(&self) -> usize
pub fn nb_entries(&self) -> usize
Returns the numbers of testcases in the corpus.