Skip to content

Comments

PR Decorator Fix - Same CVEs should be aggregated in the same record#1067

Open
orto17 wants to merge 1 commit intojfrog:v3_erfrom
orto17:fix-pr-decorators
Open

PR Decorator Fix - Same CVEs should be aggregated in the same record#1067
orto17 wants to merge 1 commit intojfrog:v3_erfrom
orto17:fix-pr-decorators

Conversation

@orto17
Copy link
Contributor

@orto17 orto17 commented Feb 22, 2026

  • All tests passed. If this feature is not already covered by the tests, I added new tests.
  • This pull request is on the dev branch.
  • I used gofmt for formatting the code before submitting the pull request.
  • Update documentation about new features / new supported technologies

@orto17 orto17 added the bug Something isn't working label Feb 22, 2026
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Feb 22, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Feb 22, 2026
@github-actions
Copy link
Contributor

👍 Frogbot scanned this pull request and did not find any new security issues.


@orto17 orto17 changed the title PR Decorator Fix - Same CVEs aggregated in the same record PR Decorator Fix - Same CVEs should be aggregated in the same record Feb 22, 2026
if existing, ok := byKey[key]; ok {
existing.ImpactPaths = append(existing.ImpactPaths, v.ImpactPaths...)
if len(v.FixedVersions) > 0 {
existing.FixedVersions = append(existing.FixedVersions, v.FixedVersions...)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we have duplicates here?

return v.IssueId + "|" + strings.Join(ids, ",")
}

func aggregateVulnerabilitiesByCve(vulnerabilities []formats.VulnerabilityOrViolationRow) []formats.VulnerabilityOrViolationRow {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt we apply this on violations too?

existing.FixedVersions = append(existing.FixedVersions, v.FixedVersions...)
}
} else {
agg := *v
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merge step only appends ImpactPaths and FixedVersions. All other fields (Severity, Applicable, ImpactedDependencyVersion, Components, etc.) are kept from the first occurrence and silently discarded from subsequent ones. This works fine for the summary table (which only renders paths), but getComponentIssueIdentifier in the details section uses ImpactedDependencyName/Version directly, so the details heading will only show the first row's version. we need to either document it or fix it if it will be used in other contexts

ids = append(ids, cve.Id)
}
sort.Strings(ids)
return v.IssueId + "|" + strings.Join(ids, ",")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key is IssueId + "|" + sorted CVE IDs. If Xray reports different IssueId values for the same CVE across different dependency paths (e.g. XRAY-12345 vs XRAY-12346 for the same CVE-2017-1000487), they won't be aggregated and the bug persists. Worth verifying that IssueId is always stable per CVE, or whether the key should be just the sorted CVE IDs.

}
}

func TestVulnerabilitiesContent_aggregatesSameCveIntoOneRow(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add unit test for aggregateVulnerabilitiesByCve

Copy link
Collaborator

@eranturgeman eranturgeman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved! see my comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants