Search in sources :

Example 1 with ProjectVersionComponentVersionVulnerabilityRemediationCvss2View

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

the class BlackDuckComponentVulnerabilityDetailsCreatorTest method createVulnsView.

private BlackDuckProjectVersionComponentVulnerabilitiesView createVulnsView(ProjectVersionComponentVersionVulnerabilityRemediationCvss2SeverityType severity) throws IntegrationException {
    ResourceMetadata meta = new ResourceMetadata();
    meta.setHref(new HttpUrl("https://google.com"));
    meta.setLinks(List.of());
    ProjectVersionComponentVersionVulnerabilityRemediationCvss2View cvss2 = new ProjectVersionComponentVersionVulnerabilityRemediationCvss2View();
    cvss2.setSeverity(severity);
    BlackDuckProjectVersionComponentVulnerabilitiesView withCriticals = new BlackDuckProjectVersionComponentVulnerabilitiesView();
    withCriticals.setRemediationStatus(VulnerabilityRemediationStatusType.NEW);
    withCriticals.setUseCvss3(false);
    withCriticals.setCvss2(cvss2);
    withCriticals.setTitle("VULN-123");
    withCriticals.setMeta(meta);
    return withCriticals;
}
Also used : ProjectVersionComponentVersionVulnerabilityRemediationCvss2View(com.synopsys.integration.blackduck.api.generated.component.ProjectVersionComponentVersionVulnerabilityRemediationCvss2View) ResourceMetadata(com.synopsys.integration.blackduck.api.core.ResourceMetadata) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Example 2 with ProjectVersionComponentVersionVulnerabilityRemediationCvss2View

use of com.synopsys.integration.blackduck.api.generated.component.ProjectVersionComponentVersionVulnerabilityRemediationCvss2View 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

ProjectVersionComponentVersionVulnerabilityRemediationCvss2View (com.synopsys.integration.blackduck.api.generated.component.ProjectVersionComponentVersionVulnerabilityRemediationCvss2View)2 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)1 ResourceMetadata (com.synopsys.integration.blackduck.api.core.ResourceMetadata)1 ProjectVersionComponentVersionVulnerabilityRemediationCvss3View (com.synopsys.integration.blackduck.api.generated.component.ProjectVersionComponentVersionVulnerabilityRemediationCvss3View)1 VulnerabilitySeverityType (com.synopsys.integration.blackduck.api.generated.enumeration.VulnerabilitySeverityType)1 HttpUrl (com.synopsys.integration.rest.HttpUrl)1