fix: backfill SCA recommendedVersion from ScanReportJson export#1506
Open
anuragtiwari005 wants to merge 1 commit into
Open
fix: backfill SCA recommendedVersion from ScanReportJson export#1506anuragtiwari005 wants to merge 1 commit into
anuragtiwari005 wants to merge 1 commit into
Conversation
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.
By submitting this pull request, you agree to the terms within the Checkmarx Code of Conduct. Please review the contributing guidelines for guidance on creating high-quality pull requests.
Description
Summary
SCA findings in JSON scan reports (
cx_result.json) often have an emptydata.recommendedVersioneven though the ScanReportJson export already contains a per-CVE fix version (NextFixedVersion).The CLI already downloads ScanReportJson during result enrichment (
ReadResults→enrichScaResults→GetExportPackage) and uses it to populate package metadata (scaPackageData, dependency paths,fixLink). However,recommendedVersionwas only passed through from the Results API and was never backfilled from the export.This change fills
data.recommendedVersionfrom export data when the Results API value is empty, using a{CveName|PackageID}lookup keyed toNextFixedVersion.Problem
recommendedVersionin JSON output comes from the paginated Results API response.Id,Type,IsIgnored,PackageID) and ignoredNextFixedVersion.recommendedVersionfor upgrade/remediation guidance.Solution
ScaTypeto parseCveNameandNextFixedVersionfrom ScanReportJsonVulnerabilities.data.recommendedVersionvalues from export using lookup key{CveName|PackageID}(falls back toIdwhenCveNameis absent).recommendedVersionvalues returned by the Results API.Files changed
internal/wrappers/export.go— add export vulnerability fieldsinternal/commands/result.go— backfill logic inenrichScaResultsinternal/commands/result_test.go— unit tests for lookup and backfill behaviorTest plan
go test ./internal/commands/ -run 'Test_backfillRecommendedVersionsFromExport|Test_buildScaUpgradeVersionLookup|Test_addPackageInformation'cx scan create --report-format jsonon a repo with SCA findings where Results API returns emptyrecommendedVersioncx_result.jsonnow containsdata.recommendedVersionpopulated from export where availablerecommendedVersionfrom the API are unchangedType of Change
Related Issues
Link any related issues or tickets.
Checklist
Screenshots (if applicable)
Add screenshots to help explain your changes.
Additional Notes
Add any other relevant information.