Skip to content

Commit 0ecfa12

Browse files
committed
build: rewrite format-suggest action to more be more secure
1 parent 02b72bc commit 0ecfa12

1 file changed

Lines changed: 3 additions & 18 deletions

File tree

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
# Workflow derived from https://github.com/posit-dev/setup-air/tree/main/examples
22

33
on:
4-
# Using `pull_request_target` over `pull_request` for elevated `GITHUB_TOKEN`
5-
# privileges, otherwise we can't set `pull-requests: write` when the pull
6-
# request comes from a fork, which is our main use case (external contributors).
7-
#
8-
# `pull_request_target` runs in the context of the target branch (`main`, usually),
9-
# rather than in the context of the pull request like `pull_request` does. Due
10-
# to this, we must explicitly checkout `ref: ${{ github.event.pull_request.head.sha }}`.
11-
# This is typically frowned upon by GitHub, as it exposes you to potentially running
12-
# untrusted code in a context where you have elevated privileges, but they explicitly
13-
# call out the use case of reformatting and committing back / commenting on the PR
14-
# as a situation that should be safe (because we aren't actually running the untrusted
15-
# code, we are just treating it as passive data).
16-
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
17-
pull_request_target:
4+
pull_request:
185

196
name: format-suggest.yaml
207

@@ -28,9 +15,7 @@ jobs:
2815
pull-requests: write
2916

3017
steps:
31-
- uses: actions/checkout@v4
32-
with:
33-
ref: ${{ github.event.pull_request.head.sha }}
18+
- uses: actions/checkout@v6
3419

3520
- name: Install
3621
uses: posit-dev/setup-air@v1
@@ -43,4 +28,4 @@ jobs:
4328
with:
4429
level: error
4530
fail_level: error
46-
tool_name: air
31+
tool_name: air

0 commit comments

Comments
 (0)