File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,16 @@ ifeq (, $(shell which golangci-lint))
186
186
$(shell curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION))
187
187
endif
188
188
189
+ TRIVY_VERSION = $(shell cd tools/mod && go list -m -f {{.Version}} github.com/aquasecurity/trivy)
190
+ .PHONY : install-trivy
191
+ install-trivy : bin/trivy
192
+ bin/trivy :
193
+ curl -sSfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b ./bin $(TRIVY_VERSION )
194
+
195
+ .PHONY : run-trivy-image-scan
196
+ run-trivy-image-scan : install-trivy
197
+ ./scripts/scan_latest_released_image.sh
198
+
189
199
.PHONY : install-lazyfs
190
200
install-lazyfs : bin/lazyfs
191
201
bin/lazyfs :
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ # Default image registry to use.
6
+ REGISTRY=${REGISTRY:- gcr.io/ etcd-development/ etcd}
7
+
8
+ # Default severity levels to report.
9
+ SEVERITY=${SEVERITY:- HIGH,CRITICAL}
10
+
11
+ source ./scripts/test_lib.sh
12
+
13
+ if ! command -v trivy > /dev/null; then
14
+ log_error " Error: Cannot find trivy. Please follow the installation instructions at: https://trivy.dev/latest/getting-started/"
15
+ exit 1
16
+ fi
17
+
18
+ # Returns the latest tag for the given branch.
19
+ function latest_branch_tag {
20
+ local branch=$1
21
+ local minor=" ${branch# release-} "
22
+
23
+ git -c ' versionsort.suffix=-' \
24
+ ls-remote --exit-code --refs --sort=' version:refname' --tags origin " v${minor} " ' *' \
25
+ | tail --lines=1 \
26
+ | cut --delimiter=' /' --fields=3
27
+ }
28
+
29
+ function main {
30
+ local current_branch
31
+ current_branch=$( git rev-parse --abbrev-ref HEAD)
32
+ if [[ ! " ${current_branch} " =~ ^release-[0-9]+.[0-9]+$ ]]; then
33
+ log_error " Error: This script is intended to be run only on stable release branches (current branch: ${current_branch} )."
34
+ return 1
35
+ fi
36
+
37
+ local latest_tag
38
+ latest_tag=$( latest_branch_tag " $current_branch " )
39
+
40
+ trivy image --severity " ${SEVERITY} " " ${REGISTRY} :${latest_tag} "
41
+ }
42
+
43
+ main
You can’t perform that action at this time.
0 commit comments