-
-
Notifications
You must be signed in to change notification settings - Fork 583
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
Fix vex export returning invalid CycloneDX #3948
Fix vex export returning invalid CycloneDX #3948
Conversation
src/test/java/org/dependencytrack/parser/cyclonedx/CycloneDXExporterTest.java
Outdated
Show resolved
Hide resolved
@SaberStrat cyclonedx-core-java 9.0.5 was released earlier today, which includes your changes. You should be able to bump the library version now to make your implementation work. |
Deduplicate found vulnerabilities and accumulate affected components per vulnerabiltiy. Signed-off-by: Kirill.Sybin <[email protected]>
Signed-off-by: Kirill.Sybin <[email protected]>
Use all fields of Vulnerability objects, except for `affects`, for deduplicated. Requires CycloneDX/cyclonedx-core-java#463. Signed-off-by: Kirill.Sybin <[email protected]>
Implement CycloneDX schema 1.5's definition of uniqueness of the vulnerability field literally and have affects contribute to a vulnerability's uniquenss too, and do not accumulate affects if other all other fields of multiple vulnerability objects are the same. Signed-off-by: Kirill.Sybin <[email protected]>
As per change request, moving, reworking and enhancing the validity test. It is moved to VexResourceTest. The rework consists of asserting the VEX export Response instead of the validity of the exported BOM object, as the new way checks for the original issue right where it is produced from the user perspective, while the old checked where the original issue was noticed by the user as well as being susceptible to errors in the validate method as well. The enhancement consists of testing with vulnerabilities with differing objects such as differing analysis of the same vuln id on different components, thereby testing the deduplication of the entire Vulnerability object. Signed-off-by: Kirill.Sybin <[email protected]>
Bump library to use the version containing the required enchangement CycloneDX/cyclonedx-core-java#463 Signed-off-by: Kirill.Sybin <[email protected]>
d988949
to
3881bd7
Compare
cyclonedx-core-java bumped and rebased to master. |
Looks like the schema validator version that comes with
|
@nscuro I take it adding escaped quotes to the expected error messages in the test methods is not a proper solution for this? |
It is, actually! Nothing special to do on our side since we merely forward the error messages. But still good to have such tests to be made aware of when these things change. |
Adjust expected json schema validator error messages after the library producing them got bumped as part of the bump of org.cyclonedx.cyclonedx-core-java. Signed-off-by: Kirill.Sybin <[email protected]>
Adjust another expected message missed in the previous commit. Signed-off-by: Kirill.Sybin <[email protected]>
Rinse and repeat. This time, I ran the full test suite locally and it passed. Should I cleanup/squash the commits down logically? |
Not necessary. |
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 preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @SaberStrat! I'll also backport this to v4.11.6.
Description
Fixes exported VEX and BOMs with vulnerabilities not conforming to CycloneDX 1.5.
Addressed Issue
#3834
Additional Details
The general idea is to deduplicate vulnerabilities based on all
Vulnerability
fields.I settled on an implementation with one HashSet that tracks all
Vulnerability
objects seen when convertingFinding
s intoVulnerability
s.It requires an enhancement of the cyclonedx-core-java library, namely adding custom
equals
andhashCode
methods to theVulnerability
class for fieldwise comparison: CycloneDX/cyclonedx-core-java#463.Other possible implementations I considered:
Vulnerability
s based on all of its fields except foraffects
and accumulate affects objects in one vulnerability if all otherVulnerability
fields have otherwise equal values. This came from an interpretation of a remark from the original issue reporter in the issue report. But the CycloneDX schema doesn't really require an accumulation, if I'm not mistaken.I considered a few different implementations of this (in case an accumulation was not wrong after all).
Vulnerability
s to HashSets ofAffect
s. This was the way I'd have gone withaffects
list defined outside of and passed toVulnerability
's convert() calls. Was not sure about havingconvert()
convert vulnerability objects AND modify a state of a list passed to it.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