use of com.synopsys.integration.blackduck.api.generated.component.ProjectVersionComponentVersionVulnerabilityRemediationCvss3View in project hub-alert by blackducksoftware.
the class BlackDuckComponentVulnerabilityDetailsCreator method toAlertVulnerabilityView.
private AlertVulnerability toAlertVulnerabilityView(BlackDuckProjectVersionComponentVulnerabilitiesView vulnerability) {
String name = vulnerability.getId();
String url = vulnerability.getFirstLinkSafely("vulnerability").map(HttpUrl::toString).orElse(null);
String severity;
ProjectVersionComponentVersionVulnerabilityRemediationCvss3View cvss3 = vulnerability.getCvss3();
if (vulnerability.getUseCvss3() && null != cvss3) {
severity = Optional.ofNullable(cvss3.getSeverity()).map(Enum::name).orElse(VulnerabilitySeverityType.HIGH.name());
} else {
ProjectVersionComponentVersionVulnerabilityRemediationCvss2View cvss2 = vulnerability.getCvss2();
severity = Optional.ofNullable(cvss2.getSeverity()).map(Enum::name).orElse(VulnerabilitySeverityType.HIGH.name());
}
VulnerabilitySeverityType vulnSeverity = EnumUtils.getEnum(VulnerabilitySeverityType.class, severity, VulnerabilitySeverityType.HIGH);
LinkableItem vulnInfo = new LinkableItem(LABEL_VULNERABILITY, name, url);
return new AlertVulnerability(vulnSeverity, vulnInfo);
}
Aggregations