Stop executing fork-controlled Maven in the privileged fork Sonar workflow (#232) - #28
Closed
devin-ai-integration[bot] wants to merge 5 commits into
Closed
devin-ai-integration[bot] wants to merge 5 commits into
devin-ai-integration[bot] wants to merge 5 commits into
Conversation
…kflow (java-helpers#232) Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…elpers#272) (java-helpers#281) * Adding a script for performance analysis and having multiple runs * Removing stability analysis because this is not needed in future * Adding a check for expected annotations on generated code so that analysis runs could not be done on different code-geration-runs before * Adding possibility to define formatting-mode when running performance-measurement * Fixing bugs in run_performance_measurements * adding script for running a full analysis with comparing the results of all builder types * Removing stability analysis because this is not needed anymore * Updating performance analysis documentation * Optimization in run_full_analysis for usage with non-mac-os systems too
…a-helpers#280) Bumps the maven-plugins group with 1 update in the /core directory: [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin). Bumps the maven-plugins group with 1 update in the /example directory: [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin). Bumps the maven-plugins group with 1 update in the /example-custom-generator directory: [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin). Bumps the maven-plugins group with 2 updates in the /processor directory: [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) and [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire). Updates `org.apache.maven.plugins:maven-compiler-plugin` from 3.15.0 to 3.16.0 - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](apache/maven-compiler-plugin@maven-compiler-plugin-3.15.0...maven-compiler-plugin-3.16.0) Updates `org.apache.maven.plugins:maven-compiler-plugin` from 3.15.0 to 3.16.0 - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](apache/maven-compiler-plugin@maven-compiler-plugin-3.15.0...maven-compiler-plugin-3.16.0) Updates `org.apache.maven.plugins:maven-compiler-plugin` from 3.15.0 to 3.16.0 - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](apache/maven-compiler-plugin@maven-compiler-plugin-3.15.0...maven-compiler-plugin-3.16.0) Updates `org.apache.maven.plugins:maven-compiler-plugin` from 3.15.0 to 3.16.0 - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](apache/maven-compiler-plugin@maven-compiler-plugin-3.15.0...maven-compiler-plugin-3.16.0) Updates `org.apache.maven.plugins:maven-surefire-plugin` from 3.5.6 to 3.6.0 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](apache/maven-surefire@surefire-3.5.6...surefire-3.6.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-version: 3.16.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: maven-plugins - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-version: 3.16.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: maven-plugins - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-version: 3.16.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: maven-plugins - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-version: 3.16.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: maven-plugins - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-version: 3.6.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: maven-plugins ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Owner
|
moved to java-helpers#285 |
…elpers#286) The action only executes the scanner on the runner — use of an unmodified tool, not distribution — so LGPL obligations do not apply. Scope the exception via allow-dependencies-licenses so the fail-closed allow-licenses list stays strict for all other dependencies. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Summary
Fixes the SonarCloud S7631 finding on
.github/workflows/fork-sonar.yml(new-code Security rating C) by removing every execution of fork-controlled content from the privilegedworkflow_runjob, while keeping thefork-cirequired-reviewer gate and the artifact-based design unchanged.Analysis (issue java-helpers#232, step 1)
The finding is real, not a false positive: the old workflow checked out
refs/pull/N/headand ranmvn ... sonar-maven-plugin:sonar --file pom.xmlwithSONAR_TOKENin the environment. Even with-DskipTests, Maven on a fork tree executes code the fork controls:.mvn/extensions.xml/<build><extensions>— arbitrary jars loaded into the Maven process.mvn/maven.config/.mvn/jvm.config— arbitrary flags, e.g.-javaagent:pom.xmlplugin bindings — any plugin/execution bound to phases run by the Sonar goal (it forks a build), or<pluginRepositories>pointing at attacker-hosted pluginsmvnwwrapper scripts (not used today, but trivially added by a PR)The required-reviewer gate reduces likelihood but not impact: a maintainer approving a plausible-looking PR cannot review
.mvn/config or plugin coordinates for exfiltration intent. The rule flags the pattern for exactly that reason.Options considered (step 2)
.gitit warnsSCM provider autodetection failedand reports 0 new lines, so PR decoration and the new-code gate become meaningless. Also duplicates data already present inrefs/pull/N/head. Rejected.Key insight: the problem was never checking out the fork tree (that only writes files), it was running a build tool on it. The fix therefore separates the two.
Implementation (step 3)
fork-sonar.ymlnow:Why each piece matters:
pom.xml: it runs before the fork tree exists in the workspace. The classpath it produces is what gives the Java analyzer full type resolution; a dependency added by the fork PR is simply unresolved (analysis degrades, nothing is downloaded on the fork's behalf).pr_head_shais now validated (^[0-9a-f]{40}$) and asserted againstrefs/pull/N/head, so the analysed sources match the artifact's bytecode even if the PR was force-pushed between the CI run and the approval.project.settingsoutside the workspace — with it set, the scanner ignores anysonar-project.propertiesin the fork tree. This matters because that file can setsonar.scanner.javaExePath(i.e. "run this binary"), which would otherwise be a new fork-controlled execution vector.maven.ymladditionally shipscore/processor target/test-classesso the standalone scanner getssonar.java.test.binaries(previously provided implicitly by the Maven plugin).Sonar properties duplicated from the root
pom.xmlare called out in a comment and indocs/CONTRIBUTING.md; the docs section now records the security model and this decision.Validation
actionlintclean on both workflows.main(30 jars, nosimple-builders-*self-references).main(workflow_run uses the base-branch workflow file) plus a maintainer approval in thefork-cienvironment. Please check the SonarCloud PR decoration shows changed lines and coverage on the first such run.Closes java-helpers#232.
Link to Devin session: https://app.devin.ai/sessions/d691231fba0842a4b842b275ca4b35ed
Open in Devin Desktop: https://app.devin.ai/desktop/session/d691231fba0842a4b842b275ca4b35ed?variant=devin
Requested by: @AndreasIgel