Fix too many query parameters when retrieving vuln aliases#5101
Fix too many query parameters when retrieving vuln aliases#5101nscuro merged 1 commit intoDependencyTrack:masterfrom
Conversation
Fixes DependencyTrack#5096 Signed-off-by: nscuro <[email protected]>
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes issue #5096 by batching the vulnIdAndSources input into smaller partitions to avoid exceeding database parameter limits when retrieving vulnerability aliases.
- Introduces batching logic that partitions the input collection into chunks of up to 250 items
- Extracts the original query implementation into a new private
getVulnerabilityAliasesInternalhelper - Aggregates results from each batch into a single
Map<VulnIdAndSource, List<VulnerabilityAlias>>
Comments suppressed due to low confidence (2)
src/main/java/org/dependencytrack/persistence/VulnerabilityQueryManager.java:695
- [nitpick] Update the method JavaDoc to note that inputs are internally batched (in groups of 250) to avoid database parameter limits, so future readers understand the reasoning.
public Map<VulnIdAndSource, List<VulnerabilityAlias>> getVulnerabilityAliases(
src/main/java/org/dependencytrack/persistence/VulnerabilityQueryManager.java:707
- Add a unit test for cases where
vulnIdAndSources.size()exceeds 250 to verify that partitioning and result aggregation work correctly without losing entries.
final var results = new HashMap<VulnIdAndSource, List<VulnerabilityAlias>>(vulnIdAndSources.size());
src/main/java/org/dependencytrack/persistence/VulnerabilityQueryManager.java
Show resolved
Hide resolved
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Description
Fixes too many query parameters when retrieving vulnerability aliases.
Addressed Issue
Fixes #5096
Additional Details
N/A
Checklist
This PR implements an enhancement, and I have provided tests to verify that it works as intendedThis PR introduces changes to the database model, and I have added corresponding update logicThis PR introduces new or alters existing behavior, and I have updated the documentation accordingly