started working
This commit is contained in:
parent
80d1c2c729
commit
5d2e7b5bc2
@ -66,33 +66,6 @@ where
|
||||
self.metadatas_mut().insert(meta.name(), meta);
|
||||
}
|
||||
|
||||
/// Get the linked observers
|
||||
fn observers(&self) -> &[Rc<RefCell<dyn Observer>>];
|
||||
|
||||
/// Get the linked observers
|
||||
fn observers_mut(&mut self) -> &mut Vec<Rc<RefCell<dyn Observer>>>;
|
||||
|
||||
/// Add a linked observer
|
||||
fn add_observer(&mut self, observer: Rc<RefCell<dyn Observer>>) {
|
||||
self.observers_mut().push(observer);
|
||||
}
|
||||
|
||||
/// Reset the state of all the observes linked to this executor
|
||||
fn reset_observers(&mut self) -> Result<(), AflError> {
|
||||
for observer in self.observers() {
|
||||
observer.borrow_mut().reset()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Run the post exec hook for all the observes linked to this executor
|
||||
fn post_exec_observers(&mut self) -> Result<(), AflError> {
|
||||
self.observers()
|
||||
.iter()
|
||||
.map(|x| x.borrow_mut().post_exec())
|
||||
.fold(Ok(()), |acc, x| if x.is_err() { x } else { acc })
|
||||
}
|
||||
|
||||
/// Returns vector of feebacks
|
||||
fn feedbacks(&self) -> &[Box<dyn Feedback<I>>];
|
||||
|
||||
|
@ -5,6 +5,7 @@ use core::ptr;
|
||||
|
||||
use crate::executors::{Executor, ExitKind};
|
||||
use crate::inputs::Input;
|
||||
use crate::metamap::NamedAnyMap;
|
||||
use crate::AflError;
|
||||
|
||||
type HarnessFunction<I> = fn(&dyn Executor<I>, &[u8]) -> ExitKind;
|
||||
@ -14,15 +15,7 @@ where
|
||||
I: Input,
|
||||
{
|
||||
harness: HarnessFunction<I>,
|
||||
}
|
||||
|
||||
impl<I> Into<Rc<RefCell<Self>>> for InMemoryExecutor<I>
|
||||
where
|
||||
I: Input,
|
||||
{
|
||||
fn into(self) -> Rc<RefCell<Self>> {
|
||||
Rc::new(RefCell::new(self))
|
||||
}
|
||||
observers: NamedAnyMap,
|
||||
}
|
||||
|
||||
static mut CURRENT_INMEMORY_EXECUTOR_PTR: *const c_void = ptr::null();
|
||||
|
@ -1,6 +1,8 @@
|
||||
pub mod inmemory;
|
||||
|
||||
use crate::inputs::Input;
|
||||
use crate::observers::Observer;
|
||||
use crate::metamap::NamedAnyMap;
|
||||
use crate::AflError;
|
||||
|
||||
pub enum ExitKind {
|
||||
@ -18,4 +20,31 @@ where
|
||||
{
|
||||
/// Instruct the target about the input and run
|
||||
fn run_target(&mut self, input: &I) -> Result<ExitKind, AflError>;
|
||||
|
||||
/// Get the linked observers
|
||||
fn observers(&self) -> &NamedAnyMap;
|
||||
|
||||
/// Get the linked observers
|
||||
fn observers_mut(&mut self) -> &mut NamedAnyMap;
|
||||
|
||||
/// Add a linked observer
|
||||
fn add_observer(&mut self, observer: Box<dyn Observer>, name: &'static str) {
|
||||
self.observers_mut().push(observer);
|
||||
}
|
||||
|
||||
/// Reset the state of all the observes linked to this executor
|
||||
fn reset_observers(&mut self) -> Result<(), AflError> {
|
||||
for observer in self.observers_mut() {
|
||||
observer.reset()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Run the post exec hook for all the observes linked to this executor
|
||||
fn post_exec_observers(&mut self) -> Result<(), AflError> {
|
||||
self.observers_mut()
|
||||
.iter()
|
||||
.map(|x| x.post_exec())
|
||||
.fold(Ok(()), |acc, x| if x.is_err() { x } else { acc })
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,14 @@ extern crate num;
|
||||
use alloc::rc::Rc;
|
||||
use core::cell::RefCell;
|
||||
use core::slice::from_raw_parts_mut;
|
||||
use core::any::Any;
|
||||
use num::Integer;
|
||||
|
||||
use crate::AflError;
|
||||
|
||||
/// Observers observe different information about the target.
|
||||
/// They can then be used by various sorts of feedback.
|
||||
pub trait Observer {
|
||||
pub trait Observer: Any {
|
||||
fn flush(&mut self) -> Result<(), AflError> {
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user