From d762d4858895f6db59a2f2ed4d359cc7b61c4322 Mon Sep 17 00:00:00 2001 From: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com> Date: Wed, 13 Apr 2022 15:42:53 +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/linter.yml | 6 ++++++ .github/workflows/tests.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 414f210bda..401be8a34c 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -1,8 +1,14 @@ on: [push, pull_request] name: linter +permissions: + contents: read + jobs: lint: + permissions: + contents: read # for actions/checkout to fetch code + pull-requests: read # for golangci/golangci-lint-action to fetch pull requests strategy: matrix: go-version: [1.x] diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7d15aa1ba8..8cd15bd67a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,8 +10,14 @@ name: tests env: GO111MODULE: on +permissions: + contents: read + jobs: test: + permissions: + actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows + contents: read # for actions/checkout to fetch code strategy: matrix: go-version: [1.x, 1.17.x]