Repository navigation
ci: fork-gate maven-sonar-build's ~/.m2 cache save; JSON-encode eslint_has_findings in ui-checkstyle - #35420
Merged
Conversation
…lint_has_findings maven-sonar-build runs on pull_request_target and builds the PR head, but its combined actions/cache@v6 saved ~/.m2 post-job with no fork guard, so a fork run wrote into main's cache scope. Split it into an ungated restore and a fork-gated save keyed on the restore's cache-primary-key, matching the other Maven caches fixed in #32436 and #32468. ui-checkstyle's privileged comment job interpolated eslint_has_findings raw inside a quoted JS string. That output is written by the PR's own scripts/eslint-pr-report.js, so wrap it in toJSON like the two outputs next to it.
pmbrull
requested review from
a team,
akash-jain-10,
harshach and
tutte
as code owners
October 14, 2026 08:10
Code Review ✅ Approved🔴 High risk · Fork-gating Maven cache saves and JSON-encoding PR-controlled output alter privileged workflow protections; regressions could re-enable cache poisoning or script injection. Two CI hardening fixes: VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
chirag-madlani
approved these changes
Oct 14, 2026
tutte
approved these changes
Oct 14, 2026
pmbrull
added this pull request to the merge queue
Oct 14, 2026
6 of 7 tasks
pmbrull
added a commit
that referenced
this pull request
Oct 20, 2026
Conflicts: - .github/workflows/maven-sonar-build.yml: kept this branch's save condition (cache-hit only). Main carries #35420's fork guard for pull_request_target, which can no longer fire now that the workflow triggers on pull_request. Follow-up from main: REVIEW.md asked reviewers to check that a missing `safe to test` label did not skip a job; that label is retired here, so the item now names the fork and Dependabot skips instead.
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.
Describe your changes:
No linked issue — two hardening fixes from an audit of the workflows that run on
pull_request_target. Follow-up to #32436 and #32468; #32468 listedmaven-sonar-build.ymlas still unguarded.1.
maven-sonar-build.yml— unguarded~/.m2cache save underpull_request_target. The workflow triggers onpull_request_targetand checks out the PR head (allow-unsafe-pr-checkout: true), so it runs in the base branch's cache scope with the PR's build on disk. Its combinedactions/cache@v6then saved~/.m2after the job with no fork guard. The key hashes**/pom.xmlonly, and the${{ runner.os }}-maven-restore prefix is shared by the merge-queue Playwright build,release-branch-validate.yml,integration-tests-postgres-elasticsearch-redis.ymland the nightlies, so whatever a fork run left in~/.m2could be restored by trusted runs.2.
ui-checkstyle.yml— a PR-controlled job output was interpolated raw intogithub-script. Theui-checkstylejob (pull-requests: write) builds its PR comment inactions/github-scriptand readeslint_has_findingsas'${{ needs.checkstyle.outputs.eslint_has_findings }}'. That output is written to$GITHUB_OUTPUTbyscripts/eslint-pr-report.jsfrom the PR checkout, so a value containing a quote closed the string literal and the rest ran as script in the privileged job. It is now wrapped intoJSON, likeeslint_summaryandeslint_detailsnext to it. The other expressions in that script were already safe: the*_changed_filesoutputs go throughtoJSON, and the*_resultoutputs,needs.checkstyle.resultand the comment id come from the runner or the API.Both paths already required the
safe to testlabel.Type of change:
High-level design:
N/A — small change, two workflow files.
maven-sonar-build.ymlnow uses an ungatedactions/cache/restore@v6and a fork-gatedactions/cache/save@v6afterBuild with Maven:~/.m2. Only the write is gated, the same shape asplaywright-knowledge-graph-postgresql-e2e.ymlandplaywright-e2e-reusable.yml.cache-hit != 'true'keeps the combined action's skip on an exact hit, and the save step inherits the implicitsuccess(), as the combined action'spost-if: success()did.cache-primary-keyinstead of evaluatinghashFiles('**/pom.xml')again after the build, so restore and save cannot end up on different keys.ui-checkstyle.yml:Rollout: both workflows run on
pull_request_target, which always usesmain's copy of the workflow file, so this PR's own checks still run the old versions and the change takes effect on merge. Same-repo PRs andworkflow_dispatchruns save the Maven cache as before; fork PRs restore it but no longer write.Tests:
Use cases covered
pull_request_target(maven-sonar-build): restores~/.m2, writes nothing into the base-branch cache scope.workflow_dispatch(maven-sonar-build): restore and save as before; an exact hit skips the save.has_findingsoftrue,falseor empty behaves exactly as before; a value containing'is read as a plain string.Unit tests
Not applicable — CI configuration only.
Backend integration tests
Not applicable — no Java changes.
Ingestion integration tests
Not applicable — no ingestion changes.
Playwright (UI) tests
Not applicable — no UI changes.
Manual testing performed
yaml.safe_loadon both changed files — both parse.maven-sonar-build.yml: no combinedactions/cache@vNis left; the restore has noif:; the save carries the fork guard and thecache-hitcheck, comes afterBuild with Maven, and uses the restore's path and primary key.actionlinton both files:maven-sonar-build.ymlis clean;ui-checkstyle.ymlreports the same 25 shellcheck info/style notes onmainand on this branch, none on the changed line.Post or update summary commentscript frommainand from this branch the way the expression engine does (toJSONgives a JSON string literal, a bare expression gives raw text) and ran each in node against a mocked GitHub client:eslint_has_findingsmaintruefalse/ emptyUI screen recording:
Not applicable — CI configuration only.
Checklist:
Fixes <issue-number>: <short explanation>— no linked issue; CI hardening, labelledskip-pr-checks.Fixes #<issue-number>above — see above.🤖 Generated with Claude Code