Skip to content

Commit 742571c

Browse files
committed
Add verify-govulncheck and verify-vulnerabilities targets and integrate to scan action
1 parent 88f495b commit 742571c

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

.github/workflows/weekly-image-scan.yaml renamed to .github/workflows/weekly-security-scan.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Weekly image scan
1+
name: Weekly security scan
22

33
on:
44
schedule:
@@ -28,5 +28,5 @@ jobs:
2828
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # tag=v4.0.1
2929
with:
3030
go-version: ${{ steps.vars.outputs.go_version }}
31-
- name: Run verify container script
32-
run: make verify-container-images
31+
- name: Run verify security target
32+
run: make verify-security

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ GOLANGCI_LINT_VER := $(shell cat .github/workflows/pr-golangci-lint.yaml | grep
164164
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER))
165165
GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
166166

167+
GOVULNCHECK_BIN := govulncheck
168+
GOVULNCHECK_VER := v1.0.0
169+
GOVULNCHECK := $(abspath $(TOOLS_BIN_DIR)/$(GOVULNCHECK_BIN)-$(GOVULNCHECK_VER))
170+
GOVULNCHECK_PKG := golang.org/x/vuln/cmd/govulncheck
171+
167172
CONVERSION_VERIFIER_BIN := conversion-verifier
168173
CONVERSION_VERIFIER := $(abspath $(TOOLS_BIN_DIR)/$(CONVERSION_VERIFIER_BIN))
169174

@@ -653,6 +658,24 @@ verify-tiltfile: ## Verify Tiltfile format
653658
verify-container-images: ## Verify container images
654659
TRACE=$(TRACE) ./hack/verify-container-images.sh
655660

661+
.PHONY: verify-govulncheck
662+
verify-govulncheck: $(GOVULNCHECK) ## Verify code for vulnerabilities
663+
$(GOVULNCHECK) ./... && R1=$$? || R1=$$?; \
664+
$(GOVULNCHECK) -C "$(TOOLS_DIR)" ./... && R2=$$? || R2=$$?; \
665+
$(GOVULNCHECK) -C "$(TEST_DIR)" ./... && R3=$$? || R3=$$?; \
666+
if [ "$$R1" -ne "0" ] || [ "$$R2" -ne "0" ] || [ "$$R3" -ne "0" ]; then \
667+
exit 1; \
668+
fi
669+
670+
.PHONY: verify-security
671+
verify-security: ## Verify code and images for vulnerabilities
672+
$(MAKE) verify-container-images && R1=$$? || R1=$$?; \
673+
$(MAKE) verify-govulncheck && R2=$$? || R2=$$?; \
674+
if [ "$$R1" -ne "0" ] || [ "$$R2" -ne "0" ]; then \
675+
echo "Check for vulnerabilities failed! There are vulnerability to be fixed"; \
676+
exit 1; \
677+
fi
678+
656679
## --------------------------------------
657680
## Binaries
658681
## --------------------------------------
@@ -1249,6 +1272,9 @@ $(GINKGO_BIN): $(GINKGO) ## Build a local copy of ginkgo.
12491272
.PHONY: $(GOLANGCI_LINT_BIN)
12501273
$(GOLANGCI_LINT_BIN): $(GOLANGCI_LINT) ## Build a local copy of golangci-lint.
12511274

1275+
.PHONY: $(GOVULNCHECK_BIN)
1276+
$(GOVULNCHECK_BIN): $(GOVULNCHECK) ## Build a local copy of govulncheck.
1277+
12521278
$(CONTROLLER_GEN): # Build controller-gen from tools folder.
12531279
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(CONTROLLER_GEN_PKG) $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER)
12541280

@@ -1300,6 +1326,9 @@ $(GINKGO): # Build ginkgo from tools folder.
13001326
$(GOLANGCI_LINT): # Build golangci-lint from tools folder.
13011327
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GOLANGCI_LINT_PKG) $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
13021328

1329+
$(GOVULNCHECK): # Build govulncheck.
1330+
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GOVULNCHECK_PKG) $(GOVULNCHECK_BIN) $(GOVULNCHECK_VER)
1331+
13031332
## --------------------------------------
13041333
## Helpers
13051334
## --------------------------------------

docs/release/release-tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ While we add test coverage for the new release branch we will also drop the test
426426
3. Remove tests for old release branches according to our policy documented in [Support and guarantees](../../CONTRIBUTING.md#support-and-guarantees)
427427
For example, let's assume we just created tests for v1.4, then we can now drop test coverage for the release-1.1 branch.
428428
4. Verify the jobs and dashboards a day later by taking a look at: `https://testgrid.k8s.io/sig-cluster-lifecycle-cluster-api-1.4`
429-
5. Update `.github/workflows/weekly-image-scan.yaml` - to setup Trivy scanning - `.github/workflows/weekly-md-link-check.yaml` - to setup link checking in the CAPI book - and `.github/workflows/weekly-test-release.yaml` - to verify the release target is working - for the currently supported branches.
429+
5. Update `.github/workflows/weekly-security-scan.yaml` - to setup Trivy and govulncheck scanning - `.github/workflows/weekly-md-link-check.yaml` - to setup link checking in the CAPI book - and `.github/workflows/weekly-test-release.yaml` - to verify the release target is working - for the currently supported branches.
430430
431431
432432
Prior art:

0 commit comments

Comments
 (0)