Skip to content

Commit

Permalink
chore: Set permissions for GitHub actions (#10399)
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: naveen <172697+naveensrinivasan@users.noreply.github.com>
  • Loading branch information
naveensrinivasan committed Jun 13, 2022
1 parent b52507b commit 0616868
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -10,8 +10,15 @@ on:
- master
- "2.9"
workflow_dispatch:
permissions:
contents: read

jobs:
build:
permissions:
checks: write # for coverallsapp/github-action to create new checks
contents: read # for dorny/paths-filter to fetch a list of changed files
pull-requests: read # for dorny/paths-filter to read pull requests
runs-on: ${{ matrix.os }}

outputs:
Expand Down Expand Up @@ -94,6 +101,8 @@ jobs:
parallel: true

finish:
permissions:
checks: write # for coverallsapp/github-action to create new checks
needs: build
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/compressed-size.yml
Expand Up @@ -2,9 +2,17 @@ name: Compressed Size

on: [pull_request]

permissions:
contents: read

jobs:
build:

permissions:
checks: write # for preactjs/compressed-size-action to create and update the checks
contents: read # for actions/checkout to fetch code
issues: write # for preactjs/compressed-size-action to create comments
pull-requests: write # for preactjs/compressed-size-action to write a PR review
runs-on: ubuntu-latest

steps:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/deploy-docs.yml
Expand Up @@ -6,8 +6,13 @@ on:
branches:
- master

permissions:
contents: read

jobs:
correct_repository:
permissions:
contents: none
runs-on: ubuntu-latest
steps:
- name: fail on fork
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/release-drafter.yml
Expand Up @@ -6,15 +6,23 @@ on:
- master
workflow_dispatch:

permissions:
contents: read

jobs:
correct_repository:
permissions:
contents: none
runs-on: ubuntu-latest
steps:
- name: fail on fork
if: github.repository_owner != 'chartjs'
run: exit 1

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
needs: correct_repository
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Expand Up @@ -2,10 +2,17 @@ name: Release

on:
release:
permissions:
contents: write # for actions/upload-release-asset to upload release asset
types: [published]

permissions:
contents: read

jobs:
setup:
permissions:
contents: none
runs-on: ubuntu-latest
outputs:
version: ${{ steps.trim.outputs.version }}
Expand Down

0 comments on commit 0616868

Please sign in to comment.