Skip to content

Commit baa742b

Browse files
🔒️ Add zizmor and fix audit findings (#2260)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 13652b5 commit baa742b

18 files changed

Lines changed: 212 additions & 24 deletions

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ updates:
55
directory: /
66
schedule:
77
interval: daily
8+
cooldown:
9+
default-days: 7
810
commit-message:
911
prefix:
1012
labels: [dependencies, internal]
@@ -13,6 +15,8 @@ updates:
1315
directory: /
1416
schedule:
1517
interval: weekly
18+
cooldown:
19+
default-days: 7
1620
commit-message:
1721
prefix:
1822
labels: [dependencies, internal]
@@ -21,6 +25,8 @@ updates:
2125
directory: /
2226
schedule:
2327
interval: weekly
28+
cooldown:
29+
default-days: 7
2430
commit-message:
2531
prefix:
2632
labels: [dependencies, internal]
@@ -33,6 +39,8 @@ updates:
3339
- /frontend
3440
schedule:
3541
interval: weekly
42+
cooldown:
43+
default-days: 7
3644
commit-message:
3745
prefix:
3846
labels: [dependencies, internal]
@@ -41,6 +49,17 @@ updates:
4149
directory: /
4250
schedule:
4351
interval: weekly
52+
cooldown:
53+
default-days: 7
54+
commit-message:
55+
prefix:
56+
labels: [dependencies, internal]
57+
- package-ecosystem: "pre-commit"
58+
directory: "/"
59+
schedule:
60+
interval: "daily"
61+
cooldown:
62+
default-days: 7
4463
commit-message:
4564
prefix:
4665
labels: [dependencies, internal]
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
name: Add to Project
22

33
on:
4-
pull_request_target:
4+
pull_request_target: # zizmor: ignore[dangerous-triggers]
55
issues:
66
types:
77
- opened
88
- reopened
99

10+
permissions: {}
11+
1012
jobs:
1113
add-to-project:
1214
name: Add to project
1315
runs-on: ubuntu-latest
16+
timeout-minutes: 5
1417
steps:
1518
- uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2
1619
with:
1720
project-url: https://github.com/orgs/fastapi/projects/2
18-
github-token: ${{ secrets.PROJECTS_TOKEN }}
21+
github-token: ${{ secrets.PROJECTS_TOKEN }} # zizmor: ignore[secrets-outside-env]

.github/workflows/deploy-production.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ on:
55
types:
66
- published
77

8+
permissions: {}
9+
810
jobs:
911
deploy:
12+
environment: production
1013
# Do not deploy in the main repository, only in user projects
1114
if: github.repository_owner != 'fastapi'
1215
runs-on:
@@ -28,5 +31,7 @@ jobs:
2831
steps:
2932
- name: Checkout
3033
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+
with:
35+
persist-credentials: false
3136
- run: docker compose -f compose.yml --project-name ${{ secrets.STACK_NAME_PRODUCTION }} build
3237
- run: docker compose -f compose.yml --project-name ${{ secrets.STACK_NAME_PRODUCTION }} up -d

.github/workflows/deploy-staging.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ on:
55
branches:
66
- master
77

8+
permissions: {}
9+
810
jobs:
911
deploy:
12+
environment: staging
1013
# Do not deploy in the main repository, only in user projects
1114
if: github.repository_owner != 'fastapi'
1215
runs-on:
@@ -28,5 +31,7 @@ jobs:
2831
steps:
2932
- name: Checkout
3033
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+
with:
35+
persist-credentials: false
3136
- run: docker compose -f compose.yml --project-name ${{ secrets.STACK_NAME_STAGING }} build
3237
- run: docker compose -f compose.yml --project-name ${{ secrets.STACK_NAME_STAGING }} up -d

.github/workflows/detect-conflicts.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
name: "Conflict detector"
22
on:
33
push:
4-
pull_request_target:
4+
pull_request_target: # zizmor: ignore[dangerous-triggers]
55
types: [synchronize]
66

7+
permissions: {}
8+
79
jobs:
810
main:
911
permissions:
1012
contents: read
1113
pull-requests: write
1214
runs-on: ubuntu-latest
15+
timeout-minutes: 5
1316
steps:
1417
- name: Check if PRs have merge conflicts
1518
uses: eps1lon/actions-label-merge-conflict@1df065ebe6e3310545d4f4c4e862e43bdca146f0 # v3.0.3

.github/workflows/issue-manager.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@ on:
99
issues:
1010
types:
1111
- labeled
12-
pull_request_target:
12+
pull_request_target: # zizmor: ignore[dangerous-triggers]
1313
types:
1414
- labeled
1515
workflow_dispatch:
1616

17-
permissions:
18-
issues: write
19-
pull-requests: write
17+
permissions: {}
2018

2119
jobs:
2220
issue-manager:
2321
if: github.repository_owner == 'fastapi'
2422
runs-on: ubuntu-latest
23+
timeout-minutes: 5
24+
permissions:
25+
issues: write
26+
pull-requests: write
2527
steps:
2628
- name: Dump GitHub context
2729
env:

.github/workflows/labeler.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Labels
22
on:
3-
pull_request_target:
3+
pull_request_target: # zizmor: ignore[dangerous-triggers]
44
types:
55
- opened
66
- synchronize
@@ -9,12 +9,15 @@ on:
99
- labeled
1010
- unlabeled
1111

12+
permissions: {}
13+
1214
jobs:
1315
labeler:
1416
permissions:
1517
contents: read
1618
pull-requests: write
1719
runs-on: ubuntu-latest
20+
timeout-minutes: 5
1821
steps:
1922
- uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.1
2023
if: ${{ github.event.action != 'labeled' && github.event.action != 'unlabeled' }}
@@ -26,6 +29,7 @@ jobs:
2629
permissions:
2730
pull-requests: read
2831
runs-on: ubuntu-latest
32+
timeout-minutes: 5
2933
steps:
3034
- uses: agilepathway/label-checker@c3d16ad512e7cea5961df85ff2486bb774caf3c5 # v1.6.65
3135
with:

.github/workflows/latest-changes.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Latest Changes
22

33
on:
4-
pull_request_target:
4+
pull_request_target: # zizmor: ignore[dangerous-triggers]
55
branches:
66
- master
77
types:
@@ -16,11 +16,15 @@ on:
1616
required: false
1717
default: "false"
1818

19+
permissions: {}
20+
1921
jobs:
2022
latest-changes:
2123
runs-on: ubuntu-latest
24+
timeout-minutes: 5
2225
permissions:
2326
pull-requests: read
27+
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true
2428
steps:
2529
- name: Dump GitHub context
2630
env:
@@ -29,7 +33,8 @@ jobs:
2933
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3034
with:
3135
# To allow latest-changes to commit to the main branch
32-
token: ${{ secrets.LATEST_CHANGES }}
36+
token: ${{ secrets.LATEST_CHANGES }} # zizmor: ignore[secrets-outside-env]
37+
persist-credentials: true # required by tiangolo/latest-changes
3338
- uses: tiangolo/latest-changes@c9d329cb147f0ddf4fb631214e3f838ff17ccbbd # 0.4.1
3439
with:
3540
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/playwright.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ on:
1515
required: false
1616
default: 'false'
1717

18+
permissions: {}
19+
1820
jobs:
1921
changes:
2022
runs-on: ubuntu-latest
23+
timeout-minutes: 5
2124
# Set job outputs to values from filter step
2225
outputs:
2326
changed: ${{ steps.filter.outputs.changed }}
2427
steps:
2528
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
with:
30+
persist-credentials: false
2631
# For pull requests it's not necessary to checkout the code but for the main branch it is
2732
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
2833
id: filter
@@ -39,7 +44,7 @@ jobs:
3944
needs:
4045
- changes
4146
if: ${{ needs.changes.outputs.changed == 'true' }}
42-
timeout-minutes: 60
47+
timeout-minutes: 15
4348
runs-on: ubuntu-latest
4449
strategy:
4550
matrix:
@@ -48,7 +53,11 @@ jobs:
4853
fail-fast: false
4954
steps:
5055
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
51-
- uses: oven-sh/setup-bun@v2
56+
with:
57+
persist-credentials: false
58+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
59+
with:
60+
bun-version: 1.3.12
5261
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
5362
with:
5463
python-version: '3.10'
@@ -58,7 +67,11 @@ jobs:
5867
with:
5968
limit-access-to-actor: true
6069
- name: Install uv
61-
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
70+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
71+
with:
72+
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum.
73+
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837
74+
version: "0.11.4"
6275
- run: uv sync
6376
working-directory: backend
6477
- run: bun ci
@@ -85,9 +98,14 @@ jobs:
8598
# Merge reports after playwright-tests, even if some shards have failed
8699
if: ${{ !cancelled() && needs.changes.outputs.changed == 'true' }}
87100
runs-on: ubuntu-latest
101+
timeout-minutes: 5
88102
steps:
89103
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
90-
- uses: oven-sh/setup-bun@v2
104+
with:
105+
persist-credentials: false
106+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
107+
with:
108+
bun-version: 1.3.12
91109
- name: Install dependencies
92110
run: bun ci
93111
- name: Download blob reports from GitHub Actions Artifacts
@@ -113,6 +131,7 @@ jobs:
113131
needs:
114132
- test-playwright
115133
runs-on: ubuntu-latest
134+
timeout-minutes: 5
116135
steps:
117136
- name: Decide whether the needed jobs succeeded or failed
118137
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2

.github/workflows/pre-commit.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ on:
66
- opened
77
- synchronize
88

9+
permissions: {}
10+
911
env:
1012
# Forks and Dependabot don't have access to secrets
1113
HAS_SECRETS: ${{ secrets.PRE_COMMIT != '' }}
1214

1315
jobs:
1416
pre-commit:
1517
runs-on: ubuntu-latest
18+
timeout-minutes: 5
1619
steps:
1720
- name: Dump GitHub context
1821
env:
@@ -28,7 +31,8 @@ jobs:
2831
# And it needs the full history to be able to compute diffs
2932
fetch-depth: 0
3033
# A token other than the default GITHUB_TOKEN is needed to be able to trigger CI
31-
token: ${{ secrets.PRE_COMMIT }}
34+
token: ${{ secrets.PRE_COMMIT }} # zizmor: ignore[secrets-outside-env]
35+
persist-credentials: true # Required for `git push` command
3236
# pre-commit lite ci needs the default checkout configs to work
3337
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3438
name: Checkout PR for fork
@@ -37,14 +41,20 @@ jobs:
3741
# To be able to commit it needs the head branch of the PR, the remote one
3842
ref: ${{ github.event.pull_request.head.sha }}
3943
fetch-depth: 0
40-
- uses: oven-sh/setup-bun@v2
44+
persist-credentials: false
45+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
46+
with:
47+
bun-version: 1.3.12
4148
- name: Set up Python
4249
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
4350
with:
4451
python-version: "3.11"
4552
- name: Setup uv
46-
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
53+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
4754
with:
55+
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum.
56+
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837
57+
version: "0.11.4"
4858
cache-dependency-glob: |
4959
requirements**.txt
5060
pyproject.toml
@@ -55,7 +65,7 @@ jobs:
5565
run: bun ci
5666
- name: Run prek - pre-commit
5767
id: precommit
58-
run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure
68+
run: uv run prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure
5969
continue-on-error: true
6070
- name: Commit and push changes
6171
if: env.HAS_SECRETS == 'true'
@@ -83,6 +93,7 @@ jobs:
8393
needs:
8494
- pre-commit
8595
runs-on: ubuntu-latest
96+
timeout-minutes: 5
8697
steps:
8798
- name: Dump GitHub context
8899
env:

0 commit comments

Comments
 (0)