Current Behavior
This curl command can take 10s of minutes to complete:
curl -v --header 'X-Api-Key: ...' https://dtrack/api/v1/vulnerability/project/uuid-goes-here
it appears to be caused by an M*N query pattern.
On one of my projects I have ~5k components. That API endpoint calls getVulnerabilities, which:
|
*/ |
|
public List<Vulnerability> getVulnerabilities(Project project, boolean includeSuppressed) { |
|
final List<Vulnerability> vulnerabilities = new ArrayList<>(); |
|
final List<Component> components = getAllComponents(project); |
|
for (final Component component: components) { |
|
final Collection<Vulnerability> componentVulns = pm.detachCopyAll( |
|
getAllVulnerabilities(component, includeSuppressed) |
|
); |
|
for (final Vulnerability componentVuln: componentVulns) { |
|
componentVuln.setComponents(Collections.singletonList(pm.detachCopy(component))); |
|
componentVuln.setAliases(new ArrayList<>(pm.detachCopyAll(getVulnerabilityAliases(componentVuln)))); |
|
} |
|
vulnerabilities.addAll(componentVulns); |
|
} |
|
return vulnerabilities; |
|
} |
- Queries all the components,
- For each component, runs getAllVulnerabilities which:
a. queries for vulnerabilities
b. For each matched vulnerability queries for aliased vulnerabilities
- For each found component vulnerability, queries for vulnerability aliases again
I'm pretty sure this is performing many tens of thousands of queries, since this process takes tens of minutes to complete on my project with ~5k components and a few hundred identified vulnerabilities.
Steps to Reproduce
- Upload a large SBOM (I can provide one privately)
- Upload the SBOM again as VEX data and trigger analysis
- Query for impacted vulnerabilities
Expected Behavior
I would expect this process to take a second or so under normal circumstances, though even a minute would be a lot better :).
Dependency-Track Version
4.14.2
Dependency-Track Distribution
Container Image
Database Server
PostgreSQL
Database Server Version
17
Browser
N/A
Checklist
Current Behavior
This curl command can take 10s of minutes to complete:
it appears to be caused by an M*N query pattern.
On one of my projects I have ~5k components. That API endpoint calls getVulnerabilities, which:
dependency-track/src/main/java/org/dependencytrack/persistence/VulnerabilityQueryManager.java
Lines 479 to 494 in dc1241c
a. queries for vulnerabilities
b. For each matched vulnerability queries for aliased vulnerabilities
I'm pretty sure this is performing many tens of thousands of queries, since this process takes tens of minutes to complete on my project with ~5k components and a few hundred identified vulnerabilities.
Steps to Reproduce
Expected Behavior
I would expect this process to take a second or so under normal circumstances, though even a minute would be a lot better :).
Dependency-Track Version
4.14.2
Dependency-Track Distribution
Container Image
Database Server
PostgreSQL
Database Server Version
17
Browser
N/A
Checklist