Initial commit of a fuzzer. Run with "cargo fuzz run simple_instantiate".

Used to discover issue #558.

We'll probably want to reconsider the default .gitignore of the artifacts and corpus directories. The fuzzer wastes a lot of time not having even a single exampel of a valid .wasm file to start with.
This commit is contained in:
Nick Lewycky 2019-07-13 17:57:30 -07:00
parent 13abdfee98
commit 5c0ede0b42
3 changed files with 38 additions and 0 deletions

4
fuzz/.gitignore vendored Normal file
View File

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

21
fuzz/Cargo.toml Normal file
View File

@ -0,0 +1,21 @@
[package]
name = "wasmer-fuzz"
version = "0.0.1"
authors = ["Automatically generated"]
publish = false
[package.metadata]
cargo-fuzz = true
[dependencies]
wasmer-runtime = { path = "../lib/runtime" }
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" }
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "simple_instantiate"
path = "fuzz_targets/simple_instantiate.rs"

View File

@ -0,0 +1,13 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate wasmer_runtime;
use wasmer_runtime::{
instantiate,
imports,
};
fuzz_target!(|data: &[u8]| {
let import_object = imports! {};
instantiate(data, &import_object);
});