Skip to content

Potential fix for code scanning alert no. 8: Workflow does not contain permissions#257

Open
FSchiltz wants to merge 1 commit intomainfrom
alert-autofix-8
Open

Potential fix for code scanning alert no. 8: Workflow does not contain permissions#257
FSchiltz wants to merge 1 commit intomainfrom
alert-autofix-8

Conversation

@FSchiltz
Copy link
Copy Markdown
Owner

Potential fix for https://github.com/FSchiltz/Helse/security/code-scanning/8

To fix this problem, the workflow should specify a permissions block that explicitly limits the permissions of the GITHUB_TOKEN. This block can be set at the root (applies to all jobs by default) or per job (overrides root defaults for that job). The secure approach is to set the root-level permission to contents: read (the minimum for typical build tasks), and if a job needs higher permissions (like uploading to a release), elevate only for that job, e.g., contents: write. For this workflow:

  • Edit: Insert at the workflow root (after name: and before on:), or just after on:.
  • Set: permissions: contents: read (default).
  • If any job needs elevated permissions (e.g., the step that runs gh release upload), set permissions: contents: write for that specific job. However, since only a step in the build job does the upload, grant contents: write to the whole build job.
  • Implementation:
    • Add to line 25 (under build:): permissions: contents: write
    • Or, if you want to restrict only the release upload step, you would need to split that step into a separate job, but as shown, it's in the single build job—thus, set job-level permission.

No additional methods, imports, or external definitions are needed for this fix.


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

@FSchiltz FSchiltz marked this pull request as ready for review September 30, 2025 05:51
@FSchiltz FSchiltz enabled auto-merge (squash) September 30, 2025 05:51
@FSchiltz FSchiltz force-pushed the alert-autofix-8 branch 3 times, most recently from ac132d2 to 2f81dc7 Compare April 2, 2026 10:12
…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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