minor cleanup

This commit is contained in:
Dominik Maier 2020-11-24 01:48:31 +01:00
parent ab894b7daf
commit bd09805243
14 changed files with 30 additions and 53 deletions

View File

@ -14,9 +14,7 @@ default = ["std"]
std = []
[dependencies]
xxhash-rust = { version = "0.8.0-beta.5", features = ["xxh3"] } # xxh3 hashing for rust
hashbrown = "0.9" # A faster hashmap, nostd compatible
libc = "0.2" # For (*nix) libc
num = "*"
#shared_memory = { version = "0.11.3", optional = true } # shared mem for windows and unix
xxhash-rust = { version = "0.8.0-beta.5", features = ["xxh3"] } # xxh3 hashing for rust

View File

@ -9,9 +9,9 @@ use core::marker::PhantomData;
#[cfg(feature = "std")]
use std::path::PathBuf;
use crate::AflError;
use crate::inputs::Input;
use crate::utils::Rand;
use crate::AflError;
pub trait HasTestcaseVec<I>
where

View File

@ -1,6 +1,3 @@
use crate::inputs::Input;
use crate::AflError;
use alloc::boxed::Box;
use alloc::rc::Rc;
use alloc::string::String;
@ -10,6 +7,9 @@ use core::default::Default;
use core::option::Option;
use hashbrown::HashMap;
use crate::AflError;
use crate::inputs::Input;
// TODO PathBuf for no_std and change filename to PathBuf
//#[cfg(feature = "std")]
//use std::path::PathBuf;

View File

@ -6,9 +6,9 @@ use alloc::vec::Vec;
use core::cell::RefCell;
use core::fmt::Debug;
use core::marker::PhantomData;
use hashbrown::HashMap;
use crate::{fire_event, AflError};
use crate::corpus::{Corpus, HasCorpus, Testcase};
use crate::events::{EventManager, LoadInitialEvent};
use crate::executors::Executor;
@ -18,7 +18,6 @@ use crate::inputs::Input;
use crate::observers::Observer;
use crate::stages::Stage;
use crate::utils::{current_milliseconds, Rand};
use crate::{fire_event, AflError};
// TODO FeedbackMetadata to store histroy_map
@ -384,6 +383,7 @@ where
#[cfg(test)]
mod tests {
use alloc::boxed::Box;
use std::io::stderr;

View File

@ -1,20 +1,25 @@
#[cfg(feature = "std")]
pub mod llmp;
#[cfg(feature = "std")]
pub mod llmp_translated; // TODO: Abstract away.
#[cfg(feature = "std")]
pub mod shmem_translated;
pub use crate::events::llmp::LLMP;
use core::any::Any;
//use core::any::TypeId;
use core::fmt::Display;
// TODO use core version
use std::io::Write;
use crate::AflError;
use crate::corpus::Corpus;
use crate::engines::State;
use crate::executors::Executor;
use crate::inputs::Input;
use crate::utils::Rand;
use crate::AflError;
pub trait Event: Display + Any {}

View File

@ -3,9 +3,9 @@ use core::cell::RefCell;
use core::ffi::c_void;
use core::ptr;
use crate::AflError;
use crate::executors::{Executor, ExitKind};
use crate::inputs::Input;
use crate::AflError;
type HarnessFunction<I> = fn(&dyn Executor<I>, &[u8]) -> ExitKind;

View File

@ -1,15 +1,13 @@
extern crate num;
use alloc::rc::Rc;
use alloc::vec::Vec;
use core::cell::RefCell;
use core::marker::PhantomData;
use num::Integer;
use crate::AflError;
use crate::corpus::{Testcase, TestcaseMetadata};
use crate::inputs::Input;
use crate::observers::MapObserver;
use crate::AflError;
pub trait Feedback<I>
where

View File

@ -2,10 +2,10 @@ use alloc::vec::Vec;
use core::cmp::min;
use core::marker::PhantomData;
use crate::AflError;
use crate::inputs::bytes::BytesInput;
use crate::inputs::Input;
use crate::utils::Rand;
use crate::AflError;
pub trait Generator<I, R>
where

View File

@ -4,8 +4,8 @@ use alloc::vec::Vec;
use core::cell::RefCell;
use core::convert::From;
use crate::inputs::{HasBytesVec, HasTargetBytes, Input};
use crate::AflError;
use crate::inputs::{HasBytesVec, HasTargetBytes, Input};
/// A bytes input is the basic input
#[derive(Clone, Debug, Default)]

View File

@ -4,14 +4,14 @@ pub use scheduled::HavocBytesMutator;
pub use scheduled::ScheduledMutator;
pub use scheduled::StdScheduledMutator;
use alloc::rc::Rc;
use core::cell::RefCell;
use crate::AflError;
use crate::corpus::Corpus;
use crate::corpus::Testcase;
use crate::inputs::Input;
use crate::utils::Rand;
use crate::AflError;
use alloc::rc::Rc;
use core::cell::RefCell;
pub trait Mutator<C, I, R>
where

View File

@ -1,11 +1,11 @@
use alloc::vec::Vec;
use core::marker::PhantomData;
use crate::AflError;
use crate::inputs::{HasBytesVec, Input};
use crate::mutators::Corpus;
use crate::mutators::Mutator;
use crate::utils::Rand;
use crate::AflError;
use alloc::vec::Vec;
use core::marker::PhantomData;
pub enum MutationResult {
Mutated,

View File

@ -1,6 +1,10 @@
pub mod mutational;
pub use mutational::StdMutationalStage;
use alloc::rc::Rc;
use core::cell::RefCell;
use crate::AflError;
use crate::corpus::testcase::Testcase;
use crate::corpus::Corpus;
use crate::engines::State;
@ -8,9 +12,6 @@ use crate::events::EventManager;
use crate::executors::Executor;
use crate::inputs::Input;
use crate::utils::Rand;
use crate::AflError;
use alloc::rc::Rc;
use core::cell::RefCell;
pub trait Stage<S, EM, E, C, I, R>
where

View File

@ -2,17 +2,16 @@ use alloc::rc::Rc;
use core::cell::RefCell;
use core::marker::PhantomData;
use crate::{AflError, fire_event};
use crate::corpus::testcase::Testcase;
use crate::engines::State;
use crate::events::{EventManager, NewTestcaseEvent};
use crate::executors::Executor;
use crate::fire_event;
use crate::inputs::Input;
use crate::mutators::Mutator;
use crate::stages::Corpus;
use crate::stages::Stage;
use crate::utils::Rand;
use crate::AflError;
// TODO multi mutators stage

View File

@ -71,30 +71,6 @@ where
}
}
/// Has a Rand Rc RefCell field (internal mutability), that can be used to get random values
pub trait HasRandRR {
type R: Rand;
/// Get the hold Rand instance
fn rand(&self) -> &Rc<RefCell<Self::R>>;
// Gets the next 64 bit value
fn rand_next(&self) -> u64 {
self.rand().borrow_mut().next()
}
// Gets a value below the given 64 bit val (inclusive)
fn rand_below(&self, upper_bound_excl: u64) -> u64 {
self.rand().borrow_mut().below(upper_bound_excl)
}
// Gets a value between the given lower bound (inclusive) and upper bound (inclusive)
fn rand_between(&self, lower_bound_incl: u64, upper_bound_incl: u64) -> u64 {
self.rand()
.borrow_mut()
.between(lower_bound_incl, upper_bound_incl)
}
}
const HASH_CONST: u64 = 0xa5b35705;
/// XXH3 Based, hopefully speedy, rnd implementation