Mgr ID improvements (#201)

* added mgr_id to eventmanager

* trying to install missing llvm to ci

* moved mgr_id to own trait

* improved imports

* removed unrelated file from pr

* no_std fixes
This commit is contained in:
Dominik Maier 2021-07-01 17:27:22 +02:00 committed by GitHub
parent 4cafa8c253
commit 204b15a432
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 10 deletions

View File

@ -27,7 +27,7 @@ use crate::{
},
events::{
BrokerEventResult, Event, EventFirer, EventManager, EventManagerId, EventProcessor,
EventRestarter,
EventRestarter, HasEventManagerId,
},
executors::{Executor, HasObservers},
fuzzer::{EvaluatorObservers, ExecutionProcessor},
@ -499,11 +499,19 @@ where
impl<E, I, OT, S, SP, Z> EventManager<E, I, S, Z> for LlmpEventManager<I, OT, S, SP>
where
SP: ShMemProvider,
E: Executor<Self, I, S, Z> + HasObservers<I, OT, S>,
I: Input,
OT: ObserversTuple<I, S>,
SP: ShMemProvider,
Z: ExecutionProcessor<I, OT, S> + EvaluatorObservers<I, OT, S>, //CE: CustomEvent<I>,
{
}
impl<I, OT, S, SP> HasEventManagerId for LlmpEventManager<I, OT, S, SP>
where
I: Input,
OT: ObserversTuple<I, S>,
SP: ShMemProvider,
{
/// Gets the id assigned to this sender.
fn mgr_id(&self) -> EventManagerId {
@ -639,6 +647,18 @@ where
{
}
impl<I, OT, S, SP> HasEventManagerId for LlmpRestartingEventManager<I, OT, S, SP>
where
I: Input,
OT: ObserversTuple<I, S>,
S: Serialize,
SP: ShMemProvider + 'static,
{
fn mgr_id(&self) -> EventManagerId {
self.llmp_mgr.mgr_id()
}
}
/// The llmp connection from the actual fuzzer to the process supervising it
const _ENV_FUZZER_SENDER: &str = "_AFL_ENV_FUZZER_SENDER";
const _ENV_FUZZER_RECEIVER: &str = "_AFL_ENV_FUZZER_RECEIVER";

View File

@ -253,19 +253,19 @@ pub trait EventProcessor<E, I, S, Z> {
}
}
pub trait HasEventManagerId {
/// The id of this manager. For Multiprocessed [`EventManager`]s,
/// each client sholud have a unique ids.
fn mgr_id(&self) -> EventManagerId;
}
/// [`EventManager`] is the main communications hub.
/// For the "normal" multi-processed mode, you may want to look into [`RestartingEventManager`]
pub trait EventManager<E, I, S, Z>:
EventFirer<I, S> + EventProcessor<E, I, S, Z> + EventRestarter<S>
EventFirer<I, S> + EventProcessor<E, I, S, Z> + EventRestarter<S> + HasEventManagerId
where
I: Input,
{
/// The id of this `0` for
fn mgr_id(&self) -> EventManagerId {
EventManagerId {
..EventManagerId::default()
}
}
}
/// An eventmgr for tests, and as placeholder if you really don't need an event manager.
@ -296,6 +296,12 @@ impl<E, I, S, Z> EventProcessor<E, I, S, Z> for NopEventManager {
impl<E, I, S, Z> EventManager<E, I, S, Z> for NopEventManager where I: Input {}
impl HasEventManagerId for NopEventManager {
fn mgr_id(&self) -> EventManagerId {
EventManagerId { id: 0 }
}
}
#[cfg(test)]
mod tests {

View File

@ -20,7 +20,10 @@ use crate::bolts::{
};
use crate::{
bolts::llmp,
events::{BrokerEventResult, Event, EventFirer, EventManager, EventProcessor, EventRestarter},
events::{
BrokerEventResult, Event, EventFirer, EventManager, EventManagerId, EventProcessor,
EventRestarter, HasEventManagerId,
},
inputs::Input,
stats::Stats,
Error,
@ -96,6 +99,16 @@ where
{
}
impl<I, ST> HasEventManagerId for SimpleEventManager<I, ST>
where
I: Input,
ST: Stats,
{
fn mgr_id(&self) -> EventManagerId {
EventManagerId { id: 0 }
}
}
impl<I, ST> SimpleEventManager<I, ST>
where
I: Input,
@ -272,6 +285,19 @@ where
{
}
#[cfg(feature = "std")]
impl<I, S, SP, ST> HasEventManagerId for SimpleRestartingEventManager<I, S, SP, ST>
where
I: Input,
S: Serialize,
SP: ShMemProvider,
ST: Stats,
{
fn mgr_id(&self) -> EventManagerId {
self.simple_event_mgr.mgr_id()
}
}
#[cfg(feature = "std")]
#[allow(clippy::type_complexity, clippy::too_many_lines)]
impl<I, S, SP, ST> SimpleRestartingEventManager<I, S, SP, ST>