Repository navigation
208 lines (200 loc) · 8.73 KB
/
Copy pathsecurity.yml
File metadata and controls
208 lines (200 loc) · 8.73 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
name: Security
# Supply-chain & secrets gates (#117):
# - gitleaks: scan the full git history for committed secrets (pool creds, the stratum
# access-password from #113, tokens) on every push and PR.
# - zizmor: static-audit the GitHub Actions workflows themselves (template injection,
# over-broad GITHUB_TOKEN, unpinned actions, credential persistence) AND cross-reference the
# actions we pin against the GitHub Advisory Database (online audit).
# Dependabot (github-actions) lives in .github/dependabot.yml; the matching gitleaks pre-commit
# hook lives in .pre-commit-config.yaml.
on:
push:
branches: [main, develop] # develop is the integration branch; main is the release branch
pull_request:
workflow_dispatch: # dispatched onto bot branches (xmrig-bump #225) whose token-created PRs can't self-trigger
inputs:
file_issue:
description: "Also file or close the workflow-audit issue, as the scheduled run does"
type: boolean
default: false
# Re-audit main on a schedule so a newly-published advisory against an action we pin trips the gate
# even during quiet periods with no pushes — the online zizmor audit is time-varying by design.
schedule:
- cron: "0 7 * * 1" # Mondays 07:00 UTC
# Both jobs only read the tree to scan it. Pin the floor to read-only (zizmor: excessive-permissions).
permissions:
contents: read
jobs:
gitleaks:
name: Secret scan (gitleaks)
runs-on: ubuntu-24.04
if: github.event_name != 'schedule'
env:
GITLEAKS_VERSION: "8.30.1"
GITLEAKS_SHA256: "551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: setup_checkout
name: "setup: Checkout"
with:
fetch-depth: 0
persist-credentials: false # zizmor: artipacked
- name: "setup: Install pinned gitleaks"
id: setup_gitleaks
run: |
set -euo pipefail
tarball="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
curl -fsSL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/${tarball}" -o "$tarball"
echo "${GITLEAKS_SHA256} ${tarball}" | sha256sum -c -
tar -xzf "$tarball" gitleaks
sudo install gitleaks /usr/local/bin/gitleaks
gitleaks version
- name: "scan: gitleaks full-history secret scan"
id: scan_gitleaks
run: gitleaks git . --redact --no-banner --verbose
- name: "assert: categorize outcome"
id: assert_categorize
if: always()
env:
CAT_SCAN_GITLEAKS: ${{ steps.scan_gitleaks.outcome }}
CAT_SETUP_CHECKOUT: ${{ steps.setup_checkout.outcome }}
CAT_SETUP_GITLEAKS: ${{ steps.setup_gitleaks.outcome }}
run: bash scripts/ci-categorize.sh "$GITHUB_JOB"
backlog-expiry:
name: Security backlog expiry
if: github.event_name == 'pull_request' && (github.base_ref == 'develop' || startsWith(github.base_ref, 'develop-v'))
runs-on: ubuntu-24.04
permissions:
contents: read
issues: read
pull-requests: read
env:
ENFORCE_FROM: "2026-12-11"
steps:
- name: "setup: checkout"
id: setup_checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false # zizmor: artipacked
- name: "assert: security backlog expiry"
id: assert_backlog_expiry
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE_REF: ${{ github.base_ref }}
HEAD_REF: ${{ github.head_ref }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }}
PR_BODY: ${{ github.event.pull_request.body }}
run: TODAY=$(date -u +%F) bash scripts/security-backlog-expiry.sh
- name: "assert: categorize outcome"
id: assert_categorize
if: always()
env:
CAT_ASSERT_BACKLOG_EXPIRY: ${{ steps.assert_backlog_expiry.outcome }}
CAT_SETUP_CHECKOUT: ${{ steps.setup_checkout.outcome }}
run: bash scripts/ci-categorize.sh "$GITHUB_JOB"
zizmor:
name: Workflow audit (zizmor)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: setup_checkout
name: "setup: Checkout"
with:
persist-credentials: false # zizmor: artipacked
- name: "setup: Install pinned Python CI tools"
id: setup_py_tools
run: |
set -euo pipefail
python3 -m venv "$RUNNER_TEMP/ci-python-tools"
"$RUNNER_TEMP/ci-python-tools/bin/pip" install -r tools/requirements-ci.txt
echo "$RUNNER_TEMP/ci-python-tools/bin" >>"$GITHUB_PATH"
- name: "scan: zizmor workflow audit"
id: scan_zizmor
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: zizmor .github/workflows/
- name: "assert: categorize outcome"
id: assert_categorize
if: always()
env:
CAT_SCAN_ZIZMOR: ${{ steps.scan_zizmor.outcome }}
CAT_SETUP_CHECKOUT: ${{ steps.setup_checkout.outcome }}
CAT_SETUP_PY_TOOLS: ${{ steps.setup_py_tools.outcome }}
run: bash scripts/ci-categorize.sh "$GITHUB_JOB"
zizmor-issue:
name: Workflow audit issue
needs: zizmor
if: ${{ always() && (github.event_name == 'schedule' || inputs.file_issue) && (needs.zizmor.result == 'success' || needs.zizmor.result == 'failure') }}
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: read
issues: write
concurrency:
group: zizmor-issue
cancel-in-progress: false
steps:
- name: "setup: checkout"
id: setup_checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false # zizmor: artipacked
- name: "assert: file or close the zizmor issue"
id: assert_file_issue
env:
GH_TOKEN: ${{ github.token }}
RESULT: ${{ needs.zizmor.result }}
REF_NAME: ${{ github.ref_name }}
run: |
set -Eeuo pipefail
run_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
title="Security: workflow audit failing on ${REF_NAME}"
if [ "$RESULT" = success ]; then
printf 'The workflow audit is clean again: %s\n' "$run_url" >"$RUNNER_TEMP/body.md"
bash scripts/file-security-issue.sh close "$title" "$RUNNER_TEMP/body.md"
exit 0
fi
{
printf '## What'"'"'s the problem\n\nThe scheduled zizmor audit of the workflows failed on %s: %s\n\n' "$REF_NAME" "$run_url"
printf '## What it impacts\n\nA workflow weakness or a newly disclosed advisory against a pinned action, until fixed.\n\n'
printf '## How I found it\n\nThe Monday zizmor re-audit; the findings are in the run log.\n\n'
printf '## How important is it\n\nSecurity: fix within 30 days (expires: %s).\n\n' "$(date -u -d '+30 days' +%F)"
printf '## Acceptance criteria\n\n- The next scheduled zizmor run on %s passes and closes this issue.\n\n' "$REF_NAME"
printf '## Possible solutions\n\nBump the flagged action pin or fix the flagged workflow line.\n'
} >"$RUNNER_TEMP/body.md"
bash scripts/file-security-issue.sh open "$title" "$RUNNER_TEMP/body.md" security-baseline
- name: "assert: categorize outcome"
id: assert_categorize
if: always()
env:
CAT_ASSERT_FILE_ISSUE: ${{ steps.assert_file_issue.outcome }}
CAT_SETUP_CHECKOUT: ${{ steps.setup_checkout.outcome }}
run: bash scripts/ci-categorize.sh "$GITHUB_JOB"
dependency-review:
name: Dependency review
runs-on: ubuntu-24.04
if: github.event_name == 'pull_request'
permissions:
contents: read
steps:
- name: "setup: checkout"
id: setup_checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false # zizmor: artipacked
- name: "scan: dependency review"
id: scan_dependency_review
uses: actions/dependency-review-action@bbc44d14a204704ccc493733616cd1e93a0321ec # v5.0.1
with:
fail-on-severity: high
vulnerability-check: true
license-check: false
comment-summary-in-pr: never
- name: "assert: categorize outcome"
id: assert_categorize
if: always()
env:
CAT_SCAN_DEPENDENCY_REVIEW: ${{ steps.scan_dependency_review.outcome }}
CAT_SETUP_CHECKOUT: ${{ steps.setup_checkout.outcome }}
run: bash scripts/ci-categorize.sh "$GITHUB_JOB"