From b29b9e8e29b4d96e8c1e3de1e902d56fab3e5320 Mon Sep 17 00:00:00 2001 From: nathannaveen <42319948+nathannaveen@users.noreply.github.com> Date: Sun, 3 Jul 2022 00:58:19 +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/benchmark.yml | 3 +++ .github/workflows/codeql.yml | 7 +++++++ .github/workflows/nightly.yml | 3 +++ 3 files changed, 13 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 7ae14ca7e76..f7fcea1fbc9 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -6,6 +6,9 @@ on: schedule: - cron: '15 4 * * *' +permissions: + contents: read + jobs: # Run our nightly builds. We build a matrix with the various build # targets and their details. Then we build either in a docker container diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index de1ec5e33e3..de6fbc22ecc 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -8,8 +8,15 @@ on: env: docker-registry: ghcr.io +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/analyze to upload SARIF results name: Analyze runs-on: ubuntu-latest diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 5f80ed010b8..74001a4ea31 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -10,6 +10,9 @@ env: docker-registry: ghcr.io docker-config-path: source/ci/docker +permissions: + contents: read + jobs: # Run our nightly builds. We build a matrix with the various build # targets and their details. Then we build either in a docker container