Build id configuration in std (#286)
* Build id configuration in std * uuid only on std
This commit is contained in:
parent
231caf0797
commit
42d213737d
@ -38,7 +38,7 @@ harness = false
|
||||
|
||||
[features]
|
||||
default = ["std", "anymap_debug", "derive", "llmp_compression"]
|
||||
std = ["serde_json", "hostname", "core_affinity", "nix", "serde/std", "bincode", "wait-timeout", "regex"] # print, env, launcher ... support
|
||||
std = ["serde_json", "hostname", "core_affinity", "nix", "serde/std", "bincode", "wait-timeout", "regex", "build_id", "uuid"] # print, env, launcher ... support
|
||||
anymap_debug = ["serde_json"] # uses serde_json to Debug the anymap trait. Disable for smaller footprint.
|
||||
derive = ["libafl_derive"] # provide derive(SerdeAny) macro.
|
||||
rand_trait = ["rand_core"] # If set, libafl's rand implementations will implement `rand::Rng`
|
||||
@ -78,6 +78,8 @@ rand = { version = "0.8.1", optional = true } #
|
||||
rand_core = { version = "0.6.2", optional = true } # This dependency allows us to export our RomuRand as rand::Rng.
|
||||
nix = { version = "0.20.0", optional = true }
|
||||
regex = { version = "1", optional = true }
|
||||
build_id = { version = "0.2.1", optional = true }
|
||||
uuid = { version = "0.8.2", optional = true, features = ["serde"] }
|
||||
libm = "0.2.1"
|
||||
|
||||
wait-timeout = { version = "0.2", optional = true } # used by CommandExecutor to wait for child process
|
||||
|
@ -10,6 +10,9 @@ use alloc::{string::String, vec::Vec};
|
||||
use core::{fmt, hash::Hasher, marker::PhantomData, time::Duration};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
executors::ExitKind, inputs::Input, observers::ObserversTuple, stats::UserStats, Error,
|
||||
};
|
||||
@ -67,10 +70,16 @@ pub enum BrokerEventResult {
|
||||
}
|
||||
|
||||
/// Distinguish a fuzzer by its config
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
|
||||
pub enum EventConfig {
|
||||
AlwaysUnique,
|
||||
FromName { name_hash: u64 },
|
||||
FromName {
|
||||
name_hash: u64,
|
||||
},
|
||||
#[cfg(feature = "std")]
|
||||
BuildID {
|
||||
id: Uuid,
|
||||
},
|
||||
}
|
||||
|
||||
impl EventConfig {
|
||||
@ -83,13 +92,29 @@ impl EventConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[must_use]
|
||||
pub fn from_build_id() -> Self {
|
||||
EventConfig::BuildID {
|
||||
id: build_id::get(),
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn match_with(&self, other: &EventConfig) -> bool {
|
||||
match self {
|
||||
EventConfig::AlwaysUnique => false,
|
||||
EventConfig::FromName { name_hash: a } => match other {
|
||||
#[cfg(not(feature = "std"))]
|
||||
EventConfig::AlwaysUnique => false,
|
||||
EventConfig::FromName { name_hash: b } => (a == b),
|
||||
#[cfg(feature = "std")]
|
||||
EventConfig::AlwaysUnique | EventConfig::BuildID { id: _ } => false,
|
||||
},
|
||||
#[cfg(feature = "std")]
|
||||
EventConfig::BuildID { id: a } => match other {
|
||||
EventConfig::AlwaysUnique | EventConfig::FromName { name_hash: _ } => false,
|
||||
EventConfig::BuildID { id: b } => (a == b),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -375,11 +375,10 @@ where
|
||||
|
||||
if send_events {
|
||||
// TODO set None for fast targets
|
||||
let observers_buf = match manager.configuration() {
|
||||
EventConfig::AlwaysUnique => None,
|
||||
EventConfig::FromName { .. } => {
|
||||
Some(manager.serialize_observers(observers)?)
|
||||
}
|
||||
let observers_buf = if manager.configuration() == EventConfig::AlwaysUnique {
|
||||
None
|
||||
} else {
|
||||
Some(manager.serialize_observers(observers)?)
|
||||
};
|
||||
manager.fire(
|
||||
state,
|
||||
@ -500,9 +499,10 @@ where
|
||||
let idx = state.corpus_mut().add(testcase)?;
|
||||
self.scheduler_mut().on_add(state, idx)?;
|
||||
|
||||
let observers_buf = match manager.configuration() {
|
||||
EventConfig::AlwaysUnique => None,
|
||||
EventConfig::FromName { .. } => Some(manager.serialize_observers(observers)?),
|
||||
let observers_buf = if manager.configuration() == EventConfig::AlwaysUnique {
|
||||
None
|
||||
} else {
|
||||
Some(manager.serialize_observers(observers)?)
|
||||
};
|
||||
manager.fire(
|
||||
state,
|
||||
|
Loading…
x
Reference in New Issue
Block a user