Powerschedule::RAND (#596)
This commit is contained in:
parent
e7a06fb30c
commit
fa69b9eff9
@ -314,7 +314,7 @@ fn fuzz(
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
let power =
|
let power =
|
||||||
StdPowerMutationalStage::new(&mut state, mutator, &edges_observer, PowerSchedule::FAST);
|
StdPowerMutationalStage::new(&mut state, mutator, &edges_observer, PowerSchedule::RAND);
|
||||||
|
|
||||||
// A minimization+queue policy to get testcasess from the corpus
|
// A minimization+queue policy to get testcasess from the corpus
|
||||||
let scheduler = IndexesLenTimeMinimizerScheduler::new(StdWeightedScheduler::new());
|
let scheduler = IndexesLenTimeMinimizerScheduler::new(StdWeightedScheduler::new());
|
||||||
|
@ -132,6 +132,7 @@ impl PowerScheduleMetadata {
|
|||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq)]
|
||||||
pub enum PowerSchedule {
|
pub enum PowerSchedule {
|
||||||
|
RAND,
|
||||||
EXPLORE,
|
EXPLORE,
|
||||||
EXPLOIT,
|
EXPLOIT,
|
||||||
FAST,
|
FAST,
|
||||||
|
@ -192,7 +192,7 @@ where
|
|||||||
// COE and Fast schedule are fairly different from what are described in the original thesis,
|
// COE and Fast schedule are fairly different from what are described in the original thesis,
|
||||||
// This implementation follows the changes made in this pull request https://github.com/AFLplusplus/AFLplusplus/pull/568
|
// This implementation follows the changes made in this pull request https://github.com/AFLplusplus/AFLplusplus/pull/568
|
||||||
match psmeta.strat() {
|
match psmeta.strat() {
|
||||||
PowerSchedule::EXPLORE => {
|
PowerSchedule::EXPLORE | PowerSchedule::RAND => {
|
||||||
// Nothing happens in EXPLORE
|
// Nothing happens in EXPLORE
|
||||||
}
|
}
|
||||||
PowerSchedule::EXPLOIT => {
|
PowerSchedule::EXPLOIT => {
|
||||||
|
@ -4,6 +4,7 @@ use alloc::string::{String, ToString};
|
|||||||
use core::{fmt::Debug, marker::PhantomData};
|
use core::{fmt::Debug, marker::PhantomData};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
bolts::rands::Rand,
|
||||||
corpus::{Corpus, PowerScheduleTestcaseMetaData},
|
corpus::{Corpus, PowerScheduleTestcaseMetaData},
|
||||||
executors::{Executor, HasObservers},
|
executors::{Executor, HasObservers},
|
||||||
fuzzer::Evaluator,
|
fuzzer::Evaluator,
|
||||||
@ -16,7 +17,7 @@ use crate::{
|
|||||||
TestcaseScore,
|
TestcaseScore,
|
||||||
},
|
},
|
||||||
stages::{MutationalStage, Stage},
|
stages::{MutationalStage, Stage},
|
||||||
state::{HasClientPerfMonitor, HasCorpus, HasMetadata},
|
state::{HasClientPerfMonitor, HasCorpus, HasMetadata, HasRand},
|
||||||
Error,
|
Error,
|
||||||
};
|
};
|
||||||
/// The mutational stage using power schedules
|
/// The mutational stage using power schedules
|
||||||
@ -47,7 +48,7 @@ where
|
|||||||
M: Mutator<I, S>,
|
M: Mutator<I, S>,
|
||||||
O: MapObserver,
|
O: MapObserver,
|
||||||
OT: ObserversTuple<I, S>,
|
OT: ObserversTuple<I, S>,
|
||||||
S: HasClientPerfMonitor + HasCorpus<I> + HasMetadata,
|
S: HasClientPerfMonitor + HasCorpus<I> + HasMetadata + HasRand,
|
||||||
Z: Evaluator<E, EM, I, S>,
|
Z: Evaluator<E, EM, I, S>,
|
||||||
{
|
{
|
||||||
/// The mutator, added to this stage
|
/// The mutator, added to this stage
|
||||||
@ -66,6 +67,15 @@ where
|
|||||||
#[allow(clippy::cast_sign_loss)]
|
#[allow(clippy::cast_sign_loss)]
|
||||||
fn iterations(&self, state: &mut S, corpus_idx: usize) -> Result<usize, Error> {
|
fn iterations(&self, state: &mut S, corpus_idx: usize) -> Result<usize, Error> {
|
||||||
// Update handicap
|
// Update handicap
|
||||||
|
let use_random = state
|
||||||
|
.metadata_mut()
|
||||||
|
.get_mut::<PowerScheduleMetadata>()
|
||||||
|
.ok_or_else(|| Error::KeyNotFound("PowerScheduleMetadata not found".to_string()))?
|
||||||
|
.strat() == PowerSchedule::RAND;
|
||||||
|
if use_random {
|
||||||
|
return Ok(1 + state.rand_mut().below(128) as usize)
|
||||||
|
}
|
||||||
|
|
||||||
let mut testcase = state.corpus().get(corpus_idx)?.borrow_mut();
|
let mut testcase = state.corpus().get(corpus_idx)?.borrow_mut();
|
||||||
let score = F::compute(&mut *testcase, state)? as usize;
|
let score = F::compute(&mut *testcase, state)? as usize;
|
||||||
let tcmeta = testcase
|
let tcmeta = testcase
|
||||||
@ -151,7 +161,7 @@ where
|
|||||||
M: Mutator<I, S>,
|
M: Mutator<I, S>,
|
||||||
O: MapObserver,
|
O: MapObserver,
|
||||||
OT: ObserversTuple<I, S>,
|
OT: ObserversTuple<I, S>,
|
||||||
S: HasClientPerfMonitor + HasCorpus<I> + HasMetadata,
|
S: HasClientPerfMonitor + HasCorpus<I> + HasMetadata + HasRand,
|
||||||
Z: Evaluator<E, EM, I, S>,
|
Z: Evaluator<E, EM, I, S>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user