Romain Malmain 9dff7a438d
Add client stats to Events (#3116)
* add stats alongside Event over the wire
2025-04-01 16:51:52 +02:00

30 lines
651 B
Rust

use libafl::{
events::{Event, EventManagerHook, EventWithStats},
state::Stoppable,
Error,
};
use libafl_bolts::ClientId;
#[derive(Clone, Copy)]
pub struct LibAflFuzzEventHook {
exit_on_solution: bool,
}
impl<I, S> EventManagerHook<I, S> for LibAflFuzzEventHook
where
S: Stoppable,
{
fn pre_receive(
&mut self,
state: &mut S,
_client_id: ClientId,
event: &EventWithStats<I>,
) -> Result<bool, Error> {
if self.exit_on_solution && matches!(event.event(), Event::Objective { .. }) {
// TODO: dump state
state.request_stop();
}
Ok(true)
}
}