Skip to content

Potential fix for code scanning alert no. 14: Workflow does not contain permissions#6334

Closed
czunker wants to merge 1 commit intomainfrom
alert-autofix-14
Closed

Potential fix for code scanning alert no. 14: Workflow does not contain permissions#6334
czunker wants to merge 1 commit intomainfrom
alert-autofix-14

Conversation

@czunker
Copy link
Copy Markdown
Contributor

@czunker czunker commented Dec 22, 2025

Potential fix for https://github.com/mondoohq/cnquery/security/code-scanning/14

To fix this, explicitly define minimal permissions for the workflow so that any job without its own permissions block (like go-test, go-test-integration, go-race, go-bench, and event_file) gets a restricted token. The best conservative default is to set permissions: contents: read at 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 as go-auto-approve, will continue to use their own block and override the default.

Concretely, in .github/workflows/pr-test-lint.yml, add a top-level permissions: section right after the name: Code Test line (before on:). Set it to contents: read. No other changes are required to jobs, including event_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.

…in permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Test Results

4 703 tests   4 699 ✅  2m 14s ⏱️
  415 suites      4 💤
   31 files        0 ❌

Results for commit 67310b3.

@czunker czunker marked this pull request as ready for review December 29, 2025 12:02
@tas50 tas50 requested a review from Copilot December 31, 2025 17:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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: read to restrict default token permissions
  • Jobs without explicit permissions inherit the minimal read-only access
  • The go-auto-approve job retains its existing write permissions through its own permissions block

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@czunker
Copy link
Copy Markdown
Contributor Author

czunker commented Jan 8, 2026

#6369

@czunker czunker closed this Jan 8, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Jan 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants