Use Self::State as much as possible and remove unnecessary type bounds (#2263)
* use Self::State as much as possible * makeing progress, little by little * more * add * more and more * more * more * mre * fix * a * pp * fix * fix * more * version * fix cargo fuzz
This commit is contained in:
parent
a7bb5196ea
commit
6373a1e1b3
@ -749,14 +749,15 @@ where
|
|||||||
fn receive_from_secondary<E, Z>(
|
fn receive_from_secondary<E, Z>(
|
||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
state: &mut EM::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
) -> Result<usize, Error>
|
) -> Result<usize, Error>
|
||||||
where
|
where
|
||||||
E: Executor<Self, Z> + HasObservers<State = EM::State>,
|
E: Executor<Self, Z> + HasObservers<State = <Self as UsesState>::State>,
|
||||||
EM::State: UsesInput + HasExecutions + HasMetadata,
|
<Self as UsesState>::State: UsesInput + HasExecutions + HasMetadata,
|
||||||
for<'a> E::Observers: Deserialize<'a>,
|
for<'a> E::Observers: Deserialize<'a>,
|
||||||
Z: ExecutionProcessor<E::Observers, State = EM::State> + EvaluatorObservers<E::Observers>,
|
Z: ExecutionProcessor<E::Observers, State = <Self as UsesState>::State>
|
||||||
|
+ EvaluatorObservers<E::Observers>,
|
||||||
{
|
{
|
||||||
// TODO: Get around local event copy by moving handle_in_client
|
// TODO: Get around local event copy by moving handle_in_client
|
||||||
let self_id = self.client.sender().id();
|
let self_id = self.client.sender().id();
|
||||||
@ -781,7 +782,7 @@ where
|
|||||||
} else {
|
} else {
|
||||||
msg
|
msg
|
||||||
};
|
};
|
||||||
let event: Event<<<EM as UsesState>::State as UsesInput>::Input> =
|
let event: Event<<<Self as UsesState>::State as UsesInput>::Input> =
|
||||||
postcard::from_bytes(event_bytes)?;
|
postcard::from_bytes(event_bytes)?;
|
||||||
self.handle_in_main(fuzzer, executor, state, client_id, event)?;
|
self.handle_in_main(fuzzer, executor, state, client_id, event)?;
|
||||||
count += 1;
|
count += 1;
|
||||||
@ -794,15 +795,16 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut EM::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
client_id: ClientId,
|
client_id: ClientId,
|
||||||
event: Event<<EM::State as UsesInput>::Input>,
|
event: Event<<<Self as UsesState>::State as UsesInput>::Input>,
|
||||||
) -> Result<(), Error>
|
) -> Result<(), Error>
|
||||||
where
|
where
|
||||||
E: Executor<Self, Z> + HasObservers<State = EM::State>,
|
E: Executor<Self, Z> + HasObservers<State = <Self as UsesState>::State>,
|
||||||
EM::State: UsesInput + HasExecutions + HasMetadata,
|
<Self as UsesState>::State: UsesInput + HasExecutions + HasMetadata,
|
||||||
for<'a> E::Observers: Deserialize<'a>,
|
for<'a> E::Observers: Deserialize<'a>,
|
||||||
Z: ExecutionProcessor<E::Observers, State = EM::State> + EvaluatorObservers<E::Observers>,
|
Z: ExecutionProcessor<E::Observers, State = <Self as UsesState>::State>
|
||||||
|
+ EvaluatorObservers<E::Observers>,
|
||||||
{
|
{
|
||||||
match event {
|
match event {
|
||||||
Event::NewTestcase {
|
Event::NewTestcase {
|
||||||
|
@ -80,15 +80,7 @@ const LIBAFL_DEBUG_OUTPUT: &str = "LIBAFL_DEBUG_OUTPUT";
|
|||||||
clippy::ignored_unit_patterns
|
clippy::ignored_unit_patterns
|
||||||
)]
|
)]
|
||||||
#[derive(TypedBuilder)]
|
#[derive(TypedBuilder)]
|
||||||
pub struct Launcher<'a, CF, EMH, MT, S, SP>
|
pub struct Launcher<'a, CF, EMH, MT, S, SP> {
|
||||||
where
|
|
||||||
CF: FnOnce(Option<S>, LlmpRestartingEventManager<EMH, S, SP>, CoreId) -> Result<(), Error>,
|
|
||||||
EMH: EventManagerHooksTuple<S>,
|
|
||||||
S::Input: 'a,
|
|
||||||
MT: Monitor,
|
|
||||||
SP: ShMemProvider + 'static,
|
|
||||||
S: State + 'a,
|
|
||||||
{
|
|
||||||
/// The `ShmemProvider` to use
|
/// The `ShmemProvider` to use
|
||||||
shmem_provider: SP,
|
shmem_provider: SP,
|
||||||
/// The monitor instance to use
|
/// The monitor instance to use
|
||||||
@ -472,23 +464,7 @@ where
|
|||||||
#[cfg(all(unix, feature = "std", feature = "fork"))]
|
#[cfg(all(unix, feature = "std", feature = "fork"))]
|
||||||
#[derive(TypedBuilder)]
|
#[derive(TypedBuilder)]
|
||||||
#[allow(clippy::type_complexity, missing_debug_implementations)]
|
#[allow(clippy::type_complexity, missing_debug_implementations)]
|
||||||
pub struct CentralizedLauncher<'a, CF, MF, MT, S, SP>
|
pub struct CentralizedLauncher<'a, CF, MF, MT, S, SP> {
|
||||||
where
|
|
||||||
CF: FnOnce(
|
|
||||||
Option<S>,
|
|
||||||
CentralizedEventManager<LlmpRestartingEventManager<(), S, SP>, SP>, // No hooks for centralized EM
|
|
||||||
CoreId,
|
|
||||||
) -> Result<(), Error>,
|
|
||||||
MF: FnOnce(
|
|
||||||
Option<S>,
|
|
||||||
CentralizedEventManager<LlmpRestartingEventManager<(), S, SP>, SP>, // No hooks for centralized EM
|
|
||||||
CoreId,
|
|
||||||
) -> Result<(), Error>,
|
|
||||||
S::Input: 'a,
|
|
||||||
MT: Monitor,
|
|
||||||
SP: ShMemProvider + 'static,
|
|
||||||
S: State + 'a,
|
|
||||||
{
|
|
||||||
/// The `ShmemProvider` to use
|
/// The `ShmemProvider` to use
|
||||||
shmem_provider: SP,
|
shmem_provider: SP,
|
||||||
/// The monitor instance to use
|
/// The monitor instance to use
|
||||||
@ -552,22 +528,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(unix, feature = "std", feature = "fork"))]
|
#[cfg(all(unix, feature = "std", feature = "fork"))]
|
||||||
impl<CF, MF, MT, S, SP> Debug for CentralizedLauncher<'_, CF, MF, MT, S, SP>
|
impl<CF, MF, MT, S, SP> Debug for CentralizedLauncher<'_, CF, MF, MT, S, SP> {
|
||||||
where
|
|
||||||
CF: FnOnce(
|
|
||||||
Option<S>,
|
|
||||||
CentralizedEventManager<LlmpRestartingEventManager<(), S, SP>, SP>,
|
|
||||||
CoreId,
|
|
||||||
) -> Result<(), Error>,
|
|
||||||
MF: FnOnce(
|
|
||||||
Option<S>,
|
|
||||||
CentralizedEventManager<LlmpRestartingEventManager<(), S, SP>, SP>, // No hooks for centralized EM
|
|
||||||
CoreId,
|
|
||||||
) -> Result<(), Error>,
|
|
||||||
MT: Monitor + Clone,
|
|
||||||
SP: ShMemProvider + 'static,
|
|
||||||
S: State,
|
|
||||||
{
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("Launcher")
|
f.debug_struct("Launcher")
|
||||||
.field("configuration", &self.configuration)
|
.field("configuration", &self.configuration)
|
||||||
|
@ -21,10 +21,7 @@ use crate::{
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct LlmpEventBroker<I, MT, SP>
|
pub struct LlmpEventBroker<I, MT, SP>
|
||||||
where
|
where
|
||||||
I: Input,
|
|
||||||
SP: ShMemProvider + 'static,
|
SP: ShMemProvider + 'static,
|
||||||
MT: Monitor,
|
|
||||||
//CE: CustomEvent<I>,
|
|
||||||
{
|
{
|
||||||
monitor: MT,
|
monitor: MT,
|
||||||
llmp: llmp::LlmpBroker<SP>,
|
llmp: llmp::LlmpBroker<SP>,
|
||||||
|
@ -787,7 +787,7 @@ where
|
|||||||
impl<E, EM, M, Z> EventManager<E, Z> for MonitorTypedEventManager<EM, M>
|
impl<E, EM, M, Z> EventManager<E, Z> for MonitorTypedEventManager<EM, M>
|
||||||
where
|
where
|
||||||
EM: EventManager<E, Z>,
|
EM: EventManager<E, Z>,
|
||||||
EM::State: HasLastReportTime + HasExecutions + HasMetadata,
|
Self::State: HasLastReportTime + HasExecutions + HasMetadata,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,7 +811,7 @@ impl<EM, M> ProgressReporter for MonitorTypedEventManager<EM, M>
|
|||||||
where
|
where
|
||||||
Self: UsesState,
|
Self: UsesState,
|
||||||
EM: ProgressReporter<State = Self::State>,
|
EM: ProgressReporter<State = Self::State>,
|
||||||
EM::State: HasLastReportTime + HasExecutions + HasMetadata,
|
Self::State: HasLastReportTime + HasExecutions + HasMetadata,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn maybe_report_progress(
|
fn maybe_report_progress(
|
||||||
|
@ -24,9 +24,9 @@ impl<A, B> CombinedExecutor<A, B> {
|
|||||||
pub fn new<EM, Z>(primary: A, secondary: B) -> Self
|
pub fn new<EM, Z>(primary: A, secondary: B) -> Self
|
||||||
where
|
where
|
||||||
A: Executor<EM, Z>,
|
A: Executor<EM, Z>,
|
||||||
B: Executor<EM, Z, State = A::State>,
|
B: Executor<EM, Z, State = <Self as UsesState>::State>,
|
||||||
EM: UsesState<State = A::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
Z: UsesState<State = A::State>,
|
Z: UsesState<State = <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
Self { primary, secondary }
|
Self { primary, secondary }
|
||||||
}
|
}
|
||||||
@ -45,10 +45,10 @@ impl<A, B> CombinedExecutor<A, B> {
|
|||||||
impl<A, B, EM, Z> Executor<EM, Z> for CombinedExecutor<A, B>
|
impl<A, B, EM, Z> Executor<EM, Z> for CombinedExecutor<A, B>
|
||||||
where
|
where
|
||||||
A: Executor<EM, Z>,
|
A: Executor<EM, Z>,
|
||||||
B: Executor<EM, Z, State = A::State>,
|
B: Executor<EM, Z, State = <Self as UsesState>::State>,
|
||||||
EM: UsesState<State = A::State>,
|
Self::State: HasExecutions,
|
||||||
EM::State: HasExecutions,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
Z: UsesState<State = A::State>,
|
Z: UsesState<State = <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
fn run_target(
|
fn run_target(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -31,10 +31,10 @@ impl<A, B, DOT, OTA, OTB> DiffExecutor<A, B, DOT, OTA, OTB> {
|
|||||||
pub fn new(primary: A, secondary: B, observers: DOT) -> Self
|
pub fn new(primary: A, secondary: B, observers: DOT) -> Self
|
||||||
where
|
where
|
||||||
A: UsesState + HasObservers<Observers = OTA>,
|
A: UsesState + HasObservers<Observers = OTA>,
|
||||||
B: UsesState<State = A::State> + HasObservers<Observers = OTB>,
|
B: UsesState<State = <Self as UsesState>::State> + HasObservers<Observers = OTB>,
|
||||||
DOT: DifferentialObserversTuple<OTA, OTB, A::State>,
|
DOT: DifferentialObserversTuple<OTA, OTB, <Self as UsesState>::State>,
|
||||||
OTA: ObserversTuple<A::State>,
|
OTA: ObserversTuple<<Self as UsesState>::State>,
|
||||||
OTB: ObserversTuple<A::State>,
|
OTB: ObserversTuple<<Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
primary,
|
primary,
|
||||||
@ -61,10 +61,10 @@ impl<A, B, DOT, OTA, OTB> DiffExecutor<A, B, DOT, OTA, OTB> {
|
|||||||
impl<A, B, DOT, EM, Z> Executor<EM, Z> for DiffExecutor<A, B, DOT, A::Observers, B::Observers>
|
impl<A, B, DOT, EM, Z> Executor<EM, Z> for DiffExecutor<A, B, DOT, A::Observers, B::Observers>
|
||||||
where
|
where
|
||||||
A: Executor<EM, Z> + HasObservers,
|
A: Executor<EM, Z> + HasObservers,
|
||||||
B: Executor<EM, Z, State = A::State> + HasObservers,
|
B: Executor<EM, Z, State = <Self as UsesState>::State> + HasObservers,
|
||||||
EM: UsesState<State = A::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
DOT: DifferentialObserversTuple<A::Observers, B::Observers, A::State>,
|
DOT: DifferentialObserversTuple<A::Observers, B::Observers, <Self as UsesState>::State>,
|
||||||
Z: UsesState<State = A::State>,
|
Z: UsesState<State = <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
fn run_target(
|
fn run_target(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -196,10 +196,10 @@ impl<A, B, DOT> ProxyObserversTuple<A, B, DOT> {
|
|||||||
impl<A, B, DOT, OTA, OTB> UsesObservers for DiffExecutor<A, B, DOT, OTA, OTB>
|
impl<A, B, DOT, OTA, OTB> UsesObservers for DiffExecutor<A, B, DOT, OTA, OTB>
|
||||||
where
|
where
|
||||||
A: HasObservers<Observers = OTA>,
|
A: HasObservers<Observers = OTA>,
|
||||||
B: HasObservers<Observers = OTB, State = A::State>,
|
B: HasObservers<Observers = OTB, State = <Self as UsesState>::State>,
|
||||||
OTA: ObserversTuple<A::State>,
|
OTA: ObserversTuple<<Self as UsesState>::State>,
|
||||||
OTB: ObserversTuple<A::State>,
|
OTB: ObserversTuple<<Self as UsesState>::State>,
|
||||||
DOT: DifferentialObserversTuple<OTA, OTB, A::State>,
|
DOT: DifferentialObserversTuple<OTA, OTB, <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
type Observers = ProxyObserversTuple<OTA, OTB, DOT>;
|
type Observers = ProxyObserversTuple<OTA, OTB, DOT>;
|
||||||
}
|
}
|
||||||
@ -207,7 +207,6 @@ where
|
|||||||
impl<A, B, DOT, OTA, OTB> UsesState for DiffExecutor<A, B, DOT, OTA, OTB>
|
impl<A, B, DOT, OTA, OTB> UsesState for DiffExecutor<A, B, DOT, OTA, OTB>
|
||||||
where
|
where
|
||||||
A: UsesState,
|
A: UsesState,
|
||||||
B: UsesState<State = A::State>,
|
|
||||||
{
|
{
|
||||||
type State = A::State;
|
type State = A::State;
|
||||||
}
|
}
|
||||||
@ -215,10 +214,10 @@ where
|
|||||||
impl<A, B, DOT, OTA, OTB> HasObservers for DiffExecutor<A, B, DOT, OTA, OTB>
|
impl<A, B, DOT, OTA, OTB> HasObservers for DiffExecutor<A, B, DOT, OTA, OTB>
|
||||||
where
|
where
|
||||||
A: HasObservers<Observers = OTA>,
|
A: HasObservers<Observers = OTA>,
|
||||||
B: HasObservers<Observers = OTB, State = A::State>,
|
B: HasObservers<Observers = OTB, State = <Self as UsesState>::State>,
|
||||||
OTA: ObserversTuple<A::State>,
|
OTA: ObserversTuple<<Self as UsesState>::State>,
|
||||||
OTB: ObserversTuple<A::State>,
|
OTB: ObserversTuple<<Self as UsesState>::State>,
|
||||||
DOT: DifferentialObserversTuple<OTA, OTB, A::State>,
|
DOT: DifferentialObserversTuple<OTA, OTB, <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn observers(&self) -> RefIndexable<&Self::Observers, Self::Observers> {
|
fn observers(&self) -> RefIndexable<&Self::Observers, Self::Observers> {
|
||||||
|
@ -21,8 +21,8 @@ pub struct ShadowExecutor<E, SOT> {
|
|||||||
|
|
||||||
impl<E, SOT> Debug for ShadowExecutor<E, SOT>
|
impl<E, SOT> Debug for ShadowExecutor<E, SOT>
|
||||||
where
|
where
|
||||||
E: UsesState + Debug,
|
E: Debug,
|
||||||
SOT: ObserversTuple<E::State> + Debug,
|
SOT: Debug,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("ShadowExecutor")
|
f.debug_struct("ShadowExecutor")
|
||||||
@ -35,7 +35,7 @@ where
|
|||||||
impl<E, SOT> ShadowExecutor<E, SOT>
|
impl<E, SOT> ShadowExecutor<E, SOT>
|
||||||
where
|
where
|
||||||
E: HasObservers,
|
E: HasObservers,
|
||||||
SOT: ObserversTuple<E::State>,
|
SOT: ObserversTuple<<Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
/// Create a new `ShadowExecutor`, wrapping the given `executor`.
|
/// Create a new `ShadowExecutor`, wrapping the given `executor`.
|
||||||
pub fn new(executor: E, shadow_observers: SOT) -> Self {
|
pub fn new(executor: E, shadow_observers: SOT) -> Self {
|
||||||
@ -61,9 +61,9 @@ where
|
|||||||
impl<E, EM, SOT, Z> Executor<EM, Z> for ShadowExecutor<E, SOT>
|
impl<E, EM, SOT, Z> Executor<EM, Z> for ShadowExecutor<E, SOT>
|
||||||
where
|
where
|
||||||
E: Executor<EM, Z> + HasObservers,
|
E: Executor<EM, Z> + HasObservers,
|
||||||
SOT: ObserversTuple<E::State>,
|
SOT: ObserversTuple<Self::State>,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = Self::State>,
|
||||||
{
|
{
|
||||||
fn run_target(
|
fn run_target(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -93,7 +93,7 @@ where
|
|||||||
impl<E, SOT> HasObservers for ShadowExecutor<E, SOT>
|
impl<E, SOT> HasObservers for ShadowExecutor<E, SOT>
|
||||||
where
|
where
|
||||||
E: HasObservers,
|
E: HasObservers,
|
||||||
SOT: ObserversTuple<E::State>,
|
SOT: ObserversTuple<Self::State>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn observers(&self) -> RefIndexable<&Self::Observers, Self::Observers> {
|
fn observers(&self) -> RefIndexable<&Self::Observers, Self::Observers> {
|
||||||
|
@ -21,8 +21,8 @@ pub struct WithObservers<E, OT> {
|
|||||||
impl<E, EM, OT, Z> Executor<EM, Z> for WithObservers<E, OT>
|
impl<E, EM, OT, Z> Executor<EM, Z> for WithObservers<E, OT>
|
||||||
where
|
where
|
||||||
E: Executor<EM, Z>,
|
E: Executor<EM, Z>,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = Self::State>,
|
||||||
{
|
{
|
||||||
fn run_target(
|
fn run_target(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -45,7 +45,7 @@ where
|
|||||||
impl<E, OT> UsesObservers for WithObservers<E, OT>
|
impl<E, OT> UsesObservers for WithObservers<E, OT>
|
||||||
where
|
where
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
OT: ObserversTuple<E::State>,
|
OT: ObserversTuple<Self::State>,
|
||||||
{
|
{
|
||||||
type Observers = OT;
|
type Observers = OT;
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ where
|
|||||||
impl<E, OT> HasObservers for WithObservers<E, OT>
|
impl<E, OT> HasObservers for WithObservers<E, OT>
|
||||||
where
|
where
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
OT: ObserversTuple<E::State>,
|
OT: ObserversTuple<Self::State>,
|
||||||
{
|
{
|
||||||
fn observers(&self) -> RefIndexable<&Self::Observers, Self::Observers> {
|
fn observers(&self) -> RefIndexable<&Self::Observers, Self::Observers> {
|
||||||
RefIndexable::from(&self.observers)
|
RefIndexable::from(&self.observers)
|
||||||
|
@ -50,7 +50,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, I, S, T> FeedbackFactory<CustomFilenameToTestcaseFeedback<F, I, S>, S, T>
|
impl<F, I, S, T> FeedbackFactory<CustomFilenameToTestcaseFeedback<F, I, S>, T>
|
||||||
for CustomFilenameToTestcaseFeedback<F, I, S>
|
for CustomFilenameToTestcaseFeedback<F, I, S>
|
||||||
where
|
where
|
||||||
I: Input,
|
I: Input,
|
||||||
|
@ -100,7 +100,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, I, O1, O2, S, T> FeedbackFactory<DiffFeedback<F, I, O1, O2, S>, S, T>
|
impl<F, I, O1, O2, S, T> FeedbackFactory<DiffFeedback<F, I, O1, O2, S>, T>
|
||||||
for DiffFeedback<F, I, O1, O2, S>
|
for DiffFeedback<F, I, O1, O2, S>
|
||||||
where
|
where
|
||||||
F: FnMut(&O1, &O2) -> DiffResult + Clone,
|
F: FnMut(&O1, &O2) -> DiffResult + Clone,
|
||||||
|
@ -310,11 +310,11 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A, B, FL, S, T> FeedbackFactory<CombinedFeedback<A, B, FL, S>, S, T>
|
impl<A, B, FL, S, T> FeedbackFactory<CombinedFeedback<A, B, FL, S>, T>
|
||||||
for CombinedFeedback<A, B, FL, S>
|
for CombinedFeedback<A, B, FL, S>
|
||||||
where
|
where
|
||||||
A: Feedback<S> + FeedbackFactory<A, S, T>,
|
A: Feedback<S> + FeedbackFactory<A, T>,
|
||||||
B: Feedback<S> + FeedbackFactory<B, S, T>,
|
B: Feedback<S> + FeedbackFactory<B, T>,
|
||||||
FL: FeedbackLogic<A, B, S>,
|
FL: FeedbackLogic<A, B, S>,
|
||||||
S: State,
|
S: State,
|
||||||
{
|
{
|
||||||
@ -383,20 +383,14 @@ where
|
|||||||
|
|
||||||
/// Factory for feedbacks which should be sensitive to an existing context, e.g. observer(s) from a
|
/// Factory for feedbacks which should be sensitive to an existing context, e.g. observer(s) from a
|
||||||
/// specific execution
|
/// specific execution
|
||||||
pub trait FeedbackFactory<F, S, T>
|
pub trait FeedbackFactory<F, T> {
|
||||||
where
|
|
||||||
F: Feedback<S>,
|
|
||||||
S: State,
|
|
||||||
{
|
|
||||||
/// Create the feedback from the provided context
|
/// Create the feedback from the provided context
|
||||||
fn create_feedback(&self, ctx: &T) -> F;
|
fn create_feedback(&self, ctx: &T) -> F;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<FE, FU, S, T> FeedbackFactory<FE, S, T> for FU
|
impl<FE, FU, T> FeedbackFactory<FE, T> for FU
|
||||||
where
|
where
|
||||||
FU: Fn(&T) -> FE,
|
FU: Fn(&T) -> FE,
|
||||||
FE: Feedback<S>,
|
|
||||||
S: State,
|
|
||||||
{
|
{
|
||||||
fn create_feedback(&self, ctx: &T) -> FE {
|
fn create_feedback(&self, ctx: &T) -> FE {
|
||||||
self(ctx)
|
self(ctx)
|
||||||
@ -982,7 +976,7 @@ impl Default for CrashFeedback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: State, T> FeedbackFactory<CrashFeedback, S, T> for CrashFeedback {
|
impl<T> FeedbackFactory<CrashFeedback, T> for CrashFeedback {
|
||||||
fn create_feedback(&self, _ctx: &T) -> CrashFeedback {
|
fn create_feedback(&self, _ctx: &T) -> CrashFeedback {
|
||||||
CrashFeedback::new()
|
CrashFeedback::new()
|
||||||
}
|
}
|
||||||
@ -1053,7 +1047,7 @@ impl Default for TimeoutFeedback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A feedback factory for timeout feedbacks
|
/// A feedback factory for timeout feedbacks
|
||||||
impl<S: State, T> FeedbackFactory<TimeoutFeedback, S, T> for TimeoutFeedback {
|
impl<T> FeedbackFactory<TimeoutFeedback, T> for TimeoutFeedback {
|
||||||
fn create_feedback(&self, _ctx: &T) -> TimeoutFeedback {
|
fn create_feedback(&self, _ctx: &T) -> TimeoutFeedback {
|
||||||
TimeoutFeedback::new()
|
TimeoutFeedback::new()
|
||||||
}
|
}
|
||||||
@ -1123,7 +1117,7 @@ impl Default for DiffExitKindFeedback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A feedback factory for diff exit kind feedbacks
|
/// A feedback factory for diff exit kind feedbacks
|
||||||
impl<S: State, T> FeedbackFactory<DiffExitKindFeedback, S, T> for DiffExitKindFeedback {
|
impl<T> FeedbackFactory<DiffExitKindFeedback, T> for DiffExitKindFeedback {
|
||||||
fn create_feedback(&self, _ctx: &T) -> DiffExitKindFeedback {
|
fn create_feedback(&self, _ctx: &T) -> DiffExitKindFeedback {
|
||||||
DiffExitKindFeedback::new()
|
DiffExitKindFeedback::new()
|
||||||
}
|
}
|
||||||
|
@ -130,11 +130,7 @@ pub trait EvaluatorObservers<OT>: UsesState + Sized {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluate an input modifying the state of the fuzzer
|
/// Evaluate an input modifying the state of the fuzzer
|
||||||
pub trait Evaluator<E, EM>: UsesState
|
pub trait Evaluator<E, EM>: UsesState {
|
||||||
where
|
|
||||||
E: UsesState<State = Self::State>,
|
|
||||||
EM: UsesState<State = Self::State>,
|
|
||||||
{
|
|
||||||
/// Runs the input and triggers observers and feedback,
|
/// Runs the input and triggers observers and feedback,
|
||||||
/// returns if is interesting an (option) the index of the new [`crate::corpus::Testcase`] in the corpus
|
/// returns if is interesting an (option) the index of the new [`crate::corpus::Testcase`] in the corpus
|
||||||
fn evaluate_input(
|
fn evaluate_input(
|
||||||
@ -204,7 +200,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
stages: &mut ST,
|
stages: &mut ST,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut EM::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<CorpusId, Error>;
|
) -> Result<CorpusId, Error>;
|
||||||
|
|
||||||
@ -213,7 +209,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
stages: &mut ST,
|
stages: &mut ST,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut EM::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let monitor_timeout = STATS_TIMEOUT_DEFAULT;
|
let monitor_timeout = STATS_TIMEOUT_DEFAULT;
|
||||||
@ -237,7 +233,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
stages: &mut ST,
|
stages: &mut ST,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut EM::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
iters: u64,
|
iters: u64,
|
||||||
) -> Result<CorpusId, Error> {
|
) -> Result<CorpusId, Error> {
|
||||||
@ -280,13 +276,7 @@ pub enum ExecuteInputResult {
|
|||||||
|
|
||||||
/// Your default fuzzer instance, for everyday use.
|
/// Your default fuzzer instance, for everyday use.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct StdFuzzer<CS, F, OF, OT>
|
pub struct StdFuzzer<CS, F, OF, OT> {
|
||||||
where
|
|
||||||
CS: Scheduler,
|
|
||||||
F: Feedback<CS::State>,
|
|
||||||
OF: Feedback<CS::State>,
|
|
||||||
CS::State: HasCorpus,
|
|
||||||
{
|
|
||||||
scheduler: CS,
|
scheduler: CS,
|
||||||
feedback: F,
|
feedback: F,
|
||||||
objective: OF,
|
objective: OF,
|
||||||
@ -296,8 +286,6 @@ where
|
|||||||
impl<CS, F, OF, OT> UsesState for StdFuzzer<CS, F, OF, OT>
|
impl<CS, F, OF, OT> UsesState for StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: Feedback<CS::State>,
|
|
||||||
OF: Feedback<CS::State>,
|
|
||||||
CS::State: HasCorpus,
|
CS::State: HasCorpus,
|
||||||
{
|
{
|
||||||
type State = CS::State;
|
type State = CS::State;
|
||||||
@ -306,8 +294,6 @@ where
|
|||||||
impl<CS, F, OF, OT> HasScheduler for StdFuzzer<CS, F, OF, OT>
|
impl<CS, F, OF, OT> HasScheduler for StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: Feedback<CS::State>,
|
|
||||||
OF: Feedback<CS::State>,
|
|
||||||
CS::State: HasCorpus,
|
CS::State: HasCorpus,
|
||||||
{
|
{
|
||||||
type Scheduler = CS;
|
type Scheduler = CS;
|
||||||
@ -324,8 +310,8 @@ where
|
|||||||
impl<CS, F, OF, OT> HasFeedback for StdFuzzer<CS, F, OF, OT>
|
impl<CS, F, OF, OT> HasFeedback for StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: Feedback<CS::State>,
|
F: Feedback<Self::State>,
|
||||||
OF: Feedback<CS::State>,
|
OF: Feedback<Self::State>,
|
||||||
CS::State: HasCorpus,
|
CS::State: HasCorpus,
|
||||||
{
|
{
|
||||||
type Feedback = F;
|
type Feedback = F;
|
||||||
@ -342,8 +328,8 @@ where
|
|||||||
impl<CS, F, OF, OT> HasObjective for StdFuzzer<CS, F, OF, OT>
|
impl<CS, F, OF, OT> HasObjective for StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: Feedback<CS::State>,
|
F: Feedback<Self::State>,
|
||||||
OF: Feedback<CS::State>,
|
OF: Feedback<Self::State>,
|
||||||
CS::State: HasCorpus,
|
CS::State: HasCorpus,
|
||||||
{
|
{
|
||||||
type Objective = OF;
|
type Objective = OF;
|
||||||
@ -360,9 +346,9 @@ where
|
|||||||
impl<CS, F, OF, OT> ExecutionProcessor<OT> for StdFuzzer<CS, F, OF, OT>
|
impl<CS, F, OF, OT> ExecutionProcessor<OT> for StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: Feedback<CS::State>,
|
F: Feedback<Self::State>,
|
||||||
OF: Feedback<CS::State>,
|
OF: Feedback<Self::State>,
|
||||||
OT: ObserversTuple<CS::State> + Serialize + DeserializeOwned,
|
OT: ObserversTuple<Self::State> + Serialize + DeserializeOwned,
|
||||||
CS::State: HasCorpus
|
CS::State: HasCorpus
|
||||||
+ HasSolutions
|
+ HasSolutions
|
||||||
+ HasExecutions
|
+ HasExecutions
|
||||||
@ -537,9 +523,9 @@ where
|
|||||||
impl<CS, F, OF, OT> EvaluatorObservers<OT> for StdFuzzer<CS, F, OF, OT>
|
impl<CS, F, OF, OT> EvaluatorObservers<OT> for StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
OT: ObserversTuple<CS::State> + Serialize + DeserializeOwned,
|
OT: ObserversTuple<Self::State> + Serialize + DeserializeOwned,
|
||||||
F: Feedback<CS::State>,
|
F: Feedback<Self::State>,
|
||||||
OF: Feedback<CS::State>,
|
OF: Feedback<Self::State>,
|
||||||
CS::State: HasCorpus + HasSolutions + HasExecutions + HasImported,
|
CS::State: HasCorpus + HasSolutions + HasExecutions + HasImported,
|
||||||
{
|
{
|
||||||
/// Process one input, adding to the respective corpora if needed and firing the right events
|
/// Process one input, adding to the respective corpora if needed and firing the right events
|
||||||
@ -568,11 +554,11 @@ where
|
|||||||
impl<CS, E, EM, F, OF, OT> Evaluator<E, EM> for StdFuzzer<CS, F, OF, OT>
|
impl<CS, E, EM, F, OF, OT> Evaluator<E, EM> for StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
E: HasObservers<State = CS::State, Observers = OT> + Executor<EM, Self>,
|
E: HasObservers<State = Self::State, Observers = OT> + Executor<EM, Self>,
|
||||||
EM: EventFirer<State = CS::State>,
|
EM: EventFirer<State = Self::State>,
|
||||||
F: Feedback<CS::State>,
|
F: Feedback<Self::State>,
|
||||||
OF: Feedback<CS::State>,
|
OF: Feedback<Self::State>,
|
||||||
OT: ObserversTuple<CS::State> + Serialize + DeserializeOwned,
|
OT: ObserversTuple<Self::State> + Serialize + DeserializeOwned,
|
||||||
CS::State: HasCorpus + HasSolutions + HasExecutions + HasImported,
|
CS::State: HasCorpus + HasSolutions + HasExecutions + HasImported,
|
||||||
{
|
{
|
||||||
/// Process one input, adding to the respective corpora if needed and firing the right events
|
/// Process one input, adding to the respective corpora if needed and firing the right events
|
||||||
@ -699,10 +685,10 @@ where
|
|||||||
impl<CS, E, EM, F, OF, OT, ST> Fuzzer<E, EM, ST> for StdFuzzer<CS, F, OF, OT>
|
impl<CS, E, EM, F, OF, OT, ST> Fuzzer<E, EM, ST> for StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
E: UsesState<State = CS::State>,
|
E: UsesState<State = Self::State>,
|
||||||
EM: ProgressReporter + EventProcessor<E, Self, State = CS::State>,
|
EM: ProgressReporter + EventProcessor<E, Self, State = Self::State>,
|
||||||
F: Feedback<CS::State>,
|
F: Feedback<Self::State>,
|
||||||
OF: Feedback<CS::State>,
|
OF: Feedback<Self::State>,
|
||||||
CS::State: HasExecutions
|
CS::State: HasExecutions
|
||||||
+ HasMetadata
|
+ HasMetadata
|
||||||
+ HasCorpus
|
+ HasCorpus
|
||||||
@ -711,13 +697,13 @@ where
|
|||||||
+ HasLastReportTime
|
+ HasLastReportTime
|
||||||
+ HasCurrentCorpusId
|
+ HasCurrentCorpusId
|
||||||
+ HasCurrentStage,
|
+ HasCurrentStage,
|
||||||
ST: StagesTuple<E, EM, CS::State, Self>,
|
ST: StagesTuple<E, EM, Self::State, Self>,
|
||||||
{
|
{
|
||||||
fn fuzz_one(
|
fn fuzz_one(
|
||||||
&mut self,
|
&mut self,
|
||||||
stages: &mut ST,
|
stages: &mut ST,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut CS::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<CorpusId, Error> {
|
) -> Result<CorpusId, Error> {
|
||||||
// Init timer for scheduler
|
// Init timer for scheduler
|
||||||
@ -772,8 +758,8 @@ where
|
|||||||
impl<CS, F, OF, OT> StdFuzzer<CS, F, OF, OT>
|
impl<CS, F, OF, OT> StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: Feedback<CS::State>,
|
F: Feedback<<Self as UsesState>::State>,
|
||||||
OF: Feedback<CS::State>,
|
OF: Feedback<<Self as UsesState>::State>,
|
||||||
CS::State: UsesInput + HasExecutions + HasCorpus,
|
CS::State: UsesInput + HasExecutions + HasCorpus,
|
||||||
{
|
{
|
||||||
/// Create a new `StdFuzzer` with standard behavior.
|
/// Create a new `StdFuzzer` with standard behavior.
|
||||||
@ -789,15 +775,15 @@ where
|
|||||||
/// Runs the input and triggers observers and feedback
|
/// Runs the input and triggers observers and feedback
|
||||||
pub fn execute_input<E, EM>(
|
pub fn execute_input<E, EM>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut CS::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
event_mgr: &mut EM,
|
event_mgr: &mut EM,
|
||||||
input: &<CS::State as UsesInput>::Input,
|
input: &<<Self as UsesState>::State as UsesInput>::Input,
|
||||||
) -> Result<ExitKind, Error>
|
) -> Result<ExitKind, Error>
|
||||||
where
|
where
|
||||||
E: Executor<EM, Self> + HasObservers<Observers = OT, State = CS::State>,
|
E: Executor<EM, Self> + HasObservers<Observers = OT, State = <Self as UsesState>::State>,
|
||||||
EM: UsesState<State = CS::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<<Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
start_timer!(state);
|
start_timer!(state);
|
||||||
executor.observers_mut().pre_exec_all(state, input)?;
|
executor.observers_mut().pre_exec_all(state, input)?;
|
||||||
@ -833,22 +819,22 @@ where
|
|||||||
) -> Result<ExitKind, Error>;
|
) -> Result<ExitKind, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CS, E, EM, F, OF> ExecutesInput<E, EM> for StdFuzzer<CS, F, OF, E::Observers>
|
impl<CS, E, EM, F, OF, OT> ExecutesInput<E, EM> for StdFuzzer<CS, F, OF, OT>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: Feedback<CS::State>,
|
F: Feedback<<Self as UsesState>::State>,
|
||||||
OF: Feedback<CS::State>,
|
OF: Feedback<<Self as UsesState>::State>,
|
||||||
E: Executor<EM, Self> + HasObservers<State = CS::State>,
|
E: Executor<EM, Self> + HasObservers<State = Self::State>,
|
||||||
EM: UsesState<State = CS::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
CS::State: UsesInput + HasExecutions + HasCorpus,
|
CS::State: UsesInput + HasExecutions + HasCorpus,
|
||||||
{
|
{
|
||||||
/// Runs the input and triggers observers and feedback
|
/// Runs the input and triggers observers and feedback
|
||||||
fn execute_input(
|
fn execute_input(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut CS::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
event_mgr: &mut EM,
|
event_mgr: &mut EM,
|
||||||
input: &<CS::State as UsesInput>::Input,
|
input: &<<Self as UsesState>::State as UsesInput>::Input,
|
||||||
) -> Result<ExitKind, Error> {
|
) -> Result<ExitKind, Error> {
|
||||||
start_timer!(state);
|
start_timer!(state);
|
||||||
executor.observers_mut().pre_exec_all(state, input)?;
|
executor.observers_mut().pre_exec_all(state, input)?;
|
||||||
@ -912,9 +898,9 @@ pub mod test {
|
|||||||
impl<ST, E, EM> Fuzzer<E, EM, ST> for NopFuzzer<E::State>
|
impl<ST, E, EM> Fuzzer<E, EM, ST> for NopFuzzer<E::State>
|
||||||
where
|
where
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: ProgressReporter<State = E::State>,
|
EM: ProgressReporter<State = Self::State>,
|
||||||
ST: StagesTuple<E, EM, E::State, Self>,
|
ST: StagesTuple<E, EM, Self::State, Self>,
|
||||||
E::State: HasMetadata + HasExecutions + HasLastReportTime + HasCurrentStage,
|
Self::State: HasMetadata + HasExecutions + HasLastReportTime + HasCurrentStage,
|
||||||
{
|
{
|
||||||
fn fuzz_one(
|
fn fuzz_one(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -131,8 +131,9 @@ where
|
|||||||
impl<'a, CS, O> Scheduler for CoverageAccountingScheduler<'a, CS, O>
|
impl<'a, CS, O> Scheduler for CoverageAccountingScheduler<'a, CS, O>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
CS::State: HasCorpus + HasMetadata + HasRand + Debug,
|
Self::State: HasCorpus + HasMetadata + HasRand,
|
||||||
<CS::State as UsesInput>::Input: HasLen,
|
CS::State: Debug,
|
||||||
|
<Self::State as UsesInput>::Input: HasLen,
|
||||||
O: CanTrack,
|
O: CanTrack,
|
||||||
{
|
{
|
||||||
fn on_add(&mut self, state: &mut Self::State, idx: CorpusId) -> Result<(), Error> {
|
fn on_add(&mut self, state: &mut Self::State, idx: CorpusId) -> Result<(), Error> {
|
||||||
|
@ -88,17 +88,17 @@ where
|
|||||||
impl<CS, F, M, O> RemovableScheduler for MinimizerScheduler<CS, F, M, O>
|
impl<CS, F, M, O> RemovableScheduler for MinimizerScheduler<CS, F, M, O>
|
||||||
where
|
where
|
||||||
CS: RemovableScheduler,
|
CS: RemovableScheduler,
|
||||||
F: TestcaseScore<CS::State>,
|
F: TestcaseScore<<Self as UsesState>::State>,
|
||||||
M: for<'a> AsIter<'a, Item = usize> + SerdeAny + HasRefCnt,
|
M: for<'a> AsIter<'a, Item = usize> + SerdeAny + HasRefCnt,
|
||||||
CS::State: HasCorpus + HasMetadata + HasRand,
|
<Self as UsesState>::State: HasCorpus + HasMetadata + HasRand,
|
||||||
O: CanTrack,
|
O: CanTrack,
|
||||||
{
|
{
|
||||||
/// Replaces the testcase at the given idx
|
/// Replaces the testcase at the given idx
|
||||||
fn on_replace(
|
fn on_replace(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut CS::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
idx: CorpusId,
|
idx: CorpusId,
|
||||||
testcase: &Testcase<<CS::State as UsesInput>::Input>,
|
testcase: &Testcase<<<Self as UsesState>::State as UsesInput>::Input>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.base.on_replace(state, idx, testcase)?;
|
self.base.on_replace(state, idx, testcase)?;
|
||||||
self.update_score(state, idx)
|
self.update_score(state, idx)
|
||||||
@ -107,9 +107,9 @@ where
|
|||||||
/// Removes an entry from the corpus
|
/// Removes an entry from the corpus
|
||||||
fn on_remove(
|
fn on_remove(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut CS::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
idx: CorpusId,
|
idx: CorpusId,
|
||||||
testcase: &Option<Testcase<<CS::State as UsesInput>::Input>>,
|
testcase: &Option<Testcase<<<Self as UsesState>::State as UsesInput>::Input>>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.base.on_remove(state, idx, testcase)?;
|
self.base.on_remove(state, idx, testcase)?;
|
||||||
let mut entries =
|
let mut entries =
|
||||||
@ -196,13 +196,13 @@ where
|
|||||||
impl<CS, F, M, O> Scheduler for MinimizerScheduler<CS, F, M, O>
|
impl<CS, F, M, O> Scheduler for MinimizerScheduler<CS, F, M, O>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: TestcaseScore<CS::State>,
|
F: TestcaseScore<Self::State>,
|
||||||
M: for<'a> AsIter<'a, Item = usize> + SerdeAny + HasRefCnt,
|
M: for<'a> AsIter<'a, Item = usize> + SerdeAny + HasRefCnt,
|
||||||
CS::State: HasCorpus + HasMetadata + HasRand,
|
Self::State: HasCorpus + HasMetadata + HasRand,
|
||||||
O: CanTrack,
|
O: CanTrack,
|
||||||
{
|
{
|
||||||
/// Called when a [`Testcase`] is added to the corpus
|
/// Called when a [`Testcase`] is added to the corpus
|
||||||
fn on_add(&mut self, state: &mut CS::State, idx: CorpusId) -> Result<(), Error> {
|
fn on_add(&mut self, state: &mut Self::State, idx: CorpusId) -> Result<(), Error> {
|
||||||
self.base.on_add(state, idx)?;
|
self.base.on_add(state, idx)?;
|
||||||
self.update_score(state, idx)
|
self.update_score(state, idx)
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the next entry
|
/// Gets the next entry
|
||||||
fn next(&mut self, state: &mut CS::State) -> Result<CorpusId, Error> {
|
fn next(&mut self, state: &mut Self::State) -> Result<CorpusId, Error> {
|
||||||
self.cull(state)?;
|
self.cull(state)?;
|
||||||
let mut idx = self.base.next(state)?;
|
let mut idx = self.base.next(state)?;
|
||||||
while {
|
while {
|
||||||
@ -252,15 +252,19 @@ where
|
|||||||
impl<CS, F, M, O> MinimizerScheduler<CS, F, M, O>
|
impl<CS, F, M, O> MinimizerScheduler<CS, F, M, O>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
F: TestcaseScore<CS::State>,
|
F: TestcaseScore<<Self as UsesState>::State>,
|
||||||
M: for<'a> AsIter<'a, Item = usize> + SerdeAny + HasRefCnt,
|
M: for<'a> AsIter<'a, Item = usize> + SerdeAny + HasRefCnt,
|
||||||
CS::State: HasCorpus + HasMetadata + HasRand,
|
<Self as UsesState>::State: HasCorpus + HasMetadata + HasRand,
|
||||||
O: CanTrack,
|
O: CanTrack,
|
||||||
{
|
{
|
||||||
/// Update the [`Corpus`] score using the [`MinimizerScheduler`]
|
/// Update the [`Corpus`] score using the [`MinimizerScheduler`]
|
||||||
#[allow(clippy::unused_self)]
|
#[allow(clippy::unused_self)]
|
||||||
#[allow(clippy::cast_possible_wrap)]
|
#[allow(clippy::cast_possible_wrap)]
|
||||||
pub fn update_score(&self, state: &mut CS::State, idx: CorpusId) -> Result<(), Error> {
|
pub fn update_score(
|
||||||
|
&self,
|
||||||
|
state: &mut <Self as UsesState>::State,
|
||||||
|
idx: CorpusId,
|
||||||
|
) -> Result<(), Error> {
|
||||||
// Create a new top rated meta if not existing
|
// Create a new top rated meta if not existing
|
||||||
if state.metadata_map().get::<TopRatedsMetadata>().is_none() {
|
if state.metadata_map().get::<TopRatedsMetadata>().is_none() {
|
||||||
state.add_metadata(TopRatedsMetadata::new());
|
state.add_metadata(TopRatedsMetadata::new());
|
||||||
@ -334,7 +338,7 @@ where
|
|||||||
|
|
||||||
/// Cull the [`Corpus`] using the [`MinimizerScheduler`]
|
/// Cull the [`Corpus`] using the [`MinimizerScheduler`]
|
||||||
#[allow(clippy::unused_self)]
|
#[allow(clippy::unused_self)]
|
||||||
pub fn cull(&self, state: &CS::State) -> Result<(), Error> {
|
pub fn cull(&self, state: &<Self as UsesState>::State) -> Result<(), Error> {
|
||||||
let Some(top_rated) = state.metadata_map().get::<TopRatedsMetadata>() else {
|
let Some(top_rated) = state.metadata_map().get::<TopRatedsMetadata>() else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
@ -14,12 +14,11 @@ use crate::{
|
|||||||
executors::{Executor, ExitKind, HasObservers},
|
executors::{Executor, ExitKind, HasObservers},
|
||||||
feedbacks::{map::MapFeedbackMetadata, HasObserverHandle},
|
feedbacks::{map::MapFeedbackMetadata, HasObserverHandle},
|
||||||
fuzzer::Evaluator,
|
fuzzer::Evaluator,
|
||||||
inputs::UsesInput,
|
|
||||||
monitors::{AggregatorOps, UserStats, UserStatsValue},
|
monitors::{AggregatorOps, UserStats, UserStatsValue},
|
||||||
observers::{MapObserver, ObserversTuple},
|
observers::{MapObserver, ObserversTuple},
|
||||||
schedulers::powersched::SchedulerMetadata,
|
schedulers::powersched::SchedulerMetadata,
|
||||||
stages::{ExecutionCountRestartHelper, Stage},
|
stages::{ExecutionCountRestartHelper, Stage},
|
||||||
state::{HasCorpus, HasCurrentTestcase, HasExecutions, State, UsesState},
|
state::{HasCorpus, HasCurrentTestcase, HasExecutions, UsesState},
|
||||||
Error, HasMetadata, HasNamedMetadata,
|
Error, HasMetadata, HasNamedMetadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -70,7 +69,7 @@ impl Default for UnstableEntriesMetadata {
|
|||||||
pub const CALIBRATION_STAGE_NAME: &str = "calibration";
|
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, E, O, OT> {
|
||||||
map_observer_handle: Handle<C>,
|
map_observer_handle: Handle<C>,
|
||||||
map_name: Cow<'static, str>,
|
map_name: Cow<'static, str>,
|
||||||
name: Cow<'static, str>,
|
name: Cow<'static, str>,
|
||||||
@ -78,29 +77,29 @@ pub struct CalibrationStage<C, O, OT, S> {
|
|||||||
/// If we should track stability
|
/// If we should track stability
|
||||||
track_stability: bool,
|
track_stability: bool,
|
||||||
restart_helper: ExecutionCountRestartHelper,
|
restart_helper: ExecutionCountRestartHelper,
|
||||||
phantom: PhantomData<(O, OT, S)>,
|
phantom: PhantomData<(E, O, OT)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const CAL_STAGE_START: usize = 4; // AFL++'s CAL_CYCLES_FAST + 1
|
const CAL_STAGE_START: usize = 4; // AFL++'s CAL_CYCLES_FAST + 1
|
||||||
const CAL_STAGE_MAX: usize = 8; // AFL++'s CAL_CYCLES + 1
|
const CAL_STAGE_MAX: usize = 8; // AFL++'s CAL_CYCLES + 1
|
||||||
|
|
||||||
impl<C, O, OT, S> UsesState for CalibrationStage<C, O, OT, S>
|
impl<C, E, O, OT> UsesState for CalibrationStage<C, E, O, OT>
|
||||||
where
|
where
|
||||||
S: State,
|
E: UsesState,
|
||||||
{
|
{
|
||||||
type State = S;
|
type State = E::State;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C, E, EM, O, OT, Z> Stage<E, EM, Z> for CalibrationStage<C, O, OT, E::State>
|
impl<C, E, EM, O, OT, Z> Stage<E, EM, Z> for CalibrationStage<C, E, O, OT>
|
||||||
where
|
where
|
||||||
E: Executor<EM, Z> + HasObservers<Observers = OT>,
|
E: Executor<EM, Z> + HasObservers<Observers = OT>,
|
||||||
EM: EventFirer<State = E::State>,
|
EM: EventFirer<State = Self::State>,
|
||||||
O: MapObserver,
|
O: MapObserver,
|
||||||
C: AsRef<O>,
|
C: AsRef<O>,
|
||||||
for<'de> <O as MapObserver>::Entry: Serialize + Deserialize<'de> + 'static,
|
for<'de> <O as MapObserver>::Entry: Serialize + Deserialize<'de> + 'static,
|
||||||
OT: ObserversTuple<E::State>,
|
OT: ObserversTuple<Self::State>,
|
||||||
E::State: HasCorpus + HasMetadata + HasNamedMetadata + HasExecutions,
|
Self::State: HasCorpus + HasMetadata + HasNamedMetadata + HasExecutions,
|
||||||
Z: Evaluator<E, EM, State = E::State>,
|
Z: Evaluator<E, EM, State = Self::State>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(
|
#[allow(
|
||||||
@ -112,7 +111,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut E::State,
|
state: &mut Self::State,
|
||||||
mgr: &mut EM,
|
mgr: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
// Run this stage only once for each corpus entry and only if we haven't already inspected it
|
// Run this stage only once for each corpus entry and only if we haven't already inspected it
|
||||||
@ -345,13 +344,13 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C, O, OT, S> CalibrationStage<C, O, OT, S>
|
impl<C, E, O, OT> CalibrationStage<C, E, O, OT>
|
||||||
where
|
where
|
||||||
O: MapObserver,
|
O: MapObserver,
|
||||||
for<'it> O: AsIter<'it, Item = O::Entry>,
|
for<'it> O: AsIter<'it, Item = O::Entry>,
|
||||||
C: AsRef<O>,
|
C: AsRef<O>,
|
||||||
OT: ObserversTuple<S>,
|
OT: ObserversTuple<<Self as UsesState>::State>,
|
||||||
S: UsesInput + HasNamedMetadata,
|
E: UsesState,
|
||||||
{
|
{
|
||||||
/// Create a new [`CalibrationStage`].
|
/// Create a new [`CalibrationStage`].
|
||||||
#[must_use]
|
#[must_use]
|
||||||
@ -388,7 +387,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C, O, OT, S> Named for CalibrationStage<C, O, OT, S> {
|
impl<C, E, O, OT> Named for CalibrationStage<C, E, O, OT> {
|
||||||
fn name(&self) -> &Cow<'static, str> {
|
fn name(&self) -> &Cow<'static, str> {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
@ -81,13 +81,13 @@ where
|
|||||||
|
|
||||||
impl<C, E, EM, O, Z> Stage<E, EM, Z> for ColorizationStage<C, E, EM, O, Z>
|
impl<C, E, EM, O, Z> Stage<E, EM, Z> for ColorizationStage<C, E, EM, O, Z>
|
||||||
where
|
where
|
||||||
EM: UsesState<State = E::State> + EventFirer,
|
EM: UsesState<State = Self::State> + EventFirer,
|
||||||
E: HasObservers + Executor<EM, Z>,
|
E: HasObservers + Executor<EM, Z>,
|
||||||
E::State: HasCorpus + HasMetadata + HasRand + HasNamedMetadata,
|
Self::State: HasCorpus + HasMetadata + HasRand + HasNamedMetadata,
|
||||||
E::Input: HasMutatorBytes,
|
E::Input: HasMutatorBytes,
|
||||||
O: MapObserver,
|
O: MapObserver,
|
||||||
C: AsRef<O> + Named,
|
C: AsRef<O> + Named,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = Self::State>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::let_and_return)]
|
#[allow(clippy::let_and_return)]
|
||||||
@ -95,7 +95,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E, // don't need the *main* executor for tracing
|
executor: &mut E, // don't need the *main* executor for tracing
|
||||||
state: &mut E::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
// Run with the mutated input
|
// Run with the mutated input
|
||||||
@ -156,20 +156,20 @@ libafl_bolts::impl_serdeany!(TaintMetadata);
|
|||||||
|
|
||||||
impl<C, E, EM, O, Z> ColorizationStage<C, E, EM, O, Z>
|
impl<C, E, EM, O, Z> ColorizationStage<C, E, EM, O, Z>
|
||||||
where
|
where
|
||||||
EM: UsesState<State = E::State> + EventFirer,
|
EM: UsesState<State = <Self as UsesState>::State> + EventFirer,
|
||||||
O: MapObserver,
|
O: MapObserver,
|
||||||
C: AsRef<O> + Named,
|
C: AsRef<O> + Named,
|
||||||
E: HasObservers + Executor<EM, Z>,
|
E: HasObservers + Executor<EM, Z>,
|
||||||
E::State: HasCorpus + HasMetadata + HasRand,
|
<Self as UsesState>::State: HasCorpus + HasMetadata + HasRand,
|
||||||
E::Input: HasMutatorBytes,
|
E::Input: HasMutatorBytes,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::let_and_return)]
|
#[allow(clippy::let_and_return)]
|
||||||
fn colorize(
|
fn colorize(
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut E::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
observer_handle: &Handle<C>,
|
observer_handle: &Handle<C>,
|
||||||
) -> Result<E::Input, Error> {
|
) -> Result<E::Input, Error> {
|
||||||
@ -320,7 +320,7 @@ where
|
|||||||
fn get_raw_map_hash_run(
|
fn get_raw_map_hash_run(
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut E::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
input: E::Input,
|
input: E::Input,
|
||||||
observer_handle: &Handle<C>,
|
observer_handle: &Handle<C>,
|
||||||
@ -346,7 +346,7 @@ where
|
|||||||
|
|
||||||
/// Replace bytes with random values but following certain rules
|
/// Replace bytes with random values but following certain rules
|
||||||
#[allow(clippy::needless_range_loop)]
|
#[allow(clippy::needless_range_loop)]
|
||||||
fn type_replace(bytes: &mut [u8], state: &mut E::State) {
|
fn type_replace(bytes: &mut [u8], state: &mut <Self as UsesState>::State) {
|
||||||
let len = bytes.len();
|
let len = bytes.len();
|
||||||
for idx in 0..len {
|
for idx in 0..len {
|
||||||
let c = match bytes[idx] {
|
let c = match bytes[idx] {
|
||||||
|
@ -58,18 +58,18 @@ impl<EM, TE, Z> Named for ConcolicTracingStage<'_, EM, TE, Z> {
|
|||||||
|
|
||||||
impl<E, EM, TE, Z> Stage<E, EM, Z> for ConcolicTracingStage<'_, EM, TE, Z>
|
impl<E, EM, TE, Z> Stage<E, EM, Z> for ConcolicTracingStage<'_, EM, TE, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = TE::State>,
|
E: UsesState<State = Self::State>,
|
||||||
EM: UsesState<State = TE::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
TE: Executor<EM, Z> + HasObservers,
|
TE: Executor<EM, Z> + HasObservers,
|
||||||
TE::State: HasExecutions + HasCorpus + HasNamedMetadata,
|
Self::State: HasExecutions + HasCorpus + HasNamedMetadata,
|
||||||
Z: UsesState<State = TE::State>,
|
Z: UsesState<State = Self::State>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
_executor: &mut E,
|
_executor: &mut E,
|
||||||
state: &mut TE::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.inner.trace(fuzzer, state, manager)?;
|
self.inner.trace(fuzzer, state, manager)?;
|
||||||
@ -369,18 +369,18 @@ where
|
|||||||
#[cfg(feature = "concolic_mutation")]
|
#[cfg(feature = "concolic_mutation")]
|
||||||
impl<E, EM, Z> Stage<E, EM, Z> for SimpleConcolicMutationalStage<Z>
|
impl<E, EM, Z> Stage<E, EM, Z> for SimpleConcolicMutationalStage<Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = Self::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::Input: HasMutatorBytes,
|
Z::Input: HasMutatorBytes,
|
||||||
Z::State: State + HasExecutions + HasCorpus + HasMetadata,
|
Self::State: State + HasExecutions + HasCorpus + HasMetadata,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut Z::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
{
|
{
|
||||||
|
@ -46,18 +46,18 @@ where
|
|||||||
|
|
||||||
impl<CB, E, EM, Z> Stage<E, EM, Z> for DumpToDiskStage<CB, EM, Z>
|
impl<CB, E, EM, Z> Stage<E, EM, Z> for DumpToDiskStage<CB, EM, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&<Z::State as UsesInput>::Input, &Z::State) -> Vec<u8>,
|
CB: FnMut(&<Self::State as UsesInput>::Input, &Self::State) -> Vec<u8>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState,
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = Self::State>,
|
||||||
Z: UsesState,
|
Z: UsesState<State = Self::State>,
|
||||||
Z::State: HasCorpus + HasSolutions + HasRand + HasMetadata,
|
Self::State: HasCorpus + HasSolutions + HasRand + HasMetadata,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
_fuzzer: &mut Z,
|
_fuzzer: &mut Z,
|
||||||
_executor: &mut E,
|
_executor: &mut E,
|
||||||
state: &mut Z::State,
|
state: &mut Self::State,
|
||||||
_manager: &mut EM,
|
_manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let (mut corpus_idx, mut solutions_idx) =
|
let (mut corpus_idx, mut solutions_idx) =
|
||||||
@ -129,9 +129,9 @@ where
|
|||||||
|
|
||||||
impl<CB, EM, Z> DumpToDiskStage<CB, EM, Z>
|
impl<CB, EM, Z> DumpToDiskStage<CB, EM, Z>
|
||||||
where
|
where
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState,
|
||||||
Z: UsesState,
|
Z: UsesState,
|
||||||
Z::State: HasCorpus + HasSolutions + HasRand + HasMetadata,
|
<Self as UsesState>::State: HasCorpus + HasSolutions + HasRand + HasMetadata,
|
||||||
{
|
{
|
||||||
/// Create a new [`DumpToDiskStage`]
|
/// Create a new [`DumpToDiskStage`]
|
||||||
pub fn new<A, B>(to_bytes: CB, corpus_dir: A, solutions_dir: B) -> Result<Self, Error>
|
pub fn new<A, B>(to_bytes: CB, corpus_dir: A, solutions_dir: B) -> Result<Self, Error>
|
||||||
|
@ -58,7 +58,6 @@ impl<C, EM, O, OT, Z> Named for GeneralizationStage<C, EM, O, OT, Z> {
|
|||||||
impl<C, EM, O, OT, Z> UsesState for GeneralizationStage<C, EM, O, OT, Z>
|
impl<C, EM, O, OT, Z> UsesState for GeneralizationStage<C, EM, O, OT, Z>
|
||||||
where
|
where
|
||||||
EM: UsesState,
|
EM: UsesState,
|
||||||
EM::State: UsesInput<Input = BytesInput>,
|
|
||||||
{
|
{
|
||||||
type State = EM::State;
|
type State = EM::State;
|
||||||
}
|
}
|
||||||
@ -67,12 +66,11 @@ impl<C, E, EM, O, Z> Stage<E, EM, Z> for GeneralizationStage<C, EM, O, E::Observ
|
|||||||
where
|
where
|
||||||
O: MapObserver,
|
O: MapObserver,
|
||||||
C: CanTrack + AsRef<O> + Named,
|
C: CanTrack + AsRef<O> + Named,
|
||||||
E: Executor<EM, Z> + HasObservers,
|
E: Executor<EM, Z, State = Self::State> + HasObservers,
|
||||||
E::Observers: ObserversTuple<E::State>,
|
Self::State:
|
||||||
E::State:
|
|
||||||
UsesInput<Input = BytesInput> + HasExecutions + HasMetadata + HasCorpus + HasNamedMetadata,
|
UsesInput<Input = BytesInput> + HasExecutions + HasMetadata + HasCorpus + HasNamedMetadata,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = Self::State>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
@ -80,7 +78,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut E::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let Some(corpus_idx) = state.current_corpus_id()? else {
|
let Some(corpus_idx) = state.current_corpus_id()? else {
|
||||||
@ -339,8 +337,9 @@ where
|
|||||||
EM: UsesState,
|
EM: UsesState,
|
||||||
O: MapObserver,
|
O: MapObserver,
|
||||||
C: CanTrack + AsRef<O> + Named,
|
C: CanTrack + AsRef<O> + Named,
|
||||||
OT: ObserversTuple<EM::State>,
|
OT: ObserversTuple<<Self as UsesState>::State>,
|
||||||
EM::State: UsesInput<Input = BytesInput> + HasExecutions + HasMetadata + HasCorpus,
|
<Self as UsesState>::State:
|
||||||
|
UsesInput<Input = BytesInput> + HasExecutions + HasMetadata + HasCorpus,
|
||||||
{
|
{
|
||||||
/// Create a new [`GeneralizationStage`].
|
/// Create a new [`GeneralizationStage`].
|
||||||
#[must_use]
|
#[must_use]
|
||||||
@ -356,14 +355,14 @@ where
|
|||||||
&self,
|
&self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut EM::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
novelties: &[usize],
|
novelties: &[usize],
|
||||||
input: &BytesInput,
|
input: &BytesInput,
|
||||||
) -> Result<bool, Error>
|
) -> Result<bool, Error>
|
||||||
where
|
where
|
||||||
E: Executor<EM, Z> + HasObservers<Observers = OT, State = EM::State>,
|
E: Executor<EM, Z> + HasObservers<Observers = OT, State = <Self as UsesState>::State>,
|
||||||
Z: UsesState<State = EM::State>,
|
Z: UsesState<State = <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
start_timer!(state);
|
start_timer!(state);
|
||||||
executor.observers_mut().pre_exec_all(state, input)?;
|
executor.observers_mut().pre_exec_all(state, input)?;
|
||||||
@ -398,7 +397,7 @@ where
|
|||||||
&self,
|
&self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut EM::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
payload: &mut Vec<Option<u8>>,
|
payload: &mut Vec<Option<u8>>,
|
||||||
novelties: &[usize],
|
novelties: &[usize],
|
||||||
@ -406,8 +405,8 @@ where
|
|||||||
split_char: u8,
|
split_char: u8,
|
||||||
) -> Result<(), Error>
|
) -> Result<(), Error>
|
||||||
where
|
where
|
||||||
E: Executor<EM, Z> + HasObservers<Observers = OT, State = EM::State>,
|
E: Executor<EM, Z> + HasObservers<Observers = OT, State = <Self as UsesState>::State>,
|
||||||
Z: UsesState<State = EM::State>,
|
Z: UsesState<State = <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
let mut start = 0;
|
let mut start = 0;
|
||||||
while start < payload.len() {
|
while start < payload.len() {
|
||||||
@ -437,7 +436,7 @@ where
|
|||||||
&self,
|
&self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut EM::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
payload: &mut Vec<Option<u8>>,
|
payload: &mut Vec<Option<u8>>,
|
||||||
novelties: &[usize],
|
novelties: &[usize],
|
||||||
@ -445,8 +444,8 @@ where
|
|||||||
closing_char: u8,
|
closing_char: u8,
|
||||||
) -> Result<(), Error>
|
) -> Result<(), Error>
|
||||||
where
|
where
|
||||||
E: Executor<EM, Z> + HasObservers<Observers = OT, State = EM::State>,
|
E: Executor<EM, Z> + HasObservers<Observers = OT, State = <Self as UsesState>::State>,
|
||||||
Z: UsesState<State = EM::State>,
|
Z: UsesState<State = <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
while index < payload.len() {
|
while index < payload.len() {
|
||||||
|
@ -17,16 +17,9 @@ use crate::{
|
|||||||
///
|
///
|
||||||
/// This stage can be used to construct black-box (e.g., grammar-based) fuzzers.
|
/// This stage can be used to construct black-box (e.g., grammar-based) fuzzers.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct GenStage<G, Z>(G, PhantomData<Z>)
|
pub struct GenStage<G, Z>(G, PhantomData<Z>);
|
||||||
where
|
|
||||||
Z: UsesState,
|
|
||||||
G: Generator<<<Z as UsesState>::State as UsesInput>::Input, Z::State>;
|
|
||||||
|
|
||||||
impl<G, Z> GenStage<G, Z>
|
impl<G, Z> GenStage<G, Z> {
|
||||||
where
|
|
||||||
Z: UsesState,
|
|
||||||
G: Generator<<<Z as UsesState>::State as UsesInput>::Input, Z::State>,
|
|
||||||
{
|
|
||||||
/// Create a new [`GenStage`].
|
/// Create a new [`GenStage`].
|
||||||
pub fn new(g: G) -> Self {
|
pub fn new(g: G) -> Self {
|
||||||
Self(g, PhantomData)
|
Self(g, PhantomData)
|
||||||
@ -36,25 +29,24 @@ where
|
|||||||
impl<G, Z> UsesState for GenStage<G, Z>
|
impl<G, Z> UsesState for GenStage<G, Z>
|
||||||
where
|
where
|
||||||
Z: UsesState,
|
Z: UsesState,
|
||||||
G: Generator<<<Z as UsesState>::State as UsesInput>::Input, Z::State>,
|
|
||||||
{
|
{
|
||||||
type State = Z::State;
|
type State = Z::State;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E, EM, Z, G> Stage<E, EM, Z> for GenStage<G, Z>
|
impl<E, EM, Z, G> Stage<E, EM, Z> for GenStage<G, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = Self::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand,
|
Self::State: HasCorpus + HasRand,
|
||||||
G: Generator<<<Z as UsesState>::State as UsesInput>::Input, Z::State>,
|
G: Generator<<<Self as UsesState>::State as UsesInput>::Input, Self::State>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut Z::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let input = self.0.generate(state)?;
|
let input = self.0.generate(state)?;
|
||||||
|
@ -32,14 +32,7 @@ impl NestedStageRestartHelper {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
/// Perform the stage while the closure evaluates to true
|
/// Perform the stage while the closure evaluates to true
|
||||||
pub struct WhileStage<CB, E, EM, ST, Z>
|
pub struct WhileStage<CB, E, EM, ST, Z> {
|
||||||
where
|
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<bool, Error>,
|
|
||||||
E: UsesState,
|
|
||||||
EM: UsesState<State = E::State>,
|
|
||||||
ST: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
|
||||||
closure: CB,
|
closure: CB,
|
||||||
stages: ST,
|
stages: ST,
|
||||||
phantom: PhantomData<(E, EM, Z)>,
|
phantom: PhantomData<(E, EM, Z)>,
|
||||||
@ -47,29 +40,25 @@ where
|
|||||||
|
|
||||||
impl<CB, E, EM, ST, Z> UsesState for WhileStage<CB, E, EM, ST, Z>
|
impl<CB, E, EM, ST, Z> UsesState for WhileStage<CB, E, EM, ST, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<bool, Error>,
|
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: UsesState<State = E::State>,
|
|
||||||
ST: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
{
|
||||||
type State = E::State;
|
type State = E::State;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CB, E, EM, ST, Z> Stage<E, EM, Z> for WhileStage<CB, E, EM, ST, Z>
|
impl<CB, E, EM, ST, Z> Stage<E, EM, Z> for WhileStage<CB, E, EM, ST, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<bool, Error>,
|
CB: FnMut(&mut Z, &mut E, &mut Self::State, &mut EM) -> Result<bool, Error>,
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = E::State>,
|
||||||
ST: StagesTuple<E, EM, E::State, Z>,
|
ST: StagesTuple<E, EM, Self::State, Z>,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = Self::State>,
|
||||||
E::State: HasNestedStageStatus,
|
Self::State: HasNestedStageStatus,
|
||||||
{
|
{
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut E::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
while state.current_stage_idx()?.is_some()
|
while state.current_stage_idx()?.is_some()
|
||||||
@ -92,11 +81,8 @@ where
|
|||||||
|
|
||||||
impl<CB, E, EM, ST, Z> WhileStage<CB, E, EM, ST, Z>
|
impl<CB, E, EM, ST, Z> WhileStage<CB, E, EM, ST, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<bool, Error>,
|
CB: FnMut(&mut Z, &mut E, &mut <Self as UsesState>::State, &mut EM) -> Result<bool, Error>,
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: UsesState<State = E::State>,
|
|
||||||
ST: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
{
|
||||||
/// Constructor
|
/// Constructor
|
||||||
pub fn new(closure: CB, stages: ST) -> Self {
|
pub fn new(closure: CB, stages: ST) -> Self {
|
||||||
@ -111,14 +97,7 @@ where
|
|||||||
/// A conditionally enabled stage.
|
/// A conditionally enabled stage.
|
||||||
/// If the closure returns true, the wrapped stage will be executed, else it will be skipped.
|
/// If the closure returns true, the wrapped stage will be executed, else it will be skipped.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct IfStage<CB, E, EM, ST, Z>
|
pub struct IfStage<CB, E, EM, ST, Z> {
|
||||||
where
|
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<bool, Error>,
|
|
||||||
E: UsesState,
|
|
||||||
EM: UsesState<State = E::State>,
|
|
||||||
ST: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
|
||||||
closure: CB,
|
closure: CB,
|
||||||
if_stages: ST,
|
if_stages: ST,
|
||||||
phantom: PhantomData<(E, EM, Z)>,
|
phantom: PhantomData<(E, EM, Z)>,
|
||||||
@ -126,29 +105,25 @@ where
|
|||||||
|
|
||||||
impl<CB, E, EM, ST, Z> UsesState for IfStage<CB, E, EM, ST, Z>
|
impl<CB, E, EM, ST, Z> UsesState for IfStage<CB, E, EM, ST, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<bool, Error>,
|
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: UsesState<State = E::State>,
|
|
||||||
ST: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
{
|
||||||
type State = E::State;
|
type State = E::State;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CB, E, EM, ST, Z> Stage<E, EM, Z> for IfStage<CB, E, EM, ST, Z>
|
impl<CB, E, EM, ST, Z> Stage<E, EM, Z> for IfStage<CB, E, EM, ST, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<bool, Error>,
|
CB: FnMut(&mut Z, &mut E, &mut Self::State, &mut EM) -> Result<bool, Error>,
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
ST: StagesTuple<E, EM, E::State, Z>,
|
ST: StagesTuple<E, EM, Self::State, Z>,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = Self::State>,
|
||||||
E::State: HasNestedStageStatus,
|
Self::State: HasNestedStageStatus,
|
||||||
{
|
{
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut E::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
if state.current_stage_idx()?.is_some() || (self.closure)(fuzzer, executor, state, manager)?
|
if state.current_stage_idx()?.is_some() || (self.closure)(fuzzer, executor, state, manager)?
|
||||||
@ -170,11 +145,8 @@ where
|
|||||||
|
|
||||||
impl<CB, E, EM, ST, Z> IfStage<CB, E, EM, ST, Z>
|
impl<CB, E, EM, ST, Z> IfStage<CB, E, EM, ST, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<bool, Error>,
|
CB: FnMut(&mut Z, &mut E, &mut <Self as UsesState>::State, &mut EM) -> Result<bool, Error>,
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: UsesState<State = E::State>,
|
|
||||||
ST: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
{
|
||||||
/// Constructor for this conditionally enabled stage.
|
/// Constructor for this conditionally enabled stage.
|
||||||
/// If the closure returns true, the wrapped stage will be executed, else it will be skipped.
|
/// If the closure returns true, the wrapped stage will be executed, else it will be skipped.
|
||||||
@ -189,15 +161,7 @@ where
|
|||||||
|
|
||||||
/// Perform the stage if closure evaluates to true
|
/// Perform the stage if closure evaluates to true
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct IfElseStage<CB, E, EM, ST1, ST2, Z>
|
pub struct IfElseStage<CB, E, EM, ST1, ST2, Z> {
|
||||||
where
|
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<bool, Error>,
|
|
||||||
E: UsesState,
|
|
||||||
EM: UsesState<State = E::State>,
|
|
||||||
ST1: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
ST2: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
|
||||||
closure: CB,
|
closure: CB,
|
||||||
if_stages: ST1,
|
if_stages: ST1,
|
||||||
else_stages: ST2,
|
else_stages: ST2,
|
||||||
@ -206,31 +170,26 @@ where
|
|||||||
|
|
||||||
impl<CB, E, EM, ST1, ST2, Z> UsesState for IfElseStage<CB, E, EM, ST1, ST2, Z>
|
impl<CB, E, EM, ST1, ST2, Z> UsesState for IfElseStage<CB, E, EM, ST1, ST2, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<bool, Error>,
|
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: UsesState<State = E::State>,
|
|
||||||
ST1: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
ST2: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
{
|
||||||
type State = E::State;
|
type State = E::State;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CB, E, EM, ST1, ST2, Z> Stage<E, EM, Z> for IfElseStage<CB, E, EM, ST1, ST2, Z>
|
impl<CB, E, EM, ST1, ST2, Z> Stage<E, EM, Z> for IfElseStage<CB, E, EM, ST1, ST2, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<bool, Error>,
|
CB: FnMut(&mut Z, &mut E, &mut Self::State, &mut EM) -> Result<bool, Error>,
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
ST1: StagesTuple<E, EM, E::State, Z>,
|
ST1: StagesTuple<E, EM, Self::State, Z>,
|
||||||
ST2: StagesTuple<E, EM, E::State, Z>,
|
ST2: StagesTuple<E, EM, Self::State, Z>,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = Self::State>,
|
||||||
E::State: HasNestedStageStatus,
|
Self::State: HasNestedStageStatus,
|
||||||
{
|
{
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut E::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let current = state.current_stage_idx()?;
|
let current = state.current_stage_idx()?;
|
||||||
@ -271,12 +230,8 @@ where
|
|||||||
|
|
||||||
impl<CB, E, EM, ST1, ST2, Z> IfElseStage<CB, E, EM, ST1, ST2, Z>
|
impl<CB, E, EM, ST1, ST2, Z> IfElseStage<CB, E, EM, ST1, ST2, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<bool, Error>,
|
CB: FnMut(&mut Z, &mut E, &mut <Self as UsesState>::State, &mut EM) -> Result<bool, Error>,
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: UsesState<State = E::State>,
|
|
||||||
ST1: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
ST2: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
{
|
||||||
/// Constructor
|
/// Constructor
|
||||||
pub fn new(closure: CB, if_stages: ST1, else_stages: ST2) -> Self {
|
pub fn new(closure: CB, if_stages: ST1, else_stages: ST2) -> Self {
|
||||||
@ -291,13 +246,7 @@ where
|
|||||||
|
|
||||||
/// A stage wrapper where the stages do not need to be initialized, but can be [`None`].
|
/// A stage wrapper where the stages do not need to be initialized, but can be [`None`].
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct OptionalStage<E, EM, ST, Z>
|
pub struct OptionalStage<E, EM, ST, Z> {
|
||||||
where
|
|
||||||
E: UsesState,
|
|
||||||
EM: UsesState<State = E::State>,
|
|
||||||
ST: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
|
||||||
stages: Option<ST>,
|
stages: Option<ST>,
|
||||||
phantom: PhantomData<(E, EM, Z)>,
|
phantom: PhantomData<(E, EM, Z)>,
|
||||||
}
|
}
|
||||||
@ -305,9 +254,6 @@ where
|
|||||||
impl<E, EM, ST, Z> UsesState for OptionalStage<E, EM, ST, Z>
|
impl<E, EM, ST, Z> UsesState for OptionalStage<E, EM, ST, Z>
|
||||||
where
|
where
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: UsesState<State = E::State>,
|
|
||||||
ST: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
{
|
||||||
type State = E::State;
|
type State = E::State;
|
||||||
}
|
}
|
||||||
@ -315,16 +261,16 @@ where
|
|||||||
impl<E, EM, ST, Z> Stage<E, EM, Z> for OptionalStage<E, EM, ST, Z>
|
impl<E, EM, ST, Z> Stage<E, EM, Z> for OptionalStage<E, EM, ST, Z>
|
||||||
where
|
where
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
ST: StagesTuple<E, EM, E::State, Z>,
|
ST: StagesTuple<E, EM, Self::State, Z>,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = Self::State>,
|
||||||
E::State: HasNestedStageStatus,
|
Self::State: HasNestedStageStatus,
|
||||||
{
|
{
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut E::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
if let Some(stages) = &mut self.stages {
|
if let Some(stages) = &mut self.stages {
|
||||||
@ -343,13 +289,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E, EM, ST, Z> OptionalStage<E, EM, ST, Z>
|
impl<E, EM, ST, Z> OptionalStage<E, EM, ST, Z> {
|
||||||
where
|
|
||||||
E: UsesState,
|
|
||||||
EM: UsesState<State = E::State>,
|
|
||||||
ST: StagesTuple<E, EM, E::State, Z>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
|
||||||
/// Constructor for this conditionally enabled stage.
|
/// Constructor for this conditionally enabled stage.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(stages: Option<ST>) -> Self {
|
pub fn new(stages: Option<ST>) -> Self {
|
||||||
|
@ -285,28 +285,19 @@ where
|
|||||||
|
|
||||||
/// A [`Stage`] that will call a closure
|
/// A [`Stage`] that will call a closure
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ClosureStage<CB, E, EM, Z>
|
pub struct ClosureStage<CB, E, EM, Z> {
|
||||||
where
|
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<(), Error>,
|
|
||||||
E: UsesState,
|
|
||||||
{
|
|
||||||
closure: CB,
|
closure: CB,
|
||||||
phantom: PhantomData<(E, EM, Z)>,
|
phantom: PhantomData<(E, EM, Z)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CB, E, EM, Z> UsesState for ClosureStage<CB, E, EM, Z>
|
impl<CB, E, EM, Z> UsesState for ClosureStage<CB, E, EM, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<(), Error>,
|
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
{
|
{
|
||||||
type State = E::State;
|
type State = E::State;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CB, E, EM, Z> Named for ClosureStage<CB, E, EM, Z>
|
impl<CB, E, EM, Z> Named for ClosureStage<CB, E, EM, Z> {
|
||||||
where
|
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<(), Error>,
|
|
||||||
E: UsesState,
|
|
||||||
{
|
|
||||||
fn name(&self) -> &Cow<'static, str> {
|
fn name(&self) -> &Cow<'static, str> {
|
||||||
static NAME: Cow<'static, str> = Cow::Borrowed("<unnamed fn>");
|
static NAME: Cow<'static, str> = Cow::Borrowed("<unnamed fn>");
|
||||||
&NAME
|
&NAME
|
||||||
@ -315,11 +306,11 @@ where
|
|||||||
|
|
||||||
impl<CB, E, EM, Z> Stage<E, EM, Z> for ClosureStage<CB, E, EM, Z>
|
impl<CB, E, EM, Z> Stage<E, EM, Z> for ClosureStage<CB, E, EM, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<(), Error>,
|
CB: FnMut(&mut Z, &mut E, &mut Self::State, &mut EM) -> Result<(), Error>,
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = Self::State>,
|
||||||
E::State: HasNamedMetadata,
|
Self::State: HasNamedMetadata,
|
||||||
{
|
{
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -344,11 +335,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A stage that takes a closure
|
/// A stage that takes a closure
|
||||||
impl<CB, E, EM, Z> ClosureStage<CB, E, EM, Z>
|
impl<CB, E, EM, Z> ClosureStage<CB, E, EM, Z> {
|
||||||
where
|
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<(), Error>,
|
|
||||||
E: UsesState,
|
|
||||||
{
|
|
||||||
/// Create a new [`ClosureStage`]
|
/// Create a new [`ClosureStage`]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(closure: CB) -> Self {
|
pub fn new(closure: CB) -> Self {
|
||||||
@ -361,7 +348,7 @@ where
|
|||||||
|
|
||||||
impl<CB, E, EM, Z> From<CB> for ClosureStage<CB, E, EM, Z>
|
impl<CB, E, EM, Z> From<CB> for ClosureStage<CB, E, EM, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut E, &mut E::State, &mut EM) -> Result<(), Error>,
|
CB: FnMut(&mut Z, &mut E, &mut <Self as UsesState>::State, &mut EM) -> Result<(), Error>,
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
{
|
{
|
||||||
#[must_use]
|
#[must_use]
|
||||||
@ -400,17 +387,17 @@ where
|
|||||||
impl<CS, E, EM, OT, PS, Z> Stage<E, EM, Z> for PushStageAdapter<CS, EM, OT, PS, Z>
|
impl<CS, E, EM, OT, PS, Z> Stage<E, EM, Z> for PushStageAdapter<CS, EM, OT, PS, Z>
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
CS: Scheduler,
|
||||||
CS::State:
|
Self::State:
|
||||||
HasExecutions + HasMetadata + HasRand + HasCorpus + HasLastReportTime + HasCurrentCorpusId,
|
HasExecutions + HasMetadata + HasRand + HasCorpus + HasLastReportTime + HasCurrentCorpusId,
|
||||||
E: Executor<EM, Z> + HasObservers<Observers = OT, State = CS::State>,
|
E: Executor<EM, Z> + HasObservers<Observers = OT, State = Self::State>,
|
||||||
EM: EventFirer<State = CS::State>
|
EM: EventFirer<State = Self::State>
|
||||||
+ EventRestarter
|
+ EventRestarter
|
||||||
+ HasEventManagerId
|
+ HasEventManagerId
|
||||||
+ ProgressReporter<State = CS::State>,
|
+ ProgressReporter<State = Self::State>,
|
||||||
OT: ObserversTuple<CS::State>,
|
OT: ObserversTuple<Self::State>,
|
||||||
PS: PushStage<CS, EM, OT, Z>,
|
PS: PushStage<CS, EM, OT, Z>,
|
||||||
Z: ExecutesInput<E, EM, State = CS::State>
|
Z: ExecutesInput<E, EM, State = Self::State>
|
||||||
+ ExecutionProcessor<OT, State = CS::State>
|
+ ExecutionProcessor<OT, State = Self::State>
|
||||||
+ EvaluatorObservers<OT>
|
+ EvaluatorObservers<OT>
|
||||||
+ HasScheduler<Scheduler = CS>,
|
+ HasScheduler<Scheduler = CS>,
|
||||||
{
|
{
|
||||||
|
@ -92,10 +92,10 @@ where
|
|||||||
fn mutator_mut(&mut self) -> &mut M;
|
fn mutator_mut(&mut self) -> &mut M;
|
||||||
|
|
||||||
/// Gets the number of iterations this mutator should run for.
|
/// Gets the number of iterations this mutator should run for.
|
||||||
fn iterations(&self, state: &mut Z::State) -> Result<usize, Error>;
|
fn iterations(&self, state: &mut Self::State) -> Result<usize, Error>;
|
||||||
|
|
||||||
/// Gets the number of executions this mutator already did since it got first called in this fuzz round.
|
/// Gets the number of executions this mutator already did since it got first called in this fuzz round.
|
||||||
fn execs_since_progress_start(&mut self, state: &mut Z::State) -> Result<u64, Error>;
|
fn execs_since_progress_start(&mut self, state: &mut Self::State) -> Result<u64, Error>;
|
||||||
|
|
||||||
/// Runs this (mutational) stage for the given testcase
|
/// Runs this (mutational) stage for the given testcase
|
||||||
#[allow(clippy::cast_possible_wrap)] // more than i32 stages on 32 bit system - highly unlikely...
|
#[allow(clippy::cast_possible_wrap)] // more than i32 stages on 32 bit system - highly unlikely...
|
||||||
@ -103,7 +103,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut Z::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
start_timer!(state);
|
start_timer!(state);
|
||||||
@ -167,11 +167,11 @@ pub struct StdMutationalStage<E, EM, I, M, Z> {
|
|||||||
|
|
||||||
impl<E, EM, I, M, Z> MutationalStage<E, EM, I, M, Z> for StdMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> MutationalStage<E, EM, I, M, Z> for StdMutationalStage<E, EM, I, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = Self::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
M: Mutator<I, Z::State>,
|
M: Mutator<I, Self::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand + HasExecutions + HasMetadata,
|
Self::State: HasCorpus + HasRand + HasExecutions + HasMetadata,
|
||||||
I: MutatedTransform<Self::Input, Self::State> + Clone,
|
I: MutatedTransform<Self::Input, Self::State> + Clone,
|
||||||
{
|
{
|
||||||
/// The mutator, added to this stage
|
/// The mutator, added to this stage
|
||||||
@ -187,33 +187,29 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the number of iterations as a random number
|
/// Gets the number of iterations as a random number
|
||||||
fn iterations(&self, state: &mut Z::State) -> Result<usize, Error> {
|
fn iterations(&self, state: &mut Self::State) -> Result<usize, Error> {
|
||||||
Ok(1 + state.rand_mut().below(self.max_iterations))
|
Ok(1 + state.rand_mut().below(self.max_iterations))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execs_since_progress_start(&mut self, state: &mut <Z>::State) -> Result<u64, Error> {
|
fn execs_since_progress_start(&mut self, state: &mut Self::State) -> Result<u64, Error> {
|
||||||
self.restart_helper.execs_since_progress_start(state)
|
self.restart_helper.execs_since_progress_start(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E, EM, I, M, Z> UsesState for StdMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> UsesState for StdMutationalStage<E, EM, I, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
Z: UsesState,
|
||||||
EM: UsesState<State = Z::State>,
|
|
||||||
M: Mutator<I, Z::State>,
|
|
||||||
Z: Evaluator<E, EM>,
|
|
||||||
Z::State: HasCorpus + HasRand,
|
|
||||||
{
|
{
|
||||||
type State = Z::State;
|
type State = Z::State;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E, EM, I, M, Z> Stage<E, EM, Z> for StdMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> Stage<E, EM, Z> for StdMutationalStage<E, EM, I, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = Self::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
M: Mutator<I, Z::State>,
|
M: Mutator<I, Self::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand + HasMetadata + HasExecutions,
|
Self::State: HasCorpus + HasRand + HasMetadata + HasExecutions,
|
||||||
I: MutatedTransform<Self::Input, Self::State> + Clone,
|
I: MutatedTransform<Self::Input, Self::State> + Clone,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -222,7 +218,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut Z::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let ret = self.perform_mutational(fuzzer, executor, state, manager);
|
let ret = self.perform_mutational(fuzzer, executor, state, manager);
|
||||||
@ -246,11 +242,11 @@ where
|
|||||||
|
|
||||||
impl<E, EM, M, Z> StdMutationalStage<E, EM, Z::Input, M, Z>
|
impl<E, EM, M, Z> StdMutationalStage<E, EM, Z::Input, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = <Self as UsesState>::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
M: Mutator<Z::Input, Z::State>,
|
M: Mutator<Z::Input, <Self as UsesState>::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand,
|
<Self as UsesState>::State: HasCorpus + HasRand,
|
||||||
{
|
{
|
||||||
/// Creates a new default mutational stage
|
/// Creates a new default mutational stage
|
||||||
pub fn new(mutator: M) -> Self {
|
pub fn new(mutator: M) -> Self {
|
||||||
@ -265,11 +261,11 @@ where
|
|||||||
|
|
||||||
impl<E, EM, I, M, Z> StdMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> StdMutationalStage<E, EM, I, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = <Self as UsesState>::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
M: Mutator<I, Z::State>,
|
M: Mutator<I, <Self as UsesState>::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand,
|
<Self as UsesState>::State: HasCorpus + HasRand,
|
||||||
{
|
{
|
||||||
/// Creates a new transforming mutational stage with the default max iterations
|
/// Creates a new transforming mutational stage with the default max iterations
|
||||||
pub fn transforming(mutator: M) -> Self {
|
pub fn transforming(mutator: M) -> Self {
|
||||||
@ -297,23 +293,12 @@ pub struct MultiMutationalStage<E, EM, I, M, Z> {
|
|||||||
|
|
||||||
impl<E, EM, I, M, Z> UsesState for MultiMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> UsesState for MultiMutationalStage<E, EM, I, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
Z: UsesState,
|
||||||
EM: UsesState<State = Z::State>,
|
|
||||||
M: MultiMutator<I, Z::State>,
|
|
||||||
Z: Evaluator<E, EM>,
|
|
||||||
Z::State: HasCorpus + HasRand,
|
|
||||||
{
|
{
|
||||||
type State = Z::State;
|
type State = Z::State;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E, EM, I, M, Z> Named for MultiMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> Named for MultiMutationalStage<E, EM, I, M, Z> {
|
||||||
where
|
|
||||||
E: UsesState<State = Z::State>,
|
|
||||||
EM: UsesState<State = Z::State>,
|
|
||||||
M: MultiMutator<I, Z::State>,
|
|
||||||
Z: Evaluator<E, EM>,
|
|
||||||
Z::State: HasCorpus + HasRand,
|
|
||||||
{
|
|
||||||
fn name(&self) -> &Cow<'static, str> {
|
fn name(&self) -> &Cow<'static, str> {
|
||||||
static NAME: Cow<'static, str> = Cow::Borrowed("MultiMutational");
|
static NAME: Cow<'static, str> = Cow::Borrowed("MultiMutational");
|
||||||
&NAME
|
&NAME
|
||||||
@ -322,11 +307,11 @@ where
|
|||||||
|
|
||||||
impl<E, EM, I, M, Z> Stage<E, EM, Z> for MultiMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> Stage<E, EM, Z> for MultiMutationalStage<E, EM, I, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = Self::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
M: MultiMutator<I, Z::State>,
|
M: MultiMutator<I, Self::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand + HasNamedMetadata,
|
Self::State: HasCorpus + HasRand + HasNamedMetadata,
|
||||||
I: MutatedTransform<Self::Input, Self::State> + Clone,
|
I: MutatedTransform<Self::Input, Self::State> + Clone,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -348,7 +333,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut Z::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let mut testcase = state.current_testcase_mut()?;
|
let mut testcase = state.current_testcase_mut()?;
|
||||||
@ -374,11 +359,7 @@ where
|
|||||||
|
|
||||||
impl<E, EM, M, Z> MultiMutationalStage<E, EM, Z::Input, M, Z>
|
impl<E, EM, M, Z> MultiMutationalStage<E, EM, Z::Input, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
Z: UsesState,
|
||||||
EM: UsesState<State = Z::State>,
|
|
||||||
M: MultiMutator<Z::Input, Z::State>,
|
|
||||||
Z: Evaluator<E, EM>,
|
|
||||||
Z::State: HasCorpus + HasRand,
|
|
||||||
{
|
{
|
||||||
/// Creates a new [`MultiMutationalStage`]
|
/// Creates a new [`MultiMutationalStage`]
|
||||||
pub fn new(mutator: M) -> Self {
|
pub fn new(mutator: M) -> Self {
|
||||||
@ -386,14 +367,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E, EM, I, M, Z> MultiMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> MultiMutationalStage<E, EM, I, M, Z> {
|
||||||
where
|
|
||||||
E: UsesState<State = Z::State>,
|
|
||||||
EM: UsesState<State = Z::State>,
|
|
||||||
M: MultiMutator<I, Z::State>,
|
|
||||||
Z: Evaluator<E, EM>,
|
|
||||||
Z::State: HasCorpus + HasRand,
|
|
||||||
{
|
|
||||||
/// Creates a new transforming mutational stage
|
/// Creates a new transforming mutational stage
|
||||||
pub fn transforming(mutator: M) -> Self {
|
pub fn transforming(mutator: M) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -44,12 +44,12 @@ impl<E, F, EM, I, M, Z> Named 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>
|
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,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
F: TestcaseScore<E::State>,
|
F: TestcaseScore<Self::State>,
|
||||||
M: Mutator<I, E::State>,
|
M: Mutator<I, Self::State>,
|
||||||
E::State: HasCorpus + HasMetadata + HasRand + HasExecutions,
|
Self::State: HasCorpus + HasMetadata + HasRand + HasExecutions,
|
||||||
Z: Evaluator<E, EM, State = E::State>,
|
Z: Evaluator<E, EM, State = Self::State>,
|
||||||
I: MutatedTransform<E::Input, E::State> + Clone,
|
I: MutatedTransform<E::Input, Self::State> + Clone,
|
||||||
{
|
{
|
||||||
/// The mutator, added to this stage
|
/// The mutator, added to this stage
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -65,7 +65,7 @@ where
|
|||||||
|
|
||||||
/// Gets the number of iterations as a random number
|
/// Gets the number of iterations as a random number
|
||||||
#[allow(clippy::cast_sign_loss)]
|
#[allow(clippy::cast_sign_loss)]
|
||||||
fn iterations(&self, state: &mut E::State) -> Result<usize, Error> {
|
fn iterations(&self, state: &mut Self::State) -> Result<usize, Error> {
|
||||||
// Update handicap
|
// Update handicap
|
||||||
let mut testcase = state.current_testcase_mut()?;
|
let mut testcase = state.current_testcase_mut()?;
|
||||||
let score = F::compute(state, &mut testcase)? as usize;
|
let score = F::compute(state, &mut testcase)? as usize;
|
||||||
@ -73,7 +73,7 @@ where
|
|||||||
Ok(score)
|
Ok(score)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execs_since_progress_start(&mut self, state: &mut <Z>::State) -> Result<u64, Error> {
|
fn execs_since_progress_start(&mut self, state: &mut Self::State) -> Result<u64, Error> {
|
||||||
self.restart_helper.execs_since_progress_start(state)
|
self.restart_helper.execs_since_progress_start(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,12 +81,12 @@ where
|
|||||||
impl<E, F, EM, I, M, Z> Stage<E, EM, Z> for PowerMutationalStage<E, F, EM, I, M, Z>
|
impl<E, F, EM, I, M, Z> Stage<E, EM, Z> for PowerMutationalStage<E, F, EM, I, M, Z>
|
||||||
where
|
where
|
||||||
E: Executor<EM, Z> + HasObservers,
|
E: Executor<EM, Z> + HasObservers,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
F: TestcaseScore<E::State>,
|
F: TestcaseScore<Self::State>,
|
||||||
M: Mutator<I, E::State>,
|
M: Mutator<I, Self::State>,
|
||||||
E::State: HasCorpus + HasMetadata + HasRand + HasExecutions,
|
Self::State: HasCorpus + HasMetadata + HasRand + HasExecutions,
|
||||||
Z: Evaluator<E, EM, State = E::State>,
|
Z: Evaluator<E, EM, State = Self::State>,
|
||||||
I: MutatedTransform<E::Input, E::State> + Clone,
|
I: MutatedTransform<Self::Input, Self::State> + Clone,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::let_and_return)]
|
#[allow(clippy::let_and_return)]
|
||||||
@ -94,7 +94,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut E::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let ret = self.perform_mutational(fuzzer, executor, state, manager);
|
let ret = self.perform_mutational(fuzzer, executor, state, manager);
|
||||||
@ -115,11 +115,11 @@ where
|
|||||||
impl<E, F, EM, M, Z> PowerMutationalStage<E, F, EM, E::Input, M, Z>
|
impl<E, F, EM, M, Z> PowerMutationalStage<E, F, EM, E::Input, M, Z>
|
||||||
where
|
where
|
||||||
E: Executor<EM, Z> + HasObservers,
|
E: Executor<EM, Z> + HasObservers,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
F: TestcaseScore<E::State>,
|
F: TestcaseScore<<Self as UsesState>::State>,
|
||||||
M: Mutator<E::Input, E::State>,
|
M: Mutator<E::Input, <Self as UsesState>::State>,
|
||||||
E::State: HasCorpus + HasMetadata + HasRand,
|
<Self as UsesState>::State: HasCorpus + HasMetadata + HasRand,
|
||||||
Z: Evaluator<E, EM, State = E::State>,
|
Z: Evaluator<E, EM, State = <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
/// Creates a new [`PowerMutationalStage`]
|
/// Creates a new [`PowerMutationalStage`]
|
||||||
pub fn new(mutator: M) -> Self {
|
pub fn new(mutator: M) -> Self {
|
||||||
|
@ -24,12 +24,7 @@ use crate::{
|
|||||||
|
|
||||||
/// The [`AflStatsStage`] is a simple stage that computes and reports some stats.
|
/// The [`AflStatsStage`] is a simple stage that computes and reports some stats.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct AflStatsStage<E, EM, Z>
|
pub struct AflStatsStage<E, EM, Z> {
|
||||||
where
|
|
||||||
E: UsesState,
|
|
||||||
EM: EventFirer<State = E::State>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
|
||||||
// the number of testcases that have been fuzzed
|
// the number of testcases that have been fuzzed
|
||||||
has_fuzzed_size: usize,
|
has_fuzzed_size: usize,
|
||||||
// the number of "favored" testcases
|
// the number of "favored" testcases
|
||||||
@ -49,8 +44,6 @@ where
|
|||||||
impl<E, EM, Z> UsesState for AflStatsStage<E, EM, Z>
|
impl<E, EM, Z> UsesState for AflStatsStage<E, EM, Z>
|
||||||
where
|
where
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: EventFirer<State = E::State>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
{
|
{
|
||||||
type State = E::State;
|
type State = E::State;
|
||||||
}
|
}
|
||||||
@ -58,15 +51,15 @@ where
|
|||||||
impl<E, EM, Z> Stage<E, EM, Z> for AflStatsStage<E, EM, Z>
|
impl<E, EM, Z> Stage<E, EM, Z> for AflStatsStage<E, EM, Z>
|
||||||
where
|
where
|
||||||
E: UsesState,
|
E: UsesState,
|
||||||
EM: EventFirer<State = E::State>,
|
EM: EventFirer<State = Self::State>,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = Self::State>,
|
||||||
E::State: HasImported + HasCorpus + HasMetadata,
|
Self::State: HasImported + HasCorpus + HasMetadata,
|
||||||
{
|
{
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
_fuzzer: &mut Z,
|
_fuzzer: &mut Z,
|
||||||
_executor: &mut E,
|
_executor: &mut E,
|
||||||
state: &mut E::State,
|
state: &mut Self::State,
|
||||||
_manager: &mut EM,
|
_manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let Some(corpus_idx) = state.current_corpus_id()? else {
|
let Some(corpus_idx) = state.current_corpus_id()? else {
|
||||||
@ -145,13 +138,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E, EM, Z> AflStatsStage<E, EM, Z>
|
impl<E, EM, Z> AflStatsStage<E, EM, Z> {
|
||||||
where
|
|
||||||
E: UsesState,
|
|
||||||
EM: EventFirer<State = E::State>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
E::State: HasImported + HasCorpus + HasMetadata,
|
|
||||||
{
|
|
||||||
/// create a new instance of the [`AflStatsStage`]
|
/// create a new instance of the [`AflStatsStage`]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(interval: Duration) -> Self {
|
pub fn new(interval: Duration) -> Self {
|
||||||
@ -162,13 +149,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E, EM, Z> Default for AflStatsStage<E, EM, Z>
|
impl<E, EM, Z> Default for AflStatsStage<E, EM, Z> {
|
||||||
where
|
|
||||||
E: UsesState,
|
|
||||||
EM: EventFirer<State = E::State>,
|
|
||||||
Z: UsesState<State = E::State>,
|
|
||||||
E::State: HasImported + HasCorpus + HasMetadata,
|
|
||||||
{
|
|
||||||
/// the default instance of the [`AflStatsStage`]
|
/// the default instance of the [`AflStatsStage`]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
@ -65,15 +65,12 @@ pub struct SyncFromDiskStage<CB, E, EM, Z> {
|
|||||||
|
|
||||||
impl<CB, E, EM, Z> UsesState for SyncFromDiskStage<CB, E, EM, Z>
|
impl<CB, E, EM, Z> UsesState for SyncFromDiskStage<CB, E, EM, Z>
|
||||||
where
|
where
|
||||||
E: UsesState,
|
Z: UsesState,
|
||||||
{
|
{
|
||||||
type State = E::State;
|
type State = Z::State;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CB, E, EM, Z> Named for SyncFromDiskStage<CB, E, EM, Z>
|
impl<CB, E, EM, Z> Named for SyncFromDiskStage<CB, E, EM, Z> {
|
||||||
where
|
|
||||||
E: UsesState,
|
|
||||||
{
|
|
||||||
fn name(&self) -> &Cow<'static, str> {
|
fn name(&self) -> &Cow<'static, str> {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
@ -81,18 +78,18 @@ where
|
|||||||
|
|
||||||
impl<CB, E, EM, Z> Stage<E, EM, Z> for SyncFromDiskStage<CB, E, EM, Z>
|
impl<CB, E, EM, Z> Stage<E, EM, Z> for SyncFromDiskStage<CB, E, EM, Z>
|
||||||
where
|
where
|
||||||
CB: FnMut(&mut Z, &mut Z::State, &Path) -> Result<<Z::State as UsesInput>::Input, Error>,
|
CB: FnMut(&mut Z, &mut Self::State, &Path) -> Result<<Self::State as UsesInput>::Input, Error>,
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = Self::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand + HasMetadata + HasNamedMetadata,
|
Self::State: HasCorpus + HasRand + HasMetadata + HasNamedMetadata,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut Z::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
log::debug!("Syncing from disk: {:?}", self.sync_dir);
|
log::debug!("Syncing from disk: {:?}", self.sync_dir);
|
||||||
@ -164,14 +161,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CB, E, EM, Z> SyncFromDiskStage<CB, E, EM, Z>
|
impl<CB, E, EM, Z> SyncFromDiskStage<CB, E, EM, Z> {
|
||||||
where
|
|
||||||
CB: FnMut(&mut Z, &mut Z::State, &Path) -> Result<<Z::State as UsesInput>::Input, Error>,
|
|
||||||
E: UsesState<State = Z::State>,
|
|
||||||
EM: UsesState<State = Z::State>,
|
|
||||||
Z: Evaluator<E, EM>,
|
|
||||||
Z::State: HasCorpus + HasRand + HasMetadata,
|
|
||||||
{
|
|
||||||
/// Creates a new [`SyncFromDiskStage`]
|
/// Creates a new [`SyncFromDiskStage`]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(sync_dir: PathBuf, load_callback: CB) -> Self {
|
pub fn new(sync_dir: PathBuf, load_callback: CB) -> Self {
|
||||||
@ -232,10 +222,9 @@ pub type SyncFromDiskFunction<S, Z> =
|
|||||||
|
|
||||||
impl<E, EM, Z> SyncFromDiskStage<SyncFromDiskFunction<Z::State, Z>, E, EM, Z>
|
impl<E, EM, Z> SyncFromDiskStage<SyncFromDiskFunction<Z::State, Z>, E, EM, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = <Self as UsesState>::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand + HasMetadata,
|
|
||||||
{
|
{
|
||||||
/// Creates a new [`SyncFromDiskStage`] invoking `Input::from_file` to load inputs
|
/// Creates a new [`SyncFromDiskStage`] invoking `Input::from_file` to load inputs
|
||||||
#[must_use]
|
#[must_use]
|
||||||
@ -318,7 +307,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut Z::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
if self.client.can_convert() {
|
if self.client.can_convert() {
|
||||||
|
@ -14,13 +14,13 @@ use crate::feedbacks::premature_last_result_err;
|
|||||||
use crate::{
|
use crate::{
|
||||||
corpus::{Corpus, HasCurrentCorpusId, Testcase},
|
corpus::{Corpus, HasCurrentCorpusId, Testcase},
|
||||||
events::EventFirer,
|
events::EventFirer,
|
||||||
executors::{Executor, ExitKind, HasObservers},
|
executors::{ExitKind, HasObservers},
|
||||||
feedbacks::{Feedback, FeedbackFactory, HasObserverHandle},
|
feedbacks::{Feedback, FeedbackFactory, HasObserverHandle},
|
||||||
inputs::UsesInput,
|
inputs::UsesInput,
|
||||||
mark_feature_time,
|
mark_feature_time,
|
||||||
mutators::{MutationResult, Mutator},
|
mutators::{MutationResult, Mutator},
|
||||||
observers::{MapObserver, ObserversTuple},
|
observers::{MapObserver, ObserversTuple},
|
||||||
schedulers::{RemovableScheduler, Scheduler},
|
schedulers::RemovableScheduler,
|
||||||
stages::{
|
stages::{
|
||||||
mutational::{MutatedTransform, MutatedTransformPost},
|
mutational::{MutatedTransform, MutatedTransformPost},
|
||||||
ExecutionCountRestartHelper, Stage,
|
ExecutionCountRestartHelper, Stage,
|
||||||
@ -36,24 +36,22 @@ use crate::{monitors::PerfFeature, state::HasClientPerfMonitor};
|
|||||||
/// Mutational stage which minimizes corpus entries.
|
/// Mutational stage which minimizes corpus entries.
|
||||||
///
|
///
|
||||||
/// You must provide at least one mutator that actually reduces size.
|
/// You must provide at least one mutator that actually reduces size.
|
||||||
pub trait TMinMutationalStage<CS, E, EM, F1, F2, I, IP, M, OT, Z>:
|
pub trait TMinMutationalStage<E, EM, F, IP, M, Z>:
|
||||||
Stage<E, EM, Z> + FeedbackFactory<F2, CS::State, OT>
|
Stage<E, EM, Z> + FeedbackFactory<F, E::Observers>
|
||||||
where
|
where
|
||||||
Self::State: HasCorpus + HasSolutions + HasExecutions + HasMaxSize,
|
E: UsesState<State = Self::State> + HasObservers,
|
||||||
<Self::State as UsesInput>::Input: HasLen + Hash,
|
EM: UsesState<State = Self::State> + EventFirer,
|
||||||
CS: Scheduler<State = Self::State> + RemovableScheduler,
|
F: Feedback<Self::State>,
|
||||||
E: Executor<EM, Z> + HasObservers<Observers = OT, State = Self::State>,
|
Self::State: HasMaxSize + HasCorpus + HasSolutions + HasExecutions,
|
||||||
EM: EventFirer<State = Self::State>,
|
Self::Input: MutatedTransform<Self::Input, Self::State, Post = IP> + Clone + Hash + HasLen,
|
||||||
F1: Feedback<Self::State>,
|
IP: Clone + MutatedTransformPost<Self::State>,
|
||||||
F2: Feedback<Self::State>,
|
M: Mutator<Self::Input, Self::State>,
|
||||||
M: Mutator<I, Self::State>,
|
Z: UsesState<State = Self::State>
|
||||||
OT: ObserversTuple<CS::State>,
|
+ HasScheduler
|
||||||
Z: ExecutionProcessor<OT, State = Self::State>
|
+ HasFeedback
|
||||||
+ ExecutesInput<E, EM>
|
+ ExecutesInput<E, EM>
|
||||||
+ HasFeedback<Feedback = F1>
|
+ ExecutionProcessor<E::Observers>,
|
||||||
+ HasScheduler<Scheduler = CS>,
|
Z::Scheduler: RemovableScheduler<State = Self::State>,
|
||||||
IP: MutatedTransformPost<Self::State> + Clone,
|
|
||||||
I: MutatedTransform<Self::Input, Self::State, Post = IP> + Clone,
|
|
||||||
{
|
{
|
||||||
/// The mutator registered for this stage
|
/// The mutator registered for this stage
|
||||||
fn mutator(&self) -> &M;
|
fn mutator(&self) -> &M;
|
||||||
@ -62,7 +60,7 @@ where
|
|||||||
fn mutator_mut(&mut self) -> &mut M;
|
fn mutator_mut(&mut self) -> &mut M;
|
||||||
|
|
||||||
/// Gets the number of iterations this mutator should run for.
|
/// Gets the number of iterations this mutator should run for.
|
||||||
fn iterations(&self, state: &mut CS::State) -> Result<usize, Error>;
|
fn iterations(&self, state: &mut Self::State) -> Result<usize, Error>;
|
||||||
|
|
||||||
/// Runs this (mutational) stage for new objectives
|
/// Runs this (mutational) stage for new objectives
|
||||||
#[allow(clippy::cast_possible_wrap)] // more than i32 stages on 32 bit system - highly unlikely...
|
#[allow(clippy::cast_possible_wrap)] // more than i32 stages on 32 bit system - highly unlikely...
|
||||||
@ -70,7 +68,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut CS::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let Some(base_corpus_idx) = state.current_corpus_id()? else {
|
let Some(base_corpus_idx) = state.current_corpus_id()? else {
|
||||||
@ -85,7 +83,8 @@ where
|
|||||||
- usize::try_from(self.execs_since_progress_start(state)?).unwrap();
|
- usize::try_from(self.execs_since_progress_start(state)?).unwrap();
|
||||||
|
|
||||||
start_timer!(state);
|
start_timer!(state);
|
||||||
let transformed = I::try_transform_from(state.current_testcase_mut()?.borrow_mut(), state)?;
|
let transformed =
|
||||||
|
Self::Input::try_transform_from(state.current_testcase_mut()?.borrow_mut(), state)?;
|
||||||
let mut base = state.current_input_cloned()?;
|
let mut base = state.current_input_cloned()?;
|
||||||
// potential post operation if base is replaced by a shorter input
|
// potential post operation if base is replaced by a shorter input
|
||||||
let mut base_post = None;
|
let mut base_post = None;
|
||||||
@ -198,12 +197,12 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the number of executions this mutator already did since it got first called in this fuzz round.
|
/// Gets the number of executions this mutator already did since it got first called in this fuzz round.
|
||||||
fn execs_since_progress_start(&mut self, state: &mut Z::State) -> Result<u64, Error>;
|
fn execs_since_progress_start(&mut self, state: &mut Self::State) -> Result<u64, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The default corpus entry minimising mutational stage
|
/// The default corpus entry minimising mutational stage
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct StdTMinMutationalStage<CS, E, EM, F1, F2, FF, I, IP, M, OT, Z> {
|
pub struct StdTMinMutationalStage<E, EM, F, FF, IP, M, Z> {
|
||||||
/// The mutator(s) this stage uses
|
/// The mutator(s) this stage uses
|
||||||
mutator: M,
|
mutator: M,
|
||||||
/// The factory
|
/// The factory
|
||||||
@ -213,41 +212,28 @@ pub struct StdTMinMutationalStage<CS, E, EM, F1, F2, FF, I, IP, M, OT, Z> {
|
|||||||
/// The progress helper for this stage, keeping track of resumes after timeouts/crashes
|
/// The progress helper for this stage, keeping track of resumes after timeouts/crashes
|
||||||
restart_helper: ExecutionCountRestartHelper,
|
restart_helper: ExecutionCountRestartHelper,
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
phantom: PhantomData<(CS, E, EM, F1, F2, I, IP, OT, Z)>,
|
phantom: PhantomData<(E, EM, F, IP, Z)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CS, E, EM, F1, F2, FF, I, IP, M, OT, Z> UsesState
|
impl<E, EM, F, FF, IP, M, Z> UsesState for StdTMinMutationalStage<E, EM, F, FF, IP, M, Z>
|
||||||
for StdTMinMutationalStage<CS, E, EM, F1, F2, FF, I, IP, M, OT, Z>
|
|
||||||
where
|
where
|
||||||
CS: Scheduler,
|
Z: UsesState,
|
||||||
M: Mutator<I, CS::State>,
|
|
||||||
Z: ExecutionProcessor<OT, State = CS::State>,
|
|
||||||
CS::State: HasCorpus,
|
|
||||||
IP: MutatedTransformPost<CS::State> + Clone,
|
|
||||||
I: MutatedTransform<CS::Input, CS::State, Post = IP> + Clone,
|
|
||||||
{
|
{
|
||||||
type State = CS::State;
|
type State = Z::State;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CS, E, EM, F1, F2, FF, I, IP, M, OT, Z> Stage<E, EM, Z>
|
impl<E, EM, F, FF, IP, M, Z> Stage<E, EM, Z> for StdTMinMutationalStage<E, EM, F, FF, IP, M, Z>
|
||||||
for StdTMinMutationalStage<CS, E, EM, F1, F2, FF, I, IP, M, OT, Z>
|
|
||||||
where
|
where
|
||||||
CS: Scheduler + RemovableScheduler,
|
Z: HasScheduler + ExecutionProcessor<E::Observers> + ExecutesInput<E, EM> + HasFeedback,
|
||||||
CS::State: HasCorpus + HasSolutions + HasExecutions + HasMaxSize + HasCorpus + HasMetadata,
|
Z::Scheduler: RemovableScheduler,
|
||||||
<CS::State as UsesInput>::Input: HasLen + Hash,
|
E: HasObservers<State = Self::State>,
|
||||||
E: Executor<EM, Z> + HasObservers<Observers = OT, State = CS::State>,
|
EM: EventFirer<State = Self::State>,
|
||||||
EM: EventFirer<State = CS::State>,
|
FF: FeedbackFactory<F, E::Observers>,
|
||||||
F1: Feedback<CS::State>,
|
F: Feedback<Self::State>,
|
||||||
F2: Feedback<CS::State>,
|
Self::Input: MutatedTransform<Self::Input, Self::State, Post = IP> + Clone + HasLen + Hash,
|
||||||
FF: FeedbackFactory<F2, CS::State, OT>,
|
Self::State: HasMetadata + HasExecutions + HasSolutions + HasCorpus + HasMaxSize,
|
||||||
M: Mutator<I, CS::State>,
|
M: Mutator<Self::Input, Self::State>,
|
||||||
OT: ObserversTuple<CS::State>,
|
IP: MutatedTransformPost<Self::State> + Clone,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State>
|
|
||||||
+ ExecutesInput<E, EM>
|
|
||||||
+ HasFeedback<Feedback = F1>
|
|
||||||
+ HasScheduler<Scheduler = CS>,
|
|
||||||
IP: MutatedTransformPost<CS::State> + Clone,
|
|
||||||
I: MutatedTransform<CS::Input, CS::State, Post = IP> + Clone,
|
|
||||||
{
|
{
|
||||||
fn restart_progress_should_run(&mut self, state: &mut Self::State) -> Result<bool, Error> {
|
fn restart_progress_should_run(&mut self, state: &mut Self::State) -> Result<bool, Error> {
|
||||||
self.restart_helper.restart_progress_should_run(state)
|
self.restart_helper.restart_progress_should_run(state)
|
||||||
@ -261,7 +247,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut CS::State,
|
state: &mut Z::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.perform_minification(fuzzer, executor, state, manager)?;
|
self.perform_minification(fuzzer, executor, state, manager)?;
|
||||||
@ -273,37 +259,30 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CS, E, EM, F1, F2, FF, I, IP, M, OT, Z> FeedbackFactory<F2, Z::State, OT>
|
impl<E, EM, F, FF, IP, M, Z> FeedbackFactory<F, E::Observers>
|
||||||
for StdTMinMutationalStage<CS, E, EM, F1, F2, FF, I, IP, M, OT, Z>
|
for StdTMinMutationalStage<E, EM, F, FF, IP, M, Z>
|
||||||
where
|
where
|
||||||
F2: Feedback<Z::State>,
|
E: HasObservers,
|
||||||
FF: FeedbackFactory<F2, Z::State, OT>,
|
FF: FeedbackFactory<F, E::Observers>,
|
||||||
Z: UsesState,
|
|
||||||
{
|
{
|
||||||
fn create_feedback(&self, ctx: &OT) -> F2 {
|
fn create_feedback(&self, ctx: &E::Observers) -> F {
|
||||||
self.factory.create_feedback(ctx)
|
self.factory.create_feedback(ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CS, E, EM, F1, F2, FF, I, IP, M, OT, Z> TMinMutationalStage<CS, E, EM, F1, F2, I, IP, M, OT, Z>
|
impl<E, EM, F, FF, IP, M, Z> TMinMutationalStage<E, EM, F, IP, M, Z>
|
||||||
for StdTMinMutationalStage<CS, E, EM, F1, F2, FF, I, IP, M, OT, Z>
|
for StdTMinMutationalStage<E, EM, F, FF, IP, M, Z>
|
||||||
where
|
where
|
||||||
CS: Scheduler + RemovableScheduler,
|
Z: HasScheduler + ExecutionProcessor<E::Observers> + ExecutesInput<E, EM> + HasFeedback,
|
||||||
E: HasObservers<Observers = OT, State = CS::State> + Executor<EM, Z>,
|
Z::Scheduler: RemovableScheduler,
|
||||||
EM: EventFirer<State = CS::State>,
|
E: HasObservers<State = Self::State>,
|
||||||
F1: Feedback<CS::State>,
|
EM: EventFirer<State = Self::State>,
|
||||||
F2: Feedback<CS::State>,
|
FF: FeedbackFactory<F, E::Observers>,
|
||||||
FF: FeedbackFactory<F2, CS::State, OT>,
|
F: Feedback<Self::State>,
|
||||||
<CS::State as UsesInput>::Input: HasLen + Hash,
|
Self::Input: MutatedTransform<Self::Input, Self::State, Post = IP> + Clone + HasLen + Hash,
|
||||||
M: Mutator<I, CS::State>,
|
Self::State: HasMetadata + HasExecutions + HasSolutions + HasCorpus + HasMaxSize,
|
||||||
OT: ObserversTuple<CS::State>,
|
M: Mutator<Self::Input, Self::State>,
|
||||||
CS::State: HasCorpus + HasSolutions + HasExecutions + HasMaxSize + HasMetadata,
|
IP: MutatedTransformPost<Self::State> + Clone,
|
||||||
Z: ExecutionProcessor<OT, State = CS::State>
|
|
||||||
+ ExecutesInput<E, EM>
|
|
||||||
+ HasFeedback<Feedback = F1>
|
|
||||||
+ HasScheduler<Scheduler = CS>,
|
|
||||||
IP: MutatedTransformPost<CS::State> + Clone,
|
|
||||||
I: MutatedTransform<CS::Input, CS::State, Post = IP> + Clone,
|
|
||||||
{
|
{
|
||||||
/// The mutator, added to this stage
|
/// The mutator, added to this stage
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -318,25 +297,16 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the number of iterations from a fixed number of runs
|
/// Gets the number of iterations from a fixed number of runs
|
||||||
fn iterations(&self, _state: &mut CS::State) -> Result<usize, Error> {
|
fn iterations(&self, _state: &mut Self::State) -> Result<usize, Error> {
|
||||||
Ok(self.runs)
|
Ok(self.runs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execs_since_progress_start(&mut self, state: &mut <Z>::State) -> Result<u64, Error> {
|
fn execs_since_progress_start(&mut self, state: &mut Self::State) -> Result<u64, Error> {
|
||||||
self.restart_helper.execs_since_progress_start(state)
|
self.restart_helper.execs_since_progress_start(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CS, E, EM, F1, F2, FF, I, IP, M, OT, Z>
|
impl<E, EM, F, FF, IP, M, Z> StdTMinMutationalStage<E, EM, F, FF, IP, M, Z> {
|
||||||
StdTMinMutationalStage<CS, E, EM, F1, F2, FF, I, IP, M, OT, Z>
|
|
||||||
where
|
|
||||||
CS: Scheduler,
|
|
||||||
M: Mutator<I, CS::State>,
|
|
||||||
Z: ExecutionProcessor<OT, State = CS::State>,
|
|
||||||
CS::State: HasCorpus,
|
|
||||||
IP: MutatedTransformPost<CS::State> + Clone,
|
|
||||||
I: MutatedTransform<CS::Input, CS::State, Post = IP> + Clone,
|
|
||||||
{
|
|
||||||
/// Creates a new minimizing mutational stage that will minimize provided corpus entries
|
/// Creates a new minimizing mutational stage that will minimize provided corpus entries
|
||||||
pub fn new(mutator: M, factory: FF, runs: usize) -> Self {
|
pub fn new(mutator: M, factory: FF, runs: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@ -439,13 +409,12 @@ impl<C, M, S> HasObserverHandle for MapEqualityFactory<C, M, S> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C, M, OT, S> FeedbackFactory<MapEqualityFeedback<C, M, S>, S, OT>
|
impl<C, M, OT, S> FeedbackFactory<MapEqualityFeedback<C, M, S>, OT> for MapEqualityFactory<C, M, S>
|
||||||
for MapEqualityFactory<C, M, S>
|
|
||||||
where
|
where
|
||||||
M: MapObserver,
|
M: MapObserver,
|
||||||
C: AsRef<M> + Handled,
|
C: AsRef<M> + Handled,
|
||||||
OT: ObserversTuple<S>,
|
OT: ObserversTuple<S>,
|
||||||
S: State + Debug,
|
S: UsesInput,
|
||||||
{
|
{
|
||||||
fn create_feedback(&self, observers: &OT) -> MapEqualityFeedback<C, M, S> {
|
fn create_feedback(&self, observers: &OT) -> MapEqualityFeedback<C, M, S> {
|
||||||
let obs = observers
|
let obs = observers
|
||||||
|
@ -36,9 +36,9 @@ where
|
|||||||
impl<EM, TE, Z> TracingStage<EM, TE, Z>
|
impl<EM, TE, Z> TracingStage<EM, TE, Z>
|
||||||
where
|
where
|
||||||
TE: Executor<EM, Z> + HasObservers,
|
TE: Executor<EM, Z> + HasObservers,
|
||||||
TE::State: HasExecutions + HasCorpus + HasNamedMetadata,
|
<Self as UsesState>::State: HasExecutions + HasCorpus + HasNamedMetadata,
|
||||||
EM: UsesState<State = TE::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
Z: UsesState<State = TE::State>,
|
Z: UsesState<State = <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
/// Perform tracing on the given `CorpusId`. Useful for if wrapping [`TracingStage`] with your
|
/// Perform tracing on the given `CorpusId`. Useful for if wrapping [`TracingStage`] with your
|
||||||
/// own stage and you need to manage [`super::NestedStageRestartHelper`] differently; see
|
/// own stage and you need to manage [`super::NestedStageRestartHelper`] differently; see
|
||||||
@ -46,7 +46,7 @@ where
|
|||||||
pub fn trace(
|
pub fn trace(
|
||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
state: &mut TE::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
start_timer!(state);
|
start_timer!(state);
|
||||||
@ -80,18 +80,18 @@ where
|
|||||||
|
|
||||||
impl<E, EM, TE, Z> Stage<E, EM, Z> for TracingStage<EM, TE, Z>
|
impl<E, EM, TE, Z> Stage<E, EM, Z> for TracingStage<EM, TE, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = TE::State>,
|
E: UsesState<State = <Self as UsesState>::State>,
|
||||||
TE: Executor<EM, Z> + HasObservers,
|
TE: Executor<EM, Z> + HasObservers,
|
||||||
TE::State: HasExecutions + HasCorpus + HasNamedMetadata,
|
<Self as UsesState>::State: HasExecutions + HasCorpus + HasNamedMetadata,
|
||||||
EM: UsesState<State = TE::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
Z: UsesState<State = TE::State>,
|
Z: UsesState<State = <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
_executor: &mut E,
|
_executor: &mut E,
|
||||||
state: &mut TE::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.trace(fuzzer, state, manager)
|
self.trace(fuzzer, state, manager)
|
||||||
@ -170,17 +170,17 @@ where
|
|||||||
impl<E, EM, SOT, Z> Stage<ShadowExecutor<E, SOT>, EM, Z> for ShadowTracingStage<E, EM, SOT, Z>
|
impl<E, EM, SOT, Z> Stage<ShadowExecutor<E, SOT>, EM, Z> for ShadowTracingStage<E, EM, SOT, Z>
|
||||||
where
|
where
|
||||||
E: Executor<EM, Z> + HasObservers,
|
E: Executor<EM, Z> + HasObservers,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
SOT: ObserversTuple<E::State>,
|
SOT: ObserversTuple<E::State>,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = <Self as UsesState>::State>,
|
||||||
E::State: State + HasExecutions + HasCorpus + HasNamedMetadata + Debug,
|
<Self as UsesState>::State: State + HasExecutions + HasCorpus + HasNamedMetadata + Debug,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn perform(
|
fn perform(
|
||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut ShadowExecutor<E, SOT>,
|
executor: &mut ShadowExecutor<E, SOT>,
|
||||||
state: &mut E::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
start_timer!(state);
|
start_timer!(state);
|
||||||
@ -225,10 +225,10 @@ where
|
|||||||
impl<E, EM, SOT, Z> ShadowTracingStage<E, EM, SOT, Z>
|
impl<E, EM, SOT, Z> ShadowTracingStage<E, EM, SOT, Z>
|
||||||
where
|
where
|
||||||
E: Executor<EM, Z> + HasObservers,
|
E: Executor<EM, Z> + HasObservers,
|
||||||
E::State: State + HasExecutions + HasCorpus,
|
<Self as UsesState>::State: State + HasExecutions + HasCorpus,
|
||||||
EM: UsesState<State = E::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
SOT: ObserversTuple<E::State>,
|
SOT: ObserversTuple<E::State>,
|
||||||
Z: UsesState<State = E::State>,
|
Z: UsesState<State = <Self as UsesState>::State>,
|
||||||
{
|
{
|
||||||
/// Creates a new default stage
|
/// Creates a new default stage
|
||||||
pub fn new(_executor: &mut ShadowExecutor<E, SOT>) -> Self {
|
pub fn new(_executor: &mut ShadowExecutor<E, SOT>) -> Self {
|
||||||
|
@ -160,12 +160,12 @@ pub struct TuneableMutationalStage<E, EM, I, M, Z> {
|
|||||||
|
|
||||||
impl<E, EM, I, M, Z> MutationalStage<E, EM, I, M, Z> for TuneableMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> MutationalStage<E, EM, I, M, Z> for TuneableMutationalStage<E, EM, I, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = Self::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
M: Mutator<I, Z::State>,
|
M: Mutator<I, Self::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand + HasNamedMetadata + HasMetadata + HasExecutions,
|
Self::State: HasCorpus + HasRand + HasNamedMetadata + HasMetadata + HasExecutions,
|
||||||
I: MutatedTransform<Z::Input, Z::State> + Clone,
|
I: MutatedTransform<Z::Input, Self::State> + Clone,
|
||||||
{
|
{
|
||||||
/// Runs this (mutational) stage for the given `testcase`
|
/// Runs this (mutational) stage for the given `testcase`
|
||||||
/// Exactly the same functionality as [`MutationalStage::perform_mutational`], but with added timeout support.
|
/// Exactly the same functionality as [`MutationalStage::perform_mutational`], but with added timeout support.
|
||||||
@ -173,7 +173,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut Z::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let fuzz_time = self.seed_fuzz_time(state)?;
|
let fuzz_time = self.seed_fuzz_time(state)?;
|
||||||
@ -242,38 +242,33 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the number of iterations as a random number
|
/// Gets the number of iterations as a random number
|
||||||
fn iterations(&self, state: &mut Z::State) -> Result<usize, Error> {
|
fn iterations(&self, state: &mut Self::State) -> Result<usize, Error> {
|
||||||
Ok(
|
Ok(
|
||||||
// fall back to random
|
// fall back to random
|
||||||
1 + state.rand_mut().below(DEFAULT_MUTATIONAL_MAX_ITERATIONS),
|
1 + state.rand_mut().below(DEFAULT_MUTATIONAL_MAX_ITERATIONS),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execs_since_progress_start(&mut self, state: &mut <Z>::State) -> Result<u64, Error> {
|
fn execs_since_progress_start(&mut self, state: &mut Self::State) -> Result<u64, Error> {
|
||||||
self.restart_helper.execs_since_progress_start(state)
|
self.restart_helper.execs_since_progress_start(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E, EM, I, M, Z> UsesState for TuneableMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> UsesState for TuneableMutationalStage<E, EM, I, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
|
||||||
EM: UsesState<State = Z::State>,
|
|
||||||
M: Mutator<I, Z::State>,
|
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand + HasExecutions,
|
|
||||||
I: MutatedTransform<Z::Input, Z::State> + Clone,
|
|
||||||
{
|
{
|
||||||
type State = Z::State;
|
type State = Z::State;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E, EM, I, M, Z> Stage<E, EM, Z> for TuneableMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> Stage<E, EM, Z> for TuneableMutationalStage<E, EM, I, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = Self::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
M: Mutator<I, Z::State>,
|
M: Mutator<I, Self::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand + HasNamedMetadata + HasMetadata + HasExecutions,
|
Self::State: HasCorpus + HasRand + HasNamedMetadata + HasMetadata + HasExecutions,
|
||||||
I: MutatedTransform<Z::Input, Z::State> + Clone,
|
I: MutatedTransform<Self::Input, Self::State> + Clone,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(clippy::let_and_return)]
|
#[allow(clippy::let_and_return)]
|
||||||
@ -281,7 +276,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut Z::State,
|
state: &mut Self::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let ret = self.perform_mutational(fuzzer, executor, state, manager);
|
let ret = self.perform_mutational(fuzzer, executor, state, manager);
|
||||||
@ -303,21 +298,22 @@ where
|
|||||||
|
|
||||||
impl<E, EM, I, M, Z> TuneableMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> TuneableMutationalStage<E, EM, I, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = <Self as UsesState>::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
M: Mutator<I, Z::State>,
|
M: Mutator<I, <Self as UsesState>::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand + HasNamedMetadata + HasMetadata + HasExecutions,
|
<Self as UsesState>::State:
|
||||||
I: MutatedTransform<Z::Input, Z::State> + Clone,
|
HasCorpus + HasRand + HasNamedMetadata + HasMetadata + HasExecutions,
|
||||||
|
I: MutatedTransform<Z::Input, <Self as UsesState>::State> + Clone,
|
||||||
{
|
{
|
||||||
/// Creates a new default tuneable mutational stage
|
/// Creates a new default tuneable mutational stage
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(state: &mut Z::State, mutator: M) -> Self {
|
pub fn new(state: &mut <Self as UsesState>::State, mutator: M) -> Self {
|
||||||
Self::transforming(state, mutator, STD_TUNEABLE_MUTATIONAL_STAGE_NAME)
|
Self::transforming(state, mutator, STD_TUNEABLE_MUTATIONAL_STAGE_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Crates a new tuneable mutational stage with the given name
|
/// Crates a new tuneable mutational stage with the given name
|
||||||
pub fn with_name(state: &mut Z::State, mutator: M, name: &str) -> Self {
|
pub fn with_name(state: &mut <Self as UsesState>::State, mutator: M, name: &str) -> Self {
|
||||||
Self::transforming(state, mutator, name)
|
Self::transforming(state, mutator, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +326,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set the number of iterations to be used by the std [`TuneableMutationalStage`]
|
/// Set the number of iterations to be used by the std [`TuneableMutationalStage`]
|
||||||
pub fn set_iters_std(state: &mut Z::State, iters: u64) -> Result<(), Error> {
|
pub fn set_iters_std(state: &mut <Self as UsesState>::State, iters: u64) -> Result<(), Error> {
|
||||||
set_iters_by_name(state, iters, STD_TUNEABLE_MUTATIONAL_STAGE_NAME)
|
set_iters_by_name(state, iters, STD_TUNEABLE_MUTATIONAL_STAGE_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +347,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the set iterations for the std [`TuneableMutationalStage`], if any
|
/// Get the set iterations for the std [`TuneableMutationalStage`], if any
|
||||||
pub fn iters_std(state: &Z::State) -> Result<Option<u64>, Error> {
|
pub fn iters_std(state: &<Self as UsesState>::State) -> Result<Option<u64>, Error> {
|
||||||
get_iters_by_name(state, STD_TUNEABLE_MUTATIONAL_STAGE_NAME)
|
get_iters_by_name(state, STD_TUNEABLE_MUTATIONAL_STAGE_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +368,10 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set the time to mutate a single input in the std [`TuneableMutationalStage`]
|
/// Set the time to mutate a single input in the std [`TuneableMutationalStage`]
|
||||||
pub fn set_seed_fuzz_time_std(state: &mut Z::State, fuzz_time: Duration) -> Result<(), Error> {
|
pub fn set_seed_fuzz_time_std(
|
||||||
|
state: &mut <Self as UsesState>::State,
|
||||||
|
fuzz_time: Duration,
|
||||||
|
) -> Result<(), Error> {
|
||||||
set_seed_fuzz_time_by_name(state, fuzz_time, STD_TUNEABLE_MUTATIONAL_STAGE_NAME)
|
set_seed_fuzz_time_by_name(state, fuzz_time, STD_TUNEABLE_MUTATIONAL_STAGE_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,7 +396,10 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set the time to mutate a single input for the std [`TuneableMutationalStage`]
|
/// Set the time to mutate a single input for the std [`TuneableMutationalStage`]
|
||||||
pub fn seed_fuzz_time_std(&self, state: &Z::State) -> Result<Option<Duration>, Error> {
|
pub fn seed_fuzz_time_std(
|
||||||
|
&self,
|
||||||
|
state: &<Self as UsesState>::State,
|
||||||
|
) -> Result<Option<Duration>, Error> {
|
||||||
get_seed_fuzz_time_by_name(state, STD_TUNEABLE_MUTATIONAL_STAGE_NAME)
|
get_seed_fuzz_time_by_name(state, STD_TUNEABLE_MUTATIONAL_STAGE_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,7 +424,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Reset the std stage to a normal, randomized, stage
|
/// Reset the std stage to a normal, randomized, stage
|
||||||
pub fn reset_std(state: &mut Z::State) -> Result<(), Error> {
|
pub fn reset_std(state: &mut <Self as UsesState>::State) -> Result<(), Error> {
|
||||||
reset_by_name(state, STD_TUNEABLE_MUTATIONAL_STAGE_NAME)
|
reset_by_name(state, STD_TUNEABLE_MUTATIONAL_STAGE_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,7 +440,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
fuzzer: &mut Z,
|
fuzzer: &mut Z,
|
||||||
executor: &mut E,
|
executor: &mut E,
|
||||||
state: &mut Z::State,
|
state: &mut <Self as UsesState>::State,
|
||||||
manager: &mut EM,
|
manager: &mut EM,
|
||||||
input: &I,
|
input: &I,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
@ -467,15 +469,15 @@ where
|
|||||||
|
|
||||||
impl<E, EM, I, M, Z> TuneableMutationalStage<E, EM, I, M, Z>
|
impl<E, EM, I, M, Z> TuneableMutationalStage<E, EM, I, M, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = Z::State>,
|
E: UsesState<State = <Self as UsesState>::State>,
|
||||||
EM: UsesState<State = Z::State>,
|
EM: UsesState<State = <Self as UsesState>::State>,
|
||||||
M: Mutator<I, Z::State>,
|
M: Mutator<I, Z::State>,
|
||||||
Z: Evaluator<E, EM>,
|
Z: Evaluator<E, EM>,
|
||||||
Z::State: HasCorpus + HasRand + HasNamedMetadata,
|
<Self as UsesState>::State: HasCorpus + HasRand + HasNamedMetadata,
|
||||||
{
|
{
|
||||||
/// Creates a new transforming mutational stage
|
/// Creates a new transforming mutational stage
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn transforming(state: &mut Z::State, mutator: M, name: &str) -> Self {
|
pub fn transforming(state: &mut <Self as UsesState>::State, mutator: M, name: &str) -> Self {
|
||||||
let _ = state.named_metadata_or_insert_with(name, TuneableMutationalStageMetadata::default);
|
let _ = state.named_metadata_or_insert_with(name, TuneableMutationalStageMetadata::default);
|
||||||
Self {
|
Self {
|
||||||
mutator,
|
mutator,
|
||||||
|
@ -36,7 +36,7 @@ libafl_bolts = { path = "../../libafl_bolts", default-features = false, features
|
|||||||
libafl_targets = { path = "../../libafl_targets", features = ["sancov_8bit", "sancov_cmplog", "sancov_pcguard", "libfuzzer", "libfuzzer_oom", "libfuzzer_define_run_driver", "libfuzzer_interceptors", "sanitizers_flags", "whole_archive", "sanitizer_interfaces"] }
|
libafl_targets = { path = "../../libafl_targets", features = ["sancov_8bit", "sancov_cmplog", "sancov_pcguard", "libfuzzer", "libfuzzer_oom", "libfuzzer_define_run_driver", "libfuzzer_interceptors", "sanitizers_flags", "whole_archive", "sanitizer_interfaces"] }
|
||||||
|
|
||||||
ahash = { version = "0.8.3", default-features = false }
|
ahash = { version = "0.8.3", default-features = false }
|
||||||
libc = "0.2.139"
|
libc = "0.2.1"
|
||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
mimalloc = { version = "0.1.34", default-features = false }
|
mimalloc = { version = "0.1.34", default-features = false }
|
||||||
num-traits = "0.2.15"
|
num-traits = "0.2.15"
|
||||||
|
@ -23,7 +23,7 @@ where
|
|||||||
TE: UsesState,
|
TE: UsesState,
|
||||||
{
|
{
|
||||||
tracer_executor: TE,
|
tracer_executor: TE,
|
||||||
cmplog_observer_handle: Option<Handle<AFLppCmpLogObserver<'a, TE::State>>>,
|
cmplog_observer_handle: Option<Handle<AFLppCmpLogObserver<'a, <Self as UsesState>::State>>>,
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
phantom: PhantomData<(EM, TE, Z)>,
|
phantom: PhantomData<(EM, TE, Z)>,
|
||||||
}
|
}
|
||||||
@ -47,12 +47,12 @@ where
|
|||||||
|
|
||||||
impl<E, EM, TE, Z> Stage<E, EM, Z> for AFLppCmplogTracingStage<'_, EM, TE, Z>
|
impl<E, EM, TE, Z> Stage<E, EM, Z> for AFLppCmplogTracingStage<'_, EM, TE, Z>
|
||||||
where
|
where
|
||||||
E: UsesState<State = TE::State>,
|
E: UsesState<State = Self::State>,
|
||||||
TE: Executor<EM, Z> + HasObservers,
|
TE: Executor<EM, Z> + HasObservers,
|
||||||
TE::State:
|
Self::State:
|
||||||
HasExecutions + HasCorpus + HasMetadata + UsesInput<Input = BytesInput> + HasNamedMetadata,
|
HasExecutions + HasCorpus + HasMetadata + UsesInput<Input = BytesInput> + HasNamedMetadata,
|
||||||
EM: UsesState<State = TE::State>,
|
EM: UsesState<State = Self::State>,
|
||||||
Z: UsesState<State = TE::State>,
|
Z: UsesState<State = Self::State>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn perform(
|
fn perform(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user