Skip to content

Commit

Permalink
chore: set permissions for GitHub actions (#4947)
Browse files Browse the repository at this point in the history
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: neilnaveen <42328488+neilnaveen@users.noreply.github.com>
  • Loading branch information
neilnaveen committed Jun 11, 2022
1 parent ff5d85e commit d449acc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/commenter.yml
Expand Up @@ -2,8 +2,13 @@ name: Commenter

on: [pull_request_target]

permissions:
contents: read

jobs:
commenter:
permissions:
pull-requests: write # for marocchino/sticky-pull-request-comment to create or update PR comment
runs-on: ubuntu-latest
steps:
- name: Comment PR
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/linter.yml
Expand Up @@ -2,6 +2,9 @@ name: Linter

on: [push, pull_request]

permissions:
contents: read

jobs:
linter:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release-drafter.yml
Expand Up @@ -5,8 +5,14 @@ on:
branches:
- master

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: write # for release-drafter/release-drafter to create a github release
pull-requests: write # for release-drafter/release-drafter to add label to PR
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/tester.yml
Expand Up @@ -2,6 +2,9 @@ name: Tester

on: [push, pull_request]

permissions:
contents: read

jobs:
tester:
runs-on: ${{ matrix.os }}
Expand All @@ -23,6 +26,9 @@ jobs:
env:
CI: true
coverage:
permissions:
checks: write # for coverallsapp/github-action to create new checks
contents: read # for actions/checkout to fetch code
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down

0 comments on commit d449acc

Please sign in to comment.