Skip to content

Commit 52c29af

Browse files
Copilotjkowalleckcyclonedx-releases[bot]
authored
chore: add zizmor workflow to harden GitHub Actions security (#968)
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jkowalleck <2765863+jkowalleck@users.noreply.github.com> Co-authored-by: Jan Kowalleck <jan.kowalleck@gmail.com> Co-authored-by: cyclonedx-releases[bot] <275040549+cyclonedx-releases[bot]@users.noreply.github.com>
1 parent 4ef5bc3 commit 52c29af

6 files changed

Lines changed: 83 additions & 10 deletions

File tree

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ updates:
77
schedule:
88
interval: 'weekly'
99
day: 'saturday'
10+
cooldown:
11+
default-days: 7
1012
allow:
1113
- dependency-type: 'all'
1214
versioning-strategy: 'auto'
@@ -21,6 +23,8 @@ updates:
2123
schedule:
2224
interval: 'weekly'
2325
day: 'saturday'
26+
cooldown:
27+
default-days: 7
2428
labels: [ 'dependencies' ]
2529
commit-message:
2630
## prefix maximum string length of 15

.github/workflows/python.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
- name: Checkout
3535
# see https://github.com/actions/checkout
3636
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
37+
with:
38+
persist-credentials: false
3739
- name: Setup Python Environment
3840
# see https://github.com/actions/setup-python
3941
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
@@ -58,6 +60,8 @@ jobs:
5860
- name: Checkout
5961
# see https://github.com/actions/checkout
6062
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
63+
with:
64+
persist-credentials: false
6165
- name: Setup Python Environment
6266
# see https://github.com/actions/setup-python
6367
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
@@ -82,6 +86,8 @@ jobs:
8286
- name: Checkout
8387
# see https://github.com/actions/checkout
8488
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
89+
with:
90+
persist-credentials: false
8591
- name: Setup Python Environment
8692
# see https://github.com/actions/setup-python
8793
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
@@ -106,6 +112,8 @@ jobs:
106112
- name: Checkout
107113
# see https://github.com/actions/checkout
108114
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
115+
with:
116+
persist-credentials: false
109117
- name: Setup Python Environment
110118
# see https://github.com/actions/setup-python
111119
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
@@ -142,6 +150,8 @@ jobs:
142150
- name: Checkout
143151
# see https://github.com/actions/checkout
144152
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
153+
with:
154+
persist-credentials: false
145155
- name: Setup Python Environment
146156
# see https://github.com/actions/setup-python
147157
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
@@ -192,6 +202,8 @@ jobs:
192202
- name: Checkout
193203
# see https://github.com/actions/checkout
194204
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
205+
with:
206+
persist-credentials: false
195207
- name: Create reports directory
196208
run: mkdir ${{ env.REPORTS_DIR }}
197209
- name: Setup Python Environment
@@ -270,6 +282,8 @@ jobs:
270282
- name: Checkout
271283
# see https://github.com/actions/checkout
272284
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
285+
with:
286+
persist-credentials: false
273287
- name: Setup Python Environment
274288
# see https://github.com/actions/setup-python
275289
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6

.github/workflows/release.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ jobs:
4949
- name: Checkout code
5050
# see https://github.com/actions/checkout
5151
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
52+
with:
53+
persist-credentials: false
5254
- name: Setup Python Environment
5355
# see https://github.com/actions/setup-python
5456
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
@@ -71,6 +73,8 @@ jobs:
7173
- name: Checkout code
7274
# see https://github.com/actions/checkout
7375
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
76+
with:
77+
persist-credentials: false
7478
- name: Setup Python Environment
7579
# see https://github.com/actions/setup-python
7680
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
@@ -106,25 +110,27 @@ jobs:
106110
- name: Generate GitHub App Token
107111
id: release-bot-token
108112
# see https://github.com/actions/create-github-app-token
109-
uses: actions/create-github-app-token@v3
113+
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3
110114
with:
111115
# see https://github.com/organizations/CycloneDX/settings/apps/cyclonedx-releases
112-
app-id: 3335294
116+
client-id: 3335294
113117
private-key: ${{ secrets.CDX_RELEASE_BOT_PRIVATE_KEY }}
118+
# for `permission-*` see `permissions` above
119+
permission-contents: write
114120
- name: Get GitHub App User ID
115121
id: release-bot-user-id
116-
run: |
117-
set -xeu
118-
echo "user-id=$(gh api "/users/${{ steps.release-bot-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
119122
env:
123+
APP_SLUG: ${{ steps.release-bot-token.outputs.app-slug }}
120124
GH_TOKEN: ${{ steps.release-bot-token.outputs.token }}
125+
run: echo "user-id=$(gh api "/users/${APP_SLUG}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
121126

122127
- name: Checkout code
123128
# see https://github.com/actions/checkout
124129
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
125130
with:
126131
fetch-depth: 0
127132
token: ${{ steps.release-bot-token.outputs.token }}
133+
persist-credentials: false
128134

129135
- name: Setup python
130136
# see https://github.com/actions/setup-python

.github/workflows/zizmor.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Analyzes all GitHub Actions workflows for security issues using zizmor.
2+
# docs: https://docs.zizmor.sh/
3+
name: Workflow Security Analysis (zizmor)
4+
5+
on:
6+
pull_request:
7+
paths:
8+
- ".github/workflows/**"
9+
push:
10+
paths:
11+
- ".github/workflows/**"
12+
schedule:
13+
# Every Saturday at 00:00 UTC
14+
- cron: "0 0 * * 6"
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
zizmor:
25+
name: zizmor
26+
runs-on: ubuntu-latest
27+
timeout-minutes: 10
28+
steps:
29+
- name: Checkout
30+
# see https://github.com/actions/checkout
31+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
32+
with:
33+
persist-credentials: false
34+
- name: Run zizmor
35+
# see https://github.com/zizmorcore/zizmor-action
36+
uses: zizmorcore/zizmor-action@b1d7e1fb5de872772f31590499237e7cce841e8e # v0.5.3
37+
with:
38+
# advanced-security: false => emit findings as workflow-command annotations (::error file=…) rather than
39+
# uploading a SARIF report to GitHub's Security tab.
40+
# Uploading SARIF requires `security-events: write` and GitHub Advanced Security (GHAS),
41+
# both of which are unnecessary here and would violate the least-privilege policy.
42+
# The two modes are mutually exclusive: advanced-security must be false for
43+
# annotations to take effect.
44+
advanced-security: false
45+
annotations: true

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ repos:
4242
entry: poetry run -- tox r -e bandit
4343
pass_filenames: false
4444
language: system
45+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
46+
rev: v1.24.1
47+
hooks:
48+
- id: zizmor

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,15 @@ exclude_commit_patterns = [
146146
match = "(main|master)"
147147
prerelease = false
148148

149-
[tool.semantic_release.branches."step"]
150-
match = "(build|chore|ci|docs|feat|fix|perf|style|refactor|tests?)"
151-
prerelease = true
152-
prerelease_token = "alpha"
153-
154149
[tool.semantic_release.branches."major-dev"]
155150
match = "(\\d+\\.0\\.0-(dev|rc)|dev/\\d+\\.0\\.0)"
156151
prerelease = true
157152
prerelease_token = "rc"
158153

154+
[tool.semantic_release.branches.fallback]
155+
match = ".*"
156+
prerelease = true
157+
prerelease_token = "alpha"
158+
159159
[tool.deptry]
160160
extend_exclude = ["docs", "examples", "package_aliases", "tools"]

0 commit comments

Comments
 (0)