Search in sources :

Example 6 with IssueVulnerabilityModel

use of com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel in project hub-alert by blackducksoftware.

the class ProjectMessageToIssueModelTransformer method createVulnerabilityProjectIssueModel.

private ProjectIssueModel createVulnerabilityProjectIssueModel(ProjectMessage projectMessage, IssueBomComponentDetails issueBomComponent, List<ComponentConcern> vulnerabilityConcerns) {
    List<IssueVulnerabilityModel> issueVulnerabilitiesAdded = new LinkedList<>();
    List<IssueVulnerabilityModel> issueVulnerabilitiesUpdated = new LinkedList<>();
    List<IssueVulnerabilityModel> issueVulnerabilitiesDeleted = new LinkedList<>();
    for (ComponentConcern vulnerabilityConcern : vulnerabilityConcerns) {
        IssueVulnerabilityModel issueVulnerabilityModel = IssueVulnerabilityModel.fromComponentConcern(vulnerabilityConcern);
        ItemOperation vulnOperation = vulnerabilityConcern.getOperation();
        if (ItemOperation.ADD.equals(vulnOperation)) {
            issueVulnerabilitiesAdded.add(issueVulnerabilityModel);
        } else if (ItemOperation.DELETE.equals(vulnOperation)) {
            issueVulnerabilitiesDeleted.add(issueVulnerabilityModel);
        } else {
            issueVulnerabilitiesUpdated.add(issueVulnerabilityModel);
        }
    }
    ComponentVulnerabilities componentVulnerabilities = issueBomComponent.getComponentVulnerabilities();
    IssueVulnerabilityDetails vulnerabilityDetails = new IssueVulnerabilityDetails(!componentVulnerabilities.hasVulnerabilities(), issueVulnerabilitiesAdded, issueVulnerabilitiesUpdated, issueVulnerabilitiesDeleted);
    return ProjectIssueModel.vulnerability(projectMessage.getProviderDetails(), projectMessage.getProject(), projectMessage.getProjectVersion().orElse(null), issueBomComponent, vulnerabilityDetails);
}
Also used : IssueVulnerabilityDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails) IssueVulnerabilityModel(com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel) ComponentConcern(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern) ItemOperation(com.synopsys.integration.alert.common.enumeration.ItemOperation) LinkedList(java.util.LinkedList) ComponentVulnerabilities(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)

Aggregations

IssueVulnerabilityModel (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel)6 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)5 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)4 ComponentVulnerabilities (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)4 Test (org.junit.jupiter.api.Test)4 MockIssueTrackerMessageFormatter (com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)3 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)3 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)3 AbstractBomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.AbstractBomComponentDetails)3 IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)2 LinkedList (java.util.LinkedList)2 ItemOperation (com.synopsys.integration.alert.common.enumeration.ItemOperation)1 ComponentConcern (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern)1 ComponentConcernSeverity (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernSeverity)1