mirror of https://github.com/google/oss-fuzz.git
* [Go] remove "-lpthread" flag from "compile_fuzzer" and fix comments (#2714). * fix unrelated go-dns and gonids errors * simplify golang/build.sh as per Abhishek's comment
This commit is contained in:
parent
82175dc123
commit
13cb49b86c
|
@ -82,11 +82,11 @@ function compile_fuzzer {
|
||||||
function=$2
|
function=$2
|
||||||
fuzzer=$3
|
fuzzer=$3
|
||||||
|
|
||||||
# Instrument all Go files relevant to this fuzzer
|
# Compile and instrument all Go files relevant to this fuzz target.
|
||||||
go-fuzz -func $function -o $fuzzer.a $path
|
go-fuzz -func $function -o $fuzzer.a $path
|
||||||
|
|
||||||
# Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary
|
# Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary.
|
||||||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o $OUT/$fuzzer
|
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_fuzzer ./pkg/compiler Fuzz compiler_fuzzer
|
compile_fuzzer ./pkg/compiler Fuzz compiler_fuzzer
|
||||||
|
|
|
@ -15,20 +15,23 @@
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Based on the function from oss-fuzz/projects/golang/build.sh script.
|
|
||||||
function compile_fuzzer {
|
function compile_fuzzer {
|
||||||
package=$1
|
package=$1
|
||||||
function=$2
|
function=$2
|
||||||
fuzzer=$3
|
fuzzer=$3
|
||||||
|
|
||||||
# Instrument all Go files relevant to this fuzzer
|
# Compile and instrument all Go files relevant to this fuzz target.
|
||||||
go-fuzz -func $function -o $fuzzer.a $package
|
go-fuzz -func $function -o $fuzzer.a $package
|
||||||
|
|
||||||
# Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary
|
# Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary.
|
||||||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o $OUT/$fuzzer
|
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_fuzzer github.com/google/go-attestation/attest FuzzParseEventLog parse_event_log_fuzzer
|
compile_fuzzer github.com/google/go-attestation/attest FuzzParseEventLog \
|
||||||
compile_fuzzer github.com/google/go-attestation/attest FuzzParseAKPublic12 parse_ak_public12_fuzzer
|
parse_event_log_fuzzer
|
||||||
compile_fuzzer github.com/google/go-attestation/attest FuzzParseAKPublic20 parse_ak_public20_fuzzer
|
compile_fuzzer github.com/google/go-attestation/attest FuzzParseAKPublic12 \
|
||||||
compile_fuzzer github.com/google/go-attestation/attest FuzzParseEKCertificate parse_ek_certificate_fuzzer
|
parse_ak_public12_fuzzer
|
||||||
|
compile_fuzzer github.com/google/go-attestation/attest FuzzParseAKPublic20 \
|
||||||
|
parse_ak_public20_fuzzer
|
||||||
|
compile_fuzzer github.com/google/go-attestation/attest FuzzParseEKCertificate \
|
||||||
|
parse_ek_certificate_fuzzer
|
||||||
|
|
|
@ -15,19 +15,18 @@
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# build target function
|
|
||||||
function compile_fuzzer {
|
function compile_fuzzer {
|
||||||
path=$1
|
path=$1
|
||||||
function=$2
|
function=$2
|
||||||
fuzzer=$3
|
fuzzer=$3
|
||||||
|
|
||||||
# Instrument all Go files relevant to this fuzzer
|
# Compile and instrument all Go files relevant to this fuzz target.
|
||||||
go-fuzz -tags fuzz -func $function -o $fuzzer.a $path
|
go-fuzz -tags fuzz -func $function -o $fuzzer.a $path
|
||||||
|
|
||||||
# Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary
|
# Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary.
|
||||||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o $OUT/$fuzzer
|
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer
|
||||||
}
|
}
|
||||||
|
|
||||||
#same as usual except for added -tags fuzz
|
# Same as usual except for added -tags fuzz.
|
||||||
compile_fuzzer /root/go/src/github.com/miekg/dns/ FuzzNewRR fuzz_newrr
|
compile_fuzzer github.com/miekg/dns FuzzNewRR fuzz_newrr
|
||||||
compile_fuzzer /root/go/src/github.com/miekg/dns/ Fuzz fuzz_msg_unpack
|
compile_fuzzer github.com/miekg/dns Fuzz fuzz_msg_unpack
|
||||||
|
|
|
@ -15,17 +15,16 @@
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# build target function
|
|
||||||
function compile_fuzzer {
|
function compile_fuzzer {
|
||||||
path=$1
|
path=$1
|
||||||
function=$2
|
function=$2
|
||||||
fuzzer=$3
|
fuzzer=$3
|
||||||
|
|
||||||
# Instrument all Go files relevant to this fuzzer
|
# Compile and instrument all Go files relevant to this fuzz target.
|
||||||
go-fuzz -func $function -o $fuzzer.a $path
|
go-fuzz -func $function -o $fuzzer.a $path
|
||||||
|
|
||||||
# Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary
|
# Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary.
|
||||||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o $OUT/$fuzzer
|
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_fuzzer . Fuzz fuzz_json
|
compile_fuzzer . Fuzz fuzz_json
|
||||||
|
|
|
@ -13,23 +13,17 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
function compile_fuzzer {
|
function compile_fuzzer {
|
||||||
fuzzer=$(basename $1)
|
fuzzer=$(basename $1)
|
||||||
|
|
||||||
# Instrument all Go files relevant to this fuzzer, compile and store in $fuzzer.a
|
# Compile and instrument all Go files relevant to this fuzz target.
|
||||||
go-fuzz -o $fuzzer.a github.com/dvyukov/go-fuzz-corpus/$fuzzer
|
go-fuzz -o $fuzzer.a github.com/dvyukov/go-fuzz-corpus/$fuzzer
|
||||||
|
|
||||||
# Instrumented, compiled Go ($fuzzer.a) + libFuzzer = fuzzer binary
|
# Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary.
|
||||||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o fuzzer-$fuzzer
|
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/fuzzer-$fuzzer
|
||||||
|
|
||||||
# Copy the fuzzer binary
|
# Pack the seed corpus
|
||||||
cp fuzzer-$fuzzer $OUT
|
zip -r $OUT/fuzzer-${fuzzer}_seed_corpus.zip \
|
||||||
|
$GOPATH/src/github.com/dvyukov/go-fuzz-corpus/$fuzzer/corpus
|
||||||
# Pack the seed corpus
|
|
||||||
zip -r fuzzer-${fuzzer}_seed_corpus.zip \
|
|
||||||
$GOPATH/src/github.com/dvyukov/go-fuzz-corpus/$fuzzer/corpus
|
|
||||||
|
|
||||||
# Copy the seed corpus
|
|
||||||
cp fuzzer-${fuzzer}_seed_corpus.zip $OUT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export -f compile_fuzzer
|
export -f compile_fuzzer
|
||||||
|
|
|
@ -21,4 +21,4 @@ RUN go get github.com/google/gonids
|
||||||
ADD https://rules.emergingthreats.net/open/suricata/emerging.rules.zip emerging.rules.zip
|
ADD https://rules.emergingthreats.net/open/suricata/emerging.rules.zip emerging.rules.zip
|
||||||
|
|
||||||
COPY build.sh $SRC/
|
COPY build.sh $SRC/
|
||||||
WORKDIR $SRC/
|
WORKDIR $SRC
|
||||||
|
|
|
@ -15,20 +15,19 @@
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# build target function
|
|
||||||
function compile_fuzzer {
|
function compile_fuzzer {
|
||||||
path=$1
|
path=$1
|
||||||
function=$2
|
function=$2
|
||||||
fuzzer=$3
|
fuzzer=$3
|
||||||
|
|
||||||
# Instrument all Go files relevant to this fuzzer
|
# Compile and instrument all Go files relevant to this fuzz target.
|
||||||
go-fuzz -func $function -o $fuzzer.a $path
|
go-fuzz -func $function -o $fuzzer.a $path
|
||||||
|
|
||||||
# Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary
|
# Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary.
|
||||||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o $OUT/$fuzzer
|
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_fuzzer /root/go/src/github.com/google/gonids/ FuzzParseRule fuzz_parserule
|
compile_fuzzer github.com/google/gonids FuzzParseRule fuzz_parserule
|
||||||
|
|
||||||
unzip emerging.rules.zip
|
unzip emerging.rules.zip
|
||||||
cd rules
|
cd rules
|
||||||
|
|
|
@ -20,17 +20,16 @@ set -o pipefail
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
# Based on the function from oss-fuzz/projects/golang/build.sh script.
|
|
||||||
function compile_fuzzer {
|
function compile_fuzzer {
|
||||||
local pkg=$1
|
local pkg=$1
|
||||||
local function=$2
|
local function=$2
|
||||||
local fuzzer="${pkg}_${function}"
|
local fuzzer="${pkg}_${function}"
|
||||||
|
|
||||||
# Instrument all Go files relevant to this fuzzer
|
# Compile and instrument all Go files relevant to this fuzz target.
|
||||||
go-fuzz -func "${function}" -o "${fuzzer}.a" "k8s.io/kubernetes/test/fuzz/${pkg}"
|
go-fuzz -func "${function}" -o "${fuzzer}.a" "k8s.io/kubernetes/test/fuzz/${pkg}"
|
||||||
|
|
||||||
# Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary
|
# Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary.
|
||||||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE "${fuzzer}.a" -lpthread -o "${OUT}/${fuzzer}"
|
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE "${fuzzer}.a" -o "${OUT}/${fuzzer}"
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_fuzzer "yaml" "FuzzDurationStrict"
|
compile_fuzzer "yaml" "FuzzDurationStrict"
|
||||||
|
|
|
@ -15,17 +15,16 @@
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Based on the function from oss-fuzz/projects/golang/build.sh script.
|
|
||||||
function compile_fuzzer {
|
function compile_fuzzer {
|
||||||
path=$1
|
path=$1
|
||||||
function=$2
|
function=$2
|
||||||
fuzzer=$3
|
fuzzer=$3
|
||||||
|
|
||||||
# Instrument all Go files relevant to this fuzzer
|
# Compile and instrument all Go files relevant to this fuzz target.
|
||||||
go-fuzz -func $function -o $fuzzer.a $path
|
go-fuzz -func $function -o $fuzzer.a $path
|
||||||
|
|
||||||
# Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary
|
# Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary.
|
||||||
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o $OUT/$fuzzer
|
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_fuzzer ./pkg/compiler Fuzz compiler_fuzzer
|
compile_fuzzer ./pkg/compiler Fuzz compiler_fuzzer
|
||||||
|
|
Loading…
Reference in New Issue