From 1b6f24e9278283acab14f721ccafee533bab29ab Mon Sep 17 00:00:00 2001 From: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com> Date: Sun, 10 Apr 2022 00:09:46 +0000 Subject: [PATCH] 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/build-dist.yaml | 5 +++++ .github/workflows/publish.yaml | 5 +++++ .github/workflows/test.yaml | 3 +++ 3 files changed, 13 insertions(+) diff --git a/.github/workflows/build-dist.yaml b/.github/workflows/build-dist.yaml index c3292c70..1ed50227 100644 --- a/.github/workflows/build-dist.yaml +++ b/.github/workflows/build-dist.yaml @@ -10,10 +10,15 @@ on: workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel +permissions: + contents: read + jobs: # This workflow contains a single job called "build" build: # The type of runner that the job will run on + permissions: + contents: write # for stefanzweifel/git-auto-commit-action to push code in repo runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 9350ca4a..69444afb 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -5,8 +5,13 @@ on: tags: - 'v*' +permissions: + contents: read + jobs: build: + permissions: + contents: write # for actions/create-release to create a release name: Upload Release Asset runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 153e4265..c8b498e9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -6,6 +6,9 @@ on: pull_request: branches: [main] +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest