Repository navigation
fix(git): checkout resolved revision before scanning - #340
Conversation
Signed-off-by: Sachin Kumar <[email protected]>
|
@sachin9058 - Your changes break the build. https://github.com/cbomkit/cbomkit/actions/runs/26979322762/job/79691333709?pr=340 Please ALWAYS run |
|
I disabled your regression test temporarily and tested the fix in GitService manually. It does indeed fix the issue.
Here's what I did to build and run cbomkit: mvn clean package
quarkus devScanning |
|
@san-zrl Thanks for verifying the fix against the Guava reproduction. I investigated the CI failure and found it was caused by the regression test setup. The test was creating a local repository URL via Regarding local verification: I attempted to run the test and full build locally, but my environment cannot currently resolve |
Signed-off-by: Sachin Kumar <[email protected]>
|
@sachin9058 - Thanks for also fixing the regression test. I'll merge this PR and will also close #339. Thank you for contributions. Btw., the mvn packages for cbomkit-lib and sonar-crypto are stored in the Github Packages Registry. Follow this procedure: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry. |
|
Thanks for the review and for helping track this down. I'll set up GitHub Packages access locally and continue contributing. |

Summary
For version-based scans (e.g. Maven packages resolved through DepsDev),
GitServicecorrectly resolves a matching tag/ref and commit hash, but the cloned working tree remains on the repository default branch.As a result, scanners analyze source code from a different revision than the one associated with the requested package version.
This PR ensures the resolved revision is checked out before scanning.
Root Cause
The clone flow for
commit == null:However, unlike the
commit != nullpath, no checkout was performed after resolving the commit hash. The scanners therefore operated on the default-branch working tree rather than the requested revision.Changes
commit == nullpath ofGitService.clone()GitServiceRevisionCheckoutTestas a regression testRegression Test
The test creates a local repository with:
v1.0.0It then executes:
Before
After
This verifies that scanners operate on the revision requested by the scan rather than the repository default branch.
Impact
Version-based scans now analyze the correct source revision, ensuring the scanned working tree matches the revision resolved from the package version.
Likely related to #339.