NewTestcase2 -> NewTestcase
This commit is contained in:
parent
6c917cc385
commit
24e01d89b5
@ -3,8 +3,8 @@ pub use testcase::{Testcase, TestcaseMetadata};
|
||||
|
||||
use alloc::borrow::ToOwned;
|
||||
use alloc::vec::Vec;
|
||||
use core::marker::PhantomData;
|
||||
use core::cell::RefCell;
|
||||
use core::marker::PhantomData;
|
||||
use core::ptr;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
@ -61,7 +61,11 @@ where
|
||||
|
||||
/// Removes an entry from the corpus, returning it if it was present.
|
||||
fn remove(&mut self, entry: &Testcase<I>) -> Option<Testcase<I>> {
|
||||
match self.entries().iter().position(|x| ptr::eq(x.as_ptr(), entry)) {
|
||||
match self
|
||||
.entries()
|
||||
.iter()
|
||||
.position(|x| ptr::eq(x.as_ptr(), entry))
|
||||
{
|
||||
Some(i) => Some(self.entries_mut().remove(i).into_inner()),
|
||||
None => None,
|
||||
}
|
||||
@ -99,7 +103,6 @@ where
|
||||
}
|
||||
Ok(())
|
||||
}*/
|
||||
|
||||
// TODO: IntoIter
|
||||
/// Gets the next entry
|
||||
fn next(&mut self, rand: &mut R) -> Result<(&RefCell<Testcase<I>>, usize), AflError>;
|
||||
|
@ -102,11 +102,7 @@ where
|
||||
// TODO move some of these, like evaluate_input, to FuzzingEngine
|
||||
|
||||
/// Runs the input and triggers observers and feedback
|
||||
pub fn evaluate_input<E>(
|
||||
&mut self,
|
||||
input: &I,
|
||||
executor: &mut E,
|
||||
) -> Result<u32, AflError>
|
||||
pub fn evaluate_input<E>(&mut self, input: &I, executor: &mut E) -> Result<u32, AflError>
|
||||
where
|
||||
E: Executor<I>,
|
||||
{
|
||||
@ -404,7 +400,13 @@ mod tests {
|
||||
|
||||
for i in 0..1000 {
|
||||
fuzzer
|
||||
.fuzz_one(&mut rand, &mut state, &mut corpus, &mut engine, &mut events_manager)
|
||||
.fuzz_one(
|
||||
&mut rand,
|
||||
&mut state,
|
||||
&mut corpus,
|
||||
&mut engine,
|
||||
&mut events_manager,
|
||||
)
|
||||
.expect(&format!("Error in iter {}", i));
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "std")]
|
||||
use std::io::Write;
|
||||
|
||||
use crate::corpus::{Corpus, Testcase};
|
||||
use crate::corpus::Corpus;
|
||||
use crate::engines::State;
|
||||
use crate::executors::Executor;
|
||||
use crate::inputs::Input;
|
||||
@ -81,11 +81,6 @@ where
|
||||
phantom: PhantomData<(C, E, I, R)>,
|
||||
},
|
||||
NewTestcase {
|
||||
sender_id: u64,
|
||||
testcase: Testcase<I>,
|
||||
phantom: PhantomData<(C, E, I, R)>,
|
||||
},
|
||||
NewTestcase2 {
|
||||
sender_id: u64,
|
||||
input: Ptr<'a, I>,
|
||||
observers: PtrMut<'a, crate::observers::observer_serde::NamedSerdeAnyMap>,
|
||||
@ -132,15 +127,10 @@ where
|
||||
phantom: _,
|
||||
} => "Initial",
|
||||
Event::NewTestcase {
|
||||
sender_id: _,
|
||||
testcase: _,
|
||||
phantom: _,
|
||||
} => "New Testcase",
|
||||
Event::NewTestcase2 {
|
||||
sender_id: _,
|
||||
input: _,
|
||||
observers: _,
|
||||
} => "New Testcase 2",
|
||||
} => "New Testcase",
|
||||
Event::UpdateStats {
|
||||
sender_id: _,
|
||||
new_execs: _,
|
||||
@ -167,6 +157,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// TODO the broker has a state? do we need to pass state and corpus?
|
||||
fn handle_in_broker(
|
||||
&self,
|
||||
/*broker: &dyn EventManager<C, E, I, R>,*/ _state: &mut State<I, R>,
|
||||
@ -178,11 +169,6 @@ where
|
||||
phantom: _,
|
||||
} => Ok(BrokerEventResult::Handled),
|
||||
Event::NewTestcase {
|
||||
sender_id: _,
|
||||
testcase: _,
|
||||
phantom: _,
|
||||
} => Ok(BrokerEventResult::Forward),
|
||||
Event::NewTestcase2 {
|
||||
sender_id: _,
|
||||
input: _,
|
||||
observers: _,
|
||||
@ -235,10 +221,12 @@ where
|
||||
match self {
|
||||
Event::NewTestcase {
|
||||
sender_id: _,
|
||||
testcase,
|
||||
phantom: _,
|
||||
input: _,
|
||||
observers: _,
|
||||
} => {
|
||||
corpus.add(testcase);
|
||||
// here u should match sender_id, if equal to the current one do not re-execute
|
||||
// we need to pass engine to process() too, TODO
|
||||
println!("PLACEHOLDER: received NewTestcase");
|
||||
Ok(())
|
||||
}
|
||||
_ => Err(AflError::Unknown(
|
||||
|
@ -8,6 +8,8 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::serde_anymap::{SerdeAny, SliceMut};
|
||||
use crate::AflError;
|
||||
|
||||
// TODO register each observer in the Registry in new()
|
||||
|
||||
/// Observers observe different information about the target.
|
||||
/// They can then be used by various sorts of feedback.
|
||||
pub trait Observer: SerdeAny + 'static {
|
||||
@ -26,31 +28,6 @@ pub trait Observer: SerdeAny + 'static {
|
||||
|
||||
crate::create_serde_registry_for_trait!(observer_serde, crate::observers::Observer);
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct NopObserver {}
|
||||
impl Observer for NopObserver {
|
||||
fn name(&self) -> &'static str {
|
||||
"aa"
|
||||
}
|
||||
|
||||
fn reset(&mut self) -> Result<(), AflError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
impl SerdeAny for NopObserver {
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
impl NopObserver {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
/// A MapObserver observes the static map, as oftentimes used for afl-like coverage information
|
||||
pub trait MapObserver<T>
|
||||
where
|
||||
|
@ -65,7 +65,7 @@ where
|
||||
if let Some(mut testcase) = testcase_maybe {
|
||||
// TODO decouple events manager and engine
|
||||
manager.fire(
|
||||
Event::NewTestcase2 {
|
||||
Event::NewTestcase {
|
||||
sender_id: 0,
|
||||
input: Ptr::Ref(testcase.load_input()?),
|
||||
observers: PtrMut::Ref(engine.executor_mut().observers_mut()),
|
||||
|
Loading…
x
Reference in New Issue
Block a user