Skip to content

Commit 2d3b322

Browse files
authored
Set Token Permissions for github workflows (#6583)
## Motivation for features / changes GitHub grants, by default, write-all permission for the GITHUB_TOKEN, which is shared by the actions used and, in case of any action got compromised, can be exploited by a malicious attacker. Considering this, it is both an [OpenSSF Scorecard](https://github.com/ossf/scorecard) and [GitHub](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-secrets) recommendation to use permissions minimally scoped. ## Technical description of changes To minimally scope the permissions, it is a good practice to set a read-only basic permission (such as contents: read) and grant any additional permission on job level. In tensorboard case, only the contents: read on top level is enough for both workflows. ## Screenshots of UI changes (or N/A) N/A ## Detailed steps to verify changes work correctly (as executed by you) I've checked the CI.yml workflow at https://github.com/joycebrum/tensorboard/actions/runs/6190658790 and it is working fine. The nightly-release does not need any permission from GITHUB_TOKEN other than contents: read (for the ci.yml to run) ## Alternate designs / implementations considered (or N/A) N/A --------- Signed-off-by: Joyce <joycebrum@google.com>
1 parent d97fef4 commit 2d3b322

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

.github/workflows/ci.yml

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

22+
permissions:
23+
contents: read
24+
2225
env:
2326
# Keep this Bazel version in sync with the `versions.check` directive
2427
# in our WORKSPACE file.

.github/workflows/nightly-release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
# (cron syntax: minute hour day-of-month month day-of-week)
88
- cron: '0 11 * * *'
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
ci:
1215
uses: ./.github/workflows/ci.yml

0 commit comments

Comments
 (0)