From 190f9d0d4b966eb38d1a0b4781c6949f6c5e7e6a Mon Sep 17 00:00:00 2001 From: ArkaSaha30 Date: Mon, 11 Sep 2023 16:16:56 +0530 Subject: [PATCH] Add govulncheck script to expose go vulnerabilities Signed-off-by: ArkaSaha30 --- hack/verify-govulncheck.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 hack/verify-govulncheck.sh diff --git a/hack/verify-govulncheck.sh b/hack/verify-govulncheck.sh new file mode 100755 index 00000000000..5c547becccb --- /dev/null +++ b/hack/verify-govulncheck.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Copyright 2022 The Kubernetes 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 -euo pipefail + +export WORKDIR=${ARTIFACTS:-$TMPDIR} +export PATH=$PATH:$GOPATH/bin +mkdir -p "${WORKDIR}" +pushd "$WORKDIR" +go install golang.org/x/vuln/cmd/govulncheck@v1.0.1 +popd + +govulncheck -scan module ./... > "${WORKDIR}/head.txt" +git reset --hard HEAD +git checkout -b base "${PULL_BASE_SHA}" +govulncheck -scan module ./... > "${WORKDIR}/pr-base.txt" +diff -s -u --ignore-all-space "${WORKDIR}"/pr-base.txt "${WORKDIR}"/head.txt || true