From 0a96b7f0aee124e76a0d47317cb06a9203e63c74 Mon Sep 17 00:00:00 2001 From: Naveen <172697+naveensrinivasan@users.noreply.github.com> Date: Tue, 3 May 2022 11:54:51 -0500 Subject: [PATCH] chore: Set permissions for GitHub actions (#17535) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- .github/workflows/codeql-analysis.yml | 7 +++++++ .github/workflows/issue.yml | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7447d34cd..161d74e26 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -9,8 +9,15 @@ on: schedule: - cron: '0 9 * * 6' +permissions: + contents: read + jobs: analyze: + permissions: + actions: read # for github/codeql-action/init to get workflow details + contents: read # for actions/checkout to fetch code + security-events: write # for github/codeql-action/autobuild to send a status report name: Analyze runs-on: ubuntu-latest diff --git a/.github/workflows/issue.yml b/.github/workflows/issue.yml index 8fc6eec28..a5d0fe59e 100644 --- a/.github/workflows/issue.yml +++ b/.github/workflows/issue.yml @@ -5,8 +5,14 @@ name: Automatic Comment on: issues: types: [opened] +permissions: + contents: read + jobs: comment: + permissions: + issues: write # for peter-evans/create-or-update-comment to create or update comment + pull-requests: write # for peter-evans/create-or-update-comment to create or update comment name: Comment runs-on: ubuntu-latest steps: