Browse Source

Add cargo-fuzz targets

async
Manos Pitsidianakis 3 years ago
parent
commit
0a34b082f6
Signed by untrusted user: epilys GPG Key ID: 73627C2F690DF710
  1. 8
      README.md
  2. 4
      fuzz/.gitignore
  3. 2409
      fuzz/Cargo.lock
  4. 24
      fuzz/Cargo.toml
  5. 25
      fuzz/envelope_tokens.dict
  6. 11
      fuzz/fuzz_targets/envelope_parse.rs

8
README.md

@ -123,3 +123,11 @@ cargo test -p {melib, meli} (-- --nocapture) (--test test_name)
perf record -g target/debug/bin
perf script | stackcollapse-perf | rust-unmangle | flamegraph > perf.svg
```
# Running fuzz targets
Note: `cargo-fuzz` requires the nightly toolchain.
```sh
cargo +nightly fuzz run envelope_parse -- -dict=fuzz/envelope_tokens.dict
```

4
fuzz/.gitignore

@ -0,0 +1,4 @@
target
corpus
artifacts

2409
fuzz/Cargo.lock
File diff suppressed because it is too large
View File

24
fuzz/Cargo.toml

@ -0,0 +1,24 @@
[package]
name = "melib-fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2018"
[package.metadata]
cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.3"
[dependencies.melib]
path = "../melib"
features = ["unicode_algorithms"]
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "envelope_parse"
path = "fuzz_targets/envelope_parse.rs"

25
fuzz/envelope_tokens.dict

@ -0,0 +1,25 @@
","
";"
"<"
">"
"@"
":"
# tab character
"\x09"
# new line character
"\x0A"
" "
"Subject: "
"Subject"
"To"
"To: "
"Date"
"Date: "
"Message-Id"
"Message-Id: "
"From"
"From: "
"Cc"
"Cc: "
"Bcc"
"Bcc: "

11
fuzz/fuzz_targets/envelope_parse.rs

@ -0,0 +1,11 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
extern crate melib;
use melib::Envelope;
fuzz_target!(|data: &[u8]| {
// fuzzed code goes here
let _envelope = Envelope::from_bytes(data, None);
});
Loading…
Cancel
Save