Skip to content

Potential fix for code scanning alert no. 13: Workflow does not contain permissions#55

Closed
byo wants to merge 1 commit intomasterfrom
alert-autofix-13
Closed

Potential fix for code scanning alert no. 13: Workflow does not contain permissions#55
byo wants to merge 1 commit intomasterfrom
alert-autofix-13

Conversation

@byo
Copy link
Contributor

@byo byo commented Sep 6, 2025

Potential fix for https://github.com/cinode/go/security/code-scanning/13

The fix involves explicitly adding a permissions key to assign the least privilege required for the workflow. In this workflow, write permissions to repository contents or other resources are not necessary: we only need to read the code to run tests/check coverage. Therefore, we should set permissions: contents: read either at the top-level of the workflow, or at the job level. If it's possible that another job would be added in the future requiring different permissions, add it at the job level. Since there's only one job (tests), adding at the job level directly above the strategy: key is sufficient and matches the line highlighted by CodeQL.
Specifically, in the .github/workflows/tests.yml file, add the following immediately after the tests: job definition and before strategy::

    permissions:
      contents: read

No imports, definitions, or other changes required.


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>
@byo byo marked this pull request as ready for review September 6, 2025 22:36
@coveralls
Copy link

Coverage Status

coverage: 95.808%. remained the same
when pulling 78878f1 on alert-autofix-13
into 8601866 on master.

@byo byo closed this Sep 7, 2025
@byo byo deleted the alert-autofix-13 branch September 7, 2025 08:02
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.

2 participants