Skip to content

Commit c2935e0

Browse files
committed
Add verify-govulncheck target and integrate to scan action
1 parent cf7352a commit c2935e0

File tree

5 files changed

+59
-34
lines changed

5 files changed

+59
-34
lines changed

.github/workflows/weekly-image-scan.yaml

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Weekly security scan
2+
3+
on:
4+
schedule:
5+
# Cron for every Monday at 12:00 UTC.
6+
- cron: "0 12 * * 1"
7+
8+
# Remove all permissions from GITHUB_TOKEN except metadata.
9+
permissions: {}
10+
11+
jobs:
12+
scan:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
branch: [ main, release-1.8, release-1.7, release-1.6, release-1.5 ]
17+
name: Trivy
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Check out code
21+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # tag=v3.5.3
22+
with:
23+
ref: ${{ matrix.branch }}
24+
- name: Calculate go version
25+
id: vars
26+
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
27+
- name: Set up Go
28+
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # tag=v4.1.0
29+
with:
30+
go-version: ${{ steps.vars.outputs.go_version }}
31+
- name: Run verify security target
32+
run: make verify-security

Makefile

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

152+
GOVULNCHECK_BIN := govulncheck
153+
GOVULNCHECK_VER := v1.0.0
154+
GOVULNCHECK := $(abspath $(TOOLS_BIN_DIR)/$(GOVULNCHECK_BIN)-$(GOVULNCHECK_VER))
155+
GOVULNCHECK_PKG := golang.org/x/vuln/cmd/govulncheck
156+
152157
GOVC_VER := $(shell cat go.mod | grep "github.com/vmware/govmomi" | awk '{print $$NF}')
153158
GOVC_BIN := govc
154159
GOVC := $(abspath $(TOOLS_BIN_DIR)/$(GOVC_BIN)-$(GOVC_VER))
@@ -381,13 +386,27 @@ verify-boilerplate: ## Verify boilerplate text exists in each file
381386
verify-container-images: ## Verify container images
382387
TRACE=$(TRACE) ./hack/verify-container-images.sh
383388

389+
.PHONY: verify-govulncheck
390+
verify-govulncheck: $(GOVULNCHECK) ## Verify code for vulnerabilities
391+
$(GOVULNCHECK) ./...
392+
393+
.PHONY: verify-security
394+
verify-security: ## Verify code and images for vulnerabilities
395+
$(MAKE) verify-container-images && R1=$$? || R1=$$?; \
396+
$(MAKE) verify-govulncheck && R2=$$? || R2=$$?; \
397+
if [ "$$R1" -ne "0" ] || [ "$$R2" -ne "0" ]; then \
398+
echo "Check for vulnerabilities failed! There are vulnerabilities to be fixed"; \
399+
exit 1; \
400+
fi
401+
384402
.PHONY: verify-flavors
385403
verify-flavors: $(FLAVOR_DIR) generate-flavors ## Verify generated flavors
386404
@if !(git diff --quiet HEAD -- $(FLAVOR_DIR)); then \
387405
git diff $(FLAVOR_DIR); \
388406
echo "flavor files in templates directory are out of date"; exit 1; \
389407
fi
390408

409+
391410
## --------------------------------------
392411
## Build
393412
## --------------------------------------
@@ -727,6 +746,9 @@ $(GINKGO_BIN): $(GINKGO) ## Build a local copy of ginkgo.
727746
.PHONY: $(GOLANGCI_LINT_BIN)
728747
$(GOLANGCI_LINT_BIN): $(GOLANGCI_LINT) ## Build a local copy of golangci-lint.
729748

749+
.PHONY: $(GOVULNCHECK_BIN)
750+
$(GOVULNCHECK_BIN): $(GOVULNCHECK) ## Build a local copy of govulncheck.
751+
730752
.PHONY: $(GOVC_BIN)
731753
$(GOVC_BIN): $(GOVC) ## Build a local copy of govc.
732754

@@ -773,6 +795,9 @@ $(GINKGO): # Build ginkgo.
773795
$(GOLANGCI_LINT): # Build golangci-lint.
774796
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GOLANGCI_LINT_PKG) $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
775797

798+
$(GOVULNCHECK): # Build govulncheck.
799+
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GOVULNCHECK_PKG) $(GOVULNCHECK_BIN) $(GOVULNCHECK_VER)
800+
776801
$(GOVC): # Build GOVC.
777802
CGO_ENABLED=0 GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GOVC_PKG) $(GOVC_BIN) $(GOVC_VER)
778803

docs/release/release-tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ From this point forward changes which should land in the release have to be cher
108108
- Adjust branches: `^main$` => `^release-1.8$`.
109109
5. Remove tests for old release branches if necessary
110110
6. Verify the jobs and dashboards a day later by taking a look at [testgrid](https://testgrid.k8s.io/sig-cluster-lifecycle-cluster-api-provider-vsphere)
111-
7. 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.
111+
7. 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.
112112

113113
## Cut a release
114114

hack/verify-container-images.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ NC='\033[0m' # No
6666

6767
if [ "$R1" -ne "0" ]
6868
then
69-
echo -e "${BRed}Check container images failed! There are vulnerability to be fixed${NC}"
69+
echo -e "${BRed}Check container images failed! There are vulnerabilities to be fixed${NC}"
7070
exit 1
7171
fi
7272

0 commit comments

Comments
 (0)