use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern 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.processor.api.extract.model.project.ComponentConcern 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.processor.api.extract.model.project.ComponentConcern in project hub-alert by blackducksoftware.
the class PolicyOverrideNotificationMessageExtractor method createBomComponentDetails.
@Override
protected List<BomComponentDetails> createBomComponentDetails(PolicyOverrideUniquePolicyNotificationContent notificationContent, BlackDuckServicesFactory blackDuckServicesFactory) throws IntegrationException {
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
BlackDuckMessageBomComponentDetailsCreator bomComponentDetailsCreator = detailsCreatorFactory.createBomComponentDetailsCreator(blackDuckServicesFactory);
ComponentConcern policyConcern = policyComponentConcernCreator.fromPolicyInfo(notificationContent.getPolicyInfo(), ItemOperation.DELETE);
String overriderName = String.format("%s %s", notificationContent.getFirstName(), notificationContent.getLastName());
LinkableItem overrider = new LinkableItem(BlackDuckMessageLabels.LABEL_OVERRIDER, overriderName);
BomComponentDetails bomComponentDetails;
try {
ProjectVersionComponentVersionView bomComponent = blackDuckApiClient.getResponse(new HttpUrl(notificationContent.getBomComponent()), ProjectVersionComponentVersionView.class);
bomComponentDetails = bomComponentDetailsCreator.createBomComponentDetails(bomComponent, policyConcern, ComponentUpgradeGuidance.none(), List.of(overrider));
} catch (IntegrationRestException e) {
bomComponent404Handler.logIf404OrThrow(e, notificationContent.getComponentName(), notificationContent.getComponentVersionName());
bomComponentDetails = bomComponentDetailsCreator.createMissingBomComponentDetails(notificationContent.getComponentName(), notificationContent.getBomComponent(), notificationContent.getComponentVersionName(), notificationContent.getBomComponent(), List.of(policyConcern), ComponentUpgradeGuidance.none(), List.of(overrider));
}
return List.of(bomComponentDetails);
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern in project hub-alert by blackducksoftware.
the class VulnerabilityNotificationMessageExtractor method createBomComponentDetails.
@Override
protected List<BomComponentDetails> createBomComponentDetails(VulnerabilityUniqueProjectNotificationContent notificationContent, BlackDuckServicesFactory blackDuckServicesFactory) throws IntegrationException {
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
BlackDuckMessageBomComponentDetailsCreator bomComponentDetailsCreator = detailsCreatorFactory.createBomComponentDetailsCreator(blackDuckServicesFactory);
AffectedProjectVersion affectedProjectVersion = notificationContent.getAffectedProjectVersion();
String bomComponentUrl = affectedProjectVersion.getBomComponent();
List<ComponentConcern> componentConcerns = createComponentConcerns(notificationContent);
BomComponentDetails bomComponentDetails;
try {
ProjectVersionComponentVersionView bomComponent = blackDuckApiClient.getResponse(new HttpUrl(bomComponentUrl), ProjectVersionComponentVersionView.class);
ComponentUpgradeGuidance componentUpgradeGuidance = createComponentUpgradeGuidance(blackDuckApiClient, bomComponent);
bomComponentDetails = bomComponentDetailsCreator.createBomComponentDetails(bomComponent, componentConcerns, componentUpgradeGuidance, List.of());
} catch (IntegrationRestException e) {
bomComponent404Handler.logIf404OrThrow(e, notificationContent.getComponentName(), notificationContent.getVersionName());
ComponentUpgradeGuidance componentUpgradeGuidance = createComponentUpgradeGuidance(blackDuckApiClient, notificationContent);
bomComponentDetails = bomComponentDetailsCreator.createMissingBomComponentDetailsForVulnerability(notificationContent.getComponentName(), bomComponentUrl, notificationContent.getVersionName(), componentConcerns, componentUpgradeGuidance, 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 BlackDuckMessageBomComponentDetailsCreator method hasConcernForPolicy.
private boolean hasConcernForPolicy(ComponentPolicyRulesView policyRulesView, List<ComponentConcern> policyConcerns) {
for (ComponentConcern policyConcern : policyConcerns) {
Optional<String> optionalUrl = policyConcern.getUrl();
HttpUrl policyRulesViewHref = policyRulesView.getHref();
if (null != policyRulesViewHref && optionalUrl.isPresent()) {
String componentConcernPolicyUrl = optionalUrl.get();
if (componentConcernPolicyUrl.equals(policyRulesViewHref.string())) {
return true;
}
} else if (policyConcern.getName().equals(policyRulesView.getName())) {
return true;
}
}
return false;
}
Aggregations