From 4418fd38f102e354c090a3e06d865b3fa4d8c3cb Mon Sep 17 00:00:00 2001 From: nathannaveen <42319948+nathannaveen@users.noreply.github.com> Date: Thu, 9 Jun 2022 01:05:21 +0000 Subject: [PATCH] chore: Set permissions for GitHub actions 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: nathannaveen <42319948+nathannaveen@users.noreply.github.com> --- .github/workflows/daily-snapshots.yml | 3 +++ .github/workflows/lint-and-analyse-php.yml | 3 +++ .github/workflows/lock.yml | 5 +++++ .github/workflows/mutation-tests.yml | 3 +++ .github/workflows/other-tools.yml | 3 +++ .github/workflows/test-selenium.yml | 3 +++ .github/workflows/update-po.yml | 5 +++++ 7 files changed, 25 insertions(+) diff --git a/.github/workflows/daily-snapshots.yml b/.github/workflows/daily-snapshots.yml index 37ba4bc3ba..3d6f85ea4f 100644 --- a/.github/workflows/daily-snapshots.yml +++ b/.github/workflows/daily-snapshots.yml @@ -9,6 +9,9 @@ on: schedule: - cron: '0 0 * * *' +permissions: + contents: read + jobs: generate-snapshots: name: Generate ${{ matrix.version }} snapshots diff --git a/.github/workflows/lint-and-analyse-php.yml b/.github/workflows/lint-and-analyse-php.yml index 6506101d08..a43b539a94 100644 --- a/.github/workflows/lint-and-analyse-php.yml +++ b/.github/workflows/lint-and-analyse-php.yml @@ -8,6 +8,9 @@ on: - master - QA_** +permissions: + contents: read + jobs: lint-node: runs-on: ubuntu-latest diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index cf13839196..b4ec30d4d7 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -4,8 +4,13 @@ on: schedule: - cron: '0 0 * * *' +permissions: + contents: read + jobs: lock: + permissions: + issues: write # for dessant/lock-threads to lock issues runs-on: ubuntu-latest steps: - uses: dessant/lock-threads@v2 diff --git a/.github/workflows/mutation-tests.yml b/.github/workflows/mutation-tests.yml index 49d6931f06..17d0da682d 100644 --- a/.github/workflows/mutation-tests.yml +++ b/.github/workflows/mutation-tests.yml @@ -6,6 +6,9 @@ on: pull_request: branches: [master] +permissions: + contents: read + jobs: tests: name: Mutation tests with PHP ${{ matrix.php-version }} diff --git a/.github/workflows/other-tools.yml b/.github/workflows/other-tools.yml index d83c38803c..493fd35990 100644 --- a/.github/workflows/other-tools.yml +++ b/.github/workflows/other-tools.yml @@ -8,6 +8,9 @@ on: - master - QA_** +permissions: + contents: read + jobs: build-documentation: runs-on: ubuntu-latest diff --git a/.github/workflows/test-selenium.yml b/.github/workflows/test-selenium.yml index a9b93c8248..aa29db1236 100644 --- a/.github/workflows/test-selenium.yml +++ b/.github/workflows/test-selenium.yml @@ -11,6 +11,9 @@ on: env: php-version: "8.1" +permissions: + contents: read + jobs: selenium: name: "Selenium" diff --git a/.github/workflows/update-po.yml b/.github/workflows/update-po.yml index ac07c2592c..a505e41e01 100644 --- a/.github/workflows/update-po.yml +++ b/.github/workflows/update-po.yml @@ -5,8 +5,13 @@ on: schedule: - cron: '0 0 * * 0' +permissions: + contents: read + jobs: update-po: + permissions: + contents: write # for Git to git push name: Update po files runs-on: ubuntu-latest # Source: https://github.community/t/do-not-run-cron-workflows-in-forks/17636/2?u=williamdes