From ac94aa8e464744523a767171e79e6edb15dadd0c Mon Sep 17 00:00:00 2001 From: naveen <172697+naveensrinivasan@users.noreply.github.com> Date: Fri, 1 Jul 2022 00:29: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: naveen <172697+naveensrinivasan@users.noreply.github.com> --- .github/workflows/codacy-analysis.yml | 6 ++++++ .github/workflows/docker-alpine.yml | 3 +++ .github/workflows/docker.yml | 3 +++ 3 files changed, 12 insertions(+) diff --git a/.github/workflows/codacy-analysis.yml b/.github/workflows/codacy-analysis.yml index 81917e6b6a..084f926641 100644 --- a/.github/workflows/codacy-analysis.yml +++ b/.github/workflows/codacy-analysis.yml @@ -17,9 +17,15 @@ on: schedule: - cron: '36 23 * * 3' +permissions: + contents: read + jobs: codacy-security-scan: # Ensure schedule job never runs on forked repos. It's only executed for 'snipe/snipe-it' + permissions: + contents: read # for actions/checkout to fetch code + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results if: (github.repository == 'snipe/snipe-it') || ((github.repository != 'snipe/snipe-it') && (github.event_name != 'schedule')) name: Codacy Security Scan runs-on: ubuntu-latest diff --git a/.github/workflows/docker-alpine.yml b/.github/workflows/docker-alpine.yml index d0acba6fd7..e922eb641f 100644 --- a/.github/workflows/docker-alpine.yml +++ b/.github/workflows/docker-alpine.yml @@ -15,6 +15,9 @@ on: pull_request: +permissions: + contents: read + jobs: docker: # Ensure this job never runs on forked repos. It's only executed for 'snipe/snipe-it' diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5df64f79f8..4a9610e118 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,6 +15,9 @@ on: pull_request: +permissions: + contents: read + jobs: docker: # Ensure this job never runs on forked repos. It's only executed for 'snipe/snipe-it'