exit kind for the feedback
This commit is contained in:
parent
7a75155e6b
commit
05c312b2bd
@ -21,6 +21,7 @@ use crate::{
|
||||
feedbacks::FeedbacksTuple,
|
||||
inputs::Input,
|
||||
state::State,
|
||||
executors::ExitKind,
|
||||
stats::Stats,
|
||||
utils::Rand,
|
||||
AflError,
|
||||
@ -278,7 +279,8 @@ where
|
||||
#[cfg(feature = "std")]
|
||||
println!("Received new Testcase");
|
||||
let observers = postcard::from_bytes(&observers_buf)?;
|
||||
let interestingness = state.is_interesting(&input, &observers)?;
|
||||
// TODO include ExitKind in NewTestcase
|
||||
let interestingness = state.is_interesting(&input, &observers, ExitKind::Ok)?;
|
||||
state.add_if_interesting(input, interestingness)?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ use crate::{
|
||||
};
|
||||
|
||||
/// How an execution finished.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ExitKind {
|
||||
Ok,
|
||||
Crash,
|
||||
|
@ -11,6 +11,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
bolts::tuples::{Named, TupleList},
|
||||
executors::ExitKind,
|
||||
corpus::Testcase,
|
||||
inputs::Input,
|
||||
observers::{MapObserver, Observer, ObserversTuple},
|
||||
@ -35,6 +36,7 @@ where
|
||||
&mut self,
|
||||
input: &I,
|
||||
observers: &OT,
|
||||
exit_kind: ExitKind,
|
||||
) -> Result<u32, AflError>;
|
||||
|
||||
/// Append to the testcase the generated metadata in case of a new corpus item
|
||||
@ -83,6 +85,7 @@ where
|
||||
&mut self,
|
||||
input: &I,
|
||||
observers: &OT,
|
||||
exit_kind: ExitKind,
|
||||
) -> Result<u32, AflError>;
|
||||
|
||||
/// Write metadata for this testcase
|
||||
@ -103,7 +106,7 @@ where
|
||||
I: Input,
|
||||
{
|
||||
#[inline]
|
||||
fn is_interesting_all<OT: ObserversTuple>(&mut self, _: &I, _: &OT) -> Result<u32, AflError> {
|
||||
fn is_interesting_all<OT: ObserversTuple>(&mut self, _: &I, _: &OT, _: ExitKind,) -> Result<u32, AflError> {
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
@ -134,9 +137,10 @@ where
|
||||
&mut self,
|
||||
input: &I,
|
||||
observers: &OT,
|
||||
exit_kind: ExitKind,
|
||||
) -> Result<u32, AflError> {
|
||||
Ok(self.0.is_interesting(input, observers)?
|
||||
+ self.1.is_interesting_all(input, observers)?)
|
||||
Ok(self.0.is_interesting(input, observers, exit_kind.clone())?
|
||||
+ self.1.is_interesting_all(input, observers, exit_kind)?)
|
||||
}
|
||||
|
||||
fn append_metadata_all(&mut self, testcase: &mut Testcase<I>) -> Result<(), AflError> {
|
||||
@ -243,6 +247,7 @@ where
|
||||
&mut self,
|
||||
_input: &I,
|
||||
observers: &OT,
|
||||
_exit_kind: ExitKind,
|
||||
) -> Result<u32, AflError> {
|
||||
let mut interesting = 0;
|
||||
// TODO optimize
|
||||
|
@ -81,7 +81,6 @@ where
|
||||
if fitness > 0 {
|
||||
let observers_buf = manager.serialize_observers(observers)?;
|
||||
|
||||
// TODO decouple events manager and engine
|
||||
manager.fire(
|
||||
state,
|
||||
Event::NewTestcase {
|
||||
|
@ -12,7 +12,7 @@ use crate::{
|
||||
bolts::serdeany::{SerdeAny, SerdeAnyMap},
|
||||
corpus::{Corpus, Testcase},
|
||||
events::{Event, EventManager, LogSeverity},
|
||||
executors::{Executor, HasObservers},
|
||||
executors::{Executor, HasObservers, ExitKind},
|
||||
feedbacks::FeedbacksTuple,
|
||||
generators::Generator,
|
||||
inputs::Input,
|
||||
@ -248,11 +248,11 @@ where
|
||||
|
||||
// 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, exit_kind: ExitKind) -> Result<u32, AflError>
|
||||
where
|
||||
OT: ObserversTuple,
|
||||
{
|
||||
Ok(self.feedbacks_mut().is_interesting_all(input, observers)?)
|
||||
Ok(self.feedbacks_mut().is_interesting_all(input, observers, exit_kind)?)
|
||||
}
|
||||
|
||||
/// Runs the input and triggers observers and feedback
|
||||
@ -271,14 +271,14 @@ where
|
||||
executor.pre_exec_observers()?;
|
||||
|
||||
executor.pre_exec(self, event_mgr, input)?;
|
||||
executor.run_target(input)?;
|
||||
let exit_kind = executor.run_target(input)?;
|
||||
executor.post_exec(&self, event_mgr, input)?;
|
||||
|
||||
self.set_executions(self.executions() + 1);
|
||||
executor.post_exec_observers()?;
|
||||
|
||||
let observers = executor.observers();
|
||||
let fitness = self.feedbacks_mut().is_interesting_all(&input, observers)?;
|
||||
let fitness = self.feedbacks_mut().is_interesting_all(&input, observers, exit_kind)?;
|
||||
Ok(fitness)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user