Skip to content

Commit 63d8e41

Browse files
committed
Fix GitHub Actions workflow linter findings
Address actionlint, octoscan, poutine and zizmor findings: drop persisted checkout credentials, add explicit permissions and concurrency, install actionlint from a checksummed release, avoid template injection, and document intentional exceptions.
1 parent 7d9573b commit 63d8e41

9 files changed

Lines changed: 89 additions & 4 deletions

File tree

‎.github/poutine.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
skip:
2+
# Every third-party action is pinned to a full commit SHA, which is what protects against
3+
# a compromised upstream; whether the publisher is a "verified creator" adds nothing on top.
4+
- rule: github_action_from_unverified_creator_used

‎.github/workflows/build.yml‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
branches:
99
- "2.1.x"
1010

11+
concurrency:
12+
group: build-${{ github.head_ref || github.run_id }} # will be canceled on subsequent pushes in pull requests but not branches
13+
cancel-in-progress: true
14+
1115
permissions:
1216
contents: read
1317

@@ -36,6 +40,8 @@ jobs:
3640

3741
- name: "Checkout"
3842
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
43+
with:
44+
persist-credentials: false
3945

4046
- name: "Install PHP"
4147
uses: "shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962" # v2
@@ -65,10 +71,13 @@ jobs:
6571

6672
- name: "Checkout"
6773
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
74+
with:
75+
persist-credentials: false
6876

6977
- name: "Checkout build-cs"
7078
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
7179
with:
80+
persist-credentials: false
7281
repository: "phpstan/build-cs"
7382
path: "build-cs"
7483
ref: "2.x"
@@ -123,6 +132,8 @@ jobs:
123132

124133
- name: "Checkout"
125134
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
135+
with:
136+
persist-credentials: false
126137

127138
- name: "Install PHP"
128139
uses: "shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962" # v2
@@ -169,6 +180,8 @@ jobs:
169180

170181
- name: "Checkout"
171182
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
183+
with:
184+
persist-credentials: false
172185

173186
- name: "Install PHP"
174187
uses: "shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962" # v2
@@ -203,14 +216,16 @@ jobs:
203216

204217
- name: "Checkout"
205218
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
219+
with:
220+
persist-credentials: false
206221

207222
- name: "Install PHP"
208223
uses: "shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962" # v2
209224
with:
210225
coverage: "none"
211226
php-version: "8.5"
212227

213-
- uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0
228+
- uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # 4.0.0
214229

215230
- name: "Name Collision Detector"
216231
run: "make name-collision"

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ on:
1515
- patch
1616
- minor
1717

18+
concurrency:
19+
group: create-tag
20+
cancel-in-progress: true
21+
22+
permissions:
23+
contents: read
24+
1825
jobs:
1926
create-tag:
2027
name: "Create tag"
@@ -25,7 +32,8 @@ jobs:
2532
with:
2633
egress-policy: audit
2734

28-
- name: "Checkout"
35+
# Credentials must stay persisted: rickstaa/action-create-tag pushes the tag with them
36+
- name: "Checkout" # zizmor: ignore[artipacked]
2937
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3038
with:
3139
fetch-depth: 0

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ on:
88
branches:
99
- "2.1.x"
1010

11+
concurrency:
12+
group: lint-workflows-${{ github.head_ref || github.run_id }} # will be canceled on subsequent pushes in pull requests but not branches
13+
cancel-in-progress: true
14+
1115
permissions: {}
1216

1317
jobs:
1418
actionlint:
19+
name: actionlint
1520
runs-on: ubuntu-latest
1621
steps:
1722
- name: Harden the runner (Audit all outbound calls)
@@ -20,10 +25,18 @@ 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
32+
env:
33+
ACTIONLINT_VERSION: "1.7.12"
34+
ACTIONLINT_SHA256: "8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8"
2435
run: |
2536
echo "::add-matcher::.github/actionlint-matcher.json"
26-
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
37+
curl -fsSL -o actionlint.tar.gz "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz"
38+
echo "${ACTIONLINT_SHA256} actionlint.tar.gz" | sha256sum -c -
39+
tar -xzf actionlint.tar.gz actionlint
2740
./actionlint -color
2841
shell: bash
2942

@@ -40,11 +53,17 @@ jobs:
4053
egress-policy: audit
4154

4255
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
56+
with:
57+
persist-credentials: false
58+
4359
- name: Run octoscan
4460
id: octoscan
4561
uses: synacktiv/action-octoscan@6b1cf2343893dfb9e5f75652388bd2dc83f456b0 # v1.0.0
4662
with:
4763
filter_triggers: ''
64+
# The only custom-ref checkouts are phpstan/build-cs and phpstan/build-infection at fixed branches,
65+
# and the only local action comes from the phpstan/build-infection checkout.
66+
ignore: "Use of 'actions/checkout' with a custom ref|Use of local action .\\./build-infection/"
4867

4968
- name: Upload SARIF file to GitHub
5069
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
@@ -4,11 +4,16 @@ on:
44
schedule:
55
- cron: '1 0 * * *'
66

7+
concurrency:
8+
group: lock-closed-issues
9+
cancel-in-progress: true
10+
711
permissions:
812
contents: read
913

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/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+
concurrency:
10+
group: toot-${{ github.event.release.tag_name }}
11+
cancel-in-progress: true
12+
13+
permissions: {}
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+
concurrency:
10+
group: tweet-${{ github.event.release.tag_name }}
11+
cancel-in-progress: true
12+
13+
permissions: {}
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)

‎.github/workflows/release.yml‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ on:
77
tags:
88
- '*'
99

10+
concurrency:
11+
group: release-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
1017
jobs:
1118
deploy:
1219
name: "Deploy"
@@ -20,14 +27,16 @@ jobs:
2027

2128
- name: "Checkout"
2229
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
30+
with:
31+
persist-credentials: false
2332

2433
- name: Generate changelog
2534
id: changelog
2635
uses: metcalfc/changelog-generator@bb7a08e07e326061351dab6ce89c72f13797043c # v4.9.1
2736
with:
2837
myToken: ${{ secrets.PHPSTAN_BOT_TOKEN }}
2938

30-
- name: "Create release"
39+
- name: "Create release" # zizmor: ignore[superfluous-actions]
3140
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
3241
with:
3342
token: ${{ secrets.PHPSTAN_BOT_TOKEN }}

‎.github/zizmor.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
rules:
2+
secrets-outside-env:
3+
config:
4+
# Repository-level secrets used by release automation; they are not scoped to deployment environments.
5+
allow:
6+
- PHPSTAN_BOT_TOKEN
7+
- MASTODON_ACCESS_TOKEN
8+
- TWITTER_CONSUMER_API_KEY
9+
- TWITTER_CONSUMER_API_SECRET
10+
- TWITTER_ACCESS_TOKEN
11+
- TWITTER_ACCESS_TOKEN_SECRET

0 commit comments

Comments
 (0)