@@ -23,16 +23,19 @@ include $(ROOT_DIR_RELATIVE)/common.mk
23
23
export GO111MODULE =on
24
24
unexport GOPATH
25
25
26
+ # Enables shell script tracing. Enable by running: TRACE=1 make <target>
27
+ TRACE ?= 0
28
+
26
29
# Go
27
30
GO_VERSION ?= 1.23.4
28
31
29
32
# Directories.
30
33
ARTIFACTS ?= $(REPO_ROOT ) /_artifacts
31
34
TOOLS_DIR := hack/tools
35
+ BIN_DIR := bin
32
36
TOOLS_DIR_DEPS := $(TOOLS_DIR ) /go.sum $(TOOLS_DIR ) /go.mod $(TOOLS_DIR ) /Makefile
33
- TOOLS_BIN_DIR := $(TOOLS_DIR ) /bin
37
+ TOOLS_BIN_DIR := $(TOOLS_DIR ) /$( BIN_DIR )
34
38
35
- BIN_DIR := bin
36
39
REPO_ROOT := $(shell git rev-parse --show-toplevel)
37
40
GH_REPO ?= kubernetes-sigs/cluster-api-provider-openstack
38
41
TEST_E2E_DIR := test/e2e
@@ -49,6 +52,13 @@ GO_APIDIFF_VER := v0.8.2
49
52
GO_APIDIFF_BIN := go-apidiff
50
53
GO_APIDIFF_PKG := github.com/joelanford/go-apidiff
51
54
55
+ # govulncheck
56
+ GOVULNCHECK_VER := v1.1.4
57
+ GOVULNCHECK_BIN := govulncheck
58
+ GOVULNCHECK_PKG := golang.org/x/vuln/cmd/govulncheck
59
+
60
+ TRIVY_VER := 0.49.1
61
+
52
62
# Binaries.
53
63
CONTROLLER_GEN := $(TOOLS_BIN_DIR ) /controller-gen
54
64
ENVSUBST := $(TOOLS_BIN_DIR ) /envsubst
@@ -62,6 +72,7 @@ RELEASE_NOTES := $(TOOLS_BIN_DIR)/release-notes
62
72
SETUP_ENVTEST := $(TOOLS_BIN_DIR ) /setup-envtest
63
73
GEN_CRD_API_REFERENCE_DOCS := $(TOOLS_BIN_DIR ) /gen-crd-api-reference-docs
64
74
GO_APIDIFF := $(TOOLS_BIN_DIR ) /$(GO_APIDIFF_BIN ) -$(GO_APIDIFF_VER )
75
+ GOVULNCHECK := $(TOOLS_BIN_DIR ) /$(GOVULNCHECK_BIN ) -$(GOVULNCHECK_VER )
65
76
66
77
# Kubebuilder
67
78
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.28.0
@@ -253,6 +264,12 @@ $(GO_APIDIFF_BIN): $(GO_APIDIFF)
253
264
$(GO_APIDIFF ) : # Build go-apidiff.
254
265
GOBIN=$(abspath $(TOOLS_BIN_DIR ) ) $(GO_INSTALL ) $(GO_APIDIFF_PKG ) $(GO_APIDIFF_BIN ) $(GO_APIDIFF_VER )
255
266
267
+ .PHONY : $(GOVULNCHECK_BIN )
268
+ $(GOVULNCHECK_BIN ) : $(GOVULNCHECK ) # # Build a local copy of govulncheck.
269
+
270
+ $(GOVULNCHECK ) : # Build govulncheck.
271
+ GOBIN=$(abspath $(TOOLS_BIN_DIR ) ) $(GO_INSTALL ) $(GOVULNCHECK_PKG ) $(GOVULNCHECK_BIN ) $(GOVULNCHECK_VER )
272
+
256
273
# # --------------------------------------
257
274
# #@ Linting
258
275
# # --------------------------------------
@@ -549,8 +566,12 @@ clean-temporary: ## Remove all temporary files and folders
549
566
clean-release : # # Remove the release folder
550
567
rm -rf $(RELEASE_DIR )
551
568
569
+ .PHONY : clean-release-git
570
+ clean-release-git : # # Restores the git files usually modified during a release
571
+ git restore ./* manager_image_patch.yaml ./* manager_pull_policy.yaml
572
+
552
573
.PHONY : verify
553
- verify : verify-boilerplate verify-modules verify-gen
574
+ verify : verify-boilerplate verify-modules verify-gen verify-govulncheck
554
575
555
576
.PHONY : verify-boilerplate
556
577
verify-boilerplate :
@@ -570,6 +591,27 @@ verify-gen: generate
570
591
echo " generated files are out of date, run make generate" ; exit 1; \
571
592
fi
572
593
594
+ .PHONY : verify-container-images
595
+ verify-container-images : # # Verify container images
596
+ TRACE=$(TRACE ) ./hack/verify-container-images.sh $(TRIVY_VER )
597
+
598
+ .PHONY : verify-govulncheck
599
+ verify-govulncheck : $(GOVULNCHECK ) # # Verify code for vulnerabilities
600
+ $(GOVULNCHECK ) ./... && R1=$$? || R1=$$? ; \
601
+ $(GOVULNCHECK ) -C " $( TOOLS_DIR) " ./... && R2=$$? || R2=$$? ; \
602
+ if [ " $$ R1" -ne " 0" ] || [ " $$ R2" -ne " 0" ]; then \
603
+ exit 1; \
604
+ fi
605
+
606
+ .PHONY : verify-security
607
+ verify-security : # # Verify code and images for vulnerabilities
608
+ $(MAKE ) verify-container-images && R1=$$? || R1=$$? ; \
609
+ $(MAKE ) verify-govulncheck && R2=$$? || R2=$$? ; \
610
+ if [ " $$ R1" -ne " 0" ] || [ " $$ R2" -ne " 0" ]; then \
611
+ echo " Check for vulnerabilities failed! There are vulnerabilities to be fixed" ; \
612
+ exit 1; \
613
+ fi
614
+
573
615
.PHONY : compile-e2e
574
616
compile-e2e : # # Test e2e compilation
575
617
go test -c -o /dev/null -tags=e2e ./test/e2e/suites/conformance
0 commit comments