Repository navigation
142 lines (127 loc) · 5.57 KB
/
Copy pathsecurity.yml
File metadata and controls
142 lines (127 loc) · 5.57 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
name: Security
on:
push:
branches: [main]
# Every pull request, not only those targeting main: a stacked pull
# request opened against its parent branch is exactly the one that
# most needs checking, and it was getting none.
pull_request:
schedule:
# Weekly scan on Monday at 6am UTC
- cron: '0 6 * * 1'
workflow_call: # Allow release.yml to invoke the full security suite
workflow_dispatch:
permissions: {}
jobs:
secrets:
name: Secret Scanning
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Install gitleaks
env:
GITLEAKS_VERSION: 8.21.2
# SHA-256 of gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz from the
# release checksums.txt — update alongside GITLEAKS_VERSION. Pinning
# the artifact hash prevents a tampered or swapped release tarball
# from running in CI (supply-chain guard).
GITLEAKS_SHA256: 5bc41815076e6ed6ef8fbecc9d9b75bcae31f39029ceb55da08086315316e3ba
run: |
curl -sSfL -o gitleaks.tar.gz "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
echo "${GITLEAKS_SHA256} gitleaks.tar.gz" | sha256sum -c -
tar -xzf gitleaks.tar.gz gitleaks
sudo install -m 0755 gitleaks /usr/local/bin/gitleaks
- name: Run gitleaks
run: make secrets
trivy:
name: Trivy Security Scan
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Run Trivy vulnerability scanner (filesystem)
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: 'fs'
scan-ref: '.'
severity: 'HIGH,CRITICAL'
exit-code: '1'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
if: always()
continue-on-error: true # Requires GitHub Advanced Security
with:
sarif_file: 'trivy-results.sarif'
gosec:
name: Go Security Checker
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
# SARIF comes from golangci-lint (gosec linter only), not the standalone
# gosec binary, so the Security tab reflects exactly what the required
# Lint gate enforces: the standalone binary can't read `//nolint:gosec`
# suppressions or .golangci.yml gosec excludes, so it perpetually
# reported every accepted site and turned the code-scanning "gosec"
# check red on any PR touching an annotated line. One suppression
# convention, one source of truth. To audit accepted findings:
# `grep -rn 'nolint:gosec'` — justifications are inline at each site.
# --issues-exit-code 0 keeps this job advisory; a real escape still
# fails the required Lint check, and code scanning still alerts on it.
- name: Run gosec (via golangci-lint)
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: v2.11.1 # keep in lockstep with test.yml Lint
args: --enable-only gosec --build-tags dev --issues-exit-code 0 --output.sarif.path gosec-results.sarif
- name: Keep code-scanning tool continuity
run: |
# Rewrite the driver name so this upload supersedes the historical
# standalone-gosec analyses (first main upload closes their alerts as
# "fixed"), and restore per-rule identity: golangci-lint flattens every
# finding to ruleId "gosec", but the G### code leads each message.
jq '.runs[].tool.driver.name = "Golang security checks by gosec"
| .runs[].results[]? |= (.ruleId = ((.message.text // "" | capture("^(?<g>G[0-9]{3}):").g)? // .ruleId))' \
gosec-results.sarif > tmp.sarif && mv tmp.sarif gosec-results.sarif
- name: Upload gosec scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
if: always()
continue-on-error: true # Requires GitHub Advanced Security
with:
sarif_file: 'gosec-results.sarif'
# NOTE: govulncheck runs in test.yml - not duplicated here
dependency-review:
name: Dependency Review
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
continue-on-error: true # Requires GitHub Advanced Security (not available on all plans)
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0