Search in sources :

Example 1 with LinkableItem

use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.

the class SlackDistributionEventHandlerTest method createTwoMessages.

private ProviderMessageHolder createTwoMessages() {
    ProviderDetails providerDetails = new ProviderDetails(1L, new LinkableItem("", ""));
    SimpleMessage simpleMessage = SimpleMessage.original(providerDetails, "", "", List.of());
    return new ProviderMessageHolder(List.of(), List.of(simpleMessage, simpleMessage));
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder)

Example 2 with LinkableItem

use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.

the class ProjectMessageSummarizerTest method printSimpleMessage.

private void printSimpleMessage(SimpleMessage simpleMessage) {
    System.out.println("Summary: " + simpleMessage.getSummary());
    System.out.println("Description: " + simpleMessage.getDescription());
    System.out.println("Details: ");
    for (LinkableItem linkableItem : simpleMessage.getDetails()) {
        System.out.println("Label: " + linkableItem.getLabel() + " | Value: " + linkableItem.getValue());
    }
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem)

Example 3 with LinkableItem

use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.

the class ProjectMessageSummarizerTest method sortedConcernsTest.

@Test
public void sortedConcernsTest() {
    ComponentConcern policyConcern1 = ComponentConcern.severePolicy(ItemOperation.ADD, "A severe policy", ComponentConcernSeverity.TRIVIAL_LOW, "https://severe-policy");
    ComponentConcern policyConcern2 = ComponentConcern.severePolicy(ItemOperation.ADD, "A severe policy", ComponentConcernSeverity.BLOCKER, "https://severe-policy");
    ComponentConcern policyConcern3 = ComponentConcern.severePolicy(ItemOperation.ADD, "A severe policy", ComponentConcernSeverity.MINOR_MEDIUM, "https://severe-policy");
    ComponentConcern vulnerabilityConcern1 = ComponentConcern.vulnerability(ItemOperation.ADD, "CVE-123", ComponentConcernSeverity.CRITICAL, "https://vuln-rul");
    ComponentConcern vulnerabilityConcern2 = ComponentConcern.vulnerability(ItemOperation.ADD, "CVE-135", ComponentConcernSeverity.TRIVIAL_LOW, "https://vuln-rul");
    ComponentConcern vulnerabilityConcern3 = ComponentConcern.vulnerability(ItemOperation.ADD, "CVE-246", ComponentConcernSeverity.MINOR_MEDIUM, "https://vuln-rul");
    ComponentConcern policyConcern4 = ComponentConcern.severePolicy(ItemOperation.ADD, "A severe policy", ComponentConcernSeverity.BLOCKER, "https://severe-policy");
    ComponentConcern policyConcern5 = ComponentConcern.severePolicy(ItemOperation.ADD, "A severe policy", ComponentConcernSeverity.MAJOR_HIGH, "https://severe-policy");
    ComponentConcern policyConcern6 = ComponentConcern.severePolicy(ItemOperation.ADD, "A severe policy", ComponentConcernSeverity.CRITICAL, "https://severe-policy");
    ComponentConcern policyConcern7 = ComponentConcern.severePolicy(ItemOperation.ADD, "A severe policy", ComponentConcernSeverity.UNSPECIFIED_UNKNOWN, "https://severe-policy");
    ComponentConcern vulnerabilityConcern4 = ComponentConcern.vulnerability(ItemOperation.ADD, "CVE-123", ComponentConcernSeverity.BLOCKER, "https://vuln-rul");
    ComponentConcern vulnerabilityConcern5 = ComponentConcern.vulnerability(ItemOperation.ADD, "CVE-123", ComponentConcernSeverity.UNSPECIFIED_UNKNOWN, "https://vuln-rul");
    ComponentConcern vulnerabilityConcern6 = ComponentConcern.vulnerability(ItemOperation.ADD, "CVE-123", ComponentConcernSeverity.MAJOR_HIGH, "https://vuln-rul");
    BomComponentDetails bomComponentDetails = createBomComponentDetails(List.of(policyConcern1, policyConcern2, policyConcern3, policyConcern4, policyConcern5, policyConcern6, policyConcern7, vulnerabilityConcern1, vulnerabilityConcern2, vulnerabilityConcern3, vulnerabilityConcern4, vulnerabilityConcern5, vulnerabilityConcern6));
    ProjectMessage projectMessage = ProjectMessage.componentConcern(providerDetails, commonProject, commonProjectVersion, List.of(bomComponentDetails));
    ProcessedProviderMessage<ProjectMessage> processedProviderMessage = new ProcessedProviderMessage<>(Set.of(1L), projectMessage);
    ProcessedProviderMessage<SimpleMessage> summarizedSimpleMessage = projectMessageSummarizer.summarize(processedProviderMessage);
    SimpleMessage simpleMessage = summarizedSimpleMessage.getProviderMessage();
    printSimpleMessage(simpleMessage);
    // There are a total of 14 details, the latter 12 being policies and vulnerabilities sorted by type then severity
    assertEquals(14, simpleMessage.getDetails().size());
    List<LinkableItem> details = simpleMessage.getDetails();
    assertTrue(details.get(2).getLabel().contains(ComponentConcernSeverity.BLOCKER.getPolicyLabel()));
    assertTrue(details.get(3).getLabel().contains(ComponentConcernSeverity.CRITICAL.getPolicyLabel()));
    assertTrue(details.get(4).getLabel().contains(ComponentConcernSeverity.MAJOR_HIGH.getPolicyLabel()));
    assertTrue(details.get(5).getLabel().contains(ComponentConcernSeverity.MINOR_MEDIUM.getPolicyLabel()));
    assertTrue(details.get(6).getLabel().contains(ComponentConcernSeverity.TRIVIAL_LOW.getPolicyLabel()));
    assertTrue(details.get(7).getLabel().contains(ComponentConcernSeverity.UNSPECIFIED_UNKNOWN.getPolicyLabel()));
    assertTrue(details.get(8).getLabel().contains(ComponentConcernSeverity.BLOCKER.getVulnerabilityLabel()));
    assertTrue(details.get(9).getLabel().contains(ComponentConcernSeverity.CRITICAL.getVulnerabilityLabel()));
    assertTrue(details.get(10).getLabel().contains(ComponentConcernSeverity.MAJOR_HIGH.getVulnerabilityLabel()));
    assertTrue(details.get(11).getLabel().contains(ComponentConcernSeverity.MINOR_MEDIUM.getVulnerabilityLabel()));
    assertTrue(details.get(12).getLabel().contains(ComponentConcernSeverity.TRIVIAL_LOW.getVulnerabilityLabel()));
    assertTrue(details.get(13).getLabel().contains(ComponentConcernSeverity.UNSPECIFIED_UNKNOWN.getVulnerabilityLabel()));
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProcessedProviderMessage(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ComponentConcern(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern) BomComponentDetails(com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails) Test(org.junit.jupiter.api.Test)

Example 4 with LinkableItem

use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.

the class ProjectMessageTest method combineProjectsDontMatchTest.

@Test
public void combineProjectsDontMatchTest() {
    LinkableItem provider = new LinkableItem("Provider", "Provider Config Name");
    ProviderDetails providerDetails = new ProviderDetails(1L, provider);
    LinkableItem project1 = new LinkableItem("Project", "Project 1");
    LinkableItem project2 = new LinkableItem("Project", "Project 2");
    ProjectOperation commonOperation = ProjectOperation.CREATE;
    ProjectMessage projectMessage1 = ProjectMessage.projectStatusInfo(providerDetails, project1, commonOperation);
    ProjectMessage projectMessage2 = ProjectMessage.projectStatusInfo(providerDetails, project2, commonOperation);
    assertNotCombined(projectMessage1, projectMessage2);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) Test(org.junit.jupiter.api.Test)

Example 5 with LinkableItem

use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.

the class ProjectMessageTest method combineProjectVersionOperationsDontMatchTest.

@Test
public void combineProjectVersionOperationsDontMatchTest() {
    LinkableItem provider = new LinkableItem("Provider", "Provider Config Name");
    ProviderDetails providerDetails = new ProviderDetails(1L, provider);
    LinkableItem commonProject = new LinkableItem("Project", "Project 1");
    LinkableItem commonProjectVersion = new LinkableItem("Project Version", "Project Version 1");
    ProjectMessage projectMessage1 = ProjectMessage.projectVersionStatusInfo(providerDetails, commonProject, commonProjectVersion, ProjectOperation.CREATE);
    ProjectMessage projectMessage2 = ProjectMessage.projectVersionStatusInfo(providerDetails, commonProject, commonProjectVersion, ProjectOperation.DELETE);
    // Create then delete
    List<ProjectMessage> combinedProjectMessages1 = projectMessage1.combine(projectMessage2);
    assertEquals(0, combinedProjectMessages1.size());
    // Delete then create
    List<ProjectMessage> combinedProjectMessages2 = projectMessage2.combine(projectMessage1);
    assertEquals(1, combinedProjectMessages2.size());
    assertEquals(projectMessage1, combinedProjectMessages2.get(0));
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) Test(org.junit.jupiter.api.Test)

Aggregations

LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)94 Test (org.junit.jupiter.api.Test)39 ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)26 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)22 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)18 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)15 BomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails)13 SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)11 ProjectOperation (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)11 ArrayList (java.util.ArrayList)11 LinkedList (java.util.LinkedList)11 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)9 ProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder)9 List (java.util.List)9 ComponentVulnerabilities (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)8 Optional (java.util.Optional)7 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)6 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)6 ComponentConcern (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern)6 ComponentConcernType (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType)6