Skip to content

Conversation

@FSchiltz
Copy link
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.

…n permissions

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