fix(security): least-privilege workflow permissions (SonarCloud New Code)#58
Merged
Conversation
…ode) SonarCloud's Quality Gate has been red on 'C Security Rating on New Code' (required >= A) since before this programme started, and had not been looked at. Its public API lists the findings without needing dashboard access: https://sonarcloud.io/api/issues/search?componentKeys=hyperpolymath_krl&types=VULNERABILITY 15 vulnerabilities, all inside the new-code period. Two of them are addressed here, including one this programme introduced. * .github/workflows/e2e.yml — 'Replace "read-all" with specific permissions'. This one is mine: e2e.yml was rewritten in #53 and carried the template's `permissions: read-all`. Narrowed to `contents: read`, which is all four jobs need. * .github/workflows/pages.yml — three findings, 'Move this read/write permission from workflow level to job level'. The workflow granted contents:read + pages:write + id-token:write to BOTH jobs, but only deploy needs the pages and id-token scopes. Split per job so the build job — the one that runs a container image and executes the SSG over repository content — never holds deploy credentials. Not addressed here, and left for a separate pass so this PR stays reviewable: secret-scanner.yml:18 Only pass required secrets to this workflow mirror.yml:12 Only pass required secrets to this workflow release.yml:38 Dependencies without locked resolved versions release.yml:91 Not enforcing HTTPS static-analysis-gate.yml:11 Workflow-level permission static-analysis-gate.yml:30,31,229,230 Not enforcing HTTPS setup.sh:144,156 Not enforcing HTTPS The rating will not reach A until those are triaged too; several may be false positives (the HTTPS findings need reading in context before changing). Verified: actionlint 0, K9 0, A2ML 0, e2e 4/4, aspect 4/4, smoke 20/20.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



mainis green as of #57. This addresses the one original red that had gone unexamined all programme: SonarCloud Quality Gate —C Security Rating on New Code(required ≥ A).Getting the findings without dashboard access
SonarCloud's project is public, so its API lists them directly:
15 vulnerabilities, all inside the new-code period. Two are fixed here — including one this programme introduced.
Fixed
e2e.yml— "Replaceread-allwith specific permissions"This one is mine.
e2e.ymlwas rewritten in #53 and carried the RSR template'spermissions: read-all. Narrowed tocontents: read, which is all four jobs need.pages.yml×3 — "Move this read/write permission from workflow level to job level"The workflow granted
contents:read+pages:write+id-token:writeto both jobs, but onlydeployneeds the pages and id-token scopes. Now split per job:buildcontents: readdeploycontents: read,pages: write,id-token: writeThat matters here beyond satisfying the linter: the
buildjob runs a container image and executes the SSG over repository content. It should not be holding deploy credentials while doing so.Not fixed — deliberately, so this stays reviewable
secret-scanner.yml:18,mirror.yml:12release.yml:38release.yml:91,static-analysis-gate.yml:30,31,229,230,setup.sh:144,156static-analysis-gate.yml:11The rating will not reach A until those are triaged too. Several of the HTTPS findings may be false positives and need reading in context before anything is changed — which is exactly why they aren't bundled into a PR about permissions.
Verified
actionlint0 · K9 0 errors · A2ML 0 errors · e2e 4/4 · aspect 4/4 · smoke 20/20