Skip to content

Potential fix for code scanning alert no. 12: Workflow does not contain permissions#3822

Merged
aldy505 merged 1 commit intomasterfrom
copilot-autofix/alert-autofix-12
Jul 27, 2025
Merged

Potential fix for code scanning alert no. 12: Workflow does not contain permissions#3822
aldy505 merged 1 commit intomasterfrom
copilot-autofix/alert-autofix-12

Conversation

@aldy505
Copy link
Collaborator

@aldy505 aldy505 commented Jul 20, 2025

Note

This was me playing around with GH Copilot Security. Feel free to merge if you think this helpful. Otherwise, please just close it.

Potential fix for https://github.com/getsentry/self-hosted/security/code-scanning/12

To fix this issue, add a permissions: block at the top level of the workflow file, directly under the name: line and before the on: block. This block should specify the minimal permissions required for the jobs in this workflow. Since the jobs only perform test-related tasks and do not push code or manage issues, setting contents: read is the safest and most appropriate minimal permission set. No changes to existing functionality are necessary, as the jobs should not require write permissions.

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>
@codecov
Copy link

codecov bot commented Jul 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.45%. Comparing base (a2447aa) to head (28232b0).
⚠️ Report is 4 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3822   +/-   ##
=======================================
  Coverage   99.45%   99.45%           
=======================================
  Files           3        3           
  Lines         183      183           
=======================================
  Hits          182      182           
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@BYK BYK requested a review from a team July 22, 2025 11:01
@aldy505 aldy505 marked this pull request as ready for review July 22, 2025 11:01
@aldy505
Copy link
Collaborator Author

aldy505 commented Jul 22, 2025

LOL. Very low quality PR.

Copy link
Collaborator

@aminvakil aminvakil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about changing the default in workflow permissions?

https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/

It should be changed for release.yml and other actions which does need write permission.

I guess this is a better approach (setting it to read by default)

@aldy505
Copy link
Collaborator Author

aldy505 commented Jul 25, 2025

@mdtro @oioki Heya, what do you folks think about what @aminvakil said above? This is a very low hanging fruit, but raises 8 security issues here: https://github.com/getsentry/self-hosted/security/code-scanning

image

@mdtro
Copy link
Contributor

mdtro commented Jul 25, 2025

@aldy505 - Setting the permissions explicitly would still be considered best practice and something we recommend even if the token is default set to read-only. Too many footguns with implicit behavior. :)

Copy link
Collaborator

@aminvakil aminvakil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aldy505 - Setting the permissions explicitly would still be considered best practice and something we recommend even if the token is default set to read-only. Too many footguns with implicit behavior. :)

Agree!

Let's do this and change default permission later (or not).

@aldy505
Copy link
Collaborator Author

aldy505 commented Jul 27, 2025

I'm really hesitant to merge this since I consider this as a very low quality PR, but I got 3 approvals, so.... 🤣

@aldy505 aldy505 merged commit 524b8d4 into master Jul 27, 2025
13 checks passed
@aldy505 aldy505 deleted the copilot-autofix/alert-autofix-12 branch July 27, 2025 01:57
@github-actions github-actions bot locked and limited conversation to collaborators Aug 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants