Add wasm-tools repository to wasmtime project (#4111)

* Add wasm-tools repository to wasmtime project

This commit expands the fuzzers run under the Wasmtime project to
include those in the https://github.com/bytecodealliance/wasm-tools
repository. This includes various parsing for utilities used by Wasmtime
itself but also generally useful for other Rust projects! The
maintainers of the wasm-tools repository are also all currently all on
the notification list for Wasmtime fuzz bugs as well.

* Load all corpuses from wasmtime-libfuzzer-corpus
This commit is contained in:
Alex Crichton 2020-07-10 21:25:01 -05:00 committed by GitHub
parent 58e519a8f2
commit cd665e2a82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 17 deletions

View File

@ -17,6 +17,8 @@
FROM gcr.io/oss-fuzz-base/base-builder
RUN apt-get update && apt-get install -y make autoconf automake libtool curl cmake python llvm-dev libclang-dev clang
RUN git clone --depth 1 https://github.com/bytecodealliance/wasm-tools wasm-tools
RUN git clone --depth 1 https://github.com/bytecodealliance/wasmtime wasmtime
WORKDIR wasmtime
RUN git submodule update --init --recursive

View File

@ -16,24 +16,36 @@
################################################################################
# Note: This project creates Rust fuzz targets exclusively
PROJECT_DIR=$SRC/wasmtime
build() {
project=$1
shift
fuzzer_prefix=$1
shift
PROJECT_DIR=$SRC/$project
cd $PROJECT_DIR/fuzz && cargo fuzz build -O --debug-assertions "$@"
FUZZ_TARGET_OUTPUT_DIR=$PROJECT_DIR/target/x86_64-unknown-linux-gnu/release
for f in $PROJECT_DIR/fuzz/fuzz_targets/*.rs
do
src_name=$(basename ${f%.*})
dst_name=$fuzzer_prefix$src_name
cp $FUZZ_TARGET_OUTPUT_DIR/$src_name $OUT/$dst_name
if [[ -d $SRC/wasmtime/wasmtime-libfuzzer-corpus/$dst_name/ ]]; then
zip -jr \
$OUT/${dst_name}_seed_corpus.zip \
$SRC/wasmtime/wasmtime-libfuzzer-corpus/$dst_name/
fi
cp $SRC/default.options $OUT/$dst_name.options
done
}
# Build with all features to enable the binaryen-using fuzz targets, and
# the peepmatic fuzz targets.
cd $PROJECT_DIR/fuzz && cargo fuzz build -O --debug-assertions --all-features
build wasmtime "" --all-features
FUZZ_TARGET_OUTPUT_DIR=$PROJECT_DIR/target/x86_64-unknown-linux-gnu/release
for f in $SRC/wasmtime/fuzz/fuzz_targets/*.rs
do
FUZZ_TARGET_NAME=$(basename ${f%.*})
cp $FUZZ_TARGET_OUTPUT_DIR/$FUZZ_TARGET_NAME $OUT/
if [[ -d $PROJECT_DIR/wasmtime-libfuzzer-corpus/$FUZZ_TARGET_NAME/ ]]; then
zip -jr \
$OUT/${FUZZ_TARGET_NAME}_seed_corpus.zip \
$PROJECT_DIR/wasmtime-libfuzzer-corpus/$FUZZ_TARGET_NAME/
fi
cp $SRC/default.options $OUT/$FUZZ_TARGET_NAME.options
done
build wasm-tools wasm-tools-