Skip to content

Commit

Permalink
Checks: add govulncheck and gosec
Browse files Browse the repository at this point in the history
gosec run G115 is disabled
  • Loading branch information
romainbou committed Nov 14, 2024
1 parent 661575c commit 77572f7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: make get_tools

- name: Run Makefile checks
run: make static_check
run: make checks

tests:
name: Run Go ${{ matrix.go }} tests
Expand Down
30 changes: 26 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ test_gotest:
go clean -testcache
go test -timeout=0 ./...

.PHONY: static_check
static_check: check_tools
.PHONY: checks
checks: check_tools
@echo Checking correct formatting of files

@FMTOUT=$$(go fmt ./...); \
Expand Down Expand Up @@ -43,6 +43,26 @@ static_check: check_tools
echo "$$STATICCHECKOUT";\
false;\
fi

@GOVULNCHECKOUT=$$(govulncheck ./...); \
if echo "$$GOVULNCHECKOUT" | grep -q "No vulnerabilities found"; then\
echo "govulncheck: OK";\
else \
echo "govulncheck:" >&2;\
echo "$$GOVULNCHECKOUT" >&2;\
false;\
fi

# gosec rule G115: Is exluded because there are int->uin64 conversions
# and the rule currently contains false positives
@GOSECOUT=$$(gosec -quiet -exclude=G115 ./...); \
if [ -z "$$GOSECOUT" ]; then\
echo "gosec: OK (excluding G115)";\
else \
echo "gosec: problems in files:";\
echo "$$GOSECOUT";\
false;\
fi

@echo Checking all local changes are committed
go mod tidy
Expand All @@ -52,13 +72,15 @@ static_check: check_tools
test: test_gotest

.PHONY: ci_test
ci_test: static_check test_gotest
ci_test: checks test_gotest

EXECUTABLES = goimports staticcheck
EXECUTABLES = goimports staticcheck govulncheck gosec
.PHONY: get_tools
get_tools:
go install golang.org/x/tools/cmd/goimports@latest
go install honnef.co/go/tools/cmd/staticcheck@2023.1.7
go install golang.org/x/vuln/cmd/govulncheck@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest

.PHONY: check_tools
check_tools:
Expand Down

0 comments on commit 77572f7

Please sign in to comment.