Skip to content

Commit 7de5cc1

Browse files
Split build/commit stages to prevent exfiltration
The commit stage requires access to GITHUB_TOKEN, which has elevated permissions. `npm run build` has the potential to run scripts that execute arbitrary code, so we need to ensure that step does not have access to GITHUB_TOKEN.
1 parent f4fbd44 commit 7de5cc1

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

.github/workflows/compile-dependabot-updates.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@ on:
44
pull_request:
55

66
jobs:
7-
build-dependencies:
7+
build:
88
# PR was opened by Dependabot PR has 'javascript' label
99
if: ${{ github.actor == 'dependabot[bot]' && contains(join(github.event.pull_request.labels.*.name, ','), 'javascript') }}
1010
runs-on: ubuntu-latest
1111
permissions:
12-
contents: write
13-
pull-requests: write
12+
contents: read
1413
steps:
1514
- name: Checkout Pull Request
1615
uses: actions/checkout@v4
17-
with:
18-
token: ${{ secrets.GITHUB_TOKEN }}
19-
persists-credentials: false
2016

2117
- name: Set up Node
2218
uses: actions/setup-node@v4
@@ -30,6 +26,32 @@ jobs:
3026
- name: Build and package
3127
run: npm run all
3228

29+
- name: Upload build artifacts
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: dist
33+
path: dist/
34+
retention-days: 1
35+
36+
commit-artifacts:
37+
needs: build
38+
runs-on: ubuntu-latest
39+
permissions:
40+
contents: write
41+
pull-requests: write
42+
steps:
43+
- name: Checkout Pull Request
44+
uses: actions/checkout@v4
45+
with:
46+
token: ${{ secrets.GITHUB_TOKEN }}
47+
fetch-depth: 0
48+
49+
- name: Download build artifacts
50+
uses: actions/download-artifact@v4
51+
with:
52+
name: dist
53+
path: dist/
54+
3355
- name: Commit and push build artifacts
3456
run: |
3557
git config user.name "github-actions[bot]"

0 commit comments

Comments
 (0)