Skip to content

Commit

Permalink
PR(CI): Fix the vulnerabilities check in a hacky way
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Sep 30, 2024
1 parent adf0c11 commit 0447e55
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
28 changes: 25 additions & 3 deletions .github/workflows/check-vulnerabilities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,32 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Run govulncheck
uses: golang/govulncheck-action@v1
- name: Checkout code into the directory
uses: actions/checkout@v4

- name: Setup Go environment explicitly
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: true
cache: false
go-package: ./...

- name: Install govulncheck
run: make deps:vulncheck

- name: Run govulncheck scan
run: govulncheck -C . -format text ./... | tee govulncheck.txt

- name: Check if only known vulnerabilities were found (there are new vulnerabilities if this fails)
run: cat govulncheck.txt | grep "Your code is affected by 2 vulnerabilities from 1 module."

# Use the steps below once the x/crisis (crisis.init) bug is fixed or if the
# ability to silence is implemented: https://github.com/golang/go/issues/61211
#steps:
# - name: Run govulncheck
# uses: golang/govulncheck-action@v1
# with:
# go-version-file: 'go.mod'
# check-latest: true
# cache: false
# go-package: ./...
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ else
$(info YAML linter 'yamllint' already installed.)
endif

.PHONY: deps\:lint
.PHONY: deps\:vulncheck
deps\:vulncheck:
go install golang.org/x/vuln/cmd/govulncheck@latest

.PHONY: deps\:vulncheck
deps\:lint:
@$(MAKE) deps:lint-go && \
$(MAKE) deps:lint-yaml
Expand Down Expand Up @@ -172,6 +176,7 @@ deps:
$(MAKE) deps:bench && \
$(MAKE) deps:chglog && \
$(MAKE) deps:lint && \
$(MAKE) deps:vulncheck && \
$(MAKE) deps:test && \
$(MAKE) deps:mocks

Expand Down

0 comments on commit 0447e55

Please sign in to comment.