-
Notifications
You must be signed in to change notification settings - Fork 51
220 lines (194 loc) · 6.81 KB
/
security.yml
File metadata and controls
220 lines (194 loc) · 6.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# Copyright 2026 Phillip Cloud
# Licensed under the Apache License, Version 2.0
name: Security
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
changes:
name: Detect Changes
runs-on: blacksmith-2vcpu-ubuntu-2404
outputs:
go: ${{ steps.detect.outputs.go }}
ci: ${{ steps.detect.outputs.ci }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
deploy-on-self-hosted-vm: true
egress-policy: block
disable-telemetry: true
disable-sudo-and-containers: true
allowed-endpoints: >
api.github.com:443
github.com:443
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
sparse-checkout: .github/detect-ci-changes.bash
sparse-checkout-cone-mode: false
persist-credentials: false
- name: Check for changes
id: detect
env:
GH_TOKEN: ${{ github.token }}
EVENT_NAME: ${{ github.event_name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
BEFORE_SHA: ${{ github.event.before }}
HEAD_SHA: ${{ github.sha }}
run: |
bash .github/detect-ci-changes.bash \
"$EVENT_NAME" "$PR_NUMBER" "$BEFORE_SHA" "$HEAD_SHA" >> "$GITHUB_OUTPUT"
govulncheck:
name: Vulnerability Check
needs: changes
if: needs.changes.outputs.go == 'true'
runs-on: blacksmith-4vcpu-ubuntu-2404
concurrency:
group: security-govulncheck-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
deploy-on-self-hosted-vm: true
egress-policy: block
disable-telemetry: true
allowed-endpoints: >
api.github.com:443
cache.nixos.org:443
github.com:443
proxy.golang.org:443
releases.nixos.org:443
storage.googleapis.com:443
vuln.go.dev:443
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- uses: cachix/install-nix-action@ab739621df7a23f52766f9ccc97f38da6b7af14f # v31.10.5
- name: Run govulncheck
run: nix run '.#govulncheck'
osv-scanner:
name: OSV Scan
needs: changes
if: needs.changes.outputs.go == 'true'
runs-on: blacksmith-4vcpu-ubuntu-2404
concurrency:
group: security-osv-scanner-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CGO_ENABLED: "0"
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
deploy-on-self-hosted-vm: true
egress-policy: block
disable-telemetry: true
disable-sudo-and-containers: true
allowed-endpoints: >
api.github.com:443
api.osv.dev:443
github.com:443
proxy.golang.org:443
release-assets.githubusercontent.com:443
storage.googleapis.com:443
sum.golang.org:443
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.26"
- name: Install osv-scanner
run: go install github.com/google/osv-scanner/v2/cmd/osv-scanner@v2.3.5
- name: Run osv-scanner
run: osv-scanner scan --config osv-scanner.toml --no-ignore --no-call-analysis=go --recursive .
secrets:
name: Secret Scan
needs: changes
if: needs.changes.outputs.ci == 'true'
runs-on: blacksmith-4vcpu-ubuntu-2404
concurrency:
group: security-secrets-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
deploy-on-self-hosted-vm: true
egress-policy: block
disable-telemetry: true
allowed-endpoints: >
ghcr.io:443
github.com:443
pkg-containers.githubusercontent.com:443
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
persist-credentials: false
- uses: trufflesecurity/trufflehog@17456f8c7d042d8c82c9a8ca9e937231f9f42e26 # v3.95.2
with:
extra_args: --only-verified
codeql:
name: CodeQL (Go)
needs: changes
if: needs.changes.outputs.go == 'true'
runs-on: blacksmith-4vcpu-ubuntu-2404
concurrency:
group: security-codeql-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
security-events: write
env:
CGO_ENABLED: "0"
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
deploy-on-self-hosted-vm: true
egress-policy: block
disable-telemetry: true
disable-sudo-and-containers: true
allowed-endpoints: >
api.github.com:443
github.com:443
proxy.golang.org:443
release-assets.githubusercontent.com:443
storage.googleapis.com:443
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.26"
- name: Initialize CodeQL
uses: github/codeql-action/init@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
with:
languages: go
build-mode: manual
- name: Build
run: go build ./...
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
result:
name: Security Result
if: always()
needs: [changes, govulncheck, osv-scanner, secrets, codeql]
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: block
disable-telemetry: true
disable-sudo-and-containers: true
allowed-endpoints: >
api.github.com:443
github.com:443
- run: exit 1
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')