Skip to content

Commit 41827d2

Browse files
committed
build: Add more security scanning.
1 parent 21deae6 commit 41827d2

File tree

7 files changed

+123
-3
lines changed

7 files changed

+123
-3
lines changed

.github/workflows/gosec.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
# This workflow uses actions that are not certified by GitHub. They are provided
3+
# by a third-party and are governed by separate terms of service, privacy
4+
# policy, and support documentation.
5+
6+
name: Run gosec
7+
on:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
branches:
13+
- main
14+
15+
# Declare default permissions as read only.
16+
permissions: read-all
17+
18+
jobs:
19+
gosec_job:
20+
runs-on: ubuntu-latest
21+
name: Run gosec
22+
steps:
23+
- name: Checkout Source
24+
uses: actions/checkout@v4
25+
26+
- name: Run Gosec Security Scanner
27+
uses: securego/gosec@master
28+
with:
29+
args: ./...

.github/workflows/govulncheck.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
# This workflow uses actions that are not certified by GitHub. They are provided
3+
# by a third-party and are governed by separate terms of service, privacy
4+
# policy, and support documentation.
5+
6+
name: Run govulncheck
7+
on:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
branches:
13+
- main
14+
15+
# Declare default permissions as read only.
16+
permissions: read-all
17+
18+
jobs:
19+
govulncheck_job:
20+
runs-on: ubuntu-latest
21+
name: Run govulncheck
22+
steps:
23+
- id: govulncheck
24+
uses: golang/govulncheck-action@v1
25+
with:
26+
check-latest: true

.github/workflows/osv-scanner.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
# This workflow uses actions that are not certified by GitHub. They are provided
3+
# by a third-party and are governed by separate terms of service, privacy
4+
# policy, and support documentation.
5+
6+
name: Run govulncheck
7+
on:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
branches:
13+
- main
14+
15+
# Declare default permissions as read only.
16+
permissions: read-all
17+
18+
jobs:
19+
osv_scanner_job:
20+
runs-on: ubuntu-latest
21+
name: Run osv-scanner
22+
steps:
23+
- name: Checkout Source
24+
uses: actions/checkout@v4
25+
26+
- name: Check dependencies for security vulnerabilities
27+
uses: g-rath/check-with-osv-detector@main

.github/workflows/trufflehog.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
# This workflow uses actions that are not certified by GitHub. They are provided
3+
# by a third-party and are governed by separate terms of service, privacy
4+
# policy, and support documentation.
5+
6+
name: TruffleHog Secrets Scan
7+
on:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
branches:
13+
- main
14+
15+
# Declare default permissions as read only.
16+
permissions: read-all
17+
18+
jobs:
19+
trufflehog_job:
20+
runs-on: ubuntu-latest
21+
name: Run osv-scanner
22+
steps:
23+
- name: Checkout Source
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Check secrets with TruffleHog OSS
29+
uses: trufflesecurity/trufflehog@main
30+
with:
31+
path: ./
32+
head: HEAD
33+
extra_args: --only-verified

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ install-tools-go:
6363
$(GO) install github.com/goph/licensei/cmd/licensei@latest
6464
$(GO) install github.com/orlangure/gocovsh@latest
6565
$(GO) install github.com/pelletier/go-toml/v2/cmd/tomljson@latest
66+
$(GO) install github.com/securego/gosec/v2/cmd/gosec@latest
6667
$(GO) install github.com/trufflesecurity/driftwood@latest
6768
$(GO) install golang.org/x/perf/cmd/benchstat@latest
6869
$(GO) install golang.org/x/tools/cmd/godoc@latest
@@ -213,6 +214,10 @@ vuln:
213214
@ $(ECHO) "\033[1;33m=====> Running osv-scanner (https://osv.dev)...\033[0m"
214215
osv-scanner -r .
215216

217+
@ $(ECHO) " "
218+
@ $(ECHO) "\033[1;33m=====> Running gosec (https://github.com/securego/gosec)...\033[0m"
219+
gosec -terse -tests ./...
220+
216221
.PHONY: secrets
217222
## secrets: [lint]* Checks for verifiable secrets.
218223
secrets:

corefunc/env_ensure_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func BenchmarkEnvEnsure(b *testing.B) {
8080
b.Run(name, func(b *testing.B) {
8181
b.ResetTimer()
8282
for i := 0; i < b.N; i++ {
83-
EnvEnsure(tc.EnvVarName)
83+
_ = EnvEnsure(tc.EnvVarName)
8484
}
8585
})
8686
}
@@ -95,7 +95,7 @@ func BenchmarkEnvEnsureParallel(b *testing.B) {
9595
b.ResetTimer()
9696
b.RunParallel(func(pb *testing.PB) {
9797
for pb.Next() {
98-
EnvEnsure(tc.EnvVarName)
98+
_ = EnvEnsure(tc.EnvVarName)
9999
}
100100
})
101101
})

generator/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func writeFileFromTemplate(varMap map[string]string, templatePath, writePath str
129129

130130
tmpl := newTemplate(templatePath)
131131

132-
f, err := os.Create(writePath) // lint:allow_possible_insecure
132+
f, err := os.Create(writePath) // #nosec G304 -- lint:allow_possible_insecure
133133
if err != nil {
134134
panic(err)
135135
}

0 commit comments

Comments
 (0)