Skip to content

Commit 980a129

Browse files
ci(StepSecurity): Harden GHA token permissions (#777)
--------- Signed-off-by: StepSecurity Bot <[email protected]> Co-authored-by: StepSecurity Bot <[email protected]>
1 parent e7d51db commit 980a129

File tree

9 files changed

+58
-2
lines changed

9 files changed

+58
-2
lines changed

.github/workflows/build-image-test.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
name: Build Dockerfile if changed and run smoke tests
44

5-
on: [pull_request]
5+
on:
6+
pull_request:
7+
8+
permissions:
9+
contents: read
610

711
env:
812
IMAGE_TAG: pr-test

.github/workflows/build-image.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ on:
1010
schedule:
1111
- cron: 00 00 * * *
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
docker:
18+
permissions:
19+
# for docker/build-push-action to publish docker image
20+
packages: write
21+
1522
runs-on: ubuntu-latest
1623
steps:
1724
- name: Checkout code

.github/workflows/ci-cd.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ on:
1515
pull_request:
1616
workflow_call: # a way to embed the main tests
1717

18+
permissions:
19+
contents: read
20+
1821
concurrency:
1922
group: >-
2023
${{

.github/workflows/pr-title.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,17 @@ on:
99
- edited
1010
- synchronize
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
main:
17+
permissions:
18+
# for amannn/action-semantic-pull-request to analyze PRs
19+
pull-requests: read
20+
# for amannn/action-semantic-pull-request to mark status of analyzed PR
21+
statuses: write
22+
1423
name: Validate PR title
1524
runs-on: ubuntu-latest
1625
steps:

.github/workflows/pre-commit.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
name: Common issues check
44

5-
on: [pull_request]
5+
on:
6+
pull_request:
7+
8+
permissions:
9+
contents: read
610

711
jobs:
812
pre-commit:
13+
permissions:
14+
contents: write # for pre-commit/action to push back fixes to PR branch
915
runs-on: ubuntu-latest
1016
steps:
1117
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

.github/workflows/release.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,20 @@ on:
1414
- .pre-commit-hooks.yaml
1515
# Ignore paths
1616
- '!tests/**'
17+
18+
permissions:
19+
contents: read
20+
1721
jobs:
1822
release:
23+
permissions:
24+
# for cycjimmy/semantic-release-action to create a release
25+
contents: write
26+
# for cycjimmy/semantic-release-action to write comments to issues
27+
issues: write
28+
# for cycjimmy/semantic-release-action to write comments to PRs
29+
pull-requests: write
30+
1931
name: Release
2032
runs-on: ubuntu-latest
2133
steps:
@@ -34,4 +46,7 @@ jobs:
3446
@semantic-release/[email protected]
3547
@semantic-release/[email protected]
3648
env:
49+
# Custom token for triggering Docker image build GH Workflow on release
50+
# created by cycjimmy/semantic-release-action. Events created by
51+
# workflows with default GITHUB_TOKEN not trigger other GH Workflow.
3752
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}

.github/workflows/reusable-tox.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ on:
8383
description: Mandatory token for uploading to Codecov
8484
required: true
8585

86+
permissions:
87+
contents: read
88+
8689
env:
8790
COLOR: >- # Supposedly, pytest or coveragepy use this
8891
yes

.github/workflows/scheduled-runs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
- cron: 3 5 * * * # run daily at 5:03 UTC
1111
workflow_dispatch: # manual trigger
1212

13+
permissions:
14+
contents: read
15+
1316
run-name: >-
1417
🌃
1518
Nightly run of

.github/workflows/stale-actions.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ on:
55
schedule:
66
- cron: 0 0 * * *
77

8+
permissions:
9+
contents: read
10+
811
jobs:
912
stale:
13+
permissions:
14+
issues: write # for actions/stale to close stale issues
15+
pull-requests: write # for actions/stale to close stale PRs
1016
runs-on: ubuntu-latest
1117
steps:
1218
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0

0 commit comments

Comments
 (0)