-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (136 loc) · 5.17 KB
/
Copy pathsecurity.yml
File metadata and controls
158 lines (136 loc) · 5.17 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
name: security
# Supply-chain and license-policy gate.
# Source of truth lives in quantcli/common; this file is the in-repo copy.
# When updating, propagate the change back to quantcli/common (and the other export-clis).
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
# Default-deny at workflow level; each job re-grants only what it needs.
permissions: {}
jobs:
govulncheck:
name: govulncheck (Go vuln DB)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Detect Go module
id: detect
run: |
if [ -f go.mod ]; then
echo "has_go=true" >> "$GITHUB_OUTPUT"
else
echo "has_go=false" >> "$GITHUB_OUTPUT"
echo "::notice::No go.mod present; skipping govulncheck."
fi
- name: Set up Go
if: steps.detect.outputs.has_go == 'true'
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version-file: go.mod
cache: true
- name: Install govulncheck
if: steps.detect.outputs.has_go == 'true'
run: go install golang.org/x/vuln/cmd/govulncheck@latest
- name: Run govulncheck
if: steps.detect.outputs.has_go == 'true'
run: govulncheck ./...
osv-scanner:
name: osv-scanner (transitive vulns)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Detect Go module
id: detect
run: |
# osv-scanner exits non-zero with "No package sources found" if there is
# nothing to scan. The quantcli org is Go-only today, so gate on go.mod.
# If a non-Go manifest (package.json, requirements.txt, Cargo.toml, …) is
# ever introduced, broaden this check.
if [ -f go.mod ]; then
echo "has_manifests=true" >> "$GITHUB_OUTPUT"
else
echo "has_manifests=false" >> "$GITHUB_OUTPUT"
echo "::notice::No go.mod found; skipping osv-scanner."
fi
- name: Set up Go
if: steps.detect.outputs.has_manifests == 'true'
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version: stable
cache: false
- name: Install osv-scanner
if: steps.detect.outputs.has_manifests == 'true'
run: go install github.com/google/osv-scanner/v2/cmd/osv-scanner@latest
- name: Run osv-scanner
if: steps.detect.outputs.has_manifests == 'true'
run: osv-scanner scan source --recursive .
license-policy:
name: license policy (allowlist)
runs-on: ubuntu-latest
permissions:
contents: read
env:
# Policy: every direct + transitive Go dep must resolve to one of these SPDX ids.
# See quantcli/common SECURITY.md "Supply-chain policy" for the rationale.
ALLOWED_LICENSES: "Apache-2.0,MIT,BSD-2-Clause,BSD-3-Clause,MPL-2.0,ISC,Unlicense"
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Detect Go module
id: detect
run: |
if [ -f go.mod ]; then
echo "has_go=true" >> "$GITHUB_OUTPUT"
else
echo "has_go=false" >> "$GITHUB_OUTPUT"
echo "::notice::No go.mod present; skipping license-policy check."
fi
- name: Set up Go
if: steps.detect.outputs.has_go == 'true'
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version-file: go.mod
cache: true
- name: Install go-licenses
if: steps.detect.outputs.has_go == 'true'
run: go install github.com/google/go-licenses@latest
- name: Check licenses against allowlist
if: steps.detect.outputs.has_go == 'true'
shell: bash
run: |
set -euo pipefail
report=$(mktemp)
# go-licenses csv emits: module,license-url,license-id (one per line).
# Warnings (e.g. license-url not found) go to stderr and are non-fatal here.
go-licenses csv ./... > "$report"
IFS=',' read -ra ALLOWED <<< "$ALLOWED_LICENSES"
is_allowed() {
local needle="$1"
for a in "${ALLOWED[@]}"; do
if [ "$needle" = "$a" ]; then return 0; fi
done
return 1
}
bad=0
while IFS=',' read -r module url license; do
[ -z "$module" ] && continue
if ! is_allowed "$license"; then
echo "::error::Disallowed license: module=$module license=$license"
bad=1
fi
done < "$report"
if [ "$bad" -ne 0 ]; then
echo "::error::License policy violated. Allowlist: ${ALLOWED_LICENSES}"
echo "::error::See quantcli/common SECURITY.md for the policy and how to request an exception."
exit 1
fi
echo "All dependency licenses are within policy."