Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add source attributions for affected component version ranges #2098

Merged
merged 23 commits into from
Nov 15, 2022
Merged

Add source attributions for affected component version ranges #2098

merged 23 commits into from
Nov 15, 2022

Conversation

sahibamittal
Copy link
Contributor

@sahibamittal sahibamittal commented Oct 26, 2022

Description

This PR adds source attributions for affected component ranges.

Starting with the OSV integration, we now have multiple sources contributing vulnerability intelligence data for the same vulnerability. For example, both the GitHub Advisories and OSV integration may contribute affected version ranges for the same GHSA vulnerability.

By tracking attributions, mirroring tasks are now able to differentiate between affected ranges they previously reported, and those reported by mirroring tasks for other sources. This makes it possible to dynamically prune outdated records, without interfering with other sources' data.

Prior to this PR, the OSV mirroring task would only ever append to the ranges already associated with a given vulnerability, while the GitHub Advisories mirroring task would bluntly replace everything with what was reported by GitHub.

Additionally, this information is exposed via REST API, and displayed in the Affected Components tab of the vulnerability details view:

image

Users can now see what source reported what, and when.

Addressed Issue

Closes #1815

Additional Details

Internally, Dependency-Track stores version ranges in VulnerableSoftware objects. Based on the data mirrored from sources, VulnerableSoftware records are associated with Vulnerability records, forming an "affected by" relationship.

The relationship between VulnerableSoftware and Vulnerability is M:N, meaning the same VulnerableSoftware record may be associated with multiple vulnerabilities. In fact, some are associated with over 1000 vulns:

image

We investigated adding the attribution fields to the VULNERABLESOFTWARE_VULNERABILITIES join table (possible with JDO, see this DataNucleus example). But this resulted in very messy code to maintain and update these relationships, so we decided against doing it this way.

Instead, attributions are now a separate object / table that just holds foreign keys to both Vulnerability and VulnerableSoftware. This is similar to the way we handle FindingAttributions already.

Signed-off-by: Sahiba Mittal <sahibamittal98@gmail.com>
Signed-off-by: Sahiba Mittal <sahibamittal98@gmail.com>
@sonatype-lift
Copy link
Contributor

sonatype-lift bot commented Oct 26, 2022

⚠️ 16 God Classes were detected by Lift in this project. Visit the Lift web console for more details.

Signed-off-by: Sahiba Mittal <sahibamittal98@gmail.com>
Signed-off-by: Sahiba Mittal <sahibamittal98@gmail.com>
@nscuro nscuro self-assigned this Oct 27, 2022
Signed-off-by: Sahiba Mittal <sahibamittal98@gmail.com>
Signed-off-by: Sahiba Mittal <sahibamittal98@gmail.com>
Signed-off-by: Sahiba Mittal <sahibamittal98@gmail.com>
Signed-off-by: Sahiba Mittal <sahibamittal98@gmail.com>
Signed-off-by: Sahiba Mittal <sahibamittal98@gmail.com>
@sahibamittal

This comment was marked as outdated.

@nscuro nscuro marked this pull request as draft November 4, 2022 12:33
…ns for the same vulnerability

Previously, GitHub was blunty overriding any VulnerableSoftware<->Vulnerability relationships established by OSV, while OSV would just append on what's already there.

Using attributions for these relationships, this issue is now solved. The performance impact so far has been minimal, although no real benchmarks have been made.

Tests are still a WIP and will be added in a later commit.

Signed-off-by: nscuro <nscuro@protonmail.com>
Signed-off-by: nscuro <nscuro@protonmail.com>
Signed-off-by: nscuro <nscuro@protonmail.com>
Signed-off-by: nscuro <nscuro@protonmail.com>
Signed-off-by: nscuro <nscuro@protonmail.com>
Signed-off-by: nscuro <nscuro@protonmail.com>
Signed-off-by: nscuro <nscuro@protonmail.com>
Signed-off-by: nscuro <nscuro@protonmail.com>
Signed-off-by: nscuro <nscuro@protonmail.com>
Signed-off-by: nscuro <nscuro@protonmail.com>
@nscuro nscuro removed their request for review November 6, 2022 18:05
This is consistent with how other sources do it, and avoids duplicate `VulnerableSoftware` records that end up meaning the same thing.

Signed-off-by: nscuro <nscuro@protonmail.com>
Signed-off-by: nscuro <nscuro@protonmail.com>
Because the latter throws an exception instead of returning `null` when the object was not found.

Signed-off-by: nscuro <nscuro@protonmail.com>
@nscuro nscuro marked this pull request as ready for review November 7, 2022 12:21
@nscuro
Copy link
Member

nscuro commented Nov 7, 2022

@sahibamittal I updated the PR description with screenshots and some implementation details.

@nscuro nscuro changed the title Issue-1815 : handle affected package new versions Add source attributions for affected component version ranges Nov 15, 2022
@nscuro nscuro merged commit 4be1a6c into DependencyTrack:master Nov 15, 2022
@sahibamittal sahibamittal deleted the Issue-1815-handle-affected-package-versions branch November 15, 2022 09:25
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Track and handle changes in which versions are affected by a given vulnerability
3 participants