Skip to content

Commit c9a1493

Browse files
kartbennashif
authored andcommitted
ci: Update GitHub Actions workflows to follow principle of least privilege
Default to `permissions: read-all` in all workflows and then add additional permissions as needed at the job level Signed-off-by: Benjamin Cabé <[email protected]>
1 parent 0ae0c3d commit c9a1493

35 files changed

+137
-1
lines changed

.github/workflows/assigner.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ on:
1515
types:
1616
- labeled
1717

18+
permissions:
19+
contents: read
20+
1821
jobs:
1922
assignment:
2023
name: Pull Request Assignment
2124
if: github.event.pull_request.draft == false
2225
runs-on: ubuntu-22.04
26+
permissions:
27+
pull-requests: write # to add assignees to pull requests
28+
issues: write # to add assignees to issues
2329

2430
steps:
2531
- name: Install Python dependencies

.github/workflows/backport.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ on:
77
branches:
88
- main
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
backport:
1215
name: Backport
1316
runs-on: ubuntu-22.04
17+
permissions:
18+
contents: write # to create/push backport branches
19+
pull-requests: write # to create backport PRs
20+
issues: write # to add labels to issue created if backport fails
1421
# Only react to merged PRs for security reasons.
1522
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
1623
if: >

.github/workflows/backport_issue_check.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
branches:
1111
- v*-branch
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
backport:
1518
name: Backport Issue Check
@@ -18,6 +21,8 @@ jobs:
1821
cancel-in-progress: true
1922
runs-on: ubuntu-22.04
2023
if: github.repository == 'zephyrproject-rtos/zephyr'
24+
permissions:
25+
issues: read # to check if associated issue exists for backport
2126

2227
steps:
2328
- name: Check out source code

.github/workflows/bsim-tests-publish.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ on:
55
workflows: ["BabbleSim Tests"]
66
types:
77
- completed
8+
9+
permissions:
10+
contents: read
11+
812
jobs:
913
bsim-test-results:
1014
name: "Publish BabbleSim Test Results"
1115
runs-on: ubuntu-22.04
1216
if: github.event.workflow_run.conclusion != 'skipped'
17+
permissions:
18+
checks: write # to create the check run entry with test results
1319

1420
steps:
1521
- name: Download artifacts

.github/workflows/bsim-tests.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ on:
2828
- "drivers/serial/*nrfx*"
2929
- "tests/drivers/uart/**"
3030

31+
permissions:
32+
contents: read
33+
3134
concurrency:
3235
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
3336
cancel-in-progress: true
@@ -45,6 +48,9 @@ jobs:
4548
BSIM_OUT_PATH: /opt/bsim/
4649
BSIM_COMPONENTS_PATH: /opt/bsim/components
4750
EDTT_PATH: ../tools/edtt
51+
permissions:
52+
checks: write # to create the check run entry with test results
53+
4854
steps:
4955
- name: Apply container owner mismatch workaround
5056
run: |

.github/workflows/bug_snapshot.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ on:
1313
# Run daily at 14:05
1414
- cron: '5 14 * * *'
1515

16+
permissions:
17+
contents: read
18+
1619
jobs:
1720
make_bugs_pickle:
1821
name: Make bugs pickle

.github/workflows/codecov.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
schedule:
55
- cron: '25 06,18 * * *'
66

7+
permissions:
8+
contents: read
9+
710
concurrency:
811
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
912
cancel-in-progress: true

.github/workflows/coding_guidelines.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Coding Guidelines
22

33
on: pull_request
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
compliance_job:
710
runs-on: ubuntu-22.04

.github/workflows/compliance.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
- reopened
99
- synchronize
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
check_compliance:
1316
runs-on: ubuntu-22.04

.github/workflows/daily_test_version.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
branches:
1111
- refs/tags/*
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
get_version:
1518
runs-on: ubuntu-22.04

0 commit comments

Comments
 (0)