Making StdOutObserver and StdErrObserver implement Observer (#2236)
* making stdout and stderr observers implement observer * fixing imports
This commit is contained in:
parent
123f508fcc
commit
b7e10ca7af
@ -236,6 +236,7 @@ where
|
|||||||
use wait_timeout::ChildExt;
|
use wait_timeout::ChildExt;
|
||||||
|
|
||||||
*state.executions_mut() += 1;
|
*state.executions_mut() += 1;
|
||||||
|
self.observers.pre_exec_child_all(state, input)?;
|
||||||
|
|
||||||
let mut child = self.configurer.spawn_child(input)?;
|
let mut child = self.configurer.spawn_child(input)?;
|
||||||
|
|
||||||
@ -258,6 +259,11 @@ where
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Ok(exit_kind) = res {
|
||||||
|
self.observers
|
||||||
|
.post_exec_child_all(state, input, &exit_kind)?;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(ref mut ob) = &mut self.configurer.stdout_observer_mut() {
|
if let Some(ref mut ob) = &mut self.configurer.stdout_observer_mut() {
|
||||||
let mut stdout = Vec::new();
|
let mut stdout = Vec::new();
|
||||||
child.stdout.as_mut().ok_or_else(|| {
|
child.stdout.as_mut().ok_or_else(|| {
|
||||||
|
@ -8,6 +8,8 @@ use std::vec::Vec;
|
|||||||
use libafl_bolts::Named;
|
use libafl_bolts::Named;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::{inputs::UsesInput, observers::Observer, state::State, Error};
|
||||||
|
|
||||||
/// An observer that captures stdout of a target.
|
/// An observer that captures stdout of a target.
|
||||||
/// Only works for supported executors.
|
/// Only works for supported executors.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
@ -41,6 +43,20 @@ impl Named for StdOutObserver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<S> Observer<S> for StdOutObserver
|
||||||
|
where
|
||||||
|
S: State,
|
||||||
|
{
|
||||||
|
fn pre_exec_child(
|
||||||
|
&mut self,
|
||||||
|
_state: &mut S,
|
||||||
|
_input: &<S as UsesInput>::Input,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
self.stdout = None;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// An observer that captures stderr of a target.
|
/// An observer that captures stderr of a target.
|
||||||
/// Only works for supported executors.
|
/// Only works for supported executors.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
@ -73,3 +89,17 @@ impl Named for StdErrObserver {
|
|||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<S> Observer<S> for StdErrObserver
|
||||||
|
where
|
||||||
|
S: State,
|
||||||
|
{
|
||||||
|
fn pre_exec_child(
|
||||||
|
&mut self,
|
||||||
|
_state: &mut S,
|
||||||
|
_input: &<S as UsesInput>::Input,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
self.stderr = None;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user