From c6a7aa08c7623c91bc7d34e45ea84192f8054ed7 Mon Sep 17 00:00:00 2001 From: naveen <172697+naveensrinivasan@users.noreply.github.com> Date: Wed, 27 Apr 2022 01:37:20 +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: naveen <172697+naveensrinivasan@users.noreply.github.com> --- .github/workflows/build-preview.yml | 3 +++ .github/workflows/publish.yml | 3 +++ .github/workflows/security.yml | 7 +++++++ .github/workflows/test.yml | 3 +++ 4 files changed, 16 insertions(+) diff --git a/.github/workflows/build-preview.yml b/.github/workflows/build-preview.yml index e77ed87fb2..bfe848aac7 100644 --- a/.github/workflows/build-preview.yml +++ b/.github/workflows/build-preview.yml @@ -5,6 +5,9 @@ on: branches: - main +permissions: + contents: read + jobs: build-preview: runs-on: ubuntu-latest diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ed22bb7298..de77dfee9a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,6 +5,9 @@ on: branches: - main +permissions: + contents: read + jobs: publish-npm: runs-on: ubuntu-latest diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 520e42e574..3b1cf54b4e 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -10,8 +10,15 @@ on: schedule: - cron: '0 0 * * 0' # At 00:00 on Sunday +permissions: + contents: read + jobs: codeql: + permissions: + actions: read # for github/codeql-action/init to get workflow details + contents: read # for actions/checkout to fetch code + security-events: write # for github/codeql-action/analyze to upload SARIF results runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 76bb17a049..6b1da8e2af 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,9 @@ on: env: CI: true +permissions: + contents: read + jobs: pretest: name: Pre-Test