From 5b4a019bfe6827743fedf116bac783e540781c95 Mon Sep 17 00:00:00 2001 From: neilnaveen <42328488+neilnaveen@users.noreply.github.com> Date: Wed, 20 Apr 2022 15:49:04 +0000 Subject: [PATCH] chore: 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 [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) Signed-off-by: neilnaveen <42328488+neilnaveen@users.noreply.github.com> --- .github/workflows/commenter.yml | 5 +++++ .github/workflows/linter.yml | 3 +++ .github/workflows/release-drafter.yml | 6 ++++++ .github/workflows/tester.yml | 6 ++++++ 4 files changed, 20 insertions(+) diff --git a/.github/workflows/commenter.yml b/.github/workflows/commenter.yml index 480f01b595..f449809a30 100644 --- a/.github/workflows/commenter.yml +++ b/.github/workflows/commenter.yml @@ -2,8 +2,13 @@ name: Commenter on: [pull_request_target] +permissions: + contents: read + jobs: commenter: + permissions: + pull-requests: write # for marocchino/sticky-pull-request-comment to create or update PR comment runs-on: ubuntu-latest steps: - name: Comment PR diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 6273035b57..d3d9678043 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -2,6 +2,9 @@ name: Linter on: [push, pull_request] +permissions: + contents: read + jobs: linter: runs-on: ubuntu-latest diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 17fdb961dd..d1955effff 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -5,8 +5,14 @@ on: branches: - master +permissions: + contents: read + jobs: update_release_draft: + permissions: + contents: write # for release-drafter/release-drafter to create a github release + pull-requests: write # for release-drafter/release-drafter to add label to PR runs-on: ubuntu-latest steps: - uses: release-drafter/release-drafter@v5 diff --git a/.github/workflows/tester.yml b/.github/workflows/tester.yml index 64f7130856..e94651c609 100644 --- a/.github/workflows/tester.yml +++ b/.github/workflows/tester.yml @@ -2,6 +2,9 @@ name: Tester on: [push, pull_request] +permissions: + contents: read + jobs: tester: runs-on: ${{ matrix.os }} @@ -23,6 +26,9 @@ jobs: env: CI: true coverage: + permissions: + checks: write # for coverallsapp/github-action to create new checks + contents: read # for actions/checkout to fetch code runs-on: ${{ matrix.os }} strategy: matrix: