add AFL stage names for calibration, colorization, power and sync stages (#2209)
* add AFL stage names for calibration, colorization, power and sync stages * clippy * add missing name field in sync stage * use consts instead of hardcoding in functions. change set_name to with_name for PowerMutationalStage remove irrelevant fn transforming * make AFL++ name default for all stages
This commit is contained in:
parent
22d8e92b08
commit
baf07445e4
@ -60,11 +60,14 @@ impl UnstableEntriesMetadata {
|
||||
}
|
||||
}
|
||||
|
||||
/// Default name for `CalibrationStage`; derived from AFL++
|
||||
pub const CALIBRATION_STAGE_NAME: &str = "calibration";
|
||||
/// The calibration stage will measure the average exec time and the target's stability for this input.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CalibrationStage<C, O, OT, S> {
|
||||
map_observer_handle: Handle<C>,
|
||||
map_name: Cow<'static, str>,
|
||||
name: Cow<'static, str>,
|
||||
stage_max: usize,
|
||||
/// If we should track stability
|
||||
track_stability: bool,
|
||||
@ -349,6 +352,7 @@ where
|
||||
track_stability: true,
|
||||
restart_helper: ExecutionCountRestartHelper::default(),
|
||||
phantom: PhantomData,
|
||||
name: Cow::Borrowed(CALIBRATION_STAGE_NAME),
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,6 +369,13 @@ where
|
||||
track_stability: false,
|
||||
restart_helper: ExecutionCountRestartHelper::default(),
|
||||
phantom: PhantomData,
|
||||
name: Cow::Borrowed(CALIBRATION_STAGE_NAME),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, O, OT, S> Named for CalibrationStage<C, O, OT, S> {
|
||||
fn name(&self) -> &Cow<'static, str> {
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
|
@ -52,10 +52,13 @@ impl Ord for Earlier {
|
||||
}
|
||||
}
|
||||
|
||||
/// Default name for `ColorizationStage`; derived from ALF++
|
||||
pub const COLORIZATION_STAGE_NAME: &str = "colorization";
|
||||
/// The mutational stage using power schedules
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ColorizationStage<C, E, EM, O, Z> {
|
||||
map_observer_handle: Handle<C>,
|
||||
name: Cow<'static, str>,
|
||||
#[allow(clippy::type_complexity)]
|
||||
phantom: PhantomData<(E, EM, O, E, Z)>,
|
||||
}
|
||||
@ -72,7 +75,7 @@ where
|
||||
E: UsesState,
|
||||
{
|
||||
fn name(&self) -> &Cow<'static, str> {
|
||||
self.map_observer_handle.name()
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,6 +311,7 @@ where
|
||||
pub fn new(map_observer: &C) -> Self {
|
||||
Self {
|
||||
map_observer_handle: map_observer.handle(),
|
||||
name: Cow::Borrowed(COLORIZATION_STAGE_NAME),
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
//! The power schedules. This stage should be invoked after the calibration stage.
|
||||
|
||||
use alloc::borrow::Cow;
|
||||
use core::{fmt::Debug, marker::PhantomData};
|
||||
|
||||
use libafl_bolts::Named;
|
||||
|
||||
use crate::{
|
||||
executors::{Executor, HasObservers},
|
||||
fuzzer::Evaluator,
|
||||
@ -11,10 +14,12 @@ use crate::{
|
||||
state::{HasCorpus, HasCurrentTestcase, HasExecutions, HasRand, UsesState},
|
||||
Error, HasMetadata,
|
||||
};
|
||||
|
||||
/// Default name for `PowerMutationalStage`; derived from AFL++
|
||||
pub const POWER_MUTATIONAL_STAGE_NAME: &str = "power";
|
||||
/// The mutational stage using power schedules
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PowerMutationalStage<E, F, EM, I, M, Z> {
|
||||
name: Cow<'static, str>,
|
||||
/// The mutators we use
|
||||
mutator: M,
|
||||
/// Helper for restarts
|
||||
@ -30,6 +35,12 @@ where
|
||||
type State = E::State;
|
||||
}
|
||||
|
||||
impl<E, F, EM, I, M, Z> Named for PowerMutationalStage<E, F, EM, I, M, Z> {
|
||||
fn name(&self) -> &Cow<'static, str> {
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
|
||||
impl<E, F, EM, I, M, Z> MutationalStage<E, EM, I, M, Z> for PowerMutationalStage<E, F, EM, I, M, Z>
|
||||
where
|
||||
E: Executor<EM, Z> + HasObservers,
|
||||
@ -112,22 +123,8 @@ where
|
||||
{
|
||||
/// Creates a new [`PowerMutationalStage`]
|
||||
pub fn new(mutator: M) -> Self {
|
||||
Self::transforming(mutator)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E, F, EM, I, M, Z> PowerMutationalStage<E, F, EM, I, M, Z>
|
||||
where
|
||||
E: Executor<EM, Z> + HasObservers,
|
||||
EM: UsesState<State = E::State>,
|
||||
F: TestcaseScore<E::State>,
|
||||
M: Mutator<I, E::State>,
|
||||
E::State: HasCorpus + HasMetadata + HasRand,
|
||||
Z: Evaluator<E, EM, State = E::State>,
|
||||
{
|
||||
/// Creates a new transforming [`PowerMutationalStage`]
|
||||
pub fn transforming(mutator: M) -> Self {
|
||||
Self {
|
||||
name: Cow::Borrowed(POWER_MUTATIONAL_STAGE_NAME),
|
||||
mutator,
|
||||
phantom: PhantomData,
|
||||
restart_helper: ExecutionCountRestartHelper::default(),
|
||||
|
@ -45,9 +45,13 @@ impl SyncFromDiskMetadata {
|
||||
}
|
||||
}
|
||||
|
||||
/// Default name for `SyncFromDiskStage`; derived from AFL++
|
||||
pub const SYNC_FROM_DISK_STAGE_NAME: &str = "sync";
|
||||
|
||||
/// A stage that loads testcases from disk to sync with other fuzzers such as AFL++
|
||||
#[derive(Debug)]
|
||||
pub struct SyncFromDiskStage<CB, E, EM, Z> {
|
||||
name: Cow<'static, str>,
|
||||
sync_dir: PathBuf,
|
||||
load_callback: CB,
|
||||
phantom: PhantomData<(E, EM, Z)>,
|
||||
@ -65,8 +69,7 @@ where
|
||||
E: UsesState,
|
||||
{
|
||||
fn name(&self) -> &Cow<'static, str> {
|
||||
static NAME: Cow<'static, str> = Cow::Borrowed("SyncFromDiskStage");
|
||||
&NAME
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,9 +141,10 @@ where
|
||||
#[must_use]
|
||||
pub fn new(sync_dir: PathBuf, load_callback: CB) -> Self {
|
||||
Self {
|
||||
name: Cow::Borrowed(SYNC_FROM_DISK_STAGE_NAME),
|
||||
phantom: PhantomData,
|
||||
sync_dir,
|
||||
load_callback,
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,6 +215,7 @@ where
|
||||
Input::from_file(p)
|
||||
}
|
||||
Self {
|
||||
name: Cow::Borrowed(SYNC_FROM_DISK_STAGE_NAME),
|
||||
sync_dir,
|
||||
load_callback: load_callback::<_, _>,
|
||||
phantom: PhantomData,
|
||||
|
Loading…
x
Reference in New Issue
Block a user