This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Added cargo-fuzz tests for Rlp crate #6145
Closed
Closed
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1bb6244
Added cargo-fuzz tests for Rlp crate
onicslabs 2ae9599
Changed fuzz-test authors to Parity Technologies
onicslabs 5d00521
Added cargo-fuzz installation & usage instructions
onicslabs d059d69
Conditional compitlation for nightly builds
onicslabs e2799de
Wrap fuzz tests with nightly feature
onicslabs 40dc411
Minor aesthetic change
onicslabs 17bd401
Syntax correction
onicslabs 5373ba4
Fixed conditional compilation
onicslabs 34fb2bc
Removed useless code from version cases
onicslabs 3766434
UntrustedRlp Fuzz test for lists and data parsing
onicslabs fbc3436
Recursive fuzzing over RLPStreams
onicslabs 728e3e1
Cleaned up writing corpus file
onicslabs c3d80a8
Added slices to fuzz corpus
onicslabs 5b84221
Added libFuzzer dict & improved fuzz harness
onicslabs 25b74cd
Confirmation panic occurs under stable build
onicslabs e3151fb
Removing unnecessary rlp-std crate
onicslabs 3786e22
Merge branch 'master' of https://github.com/paritytech/parity into fu…
onicslabs a7f2279
Cleaned up adding nightly feature flag
onicslabs 0d23592
Removed environment variable from Path creation
onicslabs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
extern crate rlp; | ||
extern crate ethcore_bigint; | ||
|
||
use std::env; | ||
use std::error::Error; | ||
use std::io::prelude::*; | ||
use std::path::Path; | ||
use std::fs::File; | ||
use rlp::RlpStream; | ||
use ethcore_bigint::prelude::{U128, U256, H64, H128, H160, H256, H512, H520, H2048}; | ||
|
||
fn create_file(path: &Path) -> File { | ||
match File::create(&path) { | ||
Err(why) => panic!("couldn't create {}: {}", | ||
path.display(), | ||
why.description()), | ||
Ok(file) => file | ||
} | ||
} | ||
|
||
fn write_to_file(f: &File, rlp: RlpStream) { | ||
let mut g = f.clone(); | ||
match g.write_all(rlp.as_raw()) { | ||
Err(why) => { | ||
panic!("couldn't write to file: {}", why.description()) | ||
}, | ||
Ok(_) => println!("successfully wrote to file") | ||
} | ||
|
||
} | ||
|
||
fn create_uint_stream() { | ||
// Create RLP Stream to encode values | ||
let mut rlp = RlpStream::new(); | ||
// U8, U16, U32, U64, U128, U256 bytes | ||
let u8b = 8 as u8; | ||
let u16b = 16 as u16; | ||
let u32b = 32 as u32; | ||
let u64b = 64 as u64; | ||
let u128b = U128::from(128); | ||
let u256b = U256::from(256); | ||
|
||
rlp.append(&u8b); | ||
rlp.append(&u16b); | ||
rlp.append(&u32b); | ||
rlp.append(&u64b); | ||
rlp.append(&u128b); | ||
rlp.append(&u256b); | ||
|
||
// Read in base path to fuzzing corpus directory from `RLPCORPUS` environment var | ||
let corp = env::var("RLPCORPUS").unwrap(); | ||
let fp = format!("{}{}", corp, "/untrusted_data/well-formed-list-uint"); | ||
let path = Path::new(&fp); | ||
|
||
// Write RLP Stream to corpus file | ||
let f = create_file(&path); | ||
write_to_file(&f, rlp); | ||
} | ||
|
||
fn create_hash_stream() { | ||
// Create RLP Stream to encode values | ||
let mut rlp = RlpStream::new(); | ||
// H64, H128, H160, H256, H512, H520, H2048 list | ||
let h64 = H64::random(); | ||
let h128 = H128::random(); | ||
let h160 = H160::random(); | ||
let h256 = H256::random(); | ||
let h512 = H512::random(); | ||
let h520 = H520::random(); | ||
let h2048 = H2048::random(); | ||
|
||
|
||
rlp.append(&h64); | ||
rlp.append(&h128); | ||
rlp.append(&h160); | ||
rlp.append(&h256); | ||
rlp.append(&h512); | ||
rlp.append(&h520); | ||
rlp.append(&h2048); | ||
|
||
// Read in base path to fuzzing corpus directory from `RLPCORPUS` environment var | ||
let corp = env::var("RLPCORPUS").unwrap(); | ||
let fp = format!("{}{}", corp, "/untrusted_data/well-formed-list-hash"); | ||
let path = Path::new(&fp); | ||
|
||
// Write RLP Stream to corpus file | ||
let f = create_file(&path); | ||
write_to_file(&f, rlp); | ||
} | ||
|
||
fn main() { | ||
create_uint_stream(); | ||
create_hash_stream(); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use
PathBuf
and appending methods for this