ci: fix excessive token permissions

Fixes: #14466

The OpenSSF scorecard report

https://scorecard.dev/viewer/?uri=github.com/rook/rook

warns about excessive token-permissions in the rook project's github CI
workflows.

This bulk change aims at improving this by

1. adding top-level read permissions where missing for integration tests.
2. adding write permissions as needed for the auto-assign workflow.
3. removing the warned-about and unused create-tag workflow

Signed-off-by: Michael Adam <obnox@samba.org>
Co-authored-by: Blaine Gardner <b.blaine.gardner@gmail.com>
This commit is contained in:
Michael Adam
2024-07-22 12:34:01 +02:00
co-authored by Blaine Gardner
parent c8f9e6549d
commit 9b2b9b7be2
12 changed files with 36 additions and 42 deletions
+6
View File
@@ -3,8 +3,14 @@ on:
issue_comment:
types: [created, edited]
permissions:
contents: read
jobs:
assign:
permissions:
# write permissions are needed to assign the issue.
contents: write
name: Run self assign job
runs-on: ubuntu-latest
steps:
@@ -24,6 +24,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
jobs:
canary-tests:
uses: ./.github/workflows/canary-integration-test.yml
-42
View File
@@ -1,42 +0,0 @@
name: Tag
on:
workflow_dispatch:
inputs:
version:
description: "Release version (e.g. v1.7.0)"
required: true
defaults:
run:
# reference: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell
shell: bash --noprofile --norc -eo pipefail -x {0}
jobs:
Create-Tag:
runs-on: ubuntu-22.04
if: github.repository == 'rook/rook' && contains('travisn,leseb,BlaineEXE,jbw976,galexrt,satoru-takeuchi', github.actor)
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: set env
run: |
echo "FROM_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "TO_TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV
echo "GITHUB_USER=rook" >> $GITHUB_ENV
- name: Create Tag
uses: negz/create-tag@v1
with:
version: ${{ github.event.inputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get Release Note
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USER: ${{ env.GITHUB_USER }}
FROM_BRANCH: ${{ env.FROM_BRANCH }}
TO_TAG: ${{ env.TO_TAG }}
run: tests/scripts/gen_release_notes.sh
+3
View File
@@ -9,6 +9,9 @@ defaults:
# reference: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell
shell: bash --noprofile --norc -eo pipefail -x {0}
permissions:
contents: read
jobs:
canary-arm64:
runs-on: [self-hosted, ubuntu-20.04-arm64, ARM64]
@@ -18,6 +18,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
jobs:
TestCephHelmSuite:
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && !contains(github.event.pull_request.labels.*.name, 'skip-ci') }}
@@ -17,6 +17,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
jobs:
TestCephMgrSuite:
runs-on: ubuntu-22.04
@@ -18,6 +18,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
jobs:
TestCephMultiClusterDeploySuite:
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && !contains(github.event.pull_request.labels.*.name, 'skip-ci') }}
@@ -18,6 +18,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
jobs:
TestCephObjectSuite:
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && !contains(github.event.pull_request.labels.*.name, 'skip-ci') }}
@@ -18,6 +18,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
jobs:
TestCephSmokeSuite:
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && !contains(github.event.pull_request.labels.*.name, 'skip-ci') }}
@@ -18,6 +18,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
jobs:
TestCephUpgradeSuite:
if: ${{ github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && !contains(github.event.pull_request.labels.*.name, 'skip-ci') }}
@@ -12,6 +12,9 @@ defaults:
# reference: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell
shell: bash --noprofile --norc -eo pipefail -x {0}
permissions:
contents: read
jobs:
TestCephHelmSuite:
runs-on: ubuntu-22.04
+3
View File
@@ -22,6 +22,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test-validation-tool:
runs-on: ubuntu-latest