Set permissions for GitHub actions (#2752)

- 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/)

 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.

Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>
This commit is contained in:
nathannaveen 2022-04-11 15:52:49 -04:00 committed by GitHub
parent 04bd969a8b
commit 4471e9f322
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 0 deletions

View file

@ -18,8 +18,14 @@ on:
#################
# Start the job #
#################
permissions:
contents: read
jobs:
update_release_draft:
permissions:
contents: write # for release-drafter/release-drafter to create a github release
pull-requests: write # for release-drafter/release-drafter to add label to PR
runs-on: ubuntu-latest
timeout-minutes: 60
steps:

View file

@ -22,6 +22,9 @@ on:
###############
# Set the Job #
###############
permissions:
contents: read
jobs:
build:
# Name the Job

View file

@ -24,6 +24,9 @@ jobs:
# Mark an Issue Stale #
#######################
markstale:
permissions:
issues: write # for actions/stale to close stale issues
pull-requests: write # for actions/stale to close stale PRs
runs-on: ubuntu-latest
# only run on schedule
if: ${{ github.event_name == 'schedule' }}

View file

@ -6,8 +6,14 @@ on:
branches:
- main
pull_request:
permissions:
contents: read
jobs:
scan-container:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
name: Build
runs-on: ubuntu-18.04
timeout-minutes: 60

View file

@ -25,8 +25,13 @@ on:
#################
# Start the job #
#################
permissions:
contents: read
jobs:
actions-tagger:
permissions:
contents: write # for Actions-R-Us/actions-tagger to create a release and add latest tag
runs-on: windows-latest
timeout-minutes: 60
steps: