Skip to content

Potential fix for code scanning alert no. 3: Workflow does not contain permissions#4

Closed
colinxu2020 wants to merge 1 commit intomasterfrom
workflow-improve
Closed

Potential fix for code scanning alert no. 3: Workflow does not contain permissions#4
colinxu2020 wants to merge 1 commit intomasterfrom
workflow-improve

Conversation

@colinxu2020
Copy link
Owner

Potential fix for https://github.com/colinxu2020/slhdsa/security/code-scanning/3

To fix the problem, we should explicitly restrict the GITHUB_TOKEN permissions instead of relying on inherited defaults. The least-privilege, generally safe baseline for CI jobs that only need to read the repository is contents: read. For this workflow, the test, build_optimized, and build_unoptimized jobs only check out code, run tests/builds, and upload artifacts; they do not push commits, modify releases, or interact with issues/PRs. The upload_pypi job already has a job-level permissions block (id-token: write) so it is not problematic and will override any workflow-level defaults.

The single best way to fix this without altering functionality is to add a workflow-root permissions block setting contents: read. This will apply to all jobs that do not define their own permissions, namely test, build_optimized, and build_unoptimized. The upload_pypi job will continue to use its own permissions block as defined. No additional imports or dependencies are required, and we do not need to change any steps. Concretely, insert:

permissions:
  contents: read

between the name: Test And Build line (line 4) and the on: section (line 6) in .github/workflows/ci.yml.

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>
@colinxu2020 colinxu2020 deleted the workflow-improve branch February 26, 2026 03:41
Repository owner deleted a comment from codecov-commenter Feb 26, 2026
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