Browse Source

Add cargo-fuzz targets

tags/alpha-0.6.0
Manos Pitsidianakis 4 months ago
parent
commit
0a34b082f6
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS. GPG Key ID: 73627C2F690DF710
6 changed files with 2481 additions and 0 deletions
  1. +8
    -0
      README.md
  2. +4
    -0
      fuzz/.gitignore
  3. +2409
    -0
      fuzz/Cargo.lock
  4. +24
    -0
      fuzz/Cargo.toml
  5. +25
    -0
      fuzz/envelope_tokens.dict
  6. +11
    -0
      fuzz/fuzz_targets/envelope_parse.rs

+ 8
- 0
README.md View File

@@ -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
- 0
fuzz/.gitignore View File

@@ -0,0 +1,4 @@

target
corpus
artifacts

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


+ 24
- 0
fuzz/Cargo.toml View File

@@ -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
- 0
fuzz/envelope_tokens.dict View File

@@ -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
- 0
fuzz/fuzz_targets/envelope_parse.rs View File

@@ -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