Skip to content

Commit 1d74b3a

Browse files
committed
fix(ci): resolve zizmor security findings
- set-version action: use GITHUB_OUTPUT instead of GITHUB_ENV to prevent env injection via crafted branch names - dependabot-auto-merge: replace pull_request_target with pull_request and drop unnecessary checkout step - release: move permissions from workflow level to per-job scope; lock workflow-level permissions to empty
1 parent 56b82dd commit 1d74b3a

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

.github/actions/set-version/action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
name: 'Set Version from Branch'
2-
description: 'Sets VERSION environment variable from the current branch name'
2+
description: 'Sets VERSION output from the current branch name'
3+
4+
outputs:
5+
version:
6+
description: 'The version extracted from the branch name'
7+
value: ${{ steps.set-version.outputs.version }}
38

49
runs:
510
using: composite
611
steps:
712
- name: Set version from branch name
13+
id: set-version
814
shell: bash
915
run: |
1016
# GITHUB_HEAD_REF contains the source branch for PRs (e.g., "v1.2.5"), but is empty for pushes
@@ -30,5 +36,5 @@ runs:
3036
exit 1
3137
fi
3238
33-
echo "VERSION=$VERSION" >> $GITHUB_ENV
39+
echo "version=$VERSION" >> $GITHUB_OUTPUT
3440
echo "Using version: $VERSION (from branch: $BRANCH_NAME)"

.github/workflows/dependabot-auto-merge.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Auto merge Dependabot pull requests
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
types:
66
- labeled
77
- opened
@@ -19,11 +19,6 @@ jobs:
1919
runs-on: ubuntu-latest
2020
if: github.event.pull_request.user.login == 'dependabot[bot]'
2121
steps:
22-
- name: Checkout
23-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
24-
with:
25-
persist-credentials: false
26-
2722
- name: Approve
2823
run: gh pr review "$PR_NUMBER" --approve
2924
env:

.github/workflows/release.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ on:
55
branches:
66
- main
77

8-
permissions:
9-
contents: write
10-
issues: write
11-
pull-requests: write
8+
permissions: {}
129

1310
concurrency:
1411
group: release
@@ -18,6 +15,8 @@ jobs:
1815
test:
1916
name: Test
2017
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
2120
steps:
2221
- name: Checkout
2322
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
@@ -48,6 +47,10 @@ jobs:
4847
name: Release
4948
runs-on: ubuntu-latest
5049
needs: test
50+
permissions:
51+
contents: write
52+
issues: write
53+
pull-requests: write
5154
outputs:
5255
release_created: ${{ steps.release.outputs.release_created }}
5356
tag_name: ${{ steps.release.outputs.tag_name }}
@@ -63,6 +66,8 @@ jobs:
6366
runs-on: ubuntu-latest
6467
needs: release
6568
if: ${{ needs.release.outputs.release_created == 'true' }}
69+
permissions:
70+
contents: read
6671
steps:
6772
- name: Checkout
6873
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
@@ -98,6 +103,8 @@ jobs:
98103
runs-on: ubuntu-latest
99104
needs: [build, release]
100105
if: ${{ needs.release.outputs.release_created == 'true' }}
106+
permissions:
107+
contents: write
101108
steps:
102109
- name: Checkout
103110
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
@@ -123,6 +130,7 @@ jobs:
123130
runs-on: ubuntu-latest
124131
needs: [build, release]
125132
if: ${{ needs.release.outputs.release_created == 'true' }}
133+
permissions: {}
126134
steps:
127135
- name: Download VSIX
128136
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
@@ -142,6 +150,7 @@ jobs:
142150
runs-on: ubuntu-latest
143151
needs: [build, release]
144152
if: ${{ needs.release.outputs.release_created == 'true' }}
153+
permissions: {}
145154
steps:
146155
- name: Download VSIX
147156
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0

0 commit comments

Comments
 (0)