chore: Set permissions for GitHub actions
authornathannaveen <42319948+nathannaveen@users.noreply.github.com>
Wed, 15 Jun 2022 00:59:10 +0000 (00:59 +0000)
committernathannaveen <42319948+nathannaveen@users.noreply.github.com>
Wed, 15 Jun 2022 00:59:10 +0000 (00:59 +0000)
 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/regen.yml

index 33a041f382ed696c4a3ca561e66f306da6e27cce..47aa736be2ce52fffe3be01bb353ab7e4c114f5c 100644 (file)
@@ -21,8 +21,13 @@ on:
         description: Autocommit to branch (y or n)
         required: false
         default: 'n'
+permissions:
+  contents: read
+
 jobs:
   runregen:
+    permissions:
+      contents: write  # for Git to git push
     runs-on: ubuntu-latest
     name: Run Regen
     services: