Skip to content

Commit 8790a28

Browse files
authored
Merge pull request #105 from crazy-max/zizmor
zizmor workflow
2 parents 6dfebfe + e7ccc69 commit 8790a28

File tree

6 files changed

+121
-4
lines changed

6 files changed

+121
-4
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
version: 2
22
updates:
33
- package-ecosystem: "github-actions"
4-
open-pull-requests-limit: 10
54
directory: "/"
65
schedule:
76
interval: "daily"
7+
cooldown:
8+
default-days: 7
89
labels:
910
- "area/dependencies"
1011
- "bot"
Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,51 @@
11
name: .pr-assign-author
22

3+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
34
permissions:
45
contents: read
56

67
on:
7-
pull_request_target:
8+
pull_request_target: # zizmor: ignore[dangerous-triggers] safe to use without checkout
89
types:
910
- opened
1011
- reopened
1112

1213
jobs:
13-
run:
14-
uses: crazy-max/.github/.github/workflows/pr-assign-author.yml@1b673f36fad86812f538c1df9794904038a23cbf
14+
assign-author:
15+
runs-on: ubuntu-24.04
1516
permissions:
1617
contents: read
1718
pull-requests: write
19+
steps:
20+
-
21+
name: Assigning author to PR
22+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
23+
with:
24+
script: |
25+
try {
26+
const dt = context.payload?.pull_request;
27+
if (!dt) {
28+
throw new Error(`No pull request payload found, skipping.`);
29+
}
30+
31+
const { assignees, number, user: { login: author, type } } = dt;
32+
if (assignees.length > 0) {
33+
throw new Error(`Pull request is already assigned to someone, skipping.`);
34+
} else if (type !== 'User') {
35+
throw new Error(`Not a user, skipping.`);
36+
}
37+
38+
const respAdd = await github.rest.issues.addAssignees({
39+
...context.repo,
40+
issue_number: number,
41+
assignees: [author]
42+
});
43+
core.debug(`addAssignees resp: ${JSON.stringify(respAdd, null, 2)}`);
44+
if (respAdd.status !== 201) {
45+
throw new Error(`Failed to assign @${author} to the pull request #${number}.`);
46+
}
47+
48+
core.info(`@${author} has been assigned to the pull request #${number}`);
49+
} catch (e) {
50+
core.warning(e.message);
51+
}

.github/workflows/.test-bake.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: .test-bake
22

3+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
4+
permissions:
5+
contents: read
6+
37
concurrency:
48
group: ${{ github.workflow }}-${{ github.ref }}
59
cancel-in-progress: true

.github/workflows/.test-build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: .test-build
22

3+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
4+
permissions:
5+
contents: read
6+
37
concurrency:
48
group: ${{ github.workflow }}-${{ github.ref }}
59
cancel-in-progress: true

.github/workflows/.zizmor.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: .zizmor
2+
3+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
4+
permissions:
5+
contents: read
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
on:
12+
workflow_dispatch:
13+
push:
14+
branches:
15+
- 'main'
16+
- 'releases/v*'
17+
pull_request:
18+
19+
env:
20+
ZIZMOR_VERSION: 1.22.0 # https://github.com/zizmorcore/zizmor
21+
22+
jobs:
23+
zizmor:
24+
runs-on: ubuntu-24.04
25+
permissions:
26+
contents: read
27+
security-events: write
28+
env:
29+
TMPDIR: /tmp/zizmor
30+
steps:
31+
-
32+
name: Checkout
33+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+
with:
35+
persist-credentials: false
36+
-
37+
name: Setup uv
38+
uses: astral-sh/setup-uv@803947b9bd8e9f986429fa0c5a41c367cd732b41 # v7.2.1
39+
with:
40+
enable-cache: false
41+
-
42+
name: Install zizmor
43+
run: |
44+
set -ex
45+
uv tool install zizmor@${ZIZMOR_VERSION}
46+
-
47+
name: Run zizmor
48+
id: zizmor
49+
run: |
50+
mkdir -p ${TMPDIR}
51+
set -ex
52+
zizmor --min-severity=medium --min-confidence=medium --persona=pedantic --no-online-audits --format=sarif . > ${TMPDIR}/zizmor.sarif
53+
env:
54+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
-
56+
name: Zizmor crash report
57+
if: ${{ failure() && steps.zizmor.conclusion == 'failure' }}
58+
run: |
59+
cat ${TMPDIR}/report-*.toml
60+
-
61+
name: Upload SARIF report
62+
uses: github/codeql-action/upload-sarif@6bc82e05fd0ea64601dd4b465378bbcf57de0314 # v4.32.1
63+
with:
64+
sarif_file: ${{ env.TMPDIR }}/zizmor.sarif
65+
category: zizmor

.github/zizmor.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
rules:
2+
# rule does not apply to reusable worfklows where permissions are defined by
3+
# the caller workflow and not the reusable workflow itself: https://github.com/docker/github-builder/issues/24
4+
# https://docs.zizmor.sh/audits/#excessive-permissions
5+
excessive-permissions:
6+
ignore:
7+
- bake.yml
8+
- build.yml
9+
- verify.yml

0 commit comments

Comments
 (0)