Search in sources :

Example 1 with VulnerabilitySeverityType

use of com.synopsys.integration.blackduck.api.generated.enumeration.VulnerabilitySeverityType in project hub-alert by blackducksoftware.

the class VulnerabilityNotificationMessageExtractor method createVulnerabilityConcern.

private ComponentConcern createVulnerabilityConcern(VulnerabilitySourceQualifiedId vulnerability, ItemOperation itemOperation) {
    VulnerabilitySeverityType vulnerabilitySeverity = EnumUtils.getEnum(VulnerabilitySeverityType.class, vulnerability.getSeverity());
    ComponentConcernSeverity componentConcernSeverity;
    if (null == vulnerabilitySeverity) {
        componentConcernSeverity = ComponentConcernSeverity.UNSPECIFIED_UNKNOWN;
    } else {
        componentConcernSeverity = SEVERITY_TYPE_MAP.getOrDefault(vulnerabilitySeverity, ComponentConcernSeverity.UNSPECIFIED_UNKNOWN);
    }
    return ComponentConcern.vulnerability(itemOperation, vulnerability.getVulnerabilityId(), componentConcernSeverity, vulnerability.getVulnerability());
}
Also used : ComponentConcernSeverity(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernSeverity) VulnerabilitySeverityType(com.synopsys.integration.blackduck.api.generated.enumeration.VulnerabilitySeverityType)

Example 2 with VulnerabilitySeverityType

use of com.synopsys.integration.blackduck.api.generated.enumeration.VulnerabilitySeverityType in project hub-alert by blackducksoftware.

the class BlackDuckComponentVulnerabilityDetailsCreator method toComponentVulnerabilities.

public ComponentVulnerabilities toComponentVulnerabilities(List<BlackDuckProjectVersionComponentVulnerabilitiesView> vulnerabilities) {
    List<LinkableItem> criticalVulns = new LinkedList<>();
    List<LinkableItem> highVulns = new LinkedList<>();
    List<LinkableItem> mediumVulns = new LinkedList<>();
    List<LinkableItem> lowVulns = new LinkedList<>();
    for (BlackDuckProjectVersionComponentVulnerabilitiesView vulnerability : vulnerabilities) {
        if (requiresRemediation(vulnerability)) {
            AlertVulnerability alertVulnerability = toAlertVulnerabilityView(vulnerability);
            VulnerabilitySeverityType severity = alertVulnerability.severity;
            LinkableItem vulnerabilityInfo = alertVulnerability.vulnerabilityInfo;
            if (VulnerabilitySeverityType.CRITICAL.equals(severity)) {
                criticalVulns.add(vulnerabilityInfo);
            } else if (VulnerabilitySeverityType.HIGH.equals(severity)) {
                highVulns.add(vulnerabilityInfo);
            } else if (VulnerabilitySeverityType.MEDIUM.equals(severity)) {
                mediumVulns.add(vulnerabilityInfo);
            } else if (VulnerabilitySeverityType.LOW.equals(severity)) {
                lowVulns.add(vulnerabilityInfo);
            }
        }
    }
    return new ComponentVulnerabilities(criticalVulns, highVulns, mediumVulns, lowVulns);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) VulnerabilitySeverityType(com.synopsys.integration.blackduck.api.generated.enumeration.VulnerabilitySeverityType) LinkedList(java.util.LinkedList) ComponentVulnerabilities(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)

Example 3 with VulnerabilitySeverityType

use of com.synopsys.integration.blackduck.api.generated.enumeration.VulnerabilitySeverityType 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);
}
Also used : ProjectVersionComponentVersionVulnerabilityRemediationCvss2View(com.synopsys.integration.blackduck.api.generated.component.ProjectVersionComponentVersionVulnerabilityRemediationCvss2View) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectVersionComponentVersionVulnerabilityRemediationCvss3View(com.synopsys.integration.blackduck.api.generated.component.ProjectVersionComponentVersionVulnerabilityRemediationCvss3View) VulnerabilitySeverityType(com.synopsys.integration.blackduck.api.generated.enumeration.VulnerabilitySeverityType)

Aggregations

VulnerabilitySeverityType (com.synopsys.integration.blackduck.api.generated.enumeration.VulnerabilitySeverityType)3 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)2 ComponentConcernSeverity (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernSeverity)1 ComponentVulnerabilities (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)1 ProjectVersionComponentVersionVulnerabilityRemediationCvss2View (com.synopsys.integration.blackduck.api.generated.component.ProjectVersionComponentVersionVulnerabilityRemediationCvss2View)1 ProjectVersionComponentVersionVulnerabilityRemediationCvss3View (com.synopsys.integration.blackduck.api.generated.component.ProjectVersionComponentVersionVulnerabilityRemediationCvss3View)1 LinkedList (java.util.LinkedList)1