From ae83c88a5430859378c420afacd1d43a768831af Mon Sep 17 00:00:00 2001 From: Navidem Date: Sun, 5 Jun 2022 20:31:04 -0500 Subject: [PATCH] Upgrade infra and projects to go1.18 (#7791) * Replace go get with go install in the scritp * Remove go get from projects * Replace gotip with go * Fix CI * Add missing dependency for cryptofuzz --- .../base-images/base-builder/compile_native_go_fuzzer | 2 +- infra/base-images/base-builder/install_go.sh | 11 ++++------- projects/cel-go/Dockerfile | 2 +- projects/cryptofuzz/build.sh | 6 ++---- projects/gcloud-go/Dockerfile | 4 ++-- projects/go-dns/Dockerfile | 4 ++-- projects/golang-protobuf/Dockerfile | 2 +- projects/golang/build.sh | 2 +- projects/gopacket/Dockerfile | 4 ++-- projects/grpc-gateway/build.sh | 2 +- projects/grpc-go/Dockerfile | 4 +++- projects/influxdb/Dockerfile | 4 ++-- projects/kubernetes/Dockerfile | 2 +- 13 files changed, 23 insertions(+), 26 deletions(-) diff --git a/infra/base-images/base-builder/compile_native_go_fuzzer b/infra/base-images/base-builder/compile_native_go_fuzzer index 41721f34a..eee208f46 100755 --- a/infra/base-images/base-builder/compile_native_go_fuzzer +++ b/infra/base-images/base-builder/compile_native_go_fuzzer @@ -58,7 +58,7 @@ function build_native_go_fuzzer() { abspath_repo=`go list -m $tags -f {{.Dir}} $fuzzed_repo || go list $tags -f {{.Dir}} $fuzzed_repo` # give equivalence to absolute paths in another file, as go test -cover uses golangish pkg.Dir echo "s=$fuzzed_repo"="$abspath_repo"= > $OUT/$fuzzer.gocovpath - gotip test -run Test${function}Corpus -v $tags -coverpkg $fuzzed_repo/... -c -o $OUT/$fuzzer $path + go test -run Test${function}Corpus -v $tags -coverpkg $fuzzed_repo/... -c -o $OUT/$fuzzer $path rm ./"${function,,}"_test.go else diff --git a/infra/base-images/base-builder/install_go.sh b/infra/base-images/base-builder/install_go.sh index 101f785b4..2b58598d9 100755 --- a/infra/base-images/base-builder/install_go.sh +++ b/infra/base-images/base-builder/install_go.sh @@ -18,24 +18,21 @@ cd /tmp curl -O https://storage.googleapis.com/golang/getgo/installer_linux chmod +x ./installer_linux -SHELL="bash" ./installer_linux -version=1.17 +SHELL="bash" ./installer_linux -version=1.18 rm -rf ./installer_linux echo 'Set "GOPATH=/root/go"' echo 'Set "PATH=$PATH:/root/.go/bin:$GOPATH/bin"' -go get -u github.com/mdempsky/go114-fuzz-build +go install github.com/mdempsky/go114-fuzz-build@latest ln -s $GOPATH/bin/go114-fuzz-build $GOPATH/bin/go-fuzz -go install golang.org/dl/gotip@latest \ - && gotip download - cd /tmp git clone https://github.com/AdamKorcz/go-118-fuzz-build cd go-118-fuzz-build -gotip build +go build mv go-118-fuzz-build $GOPATH/bin/ cd addimport -gotip build +go build mv addimport $GOPATH/bin/ diff --git a/projects/cel-go/Dockerfile b/projects/cel-go/Dockerfile index cac4a1e49..a3997a080 100644 --- a/projects/cel-go/Dockerfile +++ b/projects/cel-go/Dockerfile @@ -27,7 +27,7 @@ RUN mkdir LPM; \ RUN git clone --depth 1 https://github.com/mdempsky/go114-fuzz-build.git -RUN go get google.golang.org/protobuf/cmd/protoc-gen-go +RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest COPY go-lpm.cc $SRC/ diff --git a/projects/cryptofuzz/build.sh b/projects/cryptofuzz/build.sh index 3332e677d..d3f299edc 100755 --- a/projects/cryptofuzz/build.sh +++ b/projects/cryptofuzz/build.sh @@ -51,10 +51,8 @@ export INCLUDE_PATH_FLAGS="" cd $SRC/cryptofuzz python gen_repository.py -go get golang.org/x/crypto/blake2b -go get golang.org/x/crypto/blake2s -go get golang.org/x/crypto/md4 -go get golang.org/x/crypto/ripemd160 +git clone https://github.com/golang/crypto $GOPATH/src/golang.org/x/crypto +git clone https://github.com/golang/sys.git $GOPATH/src/golang.org/x/sys # This enables runtime checks for C++-specific undefined behaviour. export CXXFLAGS="$CXXFLAGS -D_GLIBCXX_DEBUG" diff --git a/projects/gcloud-go/Dockerfile b/projects/gcloud-go/Dockerfile index fe2f3b253..52904c365 100644 --- a/projects/gcloud-go/Dockerfile +++ b/projects/gcloud-go/Dockerfile @@ -16,6 +16,6 @@ FROM gcr.io/oss-fuzz-base/base-builder-go LABEL maintainer="codyoss@google.com" -RUN go get cloud.google.com/go/spanner +RUN git clone https://github.com/googleapis/google-cloud-go COPY build.sh $SRC/ -WORKDIR $SRC/ +WORKDIR $SRC/google-cloud-go/spanner/ diff --git a/projects/go-dns/Dockerfile b/projects/go-dns/Dockerfile index 3d90e4c3a..af8644fbe 100644 --- a/projects/go-dns/Dockerfile +++ b/projects/go-dns/Dockerfile @@ -16,7 +16,7 @@ #FROM gcr.io/oss-fuzz-base/base-builder-go-codeintelligencetesting FROM gcr.io/oss-fuzz-base/base-builder-go -RUN go get -t github.com/miekg/dns +RUN git clone https://github.com/miekg/dns.git COPY build.sh $SRC/ -WORKDIR $SRC/ +WORKDIR $SRC/dns diff --git a/projects/golang-protobuf/Dockerfile b/projects/golang-protobuf/Dockerfile index 8c7272eb7..fd2a68345 100644 --- a/projects/golang-protobuf/Dockerfile +++ b/projects/golang-protobuf/Dockerfile @@ -19,7 +19,7 @@ FROM gcr.io/oss-fuzz-base/base-builder-go ENV GO111MODULE="on" ENV GOFUZZ111MODULE="on" -RUN go get google.golang.org/protobuf/proto +RUN git clone https://github.com/protocolbuffers/protobuf-go.git RUN git clone https://go.googlesource.com/protobuf $GOPATH/src/google.golang.org/protobuf COPY build.sh $SRC/ WORKDIR $GOPATH/src/google.golang.org/protobuf diff --git a/projects/golang/build.sh b/projects/golang/build.sh index 99868c4ca..b60bb20b6 100755 --- a/projects/golang/build.sh +++ b/projects/golang/build.sh @@ -18,7 +18,7 @@ rm -r parser mkdir math && cp $SRC/math_big_fuzzer.go ./math/ -go get -u golang.org/x/text +git clone https://github.com/golang/text $GOPATH/src/golang.org/x/text mkdir text && cp $SRC/text_fuzzer.go ./text/ go mod init "github.com/dvyukov/go-fuzz-corpus" diff --git a/projects/gopacket/Dockerfile b/projects/gopacket/Dockerfile index 7f6c09a9e..9c67c14a9 100644 --- a/projects/gopacket/Dockerfile +++ b/projects/gopacket/Dockerfile @@ -15,7 +15,7 @@ ################################################################################ FROM gcr.io/oss-fuzz-base/base-builder-go -RUN go get github.com/google/gopacket +RUN git clone https://github.com/google/gopacket.git COPY build.sh $SRC/ -WORKDIR $SRC +WORKDIR $SRC/gopacket diff --git a/projects/grpc-gateway/build.sh b/projects/grpc-gateway/build.sh index 19c4ac5f6..b084b408a 100755 --- a/projects/grpc-gateway/build.sh +++ b/projects/grpc-gateway/build.sh @@ -17,7 +17,7 @@ if [ "$SANITIZER" = "coverage" ] then - go get github.com/grpc-ecosystem/grpc-gateway/... + git clone https://github.com/grpc-ecosystem/grpc-gateway.git compile_go_fuzzer github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule Fuzz fuzz gofuzz else compile_go_fuzzer github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule Fuzz fuzz gofuzz diff --git a/projects/grpc-go/Dockerfile b/projects/grpc-go/Dockerfile index fa10f6d32..f0ab9e3df 100644 --- a/projects/grpc-go/Dockerfile +++ b/projects/grpc-go/Dockerfile @@ -16,7 +16,9 @@ FROM gcr.io/oss-fuzz-base/base-builder-go ENV GO111MODULE=on -RUN go get google.golang.org/protobuf/cmd/protoc-gen-go google.golang.org/grpc/cmd/protoc-gen-go-grpc +RUN git clone https://github.com/protocolbuffers/protobuf-go +RUN git clone https://github.com/grpc/grpc-go + RUN git clone --depth 1 https://github.com/grpc/grpc-go $GOPATH/src/google.golang.org/grpc COPY build.sh fuzz_*.go $SRC/ diff --git a/projects/influxdb/Dockerfile b/projects/influxdb/Dockerfile index d108fe892..2fc40ee29 100644 --- a/projects/influxdb/Dockerfile +++ b/projects/influxdb/Dockerfile @@ -16,8 +16,8 @@ FROM gcr.io/oss-fuzz-base/base-builder-go MAINTAINER william@influxdata.com -RUN go get github.com/influxdata/influxdb -RUN go get github.com/dgrijalva/jwt-go +RUN git clone https://github.com/influxdata/influxdb.git +RUN git clone https://github.com/dgrijalva/jwt-go.git COPY build.sh $SRC/ WORKDIR $SRC/ diff --git a/projects/kubernetes/Dockerfile b/projects/kubernetes/Dockerfile index b9d0c91ba..3a1bc1526 100644 --- a/projects/kubernetes/Dockerfile +++ b/projects/kubernetes/Dockerfile @@ -16,7 +16,7 @@ FROM gcr.io/oss-fuzz-base/base-builder-go -RUN go get github.com/ianlancetaylor/demangle +RUN git clone https://github.com/ianlancetaylor/demangle.git RUN git clone --depth 1 https://github.com/kubernetes/kubernetes.git RUN git clone --depth 1 https://github.com/google/AFL RUN git clone --depth 1 https://github.com/dvyukov/go-fuzz-corpus