use of com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails in project hub-alert by blackducksoftware.
the class AzureBoardsComponentIssueFinderTest method findExistingIssuesByProjectIssueModelForUnknownVersionTest.
@Test
public void findExistingIssuesByProjectIssueModelForUnknownVersionTest() throws AlertException {
Gson gson = new Gson();
String organizationName = "orgName";
AzureBoardsIssueTrackerQueryManager queryManager = Mockito.mock(AzureBoardsIssueTrackerQueryManager.class);
IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
AzureBoardsExistingIssueDetailsCreator issueDetailsCreator = new AzureBoardsExistingIssueDetailsCreator(organizationName, issueCategoryRetriever, azureBoardsIssueStatusResolver);
AzureBoardsWorkItemFinder workItemFinder = new AzureBoardsWorkItemFinder(queryManager, "test proj");
AzureBoardsComponentIssueFinder componentIssueFinder = new AzureBoardsComponentIssueFinder(gson, workItemFinder, issueDetailsCreator);
IssueComponentUnknownVersionDetails componentUnknownVersionDetails = new IssueComponentUnknownVersionDetails(ItemOperation.ADD, createRiskModels());
IssuePolicyDetails testPolicy = new IssuePolicyDetails("Test Policy", ItemOperation.ADD, ComponentConcernSeverity.UNSPECIFIED_UNKNOWN);
ProjectIssueModel projectIssueModel = ProjectIssueModel.componentUnknownVersion(PROVIDER_DETAILS, PROJECT_ITEM, PROJECT_VERSION_ITEM, ISSUE_BOM_COMPONENT_DETAILS, componentUnknownVersionDetails);
WorkItemResponseModel workItemResponseModel = createWorkItemResponseModel(workItemReopenState);
Mockito.when(queryManager.executeQueryAndRetrieveWorkItems(Mockito.any())).thenReturn(List.of(workItemResponseModel));
List<ExistingIssueDetails<Integer>> existingIssueDetailsList = componentIssueFinder.findExistingIssuesByProjectIssueModel(projectIssueModel);
assertEquals(1, existingIssueDetailsList.size());
ExistingIssueDetails<Integer> existingIssueDetails = existingIssueDetailsList.get(0);
assertEquals(IssueStatus.RESOLVABLE, existingIssueDetails.getIssueStatus());
assertEquals(IssueCategory.BOM, existingIssueDetails.getIssueCategory());
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails in project hub-alert by blackducksoftware.
the class ProjectMessageToIssueModelTransformerTest method convertToIssueModelsForComponentUnknownVersionTest.
@Test
public void convertToIssueModelsForComponentUnknownVersionTest() {
ComponentConcern unknownComponentConcern = ComponentConcern.unknownComponentVersion(ItemOperation.ADD, "Component01", ComponentConcernSeverity.MAJOR_HIGH, 2, "https://synopsys.com");
BomComponentDetails bomComponentDetails = createBomComponentDetails(unknownComponentConcern);
ProjectMessage projectMessage = ProjectMessage.componentConcern(PROVIDER_DETAILS, PROJECT, PROJECT_VERSION, List.of(bomComponentDetails));
ProjectMessageToIssueModelTransformer modelTransformer = new ProjectMessageToIssueModelTransformer();
List<ProjectIssueModel> policyIssueModels = modelTransformer.convertToIssueModels(projectMessage);
assertEquals(1, policyIssueModels.size());
ProjectIssueModel unknownVersionIssueModel = policyIssueModels.get(0);
assertRequiredDetails(unknownVersionIssueModel);
Optional<IssueComponentUnknownVersionDetails> optionalDetails = unknownVersionIssueModel.getComponentUnknownVersionDetails();
assertTrue(optionalDetails.isPresent(), "Expected unknown component details to be present");
IssueComponentUnknownVersionDetails details = optionalDetails.get();
assertEquals(ItemOperation.ADD, details.getItemOperation());
assertEquals(1, details.getEstimatedRiskModelList().size());
IssueEstimatedRiskModel estimatedRiskModel = details.getEstimatedRiskModelList().get(0);
assertEquals(ComponentConcernSeverity.MAJOR_HIGH, estimatedRiskModel.getSeverity());
assertEquals("Component01", estimatedRiskModel.getName());
assertEquals(2, estimatedRiskModel.getCount());
assertTrue(estimatedRiskModel.getComponentVersionUrl().isPresent());
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails 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.api.channel.issue.model.IssueComponentUnknownVersionDetails in project hub-alert by blackducksoftware.
the class IssueTrackerSearcher method isOnlyDeleteOperation.
private boolean isOnlyDeleteOperation(ProjectIssueModel projectIssueModel) {
boolean isPolicyDelete = projectIssueModel.getPolicyDetails().map(IssuePolicyDetails::getOperation).filter(ItemOperation.DELETE::equals).isPresent();
boolean isEstimatedRiskDelete = projectIssueModel.getComponentUnknownVersionDetails().map(IssueComponentUnknownVersionDetails::getItemOperation).filter(ItemOperation.DELETE::equals).isPresent();
boolean isVulnerabilityDelete = false;
Optional<IssueVulnerabilityDetails> optionalVulnDetails = projectIssueModel.getVulnerabilityDetails();
if (optionalVulnDetails.isPresent()) {
IssueVulnerabilityDetails vulnDetails = optionalVulnDetails.get();
boolean allVulnsRemediated = vulnDetails.areAllComponentVulnerabilitiesRemediated();
boolean hasDeletions = !vulnDetails.getVulnerabilitiesDeleted().isEmpty();
boolean doesNotHaveAdditions = vulnDetails.getVulnerabilitiesAdded().isEmpty();
boolean doesNotHaveUpdates = vulnDetails.getVulnerabilitiesUpdated().isEmpty();
isVulnerabilityDelete = allVulnsRemediated || (hasDeletions && doesNotHaveAdditions && doesNotHaveUpdates);
}
return isPolicyDelete || isVulnerabilityDelete || isEstimatedRiskDelete;
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails in project hub-alert by blackducksoftware.
the class ProjectIssueModelConverter method createProjectIssueModelConcernSectionPieces.
private List<String> createProjectIssueModelConcernSectionPieces(ProjectIssueModel projectIssueModel, boolean commentFormat) {
List<String> concernSectionPieces = new LinkedList<>();
IssueBomComponentDetails bomComponentDetails = projectIssueModel.getBomComponentDetails();
Optional<IssuePolicyDetails> optionalPolicyDetails = projectIssueModel.getPolicyDetails();
if (optionalPolicyDetails.isPresent()) {
List<String> policyDetailsSectionPieces = issuePolicyDetailsConverter.createPolicyDetailsSectionPieces(bomComponentDetails, optionalPolicyDetails.get());
concernSectionPieces.addAll(policyDetailsSectionPieces);
concernSectionPieces.add(formatter.getLineSeparator());
concernSectionPieces.add(formatter.getSectionSeparator());
concernSectionPieces.add(formatter.getLineSeparator());
}
Optional<IssueVulnerabilityDetails> optionalVulnDetails = projectIssueModel.getVulnerabilityDetails();
if (optionalVulnDetails.isPresent()) {
List<String> vulnDetailsSectionPieces;
if (commentFormat) {
vulnDetailsSectionPieces = issueVulnerabilityDetailsConverter.createVulnerabilityDetailsSectionPieces(optionalVulnDetails.get());
} else {
vulnDetailsSectionPieces = componentVulnerabilitiesConverter.createComponentVulnerabilitiesSectionPieces(projectIssueModel.getBomComponentDetails().getComponentVulnerabilities());
}
concernSectionPieces.addAll(vulnDetailsSectionPieces);
concernSectionPieces.add(formatter.getLineSeparator());
concernSectionPieces.add(formatter.getSectionSeparator());
concernSectionPieces.add(formatter.getLineSeparator());
}
Optional<IssueComponentUnknownVersionDetails> optionalUnknownVersionDetails = projectIssueModel.getComponentUnknownVersionDetails();
if (optionalUnknownVersionDetails.isPresent()) {
List<String> componentUnknownVersionDetailsSectionPieces;
componentUnknownVersionDetailsSectionPieces = issueComponentUnknownVersionDetailsConverter.createEstimatedRiskDetailsSectionPieces(optionalUnknownVersionDetails.get());
concernSectionPieces.addAll(componentUnknownVersionDetailsSectionPieces);
concernSectionPieces.add(formatter.getLineSeparator());
concernSectionPieces.add(formatter.getSectionSeparator());
concernSectionPieces.add(formatter.getLineSeparator());
}
return concernSectionPieces;
}
Aggregations