From f2580f58a6ce18e31ef0fb26ba76677e3390492d Mon Sep 17 00:00:00 2001 From: Naveen <172697+naveensrinivasan@users.noreply.github.com> Date: Sun, 8 May 2022 04:47:44 -0500 Subject: [PATCH] chore: set permissions for GitHub actions (#45876) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: Set permissions for GitHub actions 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> * Update .github/workflows/codeql-analysis.yml Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> * Update .github/workflows/labeler.yaml Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> * Update .github/workflows/node.js-tests-upcoming.yml Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> * Update .github/workflows/node.js-tests.yml Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> * Update .github/workflows/codeql-analysis.yml Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> * Update .github/workflows/labeler.yaml Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> * Update .github/workflows/labeler.yaml Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> --- .github/workflows/codeql-analysis.yml | 10 ++++++++++ .github/workflows/labeler.yaml | 8 ++++++++ .github/workflows/node.js-tests-upcoming.yml | 4 ++++ .github/workflows/node.js-tests.yml | 4 ++++ 4 files changed, 26 insertions(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index ff460e8197f..843e1e1a8e4 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -10,8 +10,18 @@ on: paths-ignore: - 'docs/**' +permissions: + contents: read + jobs: analyse: + permissions: + # for github/codeql-action/init to get workflow details + actions: read + # for actions/checkout to fetch code + contents: read + # for github/codeql-action/analyze to upload SARIF results + security-events: write name: Analyse runs-on: ubuntu-20.04 if: ${{ github.actor != 'renovate[bot]' && github.actor != 'camperbot' }} diff --git a/.github/workflows/labeler.yaml b/.github/workflows/labeler.yaml index 227b59d27e2..9d29a16e5ae 100644 --- a/.github/workflows/labeler.yaml +++ b/.github/workflows/labeler.yaml @@ -2,8 +2,16 @@ name: 'Pull Request Labeler' on: - pull_request_target +permissions: + contents: read + jobs: triage: + permissions: + # for actions/labeler to determine modified files + contents: read + # for actions/labeler to add labels to PRs + pull-requests: write runs-on: ubuntu-20.04 steps: - uses: actions/labeler@v4 diff --git a/.github/workflows/node.js-tests-upcoming.yml b/.github/workflows/node.js-tests-upcoming.yml index 8834b970277..4b6870bc5ee 100644 --- a/.github/workflows/node.js-tests-upcoming.yml +++ b/.github/workflows/node.js-tests-upcoming.yml @@ -9,6 +9,10 @@ on: # run this Action every 14 days - cron: '0 * */14 * *' workflow_dispatch: + +permissions: + contents: read + jobs: lint: name: Lint diff --git a/.github/workflows/node.js-tests.yml b/.github/workflows/node.js-tests.yml index 1fb3ea950bd..0733218d9d7 100644 --- a/.github/workflows/node.js-tests.yml +++ b/.github/workflows/node.js-tests.yml @@ -4,6 +4,10 @@ on: branches-ignore: - 'renovate/**' pull_request: + +permissions: + contents: read + jobs: lint: name: Lint