Search in sources :

Example 1 with ItemOperation

use of com.synopsys.integration.alert.common.enumeration.ItemOperation in project hub-alert by blackducksoftware.

the class ProjectMessageToIssueModelTransformer method createEstimatedRiskProjectIssueModel.

private ProjectIssueModel createEstimatedRiskProjectIssueModel(ProjectMessage projectMessage, IssueBomComponentDetails issueBomComponent, List<ComponentConcern> estimatedRiskConcerns) {
    List<IssueEstimatedRiskModel> estimatedRiskModels = new LinkedList<>();
    ItemOperation itemOperation = estimatedRiskConcerns.stream().map(ComponentConcern::getOperation).findFirst().orElse(ItemOperation.ADD);
    // all component concerns for this type have the same operation.
    for (ComponentConcern componentConcern : estimatedRiskConcerns) {
        estimatedRiskModels.add(IssueEstimatedRiskModel.fromComponentConcern(componentConcern));
    }
    IssueComponentUnknownVersionDetails unknownVersionDetails = new IssueComponentUnknownVersionDetails(itemOperation, estimatedRiskModels);
    return ProjectIssueModel.componentUnknownVersion(projectMessage.getProviderDetails(), projectMessage.getProject(), projectMessage.getProjectVersion().orElse(null), issueBomComponent, unknownVersionDetails);
}
Also used : IssueComponentUnknownVersionDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails) IssueEstimatedRiskModel(com.synopsys.integration.alert.api.channel.issue.model.IssueEstimatedRiskModel) ItemOperation(com.synopsys.integration.alert.common.enumeration.ItemOperation) ComponentConcern(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern) LinkedList(java.util.LinkedList)

Example 2 with ItemOperation

use of com.synopsys.integration.alert.common.enumeration.ItemOperation 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)

Example 3 with ItemOperation

use of com.synopsys.integration.alert.common.enumeration.ItemOperation in project hub-alert by blackducksoftware.

the class IssueTrackerSearcher method findVulnerabilitySearchResultOperation.

private ItemOperation findVulnerabilitySearchResultOperation(ExistingIssueDetails<T> existingIssue, IssueVulnerabilityDetails issueVulnerabilityDetails) {
    ItemOperation searchResultOperation;
    boolean isResolvableOrUnknown = IssueStatus.RESOLVABLE.equals(existingIssue.getIssueStatus()) || IssueStatus.UNKNOWN.equals(existingIssue.getIssueStatus());
    boolean isReopenableOrUnknown = IssueStatus.REOPENABLE.equals(existingIssue.getIssueStatus()) || IssueStatus.UNKNOWN.equals(existingIssue.getIssueStatus());
    if (issueVulnerabilityDetails.areAllComponentVulnerabilitiesRemediated() && isResolvableOrUnknown) {
        searchResultOperation = ItemOperation.DELETE;
    } else if (!issueVulnerabilityDetails.areAllComponentVulnerabilitiesRemediated() && isReopenableOrUnknown) {
        searchResultOperation = ItemOperation.ADD;
    } else {
        searchResultOperation = ItemOperation.UPDATE;
    }
    return searchResultOperation;
}
Also used : ItemOperation(com.synopsys.integration.alert.common.enumeration.ItemOperation)

Example 4 with ItemOperation

use of com.synopsys.integration.alert.common.enumeration.ItemOperation in project hub-alert by blackducksoftware.

the class ComponentUnknownVersionExtractor method createComponentConcerns.

private List<ComponentConcern> createComponentConcerns(ComponentUnknownVersionWithStatusNotificationContent notificationContent) {
    ComponentUnknownVersionStatus status = notificationContent.getStatus();
    String componentName = notificationContent.getComponentName();
    ItemOperation itemOperation = ComponentUnknownVersionStatus.REMOVED == status ? ItemOperation.DELETE : ItemOperation.ADD;
    ComponentConcern criticalCount = createComponentConcernWithCount(itemOperation, ComponentConcernSeverity.CRITICAL, notificationContent.getCriticalVulnerabilityCount(), componentName, notificationContent.getCriticalVulnerabilityVersionName(), notificationContent.getCriticalVulnerabilityVersion());
    ComponentConcern highCount = createComponentConcernWithCount(itemOperation, ComponentConcernSeverity.MAJOR_HIGH, notificationContent.getHighVulnerabilityCount(), componentName, notificationContent.getHighVulnerabilityVersionName(), notificationContent.getHighVulnerabilityVersion());
    ComponentConcern mediumCount = createComponentConcernWithCount(itemOperation, ComponentConcernSeverity.MINOR_MEDIUM, notificationContent.getMediumVulnerabilityCount(), componentName, notificationContent.getMediumVulnerabilityVersionName(), notificationContent.getMediumVulnerabilityVersion());
    ComponentConcern lowCount = createComponentConcernWithCount(itemOperation, ComponentConcernSeverity.TRIVIAL_LOW, notificationContent.getLowVulnerabilityCount(), componentName, notificationContent.getLowVulnerabilityVersionName(), notificationContent.getLowVulnerabilityVersion());
    return List.of(criticalCount, highCount, mediumCount, lowCount);
}
Also used : ComponentUnknownVersionStatus(com.synopsys.integration.blackduck.api.manual.enumeration.ComponentUnknownVersionStatus) ItemOperation(com.synopsys.integration.alert.common.enumeration.ItemOperation) ComponentConcern(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern)

Example 5 with ItemOperation

use of com.synopsys.integration.alert.common.enumeration.ItemOperation in project hub-alert by blackducksoftware.

the class ComponentConcernConverter method createVulnerabilitySectionPieces.

private List<String> createVulnerabilitySectionPieces(List<ComponentConcern> vulnerabilityConcerns) {
    if (vulnerabilityConcerns.isEmpty()) {
        return List.of();
    }
    List<ComponentConcern> addedVulnerabilityConcerns = new LinkedList<>();
    List<ComponentConcern> updatedVulnerabilityConcerns = new LinkedList<>();
    List<ComponentConcern> deletedVulnerabilityConcerns = new LinkedList<>();
    for (ComponentConcern vulnerabilityConcern : vulnerabilityConcerns) {
        ItemOperation operation = vulnerabilityConcern.getOperation();
        if (ItemOperation.ADD.equals(operation)) {
            addedVulnerabilityConcerns.add(vulnerabilityConcern);
        } else if (ItemOperation.DELETE.equals(operation)) {
            deletedVulnerabilityConcerns.add(vulnerabilityConcern);
        } else {
            updatedVulnerabilityConcerns.add(vulnerabilityConcern);
        }
    }
    List<String> vulnerabilitySectionPieces = new LinkedList<>();
    vulnerabilitySectionPieces.add(formatter.getSectionSeparator());
    vulnerabilitySectionPieces.add(formatter.getLineSeparator());
    // Add Sections
    List<String> vulnerabilitiesAddedPieces = createVulnerabilityConcernsForOperation(formattedVerbAdded, addedVulnerabilityConcerns);
    vulnerabilitySectionPieces.addAll(vulnerabilitiesAddedPieces);
    List<String> vulnerabilitiesUpdatedPieces = createVulnerabilityConcernsForOperation(formattedVerbUpdated, updatedVulnerabilityConcerns);
    vulnerabilitySectionPieces.addAll(vulnerabilitiesUpdatedPieces);
    List<String> vulnerabilitiesDeletedPieces = createVulnerabilityConcernsForOperation(formattedVerbRemoved, deletedVulnerabilityConcerns);
    vulnerabilitySectionPieces.addAll(vulnerabilitiesDeletedPieces);
    return vulnerabilitySectionPieces;
}
Also used : ComponentConcern(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern) ItemOperation(com.synopsys.integration.alert.common.enumeration.ItemOperation) LinkedList(java.util.LinkedList)

Aggregations

ItemOperation (com.synopsys.integration.alert.common.enumeration.ItemOperation)7 ComponentConcern (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern)4 LinkedList (java.util.LinkedList)3 IssueComponentUnknownVersionDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails)2 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)2 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)2 MockIssueTrackerMessageFormatter (com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)1 IssueEstimatedRiskModel (com.synopsys.integration.alert.api.channel.issue.model.IssueEstimatedRiskModel)1 IssueTransitionModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel)1 IssueVulnerabilityModel (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel)1 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)1 ActionableIssueSearchResult (com.synopsys.integration.alert.api.channel.issue.search.ActionableIssueSearchResult)1 ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)1 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 IssueOperation (com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation)1 ComponentVulnerabilities (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)1 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)1 ComponentUnknownVersionStatus (com.synopsys.integration.blackduck.api.manual.enumeration.ComponentUnknownVersionStatus)1 Set (java.util.Set)1 Test (org.junit.jupiter.api.Test)1