Potential fix for code scanning alert no. 14: Workflow does not contain permissions#6334
Closed
Potential fix for code scanning alert no. 14: Workflow does not contain permissions#6334
Conversation
…in permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Contributor
Test Results4 703 tests 4 699 ✅ 2m 14s ⏱️ Results for commit 67310b3. |
There was a problem hiding this comment.
Pull request overview
This PR addresses GitHub code scanning alert #14 by adding explicit minimal permissions to the workflow. The change implements the principle of least privilege by setting a default contents: read permission at the workflow level.
- Adds workflow-level
permissions: contents: readto restrict default token permissions - Jobs without explicit permissions inherit the minimal read-only access
- The
go-auto-approvejob retains its existing write permissions through its own permissions block
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Potential fix for https://github.com/mondoohq/cnquery/security/code-scanning/14
To fix this, explicitly define minimal
permissionsfor the workflow so that any job without its ownpermissionsblock (likego-test,go-test-integration,go-race,go-bench, andevent_file) gets a restricted token. The best conservative default is to setpermissions: contents: readat the workflow root, which is sufficient for typical checkout and read-only operations and is compatible with most third‑party actions. Jobs that already have custom permissions, such asgo-auto-approve, will continue to use their own block and override the default.Concretely, in
.github/workflows/pr-test-lint.yml, add a top-levelpermissions:section right after thename: Code Testline (beforeon:). Set it tocontents: read. No other changes are required to jobs, includingevent_file; it will now inherit the minimal read-only permissions. No additional imports or external libraries are needed, since this is only a YAML configuration change.Suggested fixes powered by Copilot Autofix. Review carefully before merging.