Search in sources :

Example 21 with ProjectIssueModel

use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel 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());
}
Also used : Logger(org.slf4j.Logger) ExactIssueFinder(com.synopsys.integration.alert.api.channel.issue.search.ExactIssueFinder) ComponentConcernType(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType) LoggerFactory(org.slf4j.LoggerFactory) IssueCategory(com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ExistingIssueDetails(com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails) Collectors(java.util.stream.Collectors) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) IssuePolicyDetails(com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails) List(java.util.List) Optional(java.util.Optional) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) IssueCategoryRetriever(com.synopsys.integration.alert.api.channel.issue.search.IssueCategoryRetriever) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ComponentConcernType(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType) IssueCategory(com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) IssuePolicyDetails(com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)

Example 22 with ProjectIssueModel

use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel 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;
}
Also used : IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) LinkedList(java.util.LinkedList) BomComponentDetails(com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)

Example 23 with ProjectIssueModel

use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel 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;
}
Also used : ComponentConcernType(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType) ComponentVulnerabilities(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) IssueComponentUnknownVersionDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails) BomComponentDetails(com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails) IssuePolicyDetails(com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails) List(java.util.List) Component(org.springframework.stereotype.Component) IssueEstimatedRiskModel(com.synopsys.integration.alert.api.channel.issue.model.IssueEstimatedRiskModel) IssueVulnerabilityDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails) ComponentConcern(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern) ItemOperation(com.synopsys.integration.alert.common.enumeration.ItemOperation) LinkedList(java.util.LinkedList) IssueVulnerabilityModel(com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) ComponentConcern(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern) LinkedList(java.util.LinkedList)

Example 24 with ProjectIssueModel

use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel in project hub-alert by blackducksoftware.

the class JiraCloudIssueCreatorTest method createIssueCreationModel.

private IssueCreationModel createIssueCreationModel() {
    ProviderDetails providerDetails = new ProviderDetails(1L, null);
    ProjectIssueModel policy = ProjectIssueModel.policy(providerDetails, null, null, null, null);
    return IssueCreationModel.project("title", "description", List.of(), policy);
}
Also used : ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)

Example 25 with ProjectIssueModel

use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel in project hub-alert by blackducksoftware.

the class AzureBoardsIssueCreator method createWorkItemCreationRequest.

private WorkItemRequest createWorkItemCreationRequest(IssueCreationModel alertIssueCreationModel) {
    List<WorkItemElementOperationModel> requestElementOps = new LinkedList<>();
    WorkItemElementOperationModel addTitleOp = createWorkItemAddOperation(WorkItemResponseFields.System_Title, alertIssueCreationModel.getTitle());
    requestElementOps.add(addTitleOp);
    WorkItemElementOperationModel addDescriptionOp = createWorkItemAddOperation(WorkItemResponseFields.System_Description, alertIssueCreationModel.getDescription());
    requestElementOps.add(addDescriptionOp);
    // Note: If a ProjectIssueModel is present, Alert Search Properties are assigned during issue-creation
    Optional<ProjectIssueModel> issueSource = alertIssueCreationModel.getSource();
    if (issueSource.isPresent()) {
        List<WorkItemElementOperationModel> alertSearchFieldOps = issuePropertiesManager.createWorkItemRequestCustomFieldOperations(issueSource.get());
        requestElementOps.addAll(alertSearchFieldOps);
    }
    return new WorkItemRequest(requestElementOps);
}
Also used : WorkItemRequest(com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemRequest) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) WorkItemElementOperationModel(com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemElementOperationModel) LinkedList(java.util.LinkedList)

Aggregations

ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)47 Test (org.junit.jupiter.api.Test)29 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)19 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)17 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)16 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)12 ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)11 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)11 IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)10 MockIssueTrackerMessageFormatter (com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)8 BomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails)8 ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)6 ComponentVulnerabilities (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)6 IssueComponentUnknownVersionDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails)5 ComponentConcernType (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType)5 LinkedList (java.util.LinkedList)5 Optional (java.util.Optional)5 IssueVulnerabilityModel (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel)4 ProjectIssueSearchResult (com.synopsys.integration.alert.api.channel.issue.search.ProjectIssueSearchResult)4 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)4