Skip to content

Commit 6178da5

Browse files
bo0tzzgithub-actions[bot]
authored andcommitted
feat: static analysis job for gha workflows (immich-app#17688)
* fix: set persist-credentials explicitly for checkout https://woodruffw.github.io/zizmor/audits/#artipacked * fix: minimize permissions scope for workflows https://woodruffw.github.io/zizmor/audits/#excessive-permissions * fix: remove potential template injections https://woodruffw.github.io/zizmor/audits/#template-injection * fix: only pass needed secrets in workflow_call https://woodruffw.github.io/zizmor/audits/#secrets-inherit * fix: push perm for single-arch build jobs I hadn't realised these push to the registry too :x * chore: fix formatting * fix: $ * fix: retag job quoting * feat: static analysis job for gha workflows * chore: fix formatting * fix: clear last zizmor checks * fix: broken merge --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 633ae1b commit 6178da5

File tree

8 files changed

+46
-13
lines changed

8 files changed

+46
-13
lines changed

.github/workflows/docker.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ jobs:
224224
BUILD_SOURCE_COMMIT=${{ github.sha }}
225225
226226
- name: Export digest
227-
run: |
227+
run: | # zizmor: ignore[template-injection]
228228
mkdir -p ${{ runner.temp }}/digests
229229
digest="${{ steps.build.outputs.digest }}"
230230
touch "${{ runner.temp }}/digests/${digest#sha256:}"
@@ -426,7 +426,7 @@ jobs:
426426
BUILD_SOURCE_COMMIT=${{ github.sha }}
427427
428428
- name: Export digest
429-
run: |
429+
run: | # zizmor: ignore[template-injection]
430430
mkdir -p ${{ runner.temp }}/digests
431431
digest="${{ steps.build.outputs.digest }}"
432432
touch "${{ runner.temp }}/digests/${digest#sha256:}"
@@ -535,6 +535,7 @@ jobs:
535535
run: exit 1
536536
- name: All jobs passed or skipped
537537
if: ${{ !(contains(needs.*.result, 'failure')) }}
538+
# zizmor: ignore[template-injection]
538539
run: echo "All jobs passed or skipped" && echo "${{ toJSON(needs.*.result) }}"
539540

540541
success-check-ml:
@@ -549,4 +550,5 @@ jobs:
549550
run: exit 1
550551
- name: All jobs passed or skipped
551552
if: ${{ !(contains(needs.*.result, 'failure')) }}
553+
# zizmor: ignore[template-injection]
552554
run: echo "All jobs passed or skipped" && echo "${{ toJSON(needs.*.result) }}"

.github/workflows/docs-deploy.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Docs deploy
22
on:
3-
workflow_run:
3+
workflow_run: # zizmor: ignore[dangerous-triggers] no attacker inputs are used here
44
workflows: ['Docs build']
55
types:
66
- completed
@@ -115,22 +115,22 @@ jobs:
115115
- name: Load parameters
116116
id: parameters
117117
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
118+
env:
119+
PARAM_JSON: ${{ needs.checks.outputs.parameters }}
118120
with:
119121
script: |
120-
const json = `${{ needs.checks.outputs.parameters }}`;
121-
const parameters = JSON.parse(json);
122+
const parameters = JSON.parse(process.env.PARAM_JSON);
122123
core.setOutput("event", parameters.event);
123124
core.setOutput("name", parameters.name);
124125
core.setOutput("shouldDeploy", parameters.shouldDeploy);
125126
126-
- run: |
127-
echo "Starting docs deployment for ${{ steps.parameters.outputs.event }} ${{ steps.parameters.outputs.name }}"
128-
129127
- name: Download artifact
130128
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
129+
env:
130+
ARTIFACT_JSON: ${{ needs.checks.outputs.artifact }}
131131
with:
132132
script: |
133-
let artifact = ${{ needs.checks.outputs.artifact }};
133+
let artifact = JSON.parse(process.env.ARTIFACT_JSON);
134134
let download = await github.rest.actions.downloadArtifact({
135135
owner: context.repo.owner,
136136
repo: context.repo.repo,

.github/workflows/docs-destroy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Docs destroy
22
on:
3-
pull_request_target:
3+
pull_request_target: # zizmor: ignore[dangerous-triggers] no attacker inputs are used here
44
types: [closed]
55

66
permissions: {}

.github/workflows/pr-label-validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PR Label Validation
22

33
on:
4-
pull_request_target:
4+
pull_request_target: # zizmor: ignore[dangerous-triggers] no attacker inputs are used here
55
types: [opened, labeled, unlabeled, synchronize]
66

77
permissions: {}

.github/workflows/pr-labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: 'Pull Request Labeler'
22
on:
3-
- pull_request_target
3+
- pull_request_target # zizmor: ignore[dangerous-triggers] no attacker inputs are used here
44

55
permissions: {}
66

.github/workflows/prepare-release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ jobs:
4747
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5
4848

4949
- name: Bump version
50-
run: misc/release/pump-version.sh -s "${{ inputs.serverBump }}" -m "${{ inputs.mobileBump }}"
50+
env:
51+
SERVER_BUMP: ${{ inputs.serverBump }}
52+
MOBILE_BUMP: ${{ inputs.mobileBump }}
53+
run: misc/release/pump-version.sh -s "${SERVER_BUMP}" -m "${MOBILE_BUMP}"
5154

5255
- name: Commit and tag
5356
id: push-tag

.github/workflows/static_analysis.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,30 @@ jobs:
9595
- name: Run dart custom_lint
9696
run: dart run custom_lint
9797
working-directory: ./mobile
98+
99+
zizmor:
100+
name: zizmor
101+
runs-on: ubuntu-latest
102+
permissions:
103+
security-events: write
104+
contents: read
105+
actions: read
106+
steps:
107+
- name: Checkout repository
108+
uses: actions/checkout@v4
109+
with:
110+
persist-credentials: false
111+
112+
- name: Install the latest version of uv
113+
uses: astral-sh/setup-uv@v5
114+
115+
- name: Run zizmor 🌈
116+
run: uvx zizmor --format=sarif . > results.sarif
117+
env:
118+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
120+
- name: Upload SARIF file
121+
uses: github/codeql-action/upload-sarif@v3
122+
with:
123+
sarif_file: results.sarif
124+
category: zizmor

.github/workflows/weblate-lock.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ jobs:
5757
run: exit 1
5858
- name: All jobs passed or skipped
5959
if: ${{ !(contains(needs.*.result, 'failure')) }}
60+
# zizmor: ignore[template-injection]
6061
run: echo "All jobs passed or skipped" && echo "${{ toJSON(needs.*.result) }}"

0 commit comments

Comments
 (0)