Skip to content

fix(workflows): restrict GITHUB_TOKEN permissions in Actions workflows - #63

Merged
tamaan-nr merged 1 commit into
mainfrom
NR-560487
Sep 22, 2026
Merged

tamaan-nr merged 1 commit into
mainfrom
NR-560487

Conversation

@tamaan-nr

Copy link
Copy Markdown
Contributor

Summary

Adds explicit permissions blocks to pull_request.yaml and trivy_schedule.yaml. CodeQL (rule MissingActionsPermissions) flagged both workflows for running jobs without a defined GITHUB_TOKEN scope, leaving the token at its default, broader access level.

Changes

pull_request.yaml

  • Added workflow-level permissions: contents: read as the baseline for all jobs.
  • Added a job-level override on security (contents: read, security-events: write), since it runs github/codeql-action/upload-sarif to publish CFN Nag results, which requires that scope.
  • validate-template-code, trivy-scan, and test-and-coverage inherit the workflow-level default and need nothing more.
  • test-and-coverage job stays read-only as it uploads a coverage report via actions/upload-artifact, which authenticates through the separate ACTIONS_RUNTIME_TOKEN GitHub injects into every job, not GITHUB_TOKEN. It isn't governed by the permissions: block at all, so no write scope is needed there.

trivy_schedule.yaml

  • Added job-level permissions (contents: read, security-events: write) directly on the single trivy job, since it also calls upload-sarif.

Testing

codeql database create ./codeql-actions-db --language=actions --source-root . --overwrite
codeql database analyze ./codeql-actions-db codeql/actions-queries --format=sarif-latest --output=actions-results.sarif --download

Confirmed the MissingActionsPermissions findings for both files no longer appear in actions-results.sarif

@tamaan-nr
tamaan-nr requested a review from maya-jha September 22, 2026 03:56
@tamaan-nr
tamaan-nr merged commit fe1d1cf into main Sep 22, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants