Skip to content

Commit eb688ae

Browse files
committed
Fix findings of the workflow linters
actionlint, octoscan, poutine and zizmor (auditor persona) now report nothing. - Check out without persisting credentials, except in create-tag, where rickstaa/action-create-tag pushes the tag with the bot token so that the push triggers release.yml - Default every workflow to no permissions and grant each job what it uses - Add concurrency: superseded pull request runs are cancelled, pushes to 2.4.x each keep their own run, and release workflows are queued, not cancelled - Pass matrix.branch and github.ref_name to scripts through env - Name the remaining anonymous jobs - Create the release with gh release create instead of softprops/action-gh-release - Download a pinned actionlint release and verify its checksum instead of piping a script from main into bash - Allow the reviewed actions from unverified creators in .github/poutine.yml and the repository secrets used outside environments in .github/zizmor.yml - Ignore octoscan's dangerous-checkout message: every flagged ref is a fixed branch or commit, and octoscan cannot ignore findings per file Amp-Thread-ID: https://ampcode.com/threads/T-01a197a6-ea3e-77f5-80d6-1bebc3252d55
1 parent af8e840 commit eb688ae

16 files changed

Lines changed: 179 additions & 15 deletions

‎.github/poutine.yml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
skip:
2+
# Actions whose owners are not GitHub verified creators. Each of them is reviewed
3+
# and pinned to a full commit SHA in the workflows that use it.
4+
- rule: github_action_from_unverified_creator_used
5+
purl:
6+
- pkg:githubactions/astral-sh/setup-uv
7+
- pkg:githubactions/cbrgm/mastodon-github-action
8+
- pkg:githubactions/dessant/lock-threads
9+
- pkg:githubactions/eomm/why-don-t-you-tweet
10+
- pkg:githubactions/everlytic/branch-merge
11+
- pkg:githubactions/metcalfc/changelog-generator
12+
- pkg:githubactions/peter-evans/create-pull-request
13+
- pkg:githubactions/rickstaa/action-create-tag
14+
- pkg:githubactions/shivammathur/setup-php
15+
- pkg:githubactions/synacktiv/action-octoscan
16+
- pkg:githubactions/wyrihaximus/github-action-get-previous-tag
17+
- pkg:githubactions/wyrihaximus/github-action-next-semvers

‎.github/workflows/apiref.yml‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
branches:
88
- "2.4.x"
99

10+
permissions: {}
11+
1012
concurrency:
1113
group: "pages"
1214
cancel-in-progress: false
@@ -16,6 +18,9 @@ jobs:
1618
name: "Build API References Pages"
1719
runs-on: "ubuntu-latest"
1820

21+
permissions:
22+
contents: read # for actions/checkout to fetch the code
23+
1924
strategy:
2025
matrix:
2126
branch:
@@ -35,6 +40,7 @@ jobs:
3540
- name: "Checkout"
3641
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3742
with:
43+
persist-credentials: false
3844
ref: ${{ matrix.branch }}
3945

4046
- name: "Install PHP"
@@ -53,7 +59,9 @@ jobs:
5359
run: "composer install --no-interaction --no-progress"
5460

5561
- name: "Run ApiGen"
56-
run: "apigen/vendor/bin/apigen -c apigen/apigen.neon --output docs/${{ matrix.branch }} -- src"
62+
run: 'apigen/vendor/bin/apigen -c apigen/apigen.neon --output "docs/$BRANCH" -- src'
63+
env:
64+
BRANCH: ${{ matrix.branch }}
5765

5866
- name: "Copy favicon"
5967
run: "cp apigen/favicon.png docs/favicon.png"
@@ -87,13 +95,14 @@ jobs:
8795
path: 'docs'
8896

8997
deploy:
98+
name: "Deploy"
9099
needs: merge
91100

92101
# from https://github.com/actions/deploy-pages
93102

94103
permissions:
95-
pages: write
96-
id-token: write
104+
pages: write # for actions/deploy-pages to deploy to GitHub Pages
105+
id-token: write # for actions/deploy-pages to verify the deployment originates from an appropriate source
97106

98107
environment:
99108
name: github-pages

‎.github/workflows/backward-compatibility.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
permissions:
1212
contents: read
1313

14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
16+
cancel-in-progress: true
17+
1418
jobs:
1519
backward-compatibility:
1620
name: "Backward Compatibility"
@@ -27,6 +31,7 @@ jobs:
2731
- name: "Checkout"
2832
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2933
with:
34+
persist-credentials: false
3035
fetch-depth: 0
3136

3237
- name: "Install PHP"

‎.github/workflows/build.yml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
permissions:
1212
contents: read
1313

14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
16+
cancel-in-progress: true
17+
1418
jobs:
1519
lint:
1620
name: "Lint"
@@ -35,6 +39,8 @@ jobs:
3539

3640
- name: "Checkout"
3741
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
42+
with:
43+
persist-credentials: false
3844

3945
- name: "Install PHP"
4046
uses: "shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962" # v2
@@ -64,10 +70,13 @@ jobs:
6470

6571
- name: "Checkout"
6672
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
73+
with:
74+
persist-credentials: false
6775

6876
- name: "Checkout build-cs"
6977
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
7078
with:
79+
persist-credentials: false
7180
repository: "phpstan/build-cs"
7281
path: "build-cs"
7382
ref: "2.x"
@@ -122,6 +131,8 @@ jobs:
122131

123132
- name: "Checkout"
124133
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
134+
with:
135+
persist-credentials: false
125136

126137
- name: "Install PHP"
127138
uses: "shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962" # v2
@@ -159,6 +170,8 @@ jobs:
159170

160171
- name: "Checkout"
161172
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
173+
with:
174+
persist-credentials: false
162175

163176
- name: "Install PHP"
164177
uses: "shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962" # v2
@@ -202,6 +215,8 @@ jobs:
202215

203216
- name: "Checkout"
204217
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
218+
with:
219+
persist-credentials: false
205220

206221
- name: "Install PHP"
207222
uses: "shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962" # v2

‎.github/workflows/create-tag.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,18 @@ on:
1515
- patch
1616
- minor
1717

18+
permissions: {}
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
cancel-in-progress: false
23+
1824
jobs:
1925
create-tag:
2026
name: "Create tag"
2127
runs-on: "ubuntu-latest"
28+
permissions:
29+
contents: read # for actions/checkout to fetch the code; the tag is pushed with PHPSTAN_BOT_TOKEN
2230
steps:
2331
- name: Harden the runner (Audit all outbound calls)
2432
uses: step-security/harden-runner@46b06cea07f9e64621fdf066ba77ac6915163d43 # v2.22.3
@@ -30,6 +38,9 @@ jobs:
3038
with:
3139
fetch-depth: 0
3240
token: ${{ secrets.PHPSTAN_BOT_TOKEN }}
41+
# rickstaa/action-create-tag pushes the tag with these credentials. A tag pushed by
42+
# PHPSTAN_BOT_TOKEN, unlike one pushed by GITHUB_TOKEN, triggers release.yml.
43+
persist-credentials: true # zizmor: ignore[artipacked]
3344

3445
- name: 'Get Previous tag'
3546
id: previoustag

‎.github/workflows/lint-workflows.yml‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ on:
1010

1111
permissions: {}
1212

13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
15+
cancel-in-progress: true
16+
1317
jobs:
1418
actionlint:
19+
name: Actionlint
1520
runs-on: ubuntu-latest
1621
steps:
1722
- name: Harden the runner (Audit all outbound calls)
@@ -20,12 +25,21 @@ jobs:
2025
egress-policy: audit
2126

2227
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
28+
with:
29+
persist-credentials: false
30+
2331
- name: Check workflow files
2432
run: |
2533
echo "::add-matcher::.github/actionlint-matcher.json"
26-
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
27-
./actionlint -color
34+
curl -fsSL -o "$RUNNER_TEMP/actionlint.tar.gz" "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz"
35+
echo "${ACTIONLINT_SHA256} $RUNNER_TEMP/actionlint.tar.gz" | sha256sum --check --strict
36+
tar -xzf "$RUNNER_TEMP/actionlint.tar.gz" -C "$RUNNER_TEMP" actionlint
37+
"$RUNNER_TEMP/actionlint" -color
2838
shell: bash
39+
env:
40+
ACTIONLINT_VERSION: "1.7.12"
41+
# From actionlint_1.7.12_checksums.txt of the release
42+
ACTIONLINT_SHA256: "8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8"
2943

3044
octoscan:
3145
name: Octoscan
@@ -40,11 +54,20 @@ jobs:
4054
egress-policy: audit
4155

4256
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
57+
with:
58+
persist-credentials: false
59+
4360
- name: Run octoscan
4461
id: octoscan
4562
uses: synacktiv/action-octoscan@6b1cf2343893dfb9e5f75652388bd2dc83f456b0 # v1.0.0
4663
with:
4764
filter_triggers: ''
65+
# octoscan treats every ref that is not made of letters and dashes only as custom,
66+
# and our checkouts only use fixed branches and commits of trusted repositories
67+
# (2.3.x, 2.x, a commit SHA, the matrix of our own branches). It cannot ignore
68+
# findings per file, so this message is ignored everywhere. zizmor and poutine
69+
# still check for checkouts of untrusted code.
70+
ignore: "Use of 'actions/checkout' with a custom ref"
4871

4972
- name: Upload SARIF file to GitHub
5073
uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1

‎.github/workflows/lock-closed-issues.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ on:
77
permissions:
88
contents: read
99

10+
concurrency:
11+
group: ${{ github.workflow }}
12+
cancel-in-progress: false
13+
1014
jobs:
1115
lock:
16+
name: Lock closed issues
1217
permissions:
1318
issues: write # for dessant/lock-threads to lock issues
1419
runs-on: ubuntu-latest

‎.github/workflows/merge-maintained-branch.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ on:
77
branches:
88
- "1.22.x"
99

10+
permissions: {}
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: false
15+
1016
jobs:
1117
merge:
1218
name: Merge branch
1319
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read # for actions/checkout to fetch the code; the merge is made with PHPSTAN_BOT_TOKEN
1422
steps:
1523
- name: Harden the runner (Audit all outbound calls)
1624
uses: step-security/harden-runner@46b06cea07f9e64621fdf066ba77ac6915163d43 # v2.22.3
@@ -19,6 +27,8 @@ jobs:
1927

2028
- name: "Checkout"
2129
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
30+
with:
31+
persist-credentials: false
2232
- name: "Merge branch"
2333
uses: everlytic/branch-merge@c4a244dc23143f824ae6c022a10732566cb8e973 # 1.1.5
2434
with:

‎.github/workflows/release-toot.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ on:
66
release:
77
types: [published]
88

9+
permissions: {}
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: false
14+
915
jobs:
1016
toot:
17+
name: Toot release
1118
runs-on: ubuntu-latest
1219
steps:
1320
- name: Harden the runner (Audit all outbound calls)

‎.github/workflows/release-tweet.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ on:
66
release:
77
types: [published]
88

9+
permissions: {}
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: false
14+
915
jobs:
1016
tweet:
17+
name: Tweet release
1118
runs-on: ubuntu-latest
1219
steps:
1320
- name: Harden the runner (Audit all outbound calls)

0 commit comments

Comments
 (0)