use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType in project hub-alert by blackducksoftware.
the class JiraIssueCreator method createSearchProperties.
private JiraIssueSearchProperties createSearchProperties(ProjectIssueModel alertIssueSource) {
LinkableItem provider = alertIssueSource.getProvider();
LinkableItem project = alertIssueSource.getProject();
LinkableItem projectVersion = alertIssueSource.getProjectVersion().orElseThrow(() -> new AlertRuntimeException("Missing project version"));
IssueBomComponentDetails bomComponent = alertIssueSource.getBomComponentDetails();
LinkableItem component = bomComponent.getComponent();
String componentVersionLabel = bomComponent.getComponentVersion().map(LinkableItem::getLabel).orElse(null);
String componentVersionName = bomComponent.getComponentVersion().map(LinkableItem::getValue).orElse(null);
String additionalKey = null;
ComponentConcernType concernType = ComponentConcernType.VULNERABILITY;
Optional<String> optionalPolicyName = alertIssueSource.getPolicyDetails().map(IssuePolicyDetails::getName);
if (optionalPolicyName.isPresent()) {
concernType = ComponentConcernType.POLICY;
additionalKey = JiraIssueSearchPropertyStringCompatibilityUtils.createPolicyAdditionalKey(optionalPolicyName.get());
}
if (alertIssueSource.getComponentUnknownVersionDetails().isPresent()) {
concernType = ComponentConcernType.UNKNOWN_VERSION;
}
String category = JiraIssueSearchPropertyStringCompatibilityUtils.createCategory(concernType);
return new JiraIssueSearchProperties(provider.getLabel(), provider.getUrl().flatMap(JiraIssueAlertPropertiesUrlCorrector::correctUrl).orElse(null), project.getLabel(), project.getValue(), projectVersion.getLabel(), projectVersion.getValue(), category, component.getLabel(), component.getValue(), componentVersionLabel, componentVersionName, additionalKey);
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType in project hub-alert by blackducksoftware.
the class JiraExactIssueFinder method findExistingIssuesByProjectIssueModel.
@Override
public List<ExistingIssueDetails<String>> findExistingIssuesByProjectIssueModel(ProjectIssueModel projectIssueModel) throws AlertException {
LinkableItem provider = projectIssueModel.getProvider();
LinkableItem project = projectIssueModel.getProject();
IssueBomComponentDetails bomComponent = projectIssueModel.getBomComponentDetails();
ComponentConcernType concernType = ComponentConcernType.VULNERABILITY;
String policyName = null;
Optional<IssuePolicyDetails> policyDetails = projectIssueModel.getPolicyDetails();
Optional<String> optionalPolicyName = policyDetails.map(IssuePolicyDetails::getName);
if (optionalPolicyName.isPresent()) {
concernType = ComponentConcernType.POLICY;
policyName = optionalPolicyName.get();
}
if (projectIssueModel.getComponentUnknownVersionDetails().isPresent()) {
concernType = ComponentConcernType.UNKNOWN_VERSION;
}
String jqlString = JqlStringCreator.createBlackDuckComponentConcernIssuesSearchString(jiraProjectKey, provider, project, projectIssueModel.getProjectVersion().orElse(null), bomComponent.getComponent(), bomComponent.getComponentVersion().orElse(null), concernType, policyName);
logger.debug("Searching for Jira issues with this Query: {}", jqlString);
IssueCategory issueCategory = issueCategoryRetriever.retrieveIssueCategoryFromComponentConcernType(concernType);
return jqlQueryExecutor.executeQuery(jqlString).stream().map(jiraSearcherResponseModel -> searchResultCreator.createExistingIssueDetails(jiraSearcherResponseModel, issueCategory)).collect(Collectors.toList());
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType in project hub-alert by blackducksoftware.
the class ProjectMessageToMessageContentGroupConversionUtils method convertToComponentItems.
private static List<ComponentItem> convertToComponentItems(BomComponentDetails bomComponent) {
List<ComponentItem> componentItems = new LinkedList<>();
for (ComponentConcern componentConcern : bomComponent.getComponentConcerns()) {
ComponentItem.Builder componentItemBuilder = new ComponentItem.Builder();
componentItemBuilder.applyOperation(componentConcern.getOperation());
ComponentConcernType type = componentConcern.getType();
String category = StringUtils.capitalize(StringUtils.lowerCase(type.name()));
componentItemBuilder.applyCategory(category);
componentItemBuilder.applyComponentData(bomComponent.getComponent());
bomComponent.getComponentVersion().ifPresent(componentItemBuilder::applySubComponent);
String categoryItemLabel = convertToCategoryLabel(type);
LinkableItem categoryItem = new LinkableItem(categoryItemLabel, componentConcern.getName(), componentConcern.getUrl().orElse(null));
componentItemBuilder.applyCategoryItem(categoryItem);
String severity = componentConcern.getSeverity().name();
componentItemBuilder.applyCategoryGroupingAttribute("Severity", severity);
boolean collapseOnCategory = ComponentConcernType.VULNERABILITY.equals(type);
componentItemBuilder.applyCollapseOnCategory(collapseOnCategory);
List<LinkableItem> componentAttributes = new LinkedList<>();
componentAttributes.add(bomComponent.getLicense());
LinkableItem usageItem = new LinkableItem("Usage", bomComponent.getUsage());
componentAttributes.add(usageItem);
ComponentUpgradeGuidance upgradeGuidance = bomComponent.getComponentUpgradeGuidance();
upgradeGuidance.getLongTermUpgradeGuidance().ifPresent(componentAttributes::add);
upgradeGuidance.getShortTermUpgradeGuidance().ifPresent(componentAttributes::add);
componentAttributes.addAll(bomComponent.getAdditionalAttributes());
componentItemBuilder.applyAllComponentAttributes(componentAttributes);
try {
componentItems.add(componentItemBuilder.build());
} catch (AlertException e) {
// Ignored for feature parity
}
}
return componentItems;
}
Aggregations