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);
}
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);
}
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;
}
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);
}
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;
}
Aggregations