compiles
This commit is contained in:
parent
c6f5f79cca
commit
8618289f12
@ -112,6 +112,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO move some of these, like evaluate_input, to FuzzingEngine
|
// TODO move some of these, like evaluate_input, to FuzzingEngine
|
||||||
|
#[inline]
|
||||||
pub fn is_interesting<OT>(&mut self, input: &I, observers: &OT) -> Result<u32, AflError>
|
pub fn is_interesting<OT>(&mut self, input: &I, observers: &OT) -> Result<u32, AflError>
|
||||||
where
|
where
|
||||||
OT: ObserversTuple,
|
OT: ObserversTuple,
|
||||||
|
@ -14,7 +14,6 @@ use serde::{Deserialize, Serialize};
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::{
|
use std::{
|
||||||
io::Write,
|
io::Write,
|
||||||
time::{SystemTime, UNIX_EPOCH},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::corpus::Corpus;
|
use crate::corpus::Corpus;
|
||||||
@ -159,11 +158,11 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_testcase<Ot>(config: String, input: I, observers: Ot) -> Result<Self, AflError>
|
pub fn new_testcase<OT>(config: String, input: I, observers: &OT) -> Result<Self, AflError>
|
||||||
where
|
where
|
||||||
Ot: ObserversTuple,
|
OT: ObserversTuple,
|
||||||
{
|
{
|
||||||
let observers_buf = postcard::to_allocvec(&observers)?;
|
let observers_buf = postcard::to_allocvec(observers)?;
|
||||||
Ok(Self::NewTestcase {
|
Ok(Self::NewTestcase {
|
||||||
sender_id: 0,
|
sender_id: 0,
|
||||||
input: input,
|
input: input,
|
||||||
@ -251,8 +250,8 @@ where
|
|||||||
}
|
}
|
||||||
Event::UpdateStats {
|
Event::UpdateStats {
|
||||||
sender_id,
|
sender_id,
|
||||||
executions,
|
executions: _,
|
||||||
execs_over_sec,
|
execs_over_sec: _,
|
||||||
phantom: _,
|
phantom: _,
|
||||||
} => {
|
} => {
|
||||||
// TODO: The stats buffer should be added on client add.
|
// TODO: The stats buffer should be added on client add.
|
||||||
@ -265,7 +264,7 @@ where
|
|||||||
executions: 0,
|
executions: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
let mut stat = &mut self.client_stats_mut()[*sender_id as usize];
|
let stat = &mut self.client_stats_mut()[*sender_id as usize];
|
||||||
println!(
|
println!(
|
||||||
"[UPDATE] corpus: {} execs: {} execs/s: {}",
|
"[UPDATE] corpus: {} execs: {} execs/s: {}",
|
||||||
self.corpus_size(),
|
self.corpus_size(),
|
||||||
@ -320,9 +319,9 @@ where
|
|||||||
// we need to pass engine to process() too, TODO
|
// we need to pass engine to process() too, TODO
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
println!("Received new Testcase");
|
println!("Received new Testcase");
|
||||||
let observers = postcard::from_bytes(&observers_buf)?;
|
let observers: OT = postcard::from_bytes(&observers_buf)?;
|
||||||
let interestingness = state.is_interesting(&input, observers)?;
|
let interestingness = state.is_interesting(&input, &observers)?;
|
||||||
state.add_if_interesting(corpus, input, interestingness);
|
state.add_if_interesting(corpus, input, interestingness)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => Err(AflError::Unknown(
|
_ => Err(AflError::Unknown(
|
||||||
@ -481,7 +480,7 @@ where
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn fire<'a>(&mut self, event: Event<I>) -> Result<(), AflError> {
|
fn fire<'a>(&mut self, event: Event<I>) -> Result<(), AflError> {
|
||||||
let serialized = postcard::to_allocvec(&event)?;
|
let serialized = postcard::to_allocvec(&event)?;
|
||||||
self.send_buf(LLMP_TAG_EVENT_TO_CLIENT, &serialized)?;
|
self.llmp.send_buf(LLMP_TAG_EVENT_TO_CLIENT, &serialized)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,12 +45,17 @@ pub trait FeedbacksTuple<I>: MatchType + MatchNameAndType
|
|||||||
where
|
where
|
||||||
I: Input,
|
I: Input,
|
||||||
{
|
{
|
||||||
|
/// Get the total interestingness value from all feedbacks
|
||||||
fn is_interesting_all<OT: ObserversTuple>(
|
fn is_interesting_all<OT: ObserversTuple>(
|
||||||
&mut self,
|
&mut self,
|
||||||
input: &I,
|
input: &I,
|
||||||
observers: &OT,
|
observers: &OT,
|
||||||
) -> Result<u32, AflError>;
|
) -> Result<u32, AflError>;
|
||||||
|
|
||||||
|
/// Write metadata for this testcase
|
||||||
fn append_metadata_all(&mut self, testcase: &mut Testcase<I>) -> Result<(), AflError>;
|
fn append_metadata_all(&mut self, testcase: &mut Testcase<I>) -> Result<(), AflError>;
|
||||||
|
|
||||||
|
/// Discards metadata - the end of this input's execution
|
||||||
fn discard_metadata_all(&mut self, input: &I) -> Result<(), AflError>;
|
fn discard_metadata_all(&mut self, input: &I) -> Result<(), AflError>;
|
||||||
//fn for_each(&self, f: fn(&dyn Feedback<I>));
|
//fn for_each(&self, f: fn(&dyn Feedback<I>));
|
||||||
//fn for_each_mut(&mut self, f: fn(&mut dyn Feedback<I>));
|
//fn for_each_mut(&mut self, f: fn(&mut dyn Feedback<I>));
|
||||||
|
@ -12,8 +12,6 @@ use crate::utils::Rand;
|
|||||||
use crate::AflError;
|
use crate::AflError;
|
||||||
use crate::{engines::State, events::Event};
|
use crate::{engines::State, events::Event};
|
||||||
|
|
||||||
use crate::serde_anymap::{Ptr, PtrMut};
|
|
||||||
|
|
||||||
// TODO multi mutators stage
|
// TODO multi mutators stage
|
||||||
|
|
||||||
/// A Mutational stage is the stage in a fuzzing run that mutates inputs.
|
/// A Mutational stage is the stage in a fuzzing run that mutates inputs.
|
||||||
@ -66,21 +64,19 @@ where
|
|||||||
self.mutator_mut()
|
self.mutator_mut()
|
||||||
.post_exec(fitness, &input_mut, i as i32)?;
|
.post_exec(fitness, &input_mut, i as i32)?;
|
||||||
|
|
||||||
|
let observers = engine.executor_mut().observers();
|
||||||
|
|
||||||
// put all this shit in some overridable function in engine maybe? or in corpus.
|
// put all this shit in some overridable function in engine maybe? or in corpus.
|
||||||
// consider a corpus that strores new testcases in a temporary queue, for later processing
|
// consider a corpus that strores new testcases in a temporary queue, for later processing
|
||||||
// in a late stage, NewTestcase should be triggere donly after the processing in the later stage
|
// in a late stage, NewTestcase should be triggere donly after the processing in the later stage
|
||||||
// So by default we shoudl trigger it in corpus.add, so that the user can override it and remove
|
// So by default we shoudl trigger it in corpus.add, so that the user can override it and remove
|
||||||
// if needed by particular cases
|
// if needed by particular cases
|
||||||
let testcase_maybe = state.testcase_if_interesting(input_mut, fitness)?;
|
if state.is_interesting(&input_mut, observers)? > 0 {
|
||||||
if let Some(mut testcase) = testcase_maybe {
|
|
||||||
// TODO decouple events manager and engine
|
// TODO decouple events manager and engine
|
||||||
manager.fire(Event::NewTestcase {
|
manager.fire(Event::new_testcase("test".into(), input_mut, observers)?)?;
|
||||||
sender_id: 0,
|
|
||||||
input: testcase.load_input()?,
|
|
||||||
observers_buf: PtrMut::Ref(engine.executor_mut().observers_mut()),
|
|
||||||
corpus_count: corpus.count() + 1,
|
|
||||||
})?;
|
|
||||||
// let _ = corpus.add(testcase);
|
// let _ = corpus.add(testcase);
|
||||||
|
} else {
|
||||||
|
state.discard_input(&input_mut)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user