Skip to content

Commit 770acd6

Browse files
authored
GitHub Workflows security hardening (#3751)
1 parent 84797fb commit 770acd6

File tree

7 files changed

+27
-0
lines changed

7 files changed

+27
-0
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: CI
22
on: workflow_call
3+
permissions:
4+
contents: read
35
jobs:
46
lint:
57
name: Lint source files
@@ -158,6 +160,7 @@ jobs:
158160
name: Run CodeQL security scan
159161
runs-on: ubuntu-latest
160162
permissions:
163+
contents: read
161164
security-events: write
162165
steps:
163166
- name: Checkout repo

.github/workflows/cmd-publish-pr-on-npm.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010
npm_canary_pr_publish_token:
1111
description: NPM token to publish canary release.
1212
required: true
13+
permissions:
14+
contents: read
1315
jobs:
1416
build-npm-dist:
1517
runs-on: ubuntu-latest

.github/workflows/cmd-run-benchmark.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
description: String that contain JSON payload for `pull_request` event.
77
required: true
88
type: string
9+
permissions:
10+
contents: read # for checkout
11+
actions: read # to list workflow runs
912
jobs:
1013
benchmark:
1114
name: Run benchmark

.github/workflows/deploy-artifact-as-branch.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ on:
1818
description: Commit message
1919
required: true
2020
type: string
21+
permissions: {}
2122
jobs:
2223
deploy-artifact-as-branch:
24+
permissions:
25+
contents: write # to push branch
2326
environment:
2427
name: ${{ inputs.environment }}
2528
url: ${{ github.server_url }}/${{ github.repository }}/tree/${{ inputs.target_branch }}

.github/workflows/github-actions-bot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ env:
2121
* `@github-actions run-benchmark` - Run benchmark comparing base and merge commits for this PR
2222
* `@github-actions publish-pr-on-npm` - Build package from this PR and publish it on NPM
2323
</details>
24+
permissions: {}
2425
jobs:
2526
hello-message:
27+
permissions:
28+
actions: read # to download event.json
29+
pull-requests: write # to add comment to pull request
30+
2631
if: github.event_name == 'workflow_run'
2732
runs-on: ubuntu-latest
2833
steps:
@@ -49,6 +54,9 @@ jobs:
4954
})
5055
5156
accept-cmd:
57+
permissions:
58+
pull-requests: write # to add comment to pull request
59+
5260
if: |
5361
github.event_name == 'issue_comment' &&
5462
github.event.issue.pull_request &&
@@ -95,6 +103,9 @@ jobs:
95103
pull_request_json: ${{ needs.accept-cmd.outputs.pull_request_json }}
96104

97105
respond-to-cmd:
106+
permissions:
107+
pull-requests: write # to add comment to pull request
108+
98109
needs:
99110
- accept-cmd
100111
- cmd-publish-pr-on-npm

.github/workflows/mutation-testing.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ on:
33
workflow_dispatch:
44
schedule:
55
- cron: '0 0 * * *' # run once every day at 00:00 UTC
6+
7+
permissions:
8+
contents: read # to fetch code (actions/checkout)
9+
610
jobs:
711
lint:
812
name: Run mutation testing

.github/workflows/push.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: Push
22
on: push
3+
permissions: {}
34
jobs:
45
ci:
56
uses: ./.github/workflows/ci.yml

0 commit comments

Comments
 (0)