From 787285e08a93574525ba088913dcd57392be0f1c Mon Sep 17 00:00:00 2001 From: nathannaveen <42319948+nathannaveen@users.noreply.github.com> Date: Thu, 26 May 2022 00:50:23 +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/codeql.yml | 7 +++++++ .github/workflows/docs.yml | 7 +++++++ .github/workflows/node.yml | 3 +++ .github/workflows/php.yml | 3 +++ 4 files changed, 20 insertions(+) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 34659701..d706f16a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -3,8 +3,15 @@ on: workflow_dispatch: schedule: - cron: '0 15 * * 6' +permissions: + contents: read + jobs: codeql: + 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 runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 3092bd27..11f7a47d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,8 +3,13 @@ on: workflow_dispatch: schedule: - cron: '0 15 * * 6' +permissions: + contents: read + jobs: create: + permissions: + contents: none name: Create runs-on: ${{ matrix.operating-system }} strategy: @@ -45,6 +50,8 @@ jobs: name: lists path: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md update: + permissions: + contents: write # for Git to git push name: Update needs: create runs-on: ubuntu-latest diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index a5f63462..040385b3 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -16,6 +16,9 @@ on: paths-ignore: - '**.md' - 'examples/**' +permissions: + contents: read + jobs: run: name: Run diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index adf35e4f..521665f9 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -17,6 +17,9 @@ on: paths-ignore: - '**.md' - 'examples/**' +permissions: + contents: read + jobs: run: name: Run