Harden SonarCloud workflow: scope permissions, fix injection vectors#1057
Harden SonarCloud workflow: scope permissions, fix injection vectors#1057efiacor wants to merge 3 commits into
Conversation
- Move permissions from workflow level to job level (least privilege) - Remove unused checks:write permission - Move clone_url expression to env var (consistent with other hardening) - Add missing -Dproject.settings to push scan step Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
✅ Deploy Preview for kpt-porch ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR hardens the SonarCloud/SonarQube GitHub Actions workflow by scoping GITHUB_TOKEN permissions per job and reducing injection risk in shell steps, while ensuring the scan uses the repository’s sonar-project.properties.
Changes:
- Scoped workflow token permissions at the job level.
- Switched checkout to use
head_shaand moved dynamic values used inrun:blocks into environment variables. - Ensured the push scan loads
sonar-project.propertiesvia-Dproject.settings.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
Address Copilot review comments: - Pin all third-party actions to commit SHAs (latest releases) - Add actions:read permission to sonarqube job for artifact downloads - Remove debug echo event step (leaks PR metadata to logs) Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
|
There was a problem hiding this comment.
Why use commit hashes for all the actions instead of just the versions?
There was a problem hiding this comment.
I know it's not ideal but it's part of the overall security compliance. Makes it difficult to read for humans but means the version is pinned for security. I added this to hopefully automate the management of them. It will start to complain about our Docker tags soon too.
See - https://github.com/kptdev/porch/security/code-scanning?query=is%3Aopen+branch%3Amain+severity%3Amedium++



Description
checks:write, movedclone_urlto env var, added missing-Dproject.settingsto push scanrun:blocks is replaced with env vars. Push scan now loadssonar-project.propertiesfor correct source/coverage config.Related Issue(s)
Type of Change
Checklist
Testing Instructions (Optional)
AI Disclosure
If so, please describe how: