Skip to content

CICD: Restrict permissions in .github/workflows/pr_build.yml#4121

Merged
tlimoncelli merged 2 commits intomainfrom
alert-autofix-36
Mar 2, 2026
Merged

CICD: Restrict permissions in .github/workflows/pr_build.yml#4121
tlimoncelli merged 2 commits intomainfrom
alert-autofix-36

Conversation

@tlimoncelli
Copy link
Collaborator

Potential fix for https://github.com/StackExchange/dnscontrol/security/code-scanning/36

In general, the fix is to explicitly define permissions for the GITHUB_TOKEN in the workflow, restricting it to the least privileges needed. Since this workflow only checks out code, uses caches, runs tests, uploads artifacts, and runs GoReleaser builds without creating releases or pushing tags, it should only require read access to repository contents.

The best way to fix this without changing existing functionality is to add a permissions block near the top of the workflow (at the root level, alongside name, on, and env). This will apply to all jobs that do not override permissions. We should set contents: read, which matches the minimal recommendation in the CodeQL message and is sufficient for actions/checkout and other used actions. No additional scopes (like pull-requests: write or packages: write) appear necessary based on the provided snippet.

Concretely, in .github/workflows/pr_build.yml, after the on: block (lines 6–15) and before the env: block (line 18), insert:

permissions:
  contents: read

No imports or additional definitions are needed; this is purely 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>
@tlimoncelli tlimoncelli changed the title Potential fix for code scanning alert no. 36: Workflow does not contain permissions CICD: Restrict permissions in .github/workflows Mar 2, 2026
@tlimoncelli tlimoncelli changed the title CICD: Restrict permissions in .github/workflows CICD: Restrict permissions in .github/workflows/pr_build.yml Mar 2, 2026
@tlimoncelli tlimoncelli marked this pull request as ready for review March 2, 2026 17:29
@tlimoncelli tlimoncelli merged commit 63ba7d9 into main Mar 2, 2026
@tlimoncelli tlimoncelli deleted the alert-autofix-36 branch March 2, 2026 17:29
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.

1 participant