-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First touch on #499 Depends on: google/oss-fuzz#12284 The way this work is by saving a cached version of `build_fuzzers` post running of `compile` and then modifying the Dockerfiles of a project to use this cached build image + an adjusted build script. For example, for brotli the Dockerfile is originally: ```sh FROM gcr.io/oss-fuzz-base/base-builder RUN apt-get update && apt-get install -y cmake libtool make RUN git clone --depth 1 https://github.com/google/brotli.git WORKDIR brotli COPY build.sh $SRC/ COPY 01.c /src/brotli/c/fuzz/decode_fuzzer.c ``` a Dockerfile is then created which relies on the cached version, and it loosk like: ```sh FROM cached_image_brotli # RUN apt-get update && apt-get install -y cmake libtool make # # RUN git clone --depth 1 https://github.com/google/brotli.git # WORKDIR brotli # COPY build.sh $SRC/ # COPY 01.c /src/brotli/c/fuzz/decode_fuzzer.c # COPY adjusted_build.sh $SRC/build.sh ``` `adjusted_build.sh` is then the script that only builds fuzzers. This means we can also use `build_fuzzers`/`compile` workflows as we know it. More specifically, this PR: - Makes it possible to build Docker images of fuzzer build containers. Does this by running `build_fuzzers`, saving the docker container and then commit the docker container to an image. This image will have a projects' build set up post running of `compile`. This is then used when building fuzzers by OFG. - Supports only ASAN mode for now. Should be easy to extend to coverage too. - Currently builds images first and then uses them locally. We could extend, probably on another step of this, to use containers pushed by OSS-Fuzz itself. - Only does the caching if a "cache-build-script" exists (added a few for some projects) which contains the build instructions post-build process. It should be easy to extend such that we can rely on some DB of auto-generated build scripts as well (ref: google/oss-fuzz#11937) but I think it's nice to have both the option of us creating the scripts ourselves + an auto-generated DB. --------- Signed-off-by: David Korczynski <[email protected]>
- Loading branch information
1 parent
abb5a5f
commit f9a8df9
Showing
11 changed files
with
285 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
INCLUDES="-I. -I./src -I./lib -I./gobex -I/usr/local/include/glib-2.0/ -I/src/glib/_build/glib/" | ||
STATIC_LIBS="./src/.libs/libshared-glib.a ./lib/.libs/libbluetooth-internal.a -l:libical.a -l:libicalss.a -l:libicalvcal.a -l:libdbus-1.a /src/glib/_build/glib/libglib-2.0.a" | ||
|
||
$CC $CFLAGS $INCLUDES $SRC/fuzz_xml.c -c | ||
$CC $CFLAGS $INCLUDES $SRC/fuzz_sdp.c -c | ||
$CC $CFLAGS $INCLUDES $SRC/fuzz_textfile.c -c | ||
$CC $CFLAGS $INCLUDES $SRC/fuzz_gobex.c -c | ||
$CC $CFLAGS $INCLUDES $SRC/fuzz_hci.c -c | ||
|
||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE \ | ||
./src/bluetoothd-sdp-xml.o fuzz_xml.o -o $OUT/fuzz_xml \ | ||
$STATIC_LIBS -ldl -lpthread | ||
|
||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE \ | ||
fuzz_sdp.o -o $OUT/fuzz_sdp $STATIC_LIBS -ldl -lpthread | ||
|
||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE fuzz_textfile.o -o $OUT/fuzz_textfile \ | ||
$STATIC_LIBS -ldl -lpthread src/textfile.o | ||
|
||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE \ | ||
fuzz_gobex.o ./gobex/gobex*.o -o $OUT/fuzz_gobex \ | ||
$STATIC_LIBS -ldl -lpthread | ||
|
||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE \ | ||
fuzz_hci.o ./gobex/gobex*.o -o $OUT/fuzz_hci \ | ||
$STATIC_LIBS -ldl -lpthread | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$CC $CFLAGS -c -std=c99 -I. -I./c/include c/fuzz/decode_fuzzer.c | ||
|
||
$CXX $CXXFLAGS ./decode_fuzzer.o -o $OUT/decode_fuzzer \ | ||
$LIB_FUZZING_ENGINE ./libbrotlidec.a ./libbrotlicommon.a | ||
|
||
cp java/org/brotli/integration/fuzz_data.zip $OUT/decode_fuzzer_seed_corpus.zip | ||
chmod a-x $OUT/decode_fuzzer_seed_corpus.zip # we will try to run it otherwise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
make -j$(nproc) libhts.a test/fuzz/hts_open_fuzzer.o | ||
|
||
# build fuzzers | ||
$CXX $CXXFLAGS -o "$OUT/hts_open_fuzzer" test/fuzz/hts_open_fuzzer.o $LIB_FUZZING_ENGINE libhts.a -lz -lbz2 -llzma -lcurl -lcrypto -lpthread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# build fuzzers | ||
$CXX $CXXFLAGS -std=c++11 -Ilibraw \ | ||
$SRC/libraw_fuzzer.cc -o $OUT/libraw_fuzzer \ | ||
$LIB_FUZZING_ENGINE -lz lib/.libs/libraw.a | ||
|
||
$CXX $CXXFLAGS -std=c++11 -Ilibraw \ | ||
$SRC/libraw_fuzzer.cc -o $OUT/libraw_cr2_fuzzer \ | ||
$LIB_FUZZING_ENGINE -lz lib/.libs/libraw.a | ||
|
||
$CXX $CXXFLAGS -std=c++11 -Ilibraw \ | ||
$SRC/libraw_fuzzer.cc -o $OUT/libraw_nef_fuzzer \ | ||
$LIB_FUZZING_ENGINE -lz lib/.libs/libraw.a | ||
|
||
$CXX $CXXFLAGS -std=c++11 -Ilibraw \ | ||
$SRC/libraw_fuzzer.cc -o $OUT/libraw_raf_fuzzer \ | ||
$LIB_FUZZING_ENGINE -lz lib/.libs/libraw.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
./ossfuzz/ossfuzz.sh | ||
|
||
# To make CIFuzz fast, see here for details: https://github.com/libsndfile/libsndfile/pull/796 | ||
for fuzzer in sndfile_alt_fuzzer sndfile_fuzzer; do | ||
echo "[libfuzzer]" > ${OUT}/${fuzzer}.options | ||
echo "close_fd_mask = 3" >> ${OUT}/${fuzzer}.options | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cd src/fuzz | ||
|
||
make -j$n CFLAGS+="$CFLAGS" CXXFLAGS+="$CXXFLAGS" | ||
|
||
for fuzzer in *_fuzzer; do | ||
cp $fuzzer $OUT | ||
|
||
corpus=${fuzzer%_fuzzer}_corpus | ||
if [ -d $corpus ]; then | ||
zip -j $OUT/${fuzzer}_seed_corpus.zip $corpus/* | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash -eu | ||
|
||
build_fuzz_target () { | ||
local target=$1 | ||
shift | ||
$CC $CFLAGS -I. -c fuzz/$target.c -o $target.o | ||
$CXX $CXXFLAGS $target.o -o $OUT/$target $@ $LIB_FUZZING_ENGINE | ||
} | ||
|
||
build_fuzz_target fuzz_eval .obj/fuzz_common.o libquickjs.fuzz.a | ||
build_fuzz_target fuzz_compile .obj/fuzz_common.o libquickjs.fuzz.a | ||
build_fuzz_target fuzz_regexp .obj/libregexp.fuzz.o .obj/cutils.fuzz.o .obj/libunicode.fuzz.o | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
make -j"$(nproc)" check | ||
find "${SRC}/tmux/fuzz/" -name '*-fuzzer' -exec cp -v '{}' "${OUT}"/ \; | ||
find "${SRC}/tmux/fuzz/" -name '*-fuzzer.options' -exec cp -v '{}' "${OUT}"/ \; | ||
find "${SRC}/tmux/fuzz/" -name '*-fuzzer.dict' -exec cp -v '{}' "${OUT}"/ \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters