use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern in project hub-alert by blackducksoftware.
the class ComponentUnknownVersionExtractor method createBomComponentDetails.
@Override
protected List<BomComponentDetails> createBomComponentDetails(ComponentUnknownVersionWithStatusNotificationContent notificationContent, BlackDuckServicesFactory blackDuckServicesFactory) throws IntegrationException {
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
BlackDuckMessageBomComponentDetailsCreator bomComponentDetailsCreator = detailsCreatorFactory.createBomComponentDetailsCreator(blackDuckServicesFactory);
List<ComponentConcern> componentConcerns = createComponentConcerns(notificationContent);
BomComponentDetails bomComponentDetails;
try {
ProjectVersionComponentVersionView bomComponent = blackDuckApiClient.getResponse(new HttpUrl(notificationContent.getBomComponent()), ProjectVersionComponentVersionView.class);
bomComponentDetails = bomComponentDetailsCreator.createBomComponentUnknownVersionDetails(bomComponent, componentConcerns, ComponentUpgradeGuidance.none(), List.of());
} catch (IntegrationRestException e) {
bomComponent404Handler.logIf404OrThrow(e, notificationContent.getComponentName(), null);
bomComponentDetails = bomComponentDetailsCreator.createMissingBomComponentDetailsForUnknownVersion(notificationContent.getComponentName(), notificationContent.getBomComponent(), BlackDuckMessageBomComponentDetailsCreator.COMPONENT_VERSION_UNKNOWN, componentConcerns, ComponentUpgradeGuidance.none(), List.of());
}
return List.of(bomComponentDetails);
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern in project hub-alert by blackducksoftware.
the class ComponentConcernConverterTest method callGatherComponentConcernSectionPieces.
private List<String> callGatherComponentConcernSectionPieces() {
ChannelMessageFormatter channelMessageFormatter = new MockChannelMessageFormatter(Integer.MAX_VALUE);
ComponentConcernConverter componentConcernConverter = new ComponentConcernConverter(channelMessageFormatter);
List<ComponentConcern> componentConcerns = createALotOfComponentConcerns();
return componentConcernConverter.gatherComponentConcernSectionPieces(componentConcerns);
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern in project hub-alert by blackducksoftware.
the class ComponentConcernConverter method gatherComponentConcernSectionPieces.
public List<String> gatherComponentConcernSectionPieces(List<ComponentConcern> componentConcerns) {
List<String> componentConcernSectionPieces = new LinkedList<>();
List<ComponentConcern> vulnerabilityConcerns = new LinkedList<>();
List<ComponentConcern> estimatedRiskConcerns = new LinkedList<>();
Set<ComponentConcern> sortedConcerns = new TreeSet<>(componentConcerns);
for (ComponentConcern componentConcern : sortedConcerns) {
if (ComponentConcernType.POLICY.equals(componentConcern.getType())) {
String policySectionPiece = createPolicySectionPiece(componentConcern);
componentConcernSectionPieces.add(policySectionPiece);
componentConcernSectionPieces.add(formatter.getLineSeparator());
} else if (ComponentConcernType.UNKNOWN_VERSION.equals(componentConcern.getType())) {
estimatedRiskConcerns.add(componentConcern);
} else {
vulnerabilityConcerns.add(componentConcern);
}
}
List<String> vulnerabilitySectionPieces = createVulnerabilitySectionPieces(vulnerabilityConcerns);
List<String> estimatedRiskSectionPieces = createEstimatedRiskSectionPieces(estimatedRiskConcerns);
componentConcernSectionPieces.addAll(vulnerabilitySectionPieces);
componentConcernSectionPieces.addAll(estimatedRiskSectionPieces);
return componentConcernSectionPieces;
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern in project hub-alert by blackducksoftware.
the class ComponentConcernConverter method createEstimatedRiskSectionPieces.
private List<String> createEstimatedRiskSectionPieces(List<ComponentConcern> estimatedRiskConcerns) {
if (estimatedRiskConcerns.isEmpty()) {
return List.of();
}
boolean isDelete = estimatedRiskConcerns.stream().allMatch(componentConcern -> ItemOperation.DELETE.equals(componentConcern.getOperation()));
List<String> estimatedRiskForOperationSectionPieces = new LinkedList<>();
estimatedRiskForOperationSectionPieces.add(formatter.getSectionSeparator());
estimatedRiskForOperationSectionPieces.add(formatter.getLineSeparator());
if (isDelete) {
estimatedRiskForOperationSectionPieces.add(formatter.encode(TEXT_COMPONENT_DELETE));
estimatedRiskForOperationSectionPieces.add(formatter.getLineSeparator());
} else {
estimatedRiskForOperationSectionPieces.add(String.format("%s%s", formattedVulnerabilityCountsString, formattedColonSpace));
estimatedRiskForOperationSectionPieces.add(formatter.getLineSeparator());
estimatedRiskForOperationSectionPieces.add(formatter.getLineSeparator());
for (ComponentConcern componentConcern : estimatedRiskConcerns) {
estimatedRiskForOperationSectionPieces.add(createEstimatedRiskConcernString(componentConcern));
estimatedRiskForOperationSectionPieces.add(formatter.getLineSeparator());
}
}
return estimatedRiskForOperationSectionPieces;
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern 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