Skip to content

Commit d5ae17d

Browse files
authored
Update GoSec workflow to latest version and add token fine-scoped token permissions (#546)
Signed-off-by: Jose R. Gonzalez <[email protected]>
1 parent cd07306 commit d5ae17d

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed
Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run Security Scan
1+
name: GoSec
22

33
on:
44
push:
@@ -9,26 +9,29 @@ on:
99
jobs:
1010
scan:
1111
runs-on: ubuntu-latest
12-
12+
permissions:
13+
# required for all workflows
14+
security-events: write
15+
contents: read
1316
steps:
17+
1418
- name: Checkout repository
1519
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1620
with:
1721
persist-credentials: false
1822

19-
- name: Run Gosec Security Scanner
23+
- name: Security scan
24+
shell: bash
2025
run: |
21-
export PATH=$PATH:$(go env GOPATH)/bin
22-
go install github.com/securego/gosec/v2/cmd/gosec@latest
23-
make gosec
24-
if [[ $? != 0 ]]
25-
then
26-
echo "gosec scanner failed to run "
27-
exit 1
28-
fi
26+
make gosec
27+
if [[ $? != 0 ]]
28+
then
29+
echo "gosec scanner failed to run "
30+
exit 1
31+
fi
2932
3033
- name: Upload SARIF file
31-
uses: github/codeql-action/upload-sarif@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.8
34+
uses: github/codeql-action/upload-sarif@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
3235
if: always()
3336
with:
3437
# Path to SARIF file relative to the root of the repository

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ push-image:
8585

8686
.PHONY: gosec
8787
gosec: install.gosec
88-
$(GOSEC) -no-fail -fmt=sarif -out=gosec.sarif -exclude-dir tests ./...
88+
$(GOSEC) -no-fail -fmt=sarif -out=gosec.sarif -exclude-dir tests --exclude G304 ./...
89+
# excluding rule G304 because hits currently produce an invalid SARIF.
8990

9091
### Python Specific Targets
9192
PY_BIN ?= python3
@@ -147,7 +148,7 @@ venv.tools.always-reinstall:
147148
### Developer Tooling Installation
148149
# gosec
149150
GOSEC = $(shell pwd)/out/gosec
150-
GOSEC_VERSION ?= latest
151+
GOSEC_VERSION ?= 6be2b51fd78feca86af91f5186b7964d76cb1256 # v2.22.10
151152
install.gosec:
152153
$(call go-install-tool,$(GOSEC),github.com/securego/gosec/v2/cmd/gosec@$(GOSEC_VERSION))
153154

0 commit comments

Comments
 (0)