-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Update vulnerabilities to use new Tool specification #438
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Usman Shaikh <shaikhu@gmail.com>
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🚀 Don’t miss a bit, follow what’s new on Codacy. Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
@JacksonXmlElementWrapper(localName = "tools") | ||
@JacksonXmlProperty(localName = "tool") | ||
private List<Tool> tools; |
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.
tools
should be marked as deprecated to avoid confusion, similar to how it's done in Metadata
:
cyclonedx-core-java/src/main/java/org/cyclonedx/model/Metadata.java
Lines 63 to 65 in 3702283
@VersionFilter(Version.VERSION_12) | |
@Deprecated | |
private List<Tool> tools; |
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.
tools
should be marked as deprecated to avoid confusion, similar to how it's done inMetadata
:cyclonedx-core-java/src/main/java/org/cyclonedx/model/Metadata.java
Lines 63 to 65 in 3702283
@VersionFilter(Version.VERSION_12) @Deprecated private List<Tool> tools;
👍 7fc564a
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.
Metadata
has a custom deserializer to deal with the tool deserialization:
cyclonedx-core-java/src/main/java/org/cyclonedx/util/deserializer/MetadataDeserializer.java
Lines 146 to 167 in 3702283
private void parseTools(JsonNode toolsNode, Metadata metadata, ObjectMapper mapper) throws JsonProcessingException { | |
if (toolsNode.isArray()) { | |
setToolInfo(toolsNode, metadata, mapper); | |
} else if (toolsNode.has("tool")) { | |
JsonNode toolNode = toolsNode.get("tool"); | |
if (toolNode.isArray()) { | |
setToolInfo(toolNode, metadata, mapper); | |
} else { | |
Tool tool = mapper.convertValue(toolNode, Tool.class); | |
metadata.setTools(Collections.singletonList(tool)); | |
} | |
} else { | |
ToolInformation toolInformation = new ToolInformation(); | |
if (toolsNode.has("components")) { | |
parseComponents(toolsNode.get("components"), toolInformation, mapper); | |
} | |
if (toolsNode.has("services")) { | |
parseServices(toolsNode.get("services"), toolInformation, mapper); | |
} | |
metadata.setToolChoice(toolInformation); | |
} | |
} |
That doesn't seem to be the case for Vulnerability
. @mr-zepol am I seeing this right that in order to support ToolInformation
in Vulnerability
, we need a custom deserializer there as well?
Signed-off-by: Usman Shaikh <shaikhu@gmail.com>
According to the docs, since v1.5 the
Tools
format has been deprecated and a new format recommended. While the entityMetada
has been updated to use the new format (new methodsetToolChoice
),Vulnerability
has not. This PR adds a similar method toVulnerability
.