Fix NPE and redundant queries in VEX/VDR export#6614
Open
heyiamwahab236 wants to merge 2 commits into
Open
Conversation
The convert() method dereferenced the Component and Vulnerability resolved by UUID without null checks. When a finding referenced a component or vulnerability that was deleted between query and export, this threw a NullPointerException and aborted the entire VEX/VDR export. Null entries are now skipped via a guard in convert() and a filter in generateVulnerabilities(). The analysis lookup also re-fetched the Component and Vulnerability by UUID even though both were already resolved earlier in the method, issuing two unnecessary database queries per finding. It now reuses the already-resolved objects. Signed-off-by: Abdul wahab Shah <abdulwahab.shah236@gmail.com>
Verifies that generateVulnerabilities skips findings whose component was deleted between the findings query and export, instead of throwing a NullPointerException, and that valid findings still convert as before. Signed-off-by: Abdul wahab Shah <abdulwahab.shah236@gmail.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Up to standards ✅🟢 Issues
|
Author
|
@nscuro Can you please have a look at it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a
NullPointerExceptionthat aborts the entire VEX/VDR CycloneDX export when afinding references a component or vulnerability that was deleted between the findings
query and the export.
ModelConverter.convert()resolved theComponentandVulnerabilityby UUID but dereferenced them without null checks, so a concurrentdeletion (e.g. re-analysis or manual removal) caused
component.getProject()to throwand the whole export to fail with a 500. Such findings are now skipped via a guard in
convert()and afilteringenerateVulnerabilities(), so the export completes withthe remaining vulnerabilities.
Also removes two redundant database queries per finding: for the VEX/VDR variant the
analysis lookup re-fetched the
ComponentandVulnerabilityby UUID even though bothwere already resolved earlier in the same method. It now reuses the resolved objects.
Addressed Issue
fixes #6613
Additional Details
A regression test (
ModelConverterTest) was added covering both a finding whosecomponent was deleted (previously reproduced the NPE, now returns an empty result) and
a normal finding that still converts correctly. The test was verified to fail against
the unpatched code and pass with the fix.
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 updated the migration changelog accordinglyThis PR introduces new or alters existing behavior, and I have updated the documentation accordinglyThis PR is a substantial change (per the ADR criteria), and I have added an ADR underdocs/adr/