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