solve conflict
This commit is contained in:
commit
c5e38d6961
@ -9,12 +9,7 @@ edition = "2018"
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = "0.3" # Benchmarking
|
criterion = "0.3" # Benchmarking
|
||||||
|
|
||||||
[[bench]]
|
|
||||||
name = "rng_hash_benchmark"
|
|
||||||
harness = false
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
xxhash-rust = { version = "0.8.0-beta.4", features = ["xxh3"] } # xxh3 hashing for rust
|
xxhash-rust = { version = "0.8.0-beta.4", features = ["xxh3"] } # xxh3 hashing for rust
|
||||||
ahash = "0.5.6" # Fast hashing algorithm
|
|
||||||
thiserror = "1.0" # A nicer way to write Errors
|
thiserror = "1.0" # A nicer way to write Errors
|
||||||
hashbrown = "0.9" # A faster hashmap, nostd compatible
|
hashbrown = "0.9" # A faster hashmap, nostd compatible
|
@ -1,13 +1,13 @@
|
|||||||
use crate::inputs::Input;
|
use crate::inputs::Input;
|
||||||
use crate::utils::Rand;
|
use crate::utils::Rand;
|
||||||
use crate::Error;
|
use crate::AflError;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
pub trait TestcaseMetadata: Debug {}
|
pub trait TestcaseMetadata: Debug {}
|
||||||
|
|
||||||
pub trait Testcase: Debug {
|
pub trait Testcase: Debug {
|
||||||
fn load_input(&mut self) -> Result<&Box<dyn Input>, Error>;
|
fn load_input(&mut self) -> Result<&Box<dyn Input>, AflError>;
|
||||||
fn is_on_disk(&self) -> bool;
|
fn is_on_disk(&self) -> bool;
|
||||||
fn get_filename(&self) -> &str;
|
fn get_filename(&self) -> &str;
|
||||||
fn get_metadatas(&mut self) -> &mut HashMap<String, Box<dyn TestcaseMetadata>>;
|
fn get_metadatas(&mut self) -> &mut HashMap<String, Box<dyn TestcaseMetadata>>;
|
||||||
@ -24,10 +24,10 @@ pub trait Corpus: Debug {
|
|||||||
fn remove(&mut self, entry: &dyn Testcase) -> Option<Box<dyn Testcase>>;
|
fn remove(&mut self, entry: &dyn Testcase) -> Option<Box<dyn Testcase>>;
|
||||||
|
|
||||||
/// Gets a random entry
|
/// Gets a random entry
|
||||||
fn random_entry(&mut self) -> Result<&Box<dyn Testcase>, Error>;
|
fn random_entry(&mut self) -> Result<&Box<dyn Testcase>, AflError>;
|
||||||
|
|
||||||
/// Gets the next entry
|
/// Gets the next entry
|
||||||
fn get(&mut self) -> Result<&Box<dyn Testcase>, Error>;
|
fn get(&mut self) -> Result<&Box<dyn Testcase>, AflError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -65,13 +65,13 @@ impl Corpus for RandomCorpus<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Gets a random entry
|
/// Gets a random entry
|
||||||
fn random_entry(&mut self) -> Result<&Box<dyn Testcase>, Error> {
|
fn random_entry(&mut self) -> Result<&Box<dyn Testcase>, AflError> {
|
||||||
let id = self.rand.below(self.entries.len() as u64) as usize;
|
let id = self.rand.below(self.entries.len() as u64) as usize;
|
||||||
Ok(self.entries.get_mut(id).unwrap())
|
Ok(self.entries.get_mut(id).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the next entry
|
/// Gets the next entry
|
||||||
fn get(&mut self) -> Result<&Box<dyn Testcase>, Error> {
|
fn get(&mut self) -> Result<&Box<dyn Testcase>, AflError> {
|
||||||
self.random_entry()
|
self.random_entry()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,14 +110,14 @@ impl Corpus for QueueCorpus<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Gets a random entry
|
/// Gets a random entry
|
||||||
fn random_entry(&mut self) -> Result<&Box<dyn Testcase>, Error> {
|
fn random_entry(&mut self) -> Result<&Box<dyn Testcase>, AflError> {
|
||||||
self.random_corpus.random_entry()
|
self.random_corpus.random_entry()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the next entry
|
/// Gets the next entry
|
||||||
fn get(&mut self) -> Result<&Box<dyn Testcase>, Error> {
|
fn get(&mut self) -> Result<&Box<dyn Testcase>, AflError> {
|
||||||
if self.count() == 0 {
|
if self.count() == 0 {
|
||||||
return Err(Error::Unknown); // TODO(andrea) why unknown? use EmptyContainerError or similar
|
return Err(AflError::Unknown); // TODO(andrea) why unknown? use EmptyContainerError or similar
|
||||||
}
|
}
|
||||||
self.pos = self.pos + 1;
|
self.pos = self.pos + 1;
|
||||||
if self.pos >= self.count() {
|
if self.pos >= self.count() {
|
||||||
@ -154,9 +154,9 @@ struct SimpleTestcase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Testcase for SimpleTestcase {
|
impl Testcase for SimpleTestcase {
|
||||||
fn load_input(&mut self) -> Result<&Box<dyn Input>, Error> {
|
fn load_input(&mut self) -> Result<&Box<dyn Input>, AflError> {
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
Err(Error::Unknown)
|
Err(AflError::Unknown)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_on_disk(&self) -> bool {
|
fn is_on_disk(&self) -> bool {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::inputs::Input;
|
use crate::inputs::Input;
|
||||||
use crate::Error;
|
use crate::AflError;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub struct BytesInput {
|
pub struct BytesInput {
|
||||||
@ -7,10 +7,10 @@ pub struct BytesInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Input for BytesInput {
|
impl Input for BytesInput {
|
||||||
fn serialize(&self) -> Result<&[u8], Error> {
|
fn serialize(&self) -> Result<&[u8], AflError> {
|
||||||
Ok(&self.bytes)
|
Ok(&self.bytes)
|
||||||
}
|
}
|
||||||
fn deserialize(&mut self, buf: &[u8]) -> Result<(), Error> {
|
fn deserialize(&mut self, buf: &[u8]) -> Result<(), AflError> {
|
||||||
self.bytes.truncate(0);
|
self.bytes.truncate(0);
|
||||||
self.bytes.extend_from_slice(buf);
|
self.bytes.extend_from_slice(buf);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -4,16 +4,16 @@ use std::fs::File;
|
|||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use crate::Error;
|
use crate::AflError;
|
||||||
|
|
||||||
pub trait Input {
|
pub trait Input {
|
||||||
fn to_file(&self, path: &str) -> Result<(), Error> {
|
fn to_file(&self, path: &str) -> Result<(), AflError> {
|
||||||
let mut file = File::create(path)?;
|
let mut file = File::create(path)?;
|
||||||
file.write_all(self.serialize()?)?;
|
file.write_all(self.serialize()?)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_file(&mut self, path: &str) -> Result<(), Error> {
|
fn from_file(&mut self, path: &str) -> Result<(), AflError> {
|
||||||
let mut file = File::create(path)?;
|
let mut file = File::create(path)?;
|
||||||
let mut buf = vec![];
|
let mut buf = vec![];
|
||||||
file.read_to_end(&mut buf)?;
|
file.read_to_end(&mut buf)?;
|
||||||
@ -21,7 +21,7 @@ pub trait Input {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize(&self) -> Result<&[u8], Error>;
|
fn serialize(&self) -> Result<&[u8], AflError>;
|
||||||
|
|
||||||
fn deserialize(&mut self, buf: &[u8]) -> Result<(), Error>;
|
fn deserialize(&mut self, buf: &[u8]) -> Result<(), AflError>;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ pub mod stages;
|
|||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum Error {
|
pub enum AflError {
|
||||||
#[error("Error in Serialization: `{0}`")]
|
#[error("Error in Serialization: `{0}`")]
|
||||||
Serialize(String),
|
Serialize(String),
|
||||||
#[error("File IO failed")]
|
#[error("File IO failed")]
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
//! Stages
|
use crate::corpus::Testcase;
|
||||||
pub trait Stage {}
|
use crate::inputs::Input;
|
||||||
|
use crate::AflError;
|
||||||
|
/// Stages
|
||||||
|
pub trait Stage {
|
||||||
|
fn perform(&mut self, input: &dyn Input, entry: &mut dyn Testcase) -> Result<(), AflError>;
|
||||||
|
}
|
||||||
|
16
src/stages/mutational.rs
Normal file
16
src/stages/mutational.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
use std::Vec;
|
||||||
|
use crate::mutators::Mutator;
|
||||||
|
use crate::inputs::Input;
|
||||||
|
|
||||||
|
pub struct MutationalStage {
|
||||||
|
mutators: Vec<Box<dyn Mutator>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Stage for MutationalStage {
|
||||||
|
|
||||||
|
fn Perform(&mut self, input: &Input, entry: &mut Entry) -> Result<(), AflError> {
|
||||||
|
// TODO: Implement me
|
||||||
|
Err(AflError::Unknown);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user