chore: Set permissions for GitHub actions (#2496)

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>
This commit is contained in:
Naveen 2022-05-31 16:23:12 -05:00 committed by GitHub
parent d0318aac4a
commit 023eb3380d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 0 deletions

View file

@ -16,8 +16,13 @@ on:
release: release:
types: [published] types: [published]
permissions:
contents: read
jobs: jobs:
build: build:
permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: windows-latest runs-on: windows-latest
strategy: strategy:
fail-fast: false fail-fast: false

View file

@ -23,6 +23,9 @@ env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release BUILD_TYPE: Release
permissions:
contents: read
jobs: jobs:
build_windows: build_windows:
name: Windows Build name: Windows Build

View file

@ -15,8 +15,13 @@ on:
release: release:
types: [published] types: [published]
permissions:
contents: read
jobs: jobs:
build: build:
permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false

View file

@ -14,6 +14,9 @@ on:
- 'examples/**' - 'examples/**'
- '.github/workflows/linux_examples.yml' - '.github/workflows/linux_examples.yml'
permissions:
contents: read
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View file

@ -15,8 +15,13 @@ on:
release: release:
types: [published] types: [published]
permissions:
contents: read
jobs: jobs:
build: build:
permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: macos-latest runs-on: macos-latest
env: env:

View file

@ -15,8 +15,13 @@ on:
release: release:
types: [published] types: [published]
permissions:
contents: read
jobs: jobs:
build: build:
permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: windows-latest runs-on: windows-latest
strategy: strategy:
fail-fast: false fail-fast: false

View file

@ -14,6 +14,9 @@ on:
- 'examples/**' - 'examples/**'
- '.github/workflows/windows_examples.yml' - '.github/workflows/windows_examples.yml'
permissions:
contents: read
jobs: jobs:
build: build:
runs-on: windows-latest runs-on: windows-latest