-
Notifications
You must be signed in to change notification settings - Fork 155
chore: reconfigure permission model for Github actions MCP-279 #714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR reconfigures GitHub Actions permissions following the principle of least privilege and fixes an issue preventing Dependabot PRs from being tested. The changes grant minimal required permissions (contents: read) and disable credential persistence to improve security, while also re-enabling code health checks for both Dependabot and fork PRs.
Key Changes:
- Switched from empty permissions to explicit
contents: readpermission - Added
persist-credentials: falseto all checkout actions for security hardening - Changed code-health-fork.yml trigger from
pull_request_targettopull_requestand re-enabled fork PR testing
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
.github/workflows/code-health.yml |
Added explicit read permission and disabled credential persistence across all checkout steps |
.github/workflows/code-health-fork.yml |
Changed trigger event, updated permissions, re-enabled fork testing, and disabled credential persistence |
5c1527d to
59b5372
Compare
Pull Request Test Coverage Report for Build 19110567098Details
💛 - Coveralls |
| --- | ||
| name: Code Health (fork) | ||
| on: | ||
| pull_request_target: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we are changing this, do we need separated workflows for fork and non fork?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have separated workflows for both forks (code-health-fork.yml) and non-forks (code-health.yml). The problem earlier was that code-health-fork.yml was never testing the actual changes of the pull request because the workflow was triggered by pull_request_target trigger which was acting in the context of main branch and never checking out the pull request changes.
59b5372 to
0569695
Compare
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: GitHubSecurityLab/actions-permissions/monitor@v1 | ||
| - uses: actions/checkout@v5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an alternative, consider switching to v6-beta as that has a mitigation for the persist-credentials issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The release is only 3 days. I am thinking of letting it marinate a bit before pulling it in. Will keep on eye on it though. Thanks for the heads up.
Proposed changes
Modifies the Github workflows (Code Health and Code Health from fork) to work with least privileges and fixes the accidental problem where dependabot created PRs and forked PRs were not being tested for the modified dependencies and PR contents.
Additionally, we don't persist Git credentials when not required.
Checklist