From 5deff9583cf6c8fad702bfd9e835bd726aeed308 Mon Sep 17 00:00:00 2001 From: nathannaveen <42319948+nathannaveen@users.noreply.github.com> Date: Mon, 4 Jul 2022 01:09:50 +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: nathannaveen <42319948+nathannaveen@users.noreply.github.com> --- .github/workflows/no-channel.yml | 5 +++++ .github/workflows/update-terraform-providers.yml | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/no-channel.yml b/.github/workflows/no-channel.yml index fb9a95851f06..90c38f22c007 100644 --- a/.github/workflows/no-channel.yml +++ b/.github/workflows/no-channel.yml @@ -6,8 +6,13 @@ on: - 'nixos-**' - 'nixpkgs-**' +permissions: + contents: read + jobs: fail: + permissions: + contents: none name: "This PR is is targeting a channel branch" runs-on: ubuntu-latest steps: diff --git a/.github/workflows/update-terraform-providers.yml b/.github/workflows/update-terraform-providers.yml index 8bd82acbe791..c966505843a1 100644 --- a/.github/workflows/update-terraform-providers.yml +++ b/.github/workflows/update-terraform-providers.yml @@ -5,8 +5,15 @@ on: - cron: "14 3 * * 1" workflow_dispatch: +permissions: + contents: read + jobs: tf-providers: + permissions: + contents: write # for peter-evans/create-pull-request to create branch + issues: write # for peter-evans/create-or-update-comment to create or update comment + pull-requests: write # for peter-evans/create-pull-request to create a PR if: github.repository_owner == 'NixOS' && github.ref == 'refs/heads/master' # ensure workflow_dispatch only runs on master runs-on: ubuntu-latest steps: