From 2e2eca672ab6e29e36971d9dc1565fe76096fab3 Mon Sep 17 00:00:00 2001 From: neilnaveen <42328488+neilnaveen@users.noreply.github.com> Date: Mon, 13 Jun 2022 01:08:18 +0000 Subject: [PATCH] ci: set permissions for github actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much. Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs Signed-off-by: neilnaveen <42328488+neilnaveen@users.noreply.github.com> --- .github/workflows/build.yml | 3 +++ .github/workflows/codegen.yml | 3 +++ .github/workflows/codespell.yaml | 3 +++ .github/workflows/crds-gen.yml | 3 +++ .github/workflows/golangci-lint.yaml | 3 +++ .github/workflows/helm-lint.yaml | 3 +++ .github/workflows/linters.yaml | 3 +++ .github/workflows/mod-check.yml | 3 +++ .github/workflows/push-build.yaml | 3 +++ .github/workflows/rbac-gen.yaml | 3 +++ .github/workflows/shellcheck.yaml | 3 +++ .github/workflows/stale.yaml | 6 ++++++ .github/workflows/synk.yaml | 3 +++ .github/workflows/unit-test.yml | 3 +++ 14 files changed, 45 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index afec7da88..076091290 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true +permissions: + contents: read + jobs: macos-build: runs-on: macos-10.15 diff --git a/.github/workflows/codegen.yml b/.github/workflows/codegen.yml index b2da7528e..8ea411f32 100644 --- a/.github/workflows/codegen.yml +++ b/.github/workflows/codegen.yml @@ -21,6 +21,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true +permissions: + contents: read + jobs: codegen: runs-on: ubuntu-18.04 diff --git a/.github/workflows/codespell.yaml b/.github/workflows/codespell.yaml index 6f0052ee1..353ca1a0f 100644 --- a/.github/workflows/codespell.yaml +++ b/.github/workflows/codespell.yaml @@ -16,6 +16,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true +permissions: + contents: read + jobs: codespell: name: codespell diff --git a/.github/workflows/crds-gen.yml b/.github/workflows/crds-gen.yml index 32d2d4aa5..af16d7672 100644 --- a/.github/workflows/crds-gen.yml +++ b/.github/workflows/crds-gen.yml @@ -21,6 +21,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true +permissions: + contents: read + jobs: crds-gen: runs-on: ubuntu-18.04 diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index 0b0e63754..f1c75bafd 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -16,6 +16,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true +permissions: + contents: read + jobs: golangci: name: golangci-lint diff --git a/.github/workflows/helm-lint.yaml b/.github/workflows/helm-lint.yaml index f23bf8b89..480d7af54 100644 --- a/.github/workflows/helm-lint.yaml +++ b/.github/workflows/helm-lint.yaml @@ -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: lint-test: runs-on: ubuntu-latest diff --git a/.github/workflows/linters.yaml b/.github/workflows/linters.yaml index 3e960aed2..14f7547b2 100644 --- a/.github/workflows/linters.yaml +++ b/.github/workflows/linters.yaml @@ -16,6 +16,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true +permissions: + contents: read + jobs: yaml-linter: runs-on: ubuntu-latest diff --git a/.github/workflows/mod-check.yml b/.github/workflows/mod-check.yml index 5daefcc33..afdefdc16 100644 --- a/.github/workflows/mod-check.yml +++ b/.github/workflows/mod-check.yml @@ -21,6 +21,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: modcheck: runs-on: ubuntu-18.04 diff --git a/.github/workflows/push-build.yaml b/.github/workflows/push-build.yaml index 29b9429c4..d75f02037 100644 --- a/.github/workflows/push-build.yaml +++ b/.github/workflows/push-build.yaml @@ -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: push-image-to-container-registry: runs-on: ubuntu-18.04 diff --git a/.github/workflows/rbac-gen.yaml b/.github/workflows/rbac-gen.yaml index d84317f39..953c38dd3 100644 --- a/.github/workflows/rbac-gen.yaml +++ b/.github/workflows/rbac-gen.yaml @@ -21,6 +21,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true +permissions: + contents: read + jobs: gen-rbac: runs-on: ubuntu-18.04 diff --git a/.github/workflows/shellcheck.yaml b/.github/workflows/shellcheck.yaml index 85cb9d79c..e9efb0112 100644 --- a/.github/workflows/shellcheck.yaml +++ b/.github/workflows/shellcheck.yaml @@ -16,6 +16,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true +permissions: + contents: read + jobs: shellcheck: name: Shellcheck diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml index cc186e7af..ce966377d 100644 --- a/.github/workflows/stale.yaml +++ b/.github/workflows/stale.yaml @@ -4,8 +4,14 @@ on: # Run the stalebot every day at 8pm UTC - cron: "00 20 * * *" +permissions: + contents: read + jobs: stale: + permissions: + issues: write # for actions/stale to close stale issues + pull-requests: write # for actions/stale to close stale PRs runs-on: ubuntu-18.04 if: github.repository == 'rook/rook' steps: diff --git a/.github/workflows/synk.yaml b/.github/workflows/synk.yaml index 90eb7efc5..29e3cb31c 100644 --- a/.github/workflows/synk.yaml +++ b/.github/workflows/synk.yaml @@ -7,6 +7,9 @@ on: - master - release-* +permissions: + contents: read + jobs: security: if: github.repository == 'rook/rook' diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 75f6d7dad..1c93b554c 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -21,6 +21,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true +permissions: + contents: read + jobs: unittests: runs-on: ubuntu-18.04