Browse Source

chore: Set permissions for GitHub actions (#9891)

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>
pull/9911/head
Naveen 4 years ago
committed by GitHub
parent
commit
2d900d4848
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .github/workflows/ci.yml
  2. 3
      .github/workflows/preview-build.yml
  3. 11
      .github/workflows/preview-deploy.yml
  4. 6
      .github/workflows/preview-start.yml
  5. 6
      .github/workflows/rebase.yml

3
.github/workflows/ci.yml

@ -2,6 +2,9 @@ name: Node CI
on: [push, pull_request] on: [push, pull_request]
permissions:
contents: read
jobs: jobs:
build: build:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}

3
.github/workflows/preview-build.yml

@ -4,6 +4,9 @@ on:
pull_request: pull_request:
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened]
permissions:
contents: read
jobs: jobs:
build-preview: build-preview:
runs-on: ubuntu-latest runs-on: ubuntu-latest

11
.github/workflows/preview-deploy.yml

@ -6,8 +6,15 @@ on:
types: types:
- completed - completed
permissions:
contents: read
jobs: jobs:
success: success:
permissions:
actions: read # for dawidd6/action-download-artifact to query and download artifacts
issues: write # for actions-cool/maintain-one-comment to modify or create issue comments
pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
steps: steps:
@ -62,6 +69,10 @@ jobs:
number: ${{ steps.pr.outputs.id }} number: ${{ steps.pr.outputs.id }}
failed: failed:
permissions:
actions: read # for dawidd6/action-download-artifact to query and download artifacts
issues: write # for actions-cool/maintain-one-comment to modify or create issue comments
pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure'
steps: steps:

6
.github/workflows/preview-start.yml

@ -2,8 +2,14 @@ name: Preview Start
on: pull_request_target on: pull_request_target
permissions:
contents: read
jobs: jobs:
preview: preview:
permissions:
issues: write # for actions-cool/maintain-one-comment to modify or create issue comments
pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: create - name: create

6
.github/workflows/rebase.yml

@ -2,8 +2,14 @@ on:
issue_comment: issue_comment:
types: [created] types: [created]
name: Automatic Rebase name: Automatic Rebase
permissions:
contents: read
jobs: jobs:
rebase: rebase:
permissions:
contents: write # for cirrus-actions/rebase to push code to rebase
pull-requests: read # for cirrus-actions/rebase to get info about PR
name: Rebase name: Rebase
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
runs-on: ubuntu-latest runs-on: ubuntu-latest

Loading…
Cancel
Save