Set the number of stacked mutations in MOpt mutator (#587)
* max_stack_pow * fix * fix * fmt * rename
This commit is contained in:
parent
1167389149
commit
034a4870e2
@ -145,7 +145,7 @@ pub fn main() {
|
||||
.expect("Failed to generate the initial corpus");
|
||||
|
||||
// Setup a mutational stage with a basic bytes mutator
|
||||
let mutator = StdScheduledMutator::with_max_iterations(
|
||||
let mutator = StdScheduledMutator::with_max_stack_pow(
|
||||
tuple_list!(
|
||||
GramatronRandomMutator::new(&generator),
|
||||
GramatronRandomMutator::new(&generator),
|
||||
|
@ -145,8 +145,8 @@ pub fn main() {
|
||||
.expect("Failed to create the Executor");
|
||||
|
||||
// Setup a mutational stage with a basic bytes mutator
|
||||
let mutator = StdScheduledMutator::with_max_iterations(havoc_mutations(), 2);
|
||||
let grimoire_mutator = StdScheduledMutator::with_max_iterations(
|
||||
let mutator = StdScheduledMutator::with_max_stack_pow(havoc_mutations(), 2);
|
||||
let grimoire_mutator = StdScheduledMutator::with_max_stack_pow(
|
||||
tuple_list!(
|
||||
GrimoireExtensionMutator::new(),
|
||||
GrimoireRecursiveReplacementMutator::new(),
|
||||
|
@ -141,7 +141,7 @@ pub fn main() {
|
||||
.expect("Failed to generate the initial corpus");
|
||||
|
||||
// Setup a mutational stage with a basic bytes mutator
|
||||
let mutator = StdScheduledMutator::with_max_iterations(
|
||||
let mutator = StdScheduledMutator::with_max_stack_pow(
|
||||
tuple_list!(
|
||||
NautilusRandomMutator::new(&context),
|
||||
NautilusRandomMutator::new(&context),
|
||||
|
@ -116,7 +116,7 @@ pub fn main() {
|
||||
.expect("Failed to create the Executor");
|
||||
|
||||
// Setup a mutational stage with a basic bytes mutator
|
||||
let mutator = StdScheduledMutator::with_max_iterations(encoded_mutations(), 2);
|
||||
let mutator = StdScheduledMutator::with_max_stack_pow(encoded_mutations(), 2);
|
||||
let mut stages = tuple_list!(StdMutationalStage::new(mutator));
|
||||
|
||||
println!("Decoder {:?} ...", &encoder_decoder);
|
||||
|
@ -306,7 +306,12 @@ fn fuzz(
|
||||
let i2s = StdMutationalStage::new(StdScheduledMutator::new(tuple_list!(I2SRandReplace::new())));
|
||||
|
||||
// Setup a MOPT mutator
|
||||
let mutator = StdMOptMutator::new(&mut state, havoc_mutations().merge(tokens_mutations()), 5)?;
|
||||
let mutator = StdMOptMutator::new(
|
||||
&mut state,
|
||||
havoc_mutations().merge(tokens_mutations()),
|
||||
7,
|
||||
5,
|
||||
)?;
|
||||
|
||||
let power =
|
||||
StdPowerMutationalStage::new(&mut state, mutator, &edges_observer, PowerSchedule::FAST);
|
||||
|
@ -277,7 +277,12 @@ fn fuzz(
|
||||
let i2s = StdMutationalStage::new(StdScheduledMutator::new(tuple_list!(I2SRandReplace::new())));
|
||||
|
||||
// Setup a MOPT mutator
|
||||
let mutator = StdMOptMutator::new(&mut state, havoc_mutations().merge(tokens_mutations()), 5)?;
|
||||
let mutator = StdMOptMutator::new(
|
||||
&mut state,
|
||||
havoc_mutations().merge(tokens_mutations()),
|
||||
7,
|
||||
5,
|
||||
)?;
|
||||
|
||||
let power =
|
||||
StdPowerMutationalStage::new(&mut state, mutator, &edges_observer, PowerSchedule::FAST);
|
||||
|
@ -290,7 +290,12 @@ fn fuzz(
|
||||
let i2s = StdMutationalStage::new(StdScheduledMutator::new(tuple_list!(I2SRandReplace::new())));
|
||||
|
||||
// Setup a MOPT mutator
|
||||
let mutator = StdMOptMutator::new(&mut state, havoc_mutations().merge(tokens_mutations()), 5)?;
|
||||
let mutator = StdMOptMutator::new(
|
||||
&mut state,
|
||||
havoc_mutations().merge(tokens_mutations()),
|
||||
7,
|
||||
5,
|
||||
)?;
|
||||
|
||||
let power =
|
||||
StdPowerMutationalStage::new(&mut state, mutator, &edges_observer, PowerSchedule::FAST);
|
||||
|
@ -367,7 +367,12 @@ fn fuzz_binary(
|
||||
let i2s = StdMutationalStage::new(StdScheduledMutator::new(tuple_list!(I2SRandReplace::new())));
|
||||
|
||||
// Setup a MOPT mutator
|
||||
let mutator = StdMOptMutator::new(&mut state, havoc_mutations().merge(tokens_mutations()), 5)?;
|
||||
let mutator = StdMOptMutator::new(
|
||||
&mut state,
|
||||
havoc_mutations().merge(tokens_mutations()),
|
||||
7,
|
||||
5,
|
||||
)?;
|
||||
|
||||
let power =
|
||||
StdPowerMutationalStage::new(&mut state, mutator, &edges_observer, PowerSchedule::FAST);
|
||||
@ -572,12 +577,17 @@ fn fuzz_text(
|
||||
let i2s = StdMutationalStage::new(StdScheduledMutator::new(tuple_list!(I2SRandReplace::new())));
|
||||
|
||||
// Setup a MOPT mutator
|
||||
let mutator = StdMOptMutator::new(&mut state, havoc_mutations().merge(tokens_mutations()), 5)?;
|
||||
let mutator = StdMOptMutator::new(
|
||||
&mut state,
|
||||
havoc_mutations().merge(tokens_mutations()),
|
||||
7,
|
||||
5,
|
||||
)?;
|
||||
|
||||
let power =
|
||||
StdPowerMutationalStage::new(&mut state, mutator, &edges_observer, PowerSchedule::FAST);
|
||||
|
||||
let grimoire_mutator = StdScheduledMutator::with_max_iterations(
|
||||
let grimoire_mutator = StdScheduledMutator::with_max_stack_pow(
|
||||
tuple_list!(
|
||||
GrimoireExtensionMutator::new(),
|
||||
GrimoireRecursiveReplacementMutator::new(),
|
||||
|
@ -306,7 +306,12 @@ fn fuzz(
|
||||
let i2s = StdMutationalStage::new(StdScheduledMutator::new(tuple_list!(I2SRandReplace::new())));
|
||||
|
||||
// Setup a MOPT mutator
|
||||
let mutator = StdMOptMutator::new(&mut state, havoc_mutations().merge(tokens_mutations()), 5)?;
|
||||
let mutator = StdMOptMutator::new(
|
||||
&mut state,
|
||||
havoc_mutations().merge(tokens_mutations()),
|
||||
7,
|
||||
5,
|
||||
)?;
|
||||
|
||||
let power =
|
||||
StdPowerMutationalStage::new(&mut state, mutator, &edges_observer, PowerSchedule::FAST);
|
||||
|
@ -369,6 +369,7 @@ where
|
||||
mode: MOptMode,
|
||||
finds_before: usize,
|
||||
mutations: MT,
|
||||
max_stack_pow: u64,
|
||||
phantom: PhantomData<(I, S)>,
|
||||
}
|
||||
|
||||
@ -531,7 +532,12 @@ where
|
||||
S: HasRand + HasMetadata + HasCorpus<I> + HasSolutions<I>,
|
||||
{
|
||||
/// Create a new [`StdMOptMutator`].
|
||||
pub fn new(state: &mut S, mutations: MT, swarm_num: usize) -> Result<Self, Error> {
|
||||
pub fn new(
|
||||
state: &mut S,
|
||||
mutations: MT,
|
||||
max_stack_pow: u64,
|
||||
swarm_num: usize,
|
||||
) -> Result<Self, Error> {
|
||||
if !state.has_metadata::<MOpt>() {
|
||||
state.add_metadata::<MOpt>(MOpt::new(mutations.len(), swarm_num)?);
|
||||
}
|
||||
@ -539,6 +545,7 @@ where
|
||||
mode: MOptMode::Pilotfuzzing,
|
||||
finds_before: 0,
|
||||
mutations,
|
||||
max_stack_pow,
|
||||
phantom: PhantomData,
|
||||
})
|
||||
}
|
||||
@ -637,7 +644,7 @@ where
|
||||
{
|
||||
/// Compute the number of iterations used to apply stacked mutations
|
||||
fn iterations(&self, state: &mut S, _: &I) -> u64 {
|
||||
1 << (1 + state.rand_mut().below(6))
|
||||
1 << (1 + state.rand_mut().below(self.max_stack_pow))
|
||||
}
|
||||
|
||||
/// Get the next mutation to apply
|
||||
|
@ -109,7 +109,7 @@ where
|
||||
S: HasRand,
|
||||
{
|
||||
mutations: MT,
|
||||
max_iterations: u64,
|
||||
max_stack_pow: u64,
|
||||
phantom: PhantomData<(I, S)>,
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ where
|
||||
{
|
||||
/// Compute the number of iterations used to apply stacked mutations
|
||||
fn iterations(&self, state: &mut S, _: &I) -> u64 {
|
||||
1 << (1 + state.rand_mut().below(self.max_iterations))
|
||||
1 << (1 + state.rand_mut().below(self.max_stack_pow))
|
||||
}
|
||||
|
||||
/// Get the next mutation to apply
|
||||
@ -193,16 +193,16 @@ where
|
||||
pub fn new(mutations: MT) -> Self {
|
||||
StdScheduledMutator {
|
||||
mutations,
|
||||
max_iterations: 6,
|
||||
max_stack_pow: 7,
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new [`StdScheduledMutator`] instance specifying mutations and the maximun number of iterations
|
||||
pub fn with_max_iterations(mutations: MT, max_iterations: u64) -> Self {
|
||||
pub fn with_max_stack_pow(mutations: MT, max_stack_pow: u64) -> Self {
|
||||
StdScheduledMutator {
|
||||
mutations,
|
||||
max_iterations,
|
||||
max_stack_pow,
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user