Skip to content

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

Merged
marcolivierarsenault merged 1 commit intomainfrom
alert-autofix-2
Nov 1, 2025
Merged

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#90
marcolivierarsenault merged 1 commit intomainfrom
alert-autofix-2

Conversation

@marcolivierarsenault
Copy link
Owner

Potential fix for https://github.com/marcolivierarsenault/coffeeanddata/security/code-scanning/2

To fix the problem, you should explicitly set a permissions: block at either the workflow root or individually for each job. The workflow contains two jobs: test and sonarQube. The test job contains a deployment step using git-publish-subdir-action, which requires write access to the contents of the repository. The SonarQube job does not appear to require write access and can be granted read-only access.

Thus, the best way to fix the problem is:

  • At workflow root: Set permissions only if all jobs need the same permissions.
  • Per job: Add a permissions: block to each job based on its needs (recommended for least privilege).

In this case:

  • For the test job, add:
    permissions:
      contents: write
  • For the sonarQube job, add:
    permissions:
      contents: read

These blocks should go directly under the job name (i.e., immediately after the job's root indentation and before runs-on).

No imports or extra definitions are needed.

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>
@marcolivierarsenault marcolivierarsenault marked this pull request as ready for review September 23, 2025 01:01
@marcolivierarsenault marcolivierarsenault merged commit 9845de7 into main Nov 1, 2025
8 of 10 checks passed
@marcolivierarsenault marcolivierarsenault deleted the alert-autofix-2 branch November 1, 2025 23:49
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