From 217175212ba1d484017c32fe6518f85c1aa1273f Mon Sep 17 00:00:00 2001 From: Catena cyber <35799796+catenacyber@users.noreply.github.com> Date: Thu, 19 Nov 2020 23:18:25 +0100 Subject: [PATCH] [infra] Use generic compile_go_fuzzer for golang projects (#4659) * Use generic compile_go_fuzzer for golang projects * fix the copyright in the new script Co-authored-by: Max Moroz --- infra/base-images/base-builder/Dockerfile | 2 +- .../base-builder/compile_go_fuzzer | 47 +++++++++++++++++++ projects/cascadia/build.sh | 10 +--- projects/dragonfly/build.sh | 12 +---- projects/fasthttp/build.sh | 10 +--- projects/fastjson/build.sh | 10 +--- projects/gcloud-go/build.sh | 10 +--- projects/go-attestation/build.sh | 18 ++----- projects/go-coredns/build.sh | 14 +----- projects/go-dns/build.sh | 31 +----------- projects/go-json-iterator/build.sh | 12 +---- projects/golang/build.sh | 6 +-- projects/gonids/build.sh | 30 +----------- projects/gopacket/build.sh | 12 +---- projects/grpc-gateway/build.sh | 10 +--- projects/influxdb/build.sh | 12 +---- projects/kubernetes/build.sh | 6 +-- projects/nats/build.sh | 12 +---- projects/p9/build.sh | 12 +---- projects/prometheus/build.sh | 16 ++----- projects/quic-go/build.sh | 22 +++------ projects/radon/build.sh | 10 +--- projects/syzkaller/build.sh | 20 ++------ projects/teleport/build.sh | 12 +---- projects/tidb/build.sh | 14 ++---- projects/vitess/build.sh | 10 +--- 26 files changed, 94 insertions(+), 286 deletions(-) create mode 100755 infra/base-images/base-builder/compile_go_fuzzer diff --git a/infra/base-images/base-builder/Dockerfile b/infra/base-images/base-builder/Dockerfile index c03543eed..a394db7e5 100644 --- a/infra/base-images/base-builder/Dockerfile +++ b/infra/base-images/base-builder/Dockerfile @@ -151,7 +151,7 @@ RUN mkdir honggfuzz && \ rm -rf $SRC/oss-fuzz.tar.gz COPY compile compile_afl compile_dataflow compile_libfuzzer compile_honggfuzz \ - precompile_honggfuzz srcmap write_labels.py /usr/local/bin/ + compile_go_fuzzer precompile_honggfuzz srcmap write_labels.py /usr/local/bin/ COPY detect_repo.py /opt/cifuzz/ COPY ossfuzz_coverage_runner.go $GOPATH diff --git a/infra/base-images/base-builder/compile_go_fuzzer b/infra/base-images/base-builder/compile_go_fuzzer new file mode 100755 index 000000000..5fc8b70f0 --- /dev/null +++ b/infra/base-images/base-builder/compile_go_fuzzer @@ -0,0 +1,47 @@ +#!/bin/bash -eu +# Copyright 2020 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +path=$1 +function=$2 +fuzzer=$3 +tags="" +if [[ $# -eq 4 ]]; then + tags="-tags $4" +fi + +if [[ $SANITIZER = *coverage* ]]; then + cd $GOPATH/src/$path + fuzzed_package=`pwd | rev | cut -d'/' -f 1 | rev` + cp $GOPATH/ossfuzz_coverage_runner.go ./"${function,,}"_test.go + sed -i -e 's/FuzzFunction/'$function'/' ./"${function,,}"_test.go + sed -i -e 's/mypackagebeingfuzzed/'$fuzzed_package'/' ./"${function,,}"_test.go + sed -i -e 's/TestFuzzCorpus/Test'$function'Corpus/' ./"${function,,}"_test.go + + echo "#/bin/sh" > $OUT/$fuzzer + echo "cd $path" >> $OUT/$fuzzer + echo "go test -run Test${function}Corpus -v $tags -coverprofile \$1 " >> $OUT/$fuzzer + chmod +x $OUT/$fuzzer + + cd - +else + # Compile and instrument all Go files relevant to this fuzz target. + echo "Running go-fuzz $tags -func $function -o $fuzzer.a $path" + go-fuzz $tags -func $function -o $fuzzer.a $path + + # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary. + $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer +fi diff --git a/projects/cascadia/build.sh b/projects/cascadia/build.sh index a7f68b9a6..4643b2c2a 100755 --- a/projects/cascadia/build.sh +++ b/projects/cascadia/build.sh @@ -14,14 +14,6 @@ # limitations under the License. # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - go-fuzz -func $function -o $fuzzer.a $path - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} - -compile_fuzzer github.com/andybalholm/cascadia/fuzz Fuzz fuzz +compile_go_fuzzer github.com/andybalholm/cascadia/fuzz Fuzz fuzz diff --git a/projects/dragonfly/build.sh b/projects/dragonfly/build.sh index 432d7651f..11364d408 100755 --- a/projects/dragonfly/build.sh +++ b/projects/dragonfly/build.sh @@ -14,17 +14,9 @@ # limitations under the License. # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - go-fuzz -func $function -o $fuzzer.a $path - - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} mkdir $GOPATH/src/github.com/dragonflyoss cp -r $SRC/Dragonfly $GOPATH/src/github.com/dragonflyoss/ -compile_fuzzer github.com/dragonflyoss/Dragonfly/dfget/core/uploader FuzzParseParams uploader_fuzz -compile_fuzzer github.com/dragonflyoss/Dragonfly/supernode/daemon/mgr/cdn Fuzz cdn_fuzz +compile_go_fuzzer github.com/dragonflyoss/Dragonfly/dfget/core/uploader FuzzParseParams uploader_fuzz +compile_go_fuzzer github.com/dragonflyoss/Dragonfly/supernode/daemon/mgr/cdn Fuzz cdn_fuzz diff --git a/projects/fasthttp/build.sh b/projects/fasthttp/build.sh index 3d2b31b0f..26556cfd5 100755 --- a/projects/fasthttp/build.sh +++ b/projects/fasthttp/build.sh @@ -15,18 +15,10 @@ # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - go-fuzz -func $function -o $fuzzer.a $path - - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} ls $GOPATH/src/github.com/valyala/fasthttp/fuzzit | while read target do - compile_fuzzer github.com/valyala/fasthttp/fuzzit/$target Fuzz fuzz_$target + compile_go_fuzzer github.com/valyala/fasthttp/fuzzit/$target Fuzz fuzz_$target done diff --git a/projects/fastjson/build.sh b/projects/fastjson/build.sh index b3e45f213..673688a28 100755 --- a/projects/fastjson/build.sh +++ b/projects/fastjson/build.sh @@ -14,14 +14,6 @@ # limitations under the License. # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - go-fuzz -func $function -o $fuzzer.a $path - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} - -compile_fuzzer github.com/valyala/fastjson Fuzz fuzz +compile_go_fuzzer github.com/valyala/fastjson Fuzz fuzz diff --git a/projects/gcloud-go/build.sh b/projects/gcloud-go/build.sh index 38db5cb90..5ff56537a 100644 --- a/projects/gcloud-go/build.sh +++ b/projects/gcloud-go/build.sh @@ -15,14 +15,6 @@ # ################################################################################ -function compile_fuzzer() { - path=$1 - function=$2 - fuzzer=$3 - go-fuzz -func $function -o $fuzzer.a $path - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} - -compile_fuzzer cloud.google.com/go/spanner/spansql FuzzParseQuery fuzz_parse_query +compile_go_fuzzer cloud.google.com/go/spanner/spansql FuzzParseQuery fuzz_parse_query diff --git a/projects/go-attestation/build.sh b/projects/go-attestation/build.sh index 20fef0038..7130cba63 100755 --- a/projects/go-attestation/build.sh +++ b/projects/go-attestation/build.sh @@ -15,23 +15,13 @@ # ################################################################################ -function compile_fuzzer { - package=$1 - function=$2 - fuzzer=$3 - # Compile and instrument all Go files relevant to this fuzz target. - go-fuzz -func $function -o $fuzzer.a $package - # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary. - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} - -compile_fuzzer github.com/google/go-attestation/attest FuzzParseEventLog \ +compile_go_fuzzer github.com/google/go-attestation/attest FuzzParseEventLog \ parse_event_log_fuzzer -compile_fuzzer github.com/google/go-attestation/attest FuzzParseAKPublic12 \ +compile_go_fuzzer github.com/google/go-attestation/attest FuzzParseAKPublic12 \ parse_ak_public12_fuzzer -compile_fuzzer github.com/google/go-attestation/attest FuzzParseAKPublic20 \ +compile_go_fuzzer github.com/google/go-attestation/attest FuzzParseAKPublic20 \ parse_ak_public20_fuzzer -compile_fuzzer github.com/google/go-attestation/attest FuzzParseEKCertificate \ +compile_go_fuzzer github.com/google/go-attestation/attest FuzzParseEKCertificate \ parse_ek_certificate_fuzzer diff --git a/projects/go-coredns/build.sh b/projects/go-coredns/build.sh index 47958f81a..d1d021b79 100755 --- a/projects/go-coredns/build.sh +++ b/projects/go-coredns/build.sh @@ -16,24 +16,14 @@ ################################################################################ # Same as usual except for added -tags gofuzz. -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - # Compile and instrument all Go files relevant to this fuzz target. - go-fuzz -func $function -o $fuzzer.a $path - - # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary. - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} cd coredns #make ls plugin/*/fuzz.go | while read target do fuzzed_plugin=`echo $target | cut -d'/' -f 2` - compile_fuzzer github.com/coredns/coredns/plugin/$fuzzed_plugin Fuzz fuzz_plugin_$fuzzed_plugin + compile_go_fuzzer github.com/coredns/coredns/plugin/$fuzzed_plugin Fuzz fuzz_plugin_$fuzzed_plugin done -compile_fuzzer github.com/coredns/coredns/test Fuzz fuzz_core +compile_go_fuzzer github.com/coredns/coredns/test Fuzz fuzz_core diff --git a/projects/go-dns/build.sh b/projects/go-dns/build.sh index 873a291d6..d274ad9ac 100755 --- a/projects/go-dns/build.sh +++ b/projects/go-dns/build.sh @@ -15,34 +15,7 @@ # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - - if [[ $SANITIZER = *coverage* ]]; then - cd $GOPATH/src/$path - fuzzed_package=`pwd | rev | cut -d'/' -f 1 | rev` - cp $GOPATH/ossfuzz_coverage_runner.go ./"${function,,}"_test.go - sed -i -e 's/FuzzFunction/'$function'/' ./"${function,,}"_test.go - sed -i -e 's/mypackagebeingfuzzed/'$fuzzed_package'/' ./"${function,,}"_test.go - sed -i -e 's/TestFuzzCorpus/Test'$function'Corpus/' ./"${function,,}"_test.go - - echo "#/bin/sh" > $OUT/$fuzzer - echo "cd $path" >> $OUT/$fuzzer - echo "go test -run Test${function}Corpus -v -tags fuzz -coverprofile \$1 " >> $OUT/$fuzzer - chmod +x $OUT/$fuzzer - - cd - - return 0 - fi - # Compile and instrument all Go files relevant to this fuzz target. - go-fuzz -tags fuzz -func $function -o $fuzzer.a $path - - # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary. - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} # Same as usual except for added -tags fuzz. -compile_fuzzer github.com/miekg/dns FuzzNewRR fuzz_newrr -compile_fuzzer github.com/miekg/dns Fuzz fuzz_msg_unpack +compile_go_fuzzer github.com/miekg/dns FuzzNewRR fuzz_newrr fuzz +compile_go_fuzzer github.com/miekg/dns Fuzz fuzz_msg_unpack fuzz diff --git a/projects/go-json-iterator/build.sh b/projects/go-json-iterator/build.sh index 1d2bc4728..060bb7c76 100755 --- a/projects/go-json-iterator/build.sh +++ b/projects/go-json-iterator/build.sh @@ -15,16 +15,6 @@ # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - # Compile and instrument all Go files relevant to this fuzz target. - go-fuzz -func $function -o $fuzzer.a $path - # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary. - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} - -compile_fuzzer . Fuzz fuzz_json +compile_go_fuzzer . Fuzz fuzz_json diff --git a/projects/golang/build.sh b/projects/golang/build.sh index f207a5931..70972fa49 100755 --- a/projects/golang/build.sh +++ b/projects/golang/build.sh @@ -15,11 +15,7 @@ function compile_fuzzer { fuzzer=$(basename $1) - # Compile and instrument all Go files relevant to this fuzz target. - go-fuzz -o $fuzzer.a github.com/dvyukov/go-fuzz-corpus/$fuzzer - - # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary. - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/fuzzer-$fuzzer + compile_fuzzer "github.com/dvyukov/go-fuzz-corpus/$fuzzer" Fuzz $fuzzer # Pack the seed corpus zip -r $OUT/fuzzer-${fuzzer}_seed_corpus.zip \ diff --git a/projects/gonids/build.sh b/projects/gonids/build.sh index 97fe7d5ee..590045f9e 100755 --- a/projects/gonids/build.sh +++ b/projects/gonids/build.sh @@ -15,35 +15,7 @@ # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - - if [[ $SANITIZER = *coverage* ]]; then - cd $GOPATH/src/$path - fuzzed_package=`pwd | rev | cut -d'/' -f 1 | rev` - cp $GOPATH/ossfuzz_coverage_runner.go ./"${function,,}"_test.go - sed -i -e 's/FuzzFunction/'$function'/' ./"${function,,}"_test.go - sed -i -e 's/mypackagebeingfuzzed/'$fuzzed_package'/' ./"${function,,}"_test.go - sed -i -e 's/TestFuzzCorpus/Test'$function'Corpus/' ./"${function,,}"_test.go - - echo "#/bin/sh" > $OUT/$fuzzer - echo "cd $path" >> $OUT/$fuzzer - echo "go test -run Test${function}Corpus -v -coverprofile \$1 " >> $OUT/$fuzzer - chmod +x $OUT/$fuzzer - - cd - - return 0 - fi - # Compile and instrument all Go files relevant to this fuzz target. - go-fuzz -func $function -o $fuzzer.a $path - - # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary. - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} - -compile_fuzzer github.com/google/gonids FuzzParseRule fuzz_parserule +compile_go_fuzzer github.com/google/gonids FuzzParseRule fuzz_parserule unzip emerging.rules.zip cd rules diff --git a/projects/gopacket/build.sh b/projects/gopacket/build.sh index f19f85eff..6fc07e6e3 100755 --- a/projects/gopacket/build.sh +++ b/projects/gopacket/build.sh @@ -15,16 +15,6 @@ # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - # Compile and instrument all Go files relevant to this fuzz target. - go-fuzz -func $function -o $fuzzer.a $path - # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary. - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} - -compile_fuzzer github.com/google/gopacket/layers FuzzLayer fuzz_layers +compile_go_fuzzer github.com/google/gopacket/layers FuzzLayer fuzz_layers diff --git a/projects/grpc-gateway/build.sh b/projects/grpc-gateway/build.sh index c775de172..b70bddd0d 100755 --- a/projects/grpc-gateway/build.sh +++ b/projects/grpc-gateway/build.sh @@ -14,14 +14,6 @@ # limitations under the License. # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - go-fuzz -func $function -o $fuzzer.a $path - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} - -compile_fuzzer github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/httprule Fuzz fuzz +compile_go_fuzzer github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/httprule Fuzz fuzz diff --git a/projects/influxdb/build.sh b/projects/influxdb/build.sh index 93ea8ab71..69c86ed18 100644 --- a/projects/influxdb/build.sh +++ b/projects/influxdb/build.sh @@ -15,16 +15,6 @@ # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - # Instrument all Go files relevant to this fuzzer - go-fuzz -func $function -o $fuzzer.a $path - # Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} - -compile_fuzzer github.com/influxdata/influxdb/jsonweb FuzzJsonWeb fuzzjsonweb +compile_go_fuzzer github.com/influxdata/influxdb/jsonweb FuzzJsonWeb fuzzjsonweb diff --git a/projects/kubernetes/build.sh b/projects/kubernetes/build.sh index 802ac6a73..4e6bded1b 100755 --- a/projects/kubernetes/build.sh +++ b/projects/kubernetes/build.sh @@ -25,11 +25,7 @@ function compile_fuzzer { local function=$2 local fuzzer="${pkg}_${function}" - # Compile and instrument all Go files relevant to this fuzz target. - go-fuzz -func "${function}" -o "${fuzzer}.a" "k8s.io/kubernetes/test/fuzz/${pkg}" - - # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary. - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE "${fuzzer}.a" -o "${OUT}/${fuzzer}" + compile_fuzzer "k8s.io/kubernetes/test/fuzz/${pkg}" $function $fuzzer } compile_fuzzer "yaml" "FuzzDurationStrict" diff --git a/projects/nats/build.sh b/projects/nats/build.sh index 79f670c08..df01c7cf8 100755 --- a/projects/nats/build.sh +++ b/projects/nats/build.sh @@ -15,16 +15,8 @@ # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - go-fuzz -func $function -o $fuzzer.a $path - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} - -compile_fuzzer github.com/nats-io/nats-server/conf Fuzz fuzz_conf -compile_fuzzer github.com/nats-io/nats-server/server FuzzClient fuzz_client +compile_go_fuzzer github.com/nats-io/nats-server/conf Fuzz fuzz_conf +compile_go_fuzzer github.com/nats-io/nats-server/server FuzzClient fuzz_client diff --git a/projects/p9/build.sh b/projects/p9/build.sh index 34a0eac23..9e194aabb 100644 --- a/projects/p9/build.sh +++ b/projects/p9/build.sh @@ -14,16 +14,6 @@ # limitations under the License. # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - # Compile and instrument all Go files relevant to this fuzz target. - go-fuzz -func $function -o $fuzzer.a $path - # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary. - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} - -compile_fuzzer github.com/hugelgupf/p9/p9 Fuzz p9_fuzzer +compile_go_fuzzer github.com/hugelgupf/p9/p9 Fuzz p9_fuzzer diff --git a/projects/prometheus/build.sh b/projects/prometheus/build.sh index c8011afb8..e1f4acfeb 100755 --- a/projects/prometheus/build.sh +++ b/projects/prometheus/build.sh @@ -14,16 +14,8 @@ # limitations under the License. # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - go-fuzz -func $function -o $fuzzer.a $path - - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} -compile_fuzzer github.com/prometheus/prometheus/promql FuzzParseMetric fuzzParseMetric -compile_fuzzer github.com/prometheus/prometheus/promql FuzzParseOpenMetric fuzzParseOpenMetric -compile_fuzzer github.com/prometheus/prometheus/promql FuzzParseMetricSelector fuzzParseMetricSelector -compile_fuzzer github.com/prometheus/prometheus/promql FuzzParseExpr fuzzParseExpr +compile_go_fuzzer github.com/prometheus/prometheus/promql FuzzParseMetric fuzzParseMetric +compile_go_fuzzer github.com/prometheus/prometheus/promql FuzzParseOpenMetric fuzzParseOpenMetric +compile_go_fuzzer github.com/prometheus/prometheus/promql FuzzParseMetricSelector fuzzParseMetricSelector +compile_go_fuzzer github.com/prometheus/prometheus/promql FuzzParseExpr fuzzParseExpr diff --git a/projects/quic-go/build.sh b/projects/quic-go/build.sh index 41f03185e..6be3fae66 100644 --- a/projects/quic-go/build.sh +++ b/projects/quic-go/build.sh @@ -17,27 +17,17 @@ set -ex -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - # Compile and instrument all Go files relevant to this fuzz target. - go-fuzz -func $function -o $fuzzer.a $path - - # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary. - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} # Fuzz qpack -compile_fuzzer github.com/marten-seemann/qpack/fuzzing Fuzz qpack_fuzzer +compile_go_fuzzer github.com/marten-seemann/qpack/fuzzing Fuzz qpack_fuzzer # Fuzz quic-go -compile_fuzzer github.com/lucas-clemente/quic-go/fuzzing/frames Fuzz frame_fuzzer -compile_fuzzer github.com/lucas-clemente/quic-go/fuzzing/header Fuzz header_fuzzer -compile_fuzzer github.com/lucas-clemente/quic-go/fuzzing/transportparameters Fuzz transportparameter_fuzzer -compile_fuzzer github.com/lucas-clemente/quic-go/fuzzing/tokens Fuzz token_fuzzer -compile_fuzzer github.com/lucas-clemente/quic-go/fuzzing/handshake Fuzz handshake_fuzzer +compile_go_fuzzer github.com/lucas-clemente/quic-go/fuzzing/frames Fuzz frame_fuzzer +compile_go_fuzzer github.com/lucas-clemente/quic-go/fuzzing/header Fuzz header_fuzzer +compile_go_fuzzer github.com/lucas-clemente/quic-go/fuzzing/transportparameters Fuzz transportparameter_fuzzer +compile_go_fuzzer github.com/lucas-clemente/quic-go/fuzzing/tokens Fuzz token_fuzzer +compile_go_fuzzer github.com/lucas-clemente/quic-go/fuzzing/handshake Fuzz handshake_fuzzer # generate seed corpora go generate $GOPATH/src/github.com/lucas-clemente/quic-go/fuzzing/... diff --git a/projects/radon/build.sh b/projects/radon/build.sh index e8c72804a..063b6284c 100644 --- a/projects/radon/build.sh +++ b/projects/radon/build.sh @@ -14,14 +14,6 @@ # limitations under the License. # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - go-fuzz -func $function -o $fuzzer.a $path - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} - -compile_fuzzer github.com/radondb/radon/src/fuzz/sqlparser Fuzz fuzz +compile_go_fuzzer github.com/radondb/radon/src/fuzz/sqlparser Fuzz fuzz diff --git a/projects/syzkaller/build.sh b/projects/syzkaller/build.sh index cf1fdc266..e47096bb8 100755 --- a/projects/syzkaller/build.sh +++ b/projects/syzkaller/build.sh @@ -15,23 +15,13 @@ # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - # Compile and instrument all Go files relevant to this fuzz target. - go-fuzz -func $function -o $fuzzer.a $path - - # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary. - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} make descriptions -compile_fuzzer github.com/google/syzkaller/pkg/compiler Fuzz compiler_fuzzer -compile_fuzzer github.com/google/syzkaller/prog/test FuzzDeserialize prog_deserialize_fuzzer -compile_fuzzer github.com/google/syzkaller/prog/test FuzzParseLog prog_parselog_fuzzer -compile_fuzzer github.com/google/syzkaller/pkg/report Fuzz report_fuzzer +compile_go_fuzzer github.com/google/syzkaller/pkg/compiler Fuzz compiler_fuzzer +compile_go_fuzzer github.com/google/syzkaller/prog/test FuzzDeserialize prog_deserialize_fuzzer +compile_go_fuzzer github.com/google/syzkaller/prog/test FuzzParseLog prog_parselog_fuzzer +compile_go_fuzzer github.com/google/syzkaller/pkg/report Fuzz report_fuzzer # This target is way too spammy and OOMs very quickly. -# compile_fuzzer ./tools/syz-trace2syz/proggen Fuzz trace2syz_fuzzer +# compile_go_fuzzer ./tools/syz-trace2syz/proggen Fuzz trace2syz_fuzzer diff --git a/projects/teleport/build.sh b/projects/teleport/build.sh index 68f3595d7..90d9e8c53 100644 --- a/projects/teleport/build.sh +++ b/projects/teleport/build.sh @@ -14,19 +14,11 @@ # limitations under the License. # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - go-fuzz -func $function -o $fuzzer.a $path - - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} mkdir -p $GOPATH/src/github.com/gravitational cd $GOPATH/src/github.com/gravitational git clone https://github.com/gravitational/teleport.git -compile_fuzzer github.com/gravitational/teleport/lib/fuzz FuzzParseProxyJump utils_fuzz -compile_fuzzer github.com/gravitational/teleport/lib/fuzz FuzzNewExpression parse_fuzz +compile_go_fuzzer github.com/gravitational/teleport/lib/fuzz FuzzParseProxyJump utils_fuzz +compile_go_fuzzer github.com/gravitational/teleport/lib/fuzz FuzzNewExpression parse_fuzz diff --git a/projects/tidb/build.sh b/projects/tidb/build.sh index 2ea7ac75e..9135a32d5 100755 --- a/projects/tidb/build.sh +++ b/projects/tidb/build.sh @@ -14,15 +14,7 @@ # limitations under the License. # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - go-fuzz -func $function -o $fuzzer.a $path - - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} -compile_fuzzer github.com/pingcap/tidb/types FuzzMarshalJSON fuzzMarshalJSON -compile_fuzzer github.com/pingcap/tidb/types FuzzNewBitLiteral fuzzNewBitLiteral -compile_fuzzer github.com/pingcap/tidb/types FuzzNewHexLiteral fuzzNewHexLiteral +compile_go_fuzzer github.com/pingcap/tidb/types FuzzMarshalJSON fuzzMarshalJSON +compile_go_fuzzer github.com/pingcap/tidb/types FuzzNewBitLiteral fuzzNewBitLiteral +compile_go_fuzzer github.com/pingcap/tidb/types FuzzNewHexLiteral fuzzNewHexLiteral diff --git a/projects/vitess/build.sh b/projects/vitess/build.sh index 99ab3ed9c..489bf4bb3 100755 --- a/projects/vitess/build.sh +++ b/projects/vitess/build.sh @@ -14,13 +14,5 @@ # limitations under the License. # ################################################################################ -function compile_fuzzer { - path=$1 - function=$2 - fuzzer=$3 - go-fuzz -func $function -o $fuzzer.a $path - - $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer -} -compile_fuzzer github.com/vitessio/vitess/go/vt/sqlparser Fuzz fuzz +compile_go_fuzzer github.com/vitessio/vitess/go/vt/sqlparser Fuzz fuzz