Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add token permissions for code-scanning/trivy.yml #1348

Merged
merged 3 commits into from
Jan 28, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions code-scanning/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ on:
schedule:
- cron: $cron-weekly

permissions:
contents: read

jobs:
build:
permissions:
contents: read # for actions/checkout to fetch code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I'm a maintainer of Trivy. I'd like to know why this line is needed. Looks like read-all is granted in the top-level permissions.

Copy link
Contributor

@laurentsimon laurentsimon Jan 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. If you define permissions in the job, those you do not specify default to none, not to the ones defined at the top level. The top level permissions only serve as a fail-safe mechanism if a developer ever adds a new job and forget to set permissions explicitly... this happens :-)
See the doc in https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idpermissions If you specify the access for any of these scopes, all of those that are not specified are set to none

It was confusing to me a first as well.

security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
name: Build
runs-on: "ubuntu-18.04"
steps:
Expand Down