Search in sources :

Example 11 with ComponentVulnerabilities

use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities in project hub-alert by blackducksoftware.

the class BlackDuckComponentVulnerabilityDetailsCreatorTest method toComponentVulnerabilitiesHasVulnerabilitiesFalseTest.

@Test
public void toComponentVulnerabilitiesHasVulnerabilitiesFalseTest() {
    BlackDuckComponentVulnerabilityDetailsCreator vulnerabilityDetailsCreator = new BlackDuckComponentVulnerabilityDetailsCreator();
    ComponentVulnerabilities vulns = vulnerabilityDetailsCreator.toComponentVulnerabilities(List.of());
    assertFalse(vulns.hasVulnerabilities(), EXPECTED_VULNERABILITIES_MESSAGE);
}
Also used : ComponentVulnerabilities(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities) Test(org.junit.jupiter.api.Test)

Example 12 with ComponentVulnerabilities

use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities in project hub-alert by blackducksoftware.

the class BlackDuckComponentVulnerabilityDetailsCreatorTest method toComponentVulnerabilitiesTest.

@Test
public void toComponentVulnerabilitiesTest() throws IntegrationException {
    BlackDuckComponentVulnerabilityDetailsCreator vulnerabilityDetailsCreator = new BlackDuckComponentVulnerabilityDetailsCreator();
    BlackDuckProjectVersionComponentVulnerabilitiesView withCriticals = createVulnsView(ProjectVersionComponentVersionVulnerabilityRemediationCvss2SeverityType.CRITICAL);
    ComponentVulnerabilities criticalVulns = vulnerabilityDetailsCreator.toComponentVulnerabilities(List.of(withCriticals));
    assertTrue(criticalVulns.hasVulnerabilities(), EXPECTED_VULNERABILITIES_MESSAGE);
    assertEquals(1, criticalVulns.getCritical().size());
    assertEquals(0, criticalVulns.getHigh().size());
    assertEquals(0, criticalVulns.getMedium().size());
    assertEquals(0, criticalVulns.getLow().size());
    BlackDuckProjectVersionComponentVulnerabilitiesView withHighs = createVulnsView(ProjectVersionComponentVersionVulnerabilityRemediationCvss2SeverityType.HIGH);
    ComponentVulnerabilities highVulns = vulnerabilityDetailsCreator.toComponentVulnerabilities(List.of(withHighs));
    assertTrue(highVulns.hasVulnerabilities(), EXPECTED_VULNERABILITIES_MESSAGE);
    assertEquals(0, highVulns.getCritical().size());
    assertEquals(1, highVulns.getHigh().size());
    assertEquals(0, highVulns.getMedium().size());
    assertEquals(0, highVulns.getLow().size());
    BlackDuckProjectVersionComponentVulnerabilitiesView withMediums = createVulnsView(ProjectVersionComponentVersionVulnerabilityRemediationCvss2SeverityType.MEDIUM);
    ComponentVulnerabilities mediumVulns = vulnerabilityDetailsCreator.toComponentVulnerabilities(List.of(withMediums));
    assertTrue(mediumVulns.hasVulnerabilities(), EXPECTED_VULNERABILITIES_MESSAGE);
    assertEquals(0, mediumVulns.getCritical().size());
    assertEquals(0, mediumVulns.getHigh().size());
    assertEquals(1, mediumVulns.getMedium().size());
    assertEquals(0, mediumVulns.getLow().size());
    BlackDuckProjectVersionComponentVulnerabilitiesView withLows = createVulnsView(ProjectVersionComponentVersionVulnerabilityRemediationCvss2SeverityType.LOW);
    ComponentVulnerabilities lowVulns = vulnerabilityDetailsCreator.toComponentVulnerabilities(List.of(withLows));
    assertTrue(lowVulns.hasVulnerabilities(), EXPECTED_VULNERABILITIES_MESSAGE);
    assertEquals(0, lowVulns.getCritical().size());
    assertEquals(0, lowVulns.getHigh().size());
    assertEquals(0, lowVulns.getMedium().size());
    assertEquals(1, lowVulns.getLow().size());
    ComponentVulnerabilities allVulns = vulnerabilityDetailsCreator.toComponentVulnerabilities(List.of(withCriticals, withHighs, withMediums, withLows));
    assertTrue(allVulns.hasVulnerabilities(), EXPECTED_VULNERABILITIES_MESSAGE);
    assertEquals(1, allVulns.getCritical().size());
    assertEquals(1, allVulns.getHigh().size());
    assertEquals(1, allVulns.getMedium().size());
    assertEquals(1, allVulns.getLow().size());
}
Also used : ComponentVulnerabilities(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities) Test(org.junit.jupiter.api.Test)

Aggregations

ComponentVulnerabilities (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)12 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)8 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)5 Test (org.junit.jupiter.api.Test)5 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)4 IssueVulnerabilityModel (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel)4 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)4 MockIssueTrackerMessageFormatter (com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)3 AbstractBomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.AbstractBomComponentDetails)3 LinkedList (java.util.LinkedList)3 IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)2 ItemOperation (com.synopsys.integration.alert.common.enumeration.ItemOperation)2 BomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails)2 ComponentPolicy (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentPolicy)2 BomComponentDetailConverter (com.synopsys.integration.alert.api.channel.convert.BomComponentDetailConverter)1 LinkableItemConverter (com.synopsys.integration.alert.api.channel.convert.LinkableItemConverter)1 IssueCommentModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCommentModel)1 IssueComponentUnknownVersionDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails)1 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)1 IssueTransitionModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel)1