Skip to content

Commit 1105264

Browse files
committed
Restrict permissions of GITHUB_TOKEN in workflows
`GITHUB_TOKEN` is an access token provided automatically by GitHub Actions. By default, this token has write permissions except when the workflow is triggered by events generated by a PR from a fork. This level of privilege is not needed by any of the workflows, which violates the security principle of least privilege. For this reason, GitHub Actions now allows fine grained control of the permissions provided to the token, which are used here to configure the workflows for only the permissions they require. The automatic permissions downgrade from write to read for workflows triggered by events generated by a PR from a fork is unaffected. Even when all permissions are withheld (permissions: {}`), the token still provides the authenticated API request rate limiting allowance, which is the most common use of the token in these workflows. Read permissions are required in the "contents" scope in order to checkout private repositories. Even though those permissions are not required for public repositories, the workflow templates are intended to be applicable in public and private repositories both and so a small excess in permissions was chosen over a large increase in maintenance effort to have an extra version of each of the workflows for use in private repositories.
1 parent 02f92d6 commit 1105264

File tree

84 files changed

+266
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+266
-0
lines changed

.github/workflows/check-configs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ on:
2424
workflow_dispatch:
2525
repository_dispatch:
2626

27+
permissions: {}
28+
2729
jobs:
2830
validate:
2931
name: ${{ matrix.configuration.path }}

.github/workflows/check-general-formatting.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
workflow_dispatch:
1212
repository_dispatch:
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
check:
1619
runs-on: ubuntu-latest

.github/workflows/check-javascript-npm.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ on:
1818
workflow_dispatch:
1919
repository_dispatch:
2020

21+
permissions:
22+
contents: read
23+
2124
jobs:
2225
check:
2326
runs-on: ubuntu-latest

.github/workflows/check-json.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ on:
1919
workflow_dispatch:
2020
repository_dispatch:
2121

22+
permissions:
23+
contents: read
24+
2225
jobs:
2326
check:
2427
runs-on: ubuntu-latest

.github/workflows/check-markdown.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ on:
2727
workflow_dispatch:
2828
repository_dispatch:
2929

30+
permissions:
31+
contents: read
32+
3033
jobs:
3134
lint:
3235
runs-on: ubuntu-latest

.github/workflows/check-npm.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ on:
2323
workflow_dispatch:
2424
repository_dispatch:
2525

26+
permissions:
27+
contents: read
28+
2629
jobs:
2730
validate:
2831
runs-on: ubuntu-latest

.github/workflows/check-prettier-formatting.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ on:
199199
workflow_dispatch:
200200
repository_dispatch:
201201

202+
permissions:
203+
contents: read
204+
202205
jobs:
203206
check:
204207
runs-on: ubuntu-latest

.github/workflows/check-shell.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ on:
2121
workflow_dispatch:
2222
repository_dispatch:
2323

24+
permissions:
25+
contents: read
26+
2427
jobs:
2528
lint:
2629
runs-on: ubuntu-latest

.github/workflows/check-sync.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ on:
1313
push:
1414
pull_request:
1515

16+
permissions: {}
17+
1618
jobs:
1719
check-sync:
1820
runs-on: ubuntu-latest

.github/workflows/check-taskfiles.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ on:
1717
workflow_dispatch:
1818
repository_dispatch:
1919

20+
permissions:
21+
contents: read
22+
2023
jobs:
2124
validate:
2225
name: Validate ${{ matrix.file }}

0 commit comments

Comments
 (0)