DependencyTrack / dependency-track

Dependency-Track is an intelligent Component Analysis platform that allows organizations to identify and reduce risk in the software supply chain.
https://dependencytrack.org/
Apache License 2.0
2.6k stars 548 forks source link

Components get deleted in update #4175

Open Gepardgame opened 5 days ago

Gepardgame commented 5 days ago

Current Behavior

If you update an internal vulnerability with components, the the components will no longer be showen.

Steps to Reproduce

  1. Create an internal vulnerability with one or more affected components.
  2. Open the vulnerability(View details) and click the "Update" Button
  3. Reload site and open Vulnerability again and go to Affected Components tab
  4. Wonder why there are no components

Expected Behavior

Components should be shown, even so the vulnerability gets updated.

The problem is there in the code VulnerabilityQueryManager.java#L798. I don't know there the attribution would be reported again.

Dependency-Track Version

4.12.0-SNAPSHOT

Dependency-Track Distribution

Executable WAR

Database Server

H2

Database Server Version

No response

Browser

N/A

Checklist

Gepardgame commented 4 days ago

@sahibamittal You implemented this function. The old source is INTERNAL and the new one is INTERNAL, which concludes to the deletion of the attributes, even so it is still relevant. I can think that has been implemented for to prevent duplications, but I don't know for sure.

nscuro commented 4 days ago

I suspect that we don't create AffectedVersionAttributions for manually created VulnerableSoftware records.

Then when it comes to reconcileVulnerableSoftware, manually created VulnerableSoftwares end up in this branch: https://github.com/DependencyTrack/dependency-track/blob/d03cb83725b3f44fa47fbc78c3f601b626178bbd/src/main/java/org/dependencytrack/persistence/VulnerabilityQueryManager.java#L779-L785

Gepardgame commented 4 days ago

That is not the problem, but the source is the same so https://github.com/DependencyTrack/dependency-track/blob/d03cb83725b3f44fa47fbc78c3f601b626178bbd/src/main/java/org/dependencytrack/persistence/VulnerabilityQueryManager.java#L787-L788 is true, which deletes the Attribut and will not add it to vsList.