From 18b6e46e69ea9f522fb4e28c82b21262917252e9 Mon Sep 17 00:00:00 2001 From: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com> Date: Fri, 22 Apr 2022 19:15:07 -0500 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: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com> --- .github/workflows/ci-workflow.yml | 3 +++ .github/workflows/codeql-analysis.yml | 7 +++++++ .github/workflows/desktop-release.yml | 3 +++ .github/workflows/npm-release.yml | 3 +++ 4 files changed, 16 insertions(+) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 1070b9e3f1..f1be2c9de5 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -9,6 +9,9 @@ on: # Allows manual run of workflow workflow_dispatch: +permissions: + contents: read + jobs: build: runs-on: ubuntu-20.04 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c68e46167d..83cf2c36b4 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -9,8 +9,15 @@ on: schedule: - cron: '0 19 * * 3' +permissions: + contents: read + jobs: analyze: + 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/autobuild to send a status report name: Analyze runs-on: ubuntu-latest diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml index 24e20d16b9..c14f002ca5 100644 --- a/.github/workflows/desktop-release.yml +++ b/.github/workflows/desktop-release.yml @@ -4,6 +4,9 @@ on: - cron: "0 0 * * 0" workflow_dispatch: +permissions: + contents: read + jobs: test: runs-on: macos-11 diff --git a/.github/workflows/npm-release.yml b/.github/workflows/npm-release.yml index 8e4d350c01..ec206db0d1 100644 --- a/.github/workflows/npm-release.yml +++ b/.github/workflows/npm-release.yml @@ -2,6 +2,9 @@ name: Release packages on: push: branches: [ main ] +permissions: + contents: read + jobs: test: runs-on: ubuntu-latest