Repository navigation
143 lines (124 loc) · 5.62 KB
/
Copy pathaudit.yml
File metadata and controls
143 lines (124 loc) · 5.62 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
name: Audit
# Publishes the objective, third-party signals that back AUDIT.md/audit/claims.yaml
# (OpenSSF Scorecard + SBOM), and re-runs the deterministic half of claims.yaml as a
# CI gate so a claim silently going false (a new Postgres/MySQL/Redis dependency, a
# real vulnerability, a leaked secret) fails the build instead of quietly rotting.
# This is separate from ci.yml (build/test) — audit signal, not correctness.
on:
push:
branches: [main]
# Also on pull requests. Without this the Go stdlib CVE that broke the
# clean-security-scan claim sat undetected until it was already on main,
# because this workflow only ran on push, weekly, and manually. The scan is
# cheap and catches that class before merge instead of after.
pull_request:
schedule:
- cron: '20 6 * * 1' # weekly, Monday — catches newly-disclosed CVEs even with no code changes
workflow_dispatch:
# Read the repository and nothing else. The SBOM and claims-guard jobs only
# check out code and upload a workflow artifact; the Scorecard job sets its
# own grants below.
permissions:
contents: read
jobs:
scorecard:
name: OpenSSF Scorecard
# Scorecard refuses any ref but the default branch ("Only the default branch
# main is supported"), so running it on a PR or a workflow_dispatch against a
# feature branch produced a red run that meant nothing and buried the real
# result from the claims guard. Schedule and push-to-main still cover it.
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
security-events: write
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# The floating v2 tag no longer resolves upstream, so this is pinned to a
# commit, per Scorecard's own pinned-deps recommendation.
- uses: ossf/scorecard-action@2d1146689b8cda280b9bc96326124645441f03bc # v2.4.4
with:
results_file: results.sarif
results_format: sarif
publish_results: true
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: scorecard-sarif
path: results.sarif
retention-days: 30
- uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
with:
sarif_file: results.sarif
sbom:
name: SBOM (syft)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: anchore/sbom-action@66cbf4bc1f1c0d2edc94016e65bc221b6bb0ad6c # v0.24.3
with:
path: .
format: cyclonedx-json
output-file: calnode-sbom.cdx.json
artifact-name: calnode-sbom.cdx.json
claims-guard:
name: Deterministic claims guard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # gitleaks needs full history
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
with:
version: 10.32.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 26
cache: pnpm
cache-dependency-path: frontend/pnpm-lock.yaml
- name: Install frontend deps
working-directory: frontend
run: pnpm install --frozen-lockfile
- name: Build frontend (required by the Go embed, same as ci.yml)
working-directory: frontend
run: pnpm build
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
- name: No server-DB driver (single-binary-no-server-db claim)
run: |
if grep -iE 'postgres|mysql|redis' go.mod; then
echo "::error::go.mod pulled in a server DB driver — this breaks the single-binary claim in audit/claims.yaml"
exit 1
fi
- name: No tenant/workspace column (instance-per-tenant-isolation claim)
run: |
if grep -rl 'tenant_id\|workspace_id' internal/db/migrations/*.sql; then
echo "::error::a tenant/workspace column appeared — re-check the instance-per-tenant claim in audit/claims.yaml"
exit 1
fi
# The three scanners below are installed at fixed versions rather than
# @latest, so a run is reproducible and a new release cannot change the
# gate unannounced. Dependabot does not see `go install` lines, so these
# are bumped by hand. govulncheck reads the live vulnerability database
# on every run whatever its own version, so pinning it does not freeze
# what it knows about.
- name: govulncheck (clean-security-scan claim)
run: |
go install golang.org/x/vuln/cmd/govulncheck@v1.9.0
govulncheck ./...
- name: gosec (clean-security-scan claim — AUDIT.md says every finding is annotated)
run: |
go install github.com/securego/gosec/v2/cmd/gosec@v2.30.0
gosec ./...
- name: gitleaks (clean-security-scan claim)
# gitleaks/gitleaks-action@v2 now requires a paid GITLEAKS_LICENSE for
# organization repos ("Calnode" is one) — the underlying CLI is still
# free/open-source (MIT), so install and run it directly instead, the
# same way govulncheck/gosec above do, and the same invocation AUDIT.md
# documents for a local run.
run: |
go install github.com/zricethezav/gitleaks/v8@v8.30.1
gitleaks detect --source . --no-banner -v