Skip to content

Commit e868eab

Browse files
committed
Set permissions for GitHub token in workflows
1 parent 2a4384d commit e868eab

27 files changed

+105
-6
lines changed

.github/workflows/build-and-publish.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Build & Publish
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: write
57
secrets:
68
PYPI_TOKEN:
79
required: true

.github/workflows/cd.yml

+8
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,23 @@ jobs:
1010
check-tag-version-job:
1111
name: Check Release Tag
1212
uses: ./.github/workflows/check-release-tag.yml
13+
permissions:
14+
contents: read
1315

1416
cd-job:
1517
name: Continuous Delivery
1618
uses: ./.github/workflows/build-and-publish.yml
19+
permissions:
20+
contents: write
1721
secrets:
1822
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
1923

2024
publish-docs:
2125
needs: [ cd-job ]
2226
name: Publish Documentation
2327
uses: ./.github/workflows/gh-pages.yml
28+
permissions:
29+
contents: read
30+
pages: write
31+
id-token: write
2432

.github/workflows/check-release-tag.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Check Release Tag
22

3-
on: workflow_call
3+
on:
4+
workflow_call:
5+
permissions:
6+
contents: read
47

58
jobs:
69

.github/workflows/checks.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Checks
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57

68
jobs:
79

.github/workflows/ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ jobs:
1616
CI:
1717
uses: ./.github/workflows/merge-gate.yml
1818
secrets: inherit
19+
permissions:
20+
contents: read
1921

2022
Metrics:
2123
needs: [ CI ]
2224
uses: ./.github/workflows/report.yml
25+
permissions:
26+
contents: read

.github/workflows/gh-pages.yml

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Publish Documentation
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
7+
pages: write
8+
id-token: write
59
workflow_dispatch:
610

711
jobs:

.github/workflows/matrix-all.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Build Matrix (All Versions)
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57
outputs:
68
matrix:
79
description: "Generates the all versions build matrix"

.github/workflows/matrix-exasol.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Build Matrix (Exasol)
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57
outputs:
68
matrix:
79
description: "Generates the exasol version build matrix"

.github/workflows/matrix-python.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ name: Build Matrix (Python)
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57
outputs:
68
matrix:
7-
description: "Generates the python version build matrix"
8-
value: ${{ jobs.python_versions.outputs.matrix }}
9+
description: "Generates the python version build matrix"
10+
value: ${{ jobs.python_versions.outputs.matrix }}
911

1012
jobs:
1113
python_versions:

.github/workflows/merge-gate.yml

+6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@ name: Merge-Gate
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57

68
jobs:
79

810
fast-checks:
911
name: Fast
1012
uses: ./.github/workflows/checks.yml
13+
permissions:
14+
contents: read
1115

1216
slow-checks:
1317
name: Slow
1418
uses: ./.github/workflows/slow-checks.yml
19+
permissions:
20+
contents: read
1521

1622
# This job ensures inputs have been executed successfully.
1723
approve-merge:

.github/workflows/pr-merge.yml

+8
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ jobs:
1111
ci-job:
1212
name: Checks
1313
uses: ./.github/workflows/checks.yml
14+
permissions:
15+
contents: read
1416

1517
publish-docs:
1618
name: Publish Documentation
1719
uses: ./.github/workflows/gh-pages.yml
20+
permissions:
21+
contents: read
22+
pages: write
23+
id-token: write
1824

1925
metrics:
2026
needs: [ ci-job ]
2127
uses: ./.github/workflows/report.yml
28+
permissions:
29+
contents: read

.github/workflows/report.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Status Report
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57

68
jobs:
79

.github/workflows/slow-checks.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Slow-Checks
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57

68
jobs:
79

doc/changes/unreleased.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ This should also create a 'github-pages' environment, if it does not yet exist.
1313
For most repos using the PTB, the updating of the github pages only happens when a
1414
PR is merged to main, so please check post-merge that it worked as expected.
1515

16+
With #422, we have hardened the security in our GitHub workflows by explicitly
17+
setting permissions to the default GitHub token. In a few repos who greatly differ
18+
from the default PTB setup, this might lead to small issues which require the allowed
19+
permissions to be increased for specific jobs.
20+
1621
## ⚒️ Refactorings
1722

1823
* [#412](https://github.com/exasol/python-toolbox/issues/392): Refactored pre commit hook package version.py into nox task
1924

2025
## Security
2126

22-
* [#420](https://github.com/exasol/python-toolbox/issues/420): Replaced 3rd party action with GitHub actions for gh-pages
27+
* [#420](https://github.com/exasol/python-toolbox/issues/420): Replaced 3rd party action with GitHub actions for gh-pages
28+
* [#422](https://github.com/exasol/python-toolbox/issues/422): Set permissions within the GitHub workflows to restrict usage of the default GitHub token

exasol/toolbox/templates/github/workflows/build-and-publish.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Build & Publish
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: write
57
secrets:
68
PYPI_TOKEN:
79
required: true

exasol/toolbox/templates/github/workflows/cd.yml

+8
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,23 @@ jobs:
1010
check-tag-version-job:
1111
name: Check Release Tag
1212
uses: ./.github/workflows/check-release-tag.yml
13+
permissions:
14+
contents: read
1315

1416
cd-job:
1517
name: Continuous Delivery
1618
uses: ./.github/workflows/build-and-publish.yml
19+
permissions:
20+
contents: write
1721
secrets:
1822
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
1923

2024
publish-docs:
2125
needs: [ cd-job ]
2226
name: Publish Documentation
2327
uses: ./.github/workflows/gh-pages.yml
28+
permissions:
29+
contents: read
30+
pages: write
31+
id-token: write
2432

exasol/toolbox/templates/github/workflows/check-release-tag.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Check Release Tag
22

3-
on: workflow_call
3+
on:
4+
workflow_call:
5+
permissions:
6+
contents: read
47

58
jobs:
69

exasol/toolbox/templates/github/workflows/checks.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Checks
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57

68
jobs:
79

exasol/toolbox/templates/github/workflows/ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ jobs:
1616
CI:
1717
uses: ./.github/workflows/merge-gate.yml
1818
secrets: inherit
19+
permissions:
20+
contents: read
1921

2022
Metrics:
2123
needs: [ CI ]
2224
uses: ./.github/workflows/report.yml
25+
permissions:
26+
contents: read

exasol/toolbox/templates/github/workflows/gh-pages.yml

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Publish Documentation
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
7+
pages: write
8+
id-token: write
59
workflow_dispatch:
610

711
jobs:

exasol/toolbox/templates/github/workflows/matrix-all.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Build Matrix (All Versions)
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57
outputs:
68
matrix:
79
description: "Generates the all versions build matrix"

exasol/toolbox/templates/github/workflows/matrix-exasol.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Build Matrix (Exasol)
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57
outputs:
68
matrix:
79
description: "Generates the exasol version build matrix"

exasol/toolbox/templates/github/workflows/matrix-python.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Build Matrix (Python)
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57
outputs:
68
matrix:
79
description: "Generates the python version build matrix"

exasol/toolbox/templates/github/workflows/merge-gate.yml

+6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@ name: Merge-Gate
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57

68
jobs:
79

810
fast-checks:
911
name: Fast
1012
uses: ./.github/workflows/checks.yml
13+
permissions:
14+
contents: read
1115

1216
slow-checks:
1317
name: Slow
1418
uses: ./.github/workflows/slow-checks.yml
19+
permissions:
20+
contents: read
1521

1622
# This job ensures inputs have been executed successfully.
1723
approve-merge:

exasol/toolbox/templates/github/workflows/pr-merge.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ jobs:
1414
ci-job:
1515
name: Checks
1616
uses: ./.github/workflows/checks.yml
17-
secrets: inherit
17+
permissions:
18+
contents: read
1819

1920
publish-docs:
2021
name: Publish Documentation
2122
uses: ./.github/workflows/gh-pages.yml
23+
permissions:
24+
contents: read
25+
pages: write
26+
id-token: write
2227

2328
metrics:
2429
needs: [ ci-job ]
2530
uses: ./.github/workflows/report.yml
31+
permissions:
32+
contents: read

exasol/toolbox/templates/github/workflows/report.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Status Report
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57

68
jobs:
79

exasol/toolbox/templates/github/workflows/slow-checks.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Slow-Checks
22

33
on:
44
workflow_call:
5+
permissions:
6+
contents: read
57

68
jobs:
79

0 commit comments

Comments
 (0)