From 5c9ef9a8435334236662009c21d95c4bcc15a532 Mon Sep 17 00:00:00 2001 From: Naveen <172697+naveensrinivasan@users.noreply.github.com> Date: Sat, 9 Apr 2022 20:38:43 -0500 Subject: [PATCH] Set permissions for GitHub actions (#5237) 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: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com> --- .github/workflows/invalid_question.yml | 6 ++++++ .github/workflows/missing_playground.yml | 6 ++++++ .github/workflows/stale.yml | 6 ++++++ .github/workflows/tests.yml | 3 +++ 4 files changed, 21 insertions(+) diff --git a/.github/workflows/invalid_question.yml b/.github/workflows/invalid_question.yml index 868bcc34..327a70f6 100644 --- a/.github/workflows/invalid_question.yml +++ b/.github/workflows/invalid_question.yml @@ -3,8 +3,14 @@ on: schedule: - cron: "*/10 * * * *" +permissions: + contents: read + jobs: stale: + permissions: + issues: write # for actions/stale to close stale issues + pull-requests: write # for actions/stale to close stale PRs runs-on: ubuntu-latest env: ACTIONS_STEP_DEBUG: true diff --git a/.github/workflows/missing_playground.yml b/.github/workflows/missing_playground.yml index 3efc90f7..15d3850f 100644 --- a/.github/workflows/missing_playground.yml +++ b/.github/workflows/missing_playground.yml @@ -3,8 +3,14 @@ on: schedule: - cron: "*/10 * * * *" +permissions: + contents: read + jobs: stale: + permissions: + issues: write # for actions/stale to close stale issues + pull-requests: write # for actions/stale to close stale PRs runs-on: ubuntu-latest env: ACTIONS_STEP_DEBUG: true diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index e0be186f..c5e0d7ab 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -3,8 +3,14 @@ on: schedule: - cron: "0 2 * * *" +permissions: + contents: read + jobs: stale: + permissions: + issues: write # for actions/stale to close stale issues + pull-requests: write # for actions/stale to close stale PRs runs-on: ubuntu-latest env: ACTIONS_STEP_DEBUG: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8194e609..8bfb2332 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,6 +8,9 @@ on: branches-ignore: - 'gh-pages' +permissions: + contents: read + jobs: # Label of the container job sqlite: