diff --git a/go.mod b/go.mod index 9c078cb63..14e0917d2 100644 --- a/go.mod +++ b/go.mod @@ -127,7 +127,7 @@ require ( github.com/rubenv/sql-migrate v1.1.2 // indirect github.com/russross/blackfriday v1.6.0 // indirect github.com/shopspring/decimal v1.2.0 // indirect - github.com/sirupsen/logrus v1.8.1 // indirect + github.com/sirupsen/logrus v1.9.0 // indirect github.com/spf13/cast v1.4.1 // indirect github.com/spf13/cobra v1.6.1 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect diff --git a/go.sum b/go.sum index fa3464b96..648b4cade 100644 --- a/go.sum +++ b/go.sum @@ -556,8 +556,9 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= diff --git a/tests/fuzz/Dockerfile.builder b/tests/fuzz/Dockerfile.builder index 0e8cbaf3e..909571e1c 100644 --- a/tests/fuzz/Dockerfile.builder +++ b/tests/fuzz/Dockerfile.builder @@ -1,6 +1,9 @@ FROM gcr.io/oss-fuzz-base/base-builder-go -COPY ./ $GOPATH/src/github.com/fluxcd/helm-controller/ -COPY ./tests/fuzz/oss_fuzz_build.sh $SRC/build.sh +ENV SRC=$GOPATH/src/github.com/fluxcd/helm-controller +ENV FLUX_CI=true + +COPY ./ $SRC +RUN wget https://raw.githubusercontent.com/google/oss-fuzz/master/projects/fluxcd/build.sh -O $SRC/build.sh WORKDIR $SRC diff --git a/tests/fuzz/oss_fuzz_build.sh b/tests/fuzz/oss_fuzz_build.sh deleted file mode 100755 index d0a645b68..000000000 --- a/tests/fuzz/oss_fuzz_build.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2022 The Flux authors -# -# 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. - -set -euxo pipefail - -# This file aims for: -# - Dynamically discover and build all fuzz tests within the repository. -# - Work for both local make fuzz-smoketest and the upstream oss-fuzz. - -GOPATH="${GOPATH:-/root/go}" -GO_SRC="${GOPATH}/src" -PROJECT_PATH="github.com/fluxcd/helm-controller" - -# install_deps installs all dependencies needed for upstream oss-fuzz. -# Unfortunately we can't pin versions here, as we want to always -# have the latest, so that we can reproduce errors occuring upstream. -install_deps(){ - if ! command -v go-118-fuzz-build &> /dev/null; then - go install github.com/AdamKorcz/go-118-fuzz-build@latest - fi -} - -install_deps - -cd "${GO_SRC}/${PROJECT_PATH}" - -# Ensure any project-specific requirements are catered for ahead of -# the generic build process. -if [ -f "tests/fuzz/oss_fuzz_prebuild.sh" ]; then - tests/fuzz/oss_fuzz_prebuild.sh -fi - -modules=$(find . -mindepth 1 -maxdepth 4 -type f -name 'go.mod' | cut -c 3- | sed 's|/[^/]*$$||' | sort -u | sed 's;/go.mod;;g' | sed 's;go.mod;.;g') - -for module in ${modules}; do - - cd "${GO_SRC}/${PROJECT_PATH}/${module}" - - # TODO: stop ignoring recorder_fuzzer_test.go. Temporary fix for fuzzing building issues. - test_files=$(grep -r --include='**_test.go' --files-with-matches 'func Fuzz' . || echo "") - if [ -z "${test_files}" ]; then - continue - fi - - go get github.com/AdamKorcz/go-118-fuzz-build/testing - - # Iterate through all Go Fuzz targets, compiling each into a fuzzer. - for file in ${test_files}; do - # If the subdir is a module, skip this file, as it will be handled - # at the next iteration of the outer loop. - if [ -f "$(dirname "${file}")/go.mod" ]; then - continue - fi - - targets=$(grep -oP 'func \K(Fuzz\w*)' "${file}") - for target_name in ${targets}; do - # Transform module path into module name (e.g. git/libgit2 to git_libgit2). - module_name=$(echo ${module} | tr / _) - # Compose fuzzer name based on the lowercase version of the func names. - # The module name is added after the fuzz prefix, for better discoverability. - fuzzer_name=$(echo "${target_name}" | tr '[:upper:]' '[:lower:]' | sed "s;fuzz_;fuzz_${module_name}_;g") - target_dir=$(dirname "${file}") - - echo "Building ${file}.${target_name} into ${fuzzer_name}" - compile_native_go_fuzzer "${target_dir}" "${target_name}" "${fuzzer_name}" - done - done -done diff --git a/tests/fuzz/oss_fuzz_run.sh b/tests/fuzz/oss_fuzz_run.sh index 4c87f489b..12912e51a 100755 --- a/tests/fuzz/oss_fuzz_run.sh +++ b/tests/fuzz/oss_fuzz_run.sh @@ -17,4 +17,4 @@ set -euxo pipefail # run each fuzzer once to ensure they are working properly -find /out -type f -name "fuzz*" -exec echo {} -runs=1 \; | bash -e +find /out -type f -iname "fuzz*" -exec echo {} -runs=1 \; | bash -e