From 5c0ede0b42ac306c5999995b8ed4357efe1f6eb7 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sat, 13 Jul 2019 17:57:30 -0700 Subject: [PATCH] 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. --- fuzz/.gitignore | 4 ++++ fuzz/Cargo.toml | 21 +++++++++++++++++++++ fuzz/fuzz_targets/simple_instantiate.rs | 13 +++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 fuzz/.gitignore create mode 100644 fuzz/Cargo.toml create mode 100644 fuzz/fuzz_targets/simple_instantiate.rs diff --git a/fuzz/.gitignore b/fuzz/.gitignore new file mode 100644 index 00000000000..572e03bdf32 --- /dev/null +++ b/fuzz/.gitignore @@ -0,0 +1,4 @@ + +target +corpus +artifacts diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 00000000000..5c37cb47ed3 --- /dev/null +++ b/fuzz/Cargo.toml @@ -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" diff --git a/fuzz/fuzz_targets/simple_instantiate.rs b/fuzz/fuzz_targets/simple_instantiate.rs new file mode 100644 index 00000000000..831bbb1a510 --- /dev/null +++ b/fuzz/fuzz_targets/simple_instantiate.rs @@ -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); +});