use of com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails 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.api.channel.issue.model.IssueBomComponentDetails in project hub-alert by blackducksoftware.
the class ProjectMessageToIssueModelTransformer method convertToIssueModels.
public List<ProjectIssueModel> convertToIssueModels(ProjectMessage projectMessage) {
List<ProjectIssueModel> projectIssueModels = new LinkedList<>();
for (BomComponentDetails bomComponent : projectMessage.getBomComponents()) {
IssueBomComponentDetails issueBomComponent = IssueBomComponentDetails.fromBomComponentDetails(bomComponent);
List<ProjectIssueModel> projectIssueModelsForConcerns = convertToIssueModels(projectMessage, issueBomComponent, bomComponent.getComponentConcerns());
projectIssueModels.addAll(projectIssueModelsForConcerns);
}
return projectIssueModels;
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails in project hub-alert by blackducksoftware.
the class ProjectMessageToIssueModelTransformer method convertToIssueModels.
private List<ProjectIssueModel> convertToIssueModels(ProjectMessage projectMessage, IssueBomComponentDetails issueBomComponent, List<ComponentConcern> componentConcerns) {
List<ComponentConcern> policyConcerns = new LinkedList<>();
List<ComponentConcern> vulnerabilityConcerns = new LinkedList<>();
List<ComponentConcern> estimatedRiskConcerns = new LinkedList<>();
for (ComponentConcern componentConcern : componentConcerns) {
if (ComponentConcernType.POLICY.equals(componentConcern.getType())) {
policyConcerns.add(componentConcern);
} else if (ComponentConcernType.UNKNOWN_VERSION.equals(componentConcern.getType())) {
estimatedRiskConcerns.add(componentConcern);
} else {
vulnerabilityConcerns.add(componentConcern);
}
}
List<ProjectIssueModel> projectIssueModels = new LinkedList<>();
policyConcerns.stream().map(concern -> createPolicyProjectIssueModel(projectMessage, issueBomComponent, concern)).forEach(projectIssueModels::add);
if (!vulnerabilityConcerns.isEmpty()) {
ProjectIssueModel vulnerabilityProjectIssueModel = createVulnerabilityProjectIssueModel(projectMessage, issueBomComponent, vulnerabilityConcerns);
projectIssueModels.add(vulnerabilityProjectIssueModel);
}
if (!estimatedRiskConcerns.isEmpty()) {
ProjectIssueModel estimatedRiskProjectIssueModel = createEstimatedRiskProjectIssueModel(projectMessage, issueBomComponent, estimatedRiskConcerns);
projectIssueModels.add(estimatedRiskProjectIssueModel);
}
return projectIssueModels;
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails in project hub-alert by blackducksoftware.
the class AzureBoardsAlertIssuePropertiesManager method createWorkItemRequestCustomFieldOperations.
public List<WorkItemElementOperationModel> createWorkItemRequestCustomFieldOperations(ProjectIssueModel alertIssueSource) {
LinkableItem provider = alertIssueSource.getProvider();
String providerKey = AzureBoardsSearchPropertiesUtils.createProviderKey(provider.getLabel(), provider.getUrl().orElse(null));
String topicKey = AzureBoardsSearchPropertiesUtils.createNullableLinkableItemKey(alertIssueSource.getProject());
String subTopicKey = AzureBoardsSearchPropertiesUtils.createNullableLinkableItemKey(alertIssueSource.getProjectVersion().orElse(null));
IssueBomComponentDetails bomComponentDetails = alertIssueSource.getBomComponentDetails();
String componentKey = AzureBoardsSearchPropertiesUtils.createNullableLinkableItemKey(bomComponentDetails.getComponent());
String subComponentKey = AzureBoardsSearchPropertiesUtils.createNullableLinkableItemKey(bomComponentDetails.getComponentVersion().orElse(null));
AzureSearchFieldBuilder azureSearchFieldBuilder = AzureSearchFieldBuilder.create().addProviderKey(providerKey).addTopicKey(topicKey).addSubTopicKey(subTopicKey).addComponentKey(componentKey).addSubComponentKey(subComponentKey);
String categoryKey = CATEGORY_TYPE_VULNERABILITY_COMPATIBILITY_LABEL;
Optional<String> optionalPolicyName = alertIssueSource.getPolicyDetails().map(IssuePolicyDetails::getName);
if (optionalPolicyName.isPresent()) {
String additionalInfoKey = POLICY_ADDITIONAL_KEY_COMPATIBILITY_LABEL + optionalPolicyName.get();
azureSearchFieldBuilder.addAdditionalInfoKey(additionalInfoKey);
categoryKey = CATEGORY_TYPE_POLICY_COMPATIBILITY_LABEL;
}
boolean unknownVersionCategory = alertIssueSource.getComponentUnknownVersionDetails().isPresent();
if (unknownVersionCategory) {
categoryKey = CATEGORY_TYPE_COMPONENT_UNKNOWN_VERSION_COMPATIBILITY_LABEL;
}
azureSearchFieldBuilder.addCategoryKey(categoryKey);
return azureSearchFieldBuilder.build();
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails in project hub-alert by blackducksoftware.
the class AzureBoardsComponentIssueFinder method findIssuesByComponent.
@Override
public List<ProjectIssueSearchResult<Integer>> findIssuesByComponent(ProviderDetails providerDetails, LinkableItem project, LinkableItem projectVersion, BomComponentDetails bomComponent) throws AlertException {
AzureSearchFieldMappingBuilder fieldRefNameToValue = createBomFieldReferenceToValueMap(projectVersion, bomComponent);
List<WorkItemResponseModel> workItems = workItemFinder.findWorkItems(providerDetails.getProvider(), project, fieldRefNameToValue);
List<ProjectIssueSearchResult<Integer>> searchResults = new ArrayList<>(workItems.size());
for (WorkItemResponseModel workItem : workItems) {
IssueBomComponentDetails issueBomComponent = IssueBomComponentDetails.fromBomComponentDetails(bomComponent);
ProjectIssueModel projectIssueModel = ProjectIssueModel.bom(providerDetails, project, projectVersion, issueBomComponent);
ExistingIssueDetails<Integer> issueDetails = issueDetailsCreator.createIssueDetails(workItem, workItem.createFieldsWrapper(gson), projectIssueModel);
ProjectIssueSearchResult<Integer> searchResult = new ProjectIssueSearchResult<>(issueDetails, projectIssueModel);
searchResults.add(searchResult);
}
return searchResults;
}
Aggregations