Skip to content

Potential fix for code scanning alert no. 1: Workflow does not contain permissions - #2

Merged
edjeffreys merged 1 commit into
mainfrom
alert-autofix-1
Mar 8, 2026
Merged

edjeffreys merged 1 commit into
mainfrom
alert-autofix-1

Conversation

@edjeffreys

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/edjeffreys/nomad-tailscale-controller/security/code-scanning/1

In general, this issue is fixed by adding an explicit permissions block to the workflow (either at the top level or per job) that grants only the scopes actually needed. For a simple CI job that just checks out code and runs tests/builds, contents: read is normally sufficient, because actions/checkout and read-only operations on the code require only read access to the repository.

The best minimal fix without changing existing functionality is to add a root-level permissions block below the name: CI (or just below on:) that sets contents: read. This will apply to all jobs in the workflow unless overridden, and it matches the CodeQL suggestion for a minimal starting point. No other scopes (like pull-requests, issues, or packages) are required by the shown steps, and the workflow does not currently perform any write operations back to GitHub. No imports or additional methods are needed, only a change to the YAML.

Concretely, in .github/workflows/ci.yml, insert:

permissions:
  contents: read

near the top, for example as line 3, shifting the rest down. This will constrain the GITHUB_TOKEN for the test job (and any future jobs that don’t override permissions) to read-only repository contents.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@edjeffreys
edjeffreys marked this pull request as ready for review March 8, 2026 13:03
@edjeffreys
edjeffreys merged commit 444ec2e into main Mar 8, 2026
5 checks passed
@edjeffreys
edjeffreys deleted the alert-autofix-1 branch March 8, 2026 13:03
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