Skip to content

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

Open
orto17 wants to merge 6 commits 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 6 commits 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

The fix:

image

@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
@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
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

@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Mar 1, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Mar 1, 2026
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Mar 1, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Mar 1, 2026
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Mar 1, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Mar 1, 2026
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Mar 1, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Mar 1, 2026
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Mar 8, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Mar 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

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


if pathErr != nil {
return fmt.Errorf("failed to rollback descriptor: %w (original error: %v)", pathErr, err)
}
// #nosec G703 -- path validated under working directory by getAbsolutePathUnderWd
Copy link
Collaborator

Choose a reason for hiding this comment

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

#nosec G703 annotation is incorrect.
gosec G703 is "Deferring a method which returns an error" — that's unrelated.
The gosec rule being triggered here is G304 ("File path provided as taint input").

return regexp.MustCompile(regexpCompleteFormat)
}

func getAbsolutePathUnderWd(path string) (string, error) {
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

if err != nil {
return "", fmt.Errorf("failed to get working directory: %w", err)
}
wdAbs, err := filepath.Abs(wd)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think Getwd already returns absolute path so calling filepath.Abs is redundant

return "", fmt.Errorf("failed to resolve working directory: %w", err)
}
rel, err := filepath.Rel(wdAbs, absPath)
if err != nil || strings.HasPrefix(rel, "..") || rel == ".." {
Copy link
Collaborator

Choose a reason for hiding this comment

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

strings.HasPrefix(rel, "..") already covers the case of "rel == ".."" so you dont need the ' rel == ".." '

agg.ImpactPaths = append([][]formats.ComponentRow(nil), v.ImpactPaths...)
agg.FixedVersions = append([]string(nil), v.FixedVersions...)
heapCopy := new(formats.VulnerabilityOrViolationRow)
*heapCopy = agg
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do you need this second copy? this is similar to the copy made here 'agg := *v'

order[key] = i
}
}
sort.Slice(result, func(i, j int) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The order-preservation pass re-iterates vulnerabilities to build the
order map after the aggregation map is already built. This can be
folded into the first loop (track first-seen index inside the main loop)
to avoid the second O(n) scan — minor but cleaner.

return out
}

func aggregateVulnerabilitiesOrViolationsByCve(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.

The violations aggregation is drops important data when two rows for
the same CVE have different Watch names (the "Watch Name" column in the
violations table is kept from the first occurrence, silently discarding
the others). If two different Watch policies trigger on the same CVE,
merging them may cause confusion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Another issue with the violation aggregation is when two violations rows for the same CVE have different impacted dependency versions (e.g., lib:1.5.15 and lib:1.5.1), the merged row will only show lib:1.5.15 in the "Impacted Dependency" column. The second version is silently dropped — it won't appear in the table at all (unlike vulnerabilities where ImpactPaths carries that info implicitly).

The Components field (used for "Direct Dependencies" via getDirectDependenciesCellData) has the same problem — it's also only kept from the first occurrence in the aggregation merge step.

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.

Please add description to PR and fix failing test in Scan Pull Request suit as they are all suppose to be green now

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