use of com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails in project hub-alert by blackducksoftware.
the class ProjectIssueModelConverterTest method toIssueCommentModelWithVulnerabilitySeverityTest.
@Test
public void toIssueCommentModelWithVulnerabilitySeverityTest() {
IssueVulnerabilityModel vuln1 = createIssueVulnerability(ComponentConcernSeverity.MAJOR_HIGH, "CVE-13579", "https://a-url");
IssueVulnerabilityDetails vulnerabilityDetails = new IssueVulnerabilityDetails(false, List.of(), List.of(vuln1), List.of());
ComponentVulnerabilities componentVulnerabilities = new ComponentVulnerabilities(List.of(new LinkableItem("VulnerabilityCritical", "CVE-004")), List.of(new LinkableItem("VulnerabilityHigh", "CVE-005")), List.of(new LinkableItem("VulnerabilityMedium", "CVE-006")), List.of(new LinkableItem("VulnerabilityLow", "CVE-007")));
AbstractBomComponentDetails vulnerableBomComponentDetails = createBomComponentDetailsWithComponentVulnerabilities(componentVulnerabilities);
IssueBomComponentDetails issueBomComponentDetails = IssueBomComponentDetails.fromBomComponentDetails(vulnerableBomComponentDetails);
ProjectIssueModel projectIssueModel = ProjectIssueModel.vulnerability(PROVIDER_DETAILS, PROJECT_ITEM, PROJECT_VERSION_ITEM, issueBomComponentDetails, vulnerabilityDetails);
MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
ProjectIssueModelConverter converter = new ProjectIssueModelConverter(formatter);
IssueCommentModel<String> issueCommentModel = converter.toIssueCommentModel(EXISTING_ISSUE_DETAILS, projectIssueModel);
assertEquals(1, issueCommentModel.getComments().size());
String comments = issueCommentModel.getComments().get(0);
assertTrue(comments.contains(ComponentConcernSeverity.CRITICAL.getVulnerabilityLabel()), "Expected highest vulnerability severity in the comment to be CRITICAL");
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails in project hub-alert by blackducksoftware.
the class IssueTrackerCallbackInfoCreator method createCallbackInfo.
private IssueTrackerCallbackInfo createCallbackInfo(ProjectIssueModel projectIssueModel, String projectVersionUrl) {
ProviderDetails providerDetails = projectIssueModel.getProviderDetails();
IssueBomComponentDetails bomComponentDetails = projectIssueModel.getBomComponentDetails();
return new IssueTrackerCallbackInfo(providerDetails.getProviderConfigId(), bomComponentDetails.getBlackDuckIssuesUrl(), projectVersionUrl);
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails 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.api.channel.issue.model.IssueBomComponentDetails in project hub-alert by blackducksoftware.
the class JiraIssueCreator method createCustomFieldReplacementValues.
protected MessageReplacementValues createCustomFieldReplacementValues(ProjectIssueModel alertIssueSource) {
IssueBomComponentDetails bomComponent = alertIssueSource.getBomComponentDetails();
ComponentUpgradeGuidance upgradeGuidance = bomComponent.getComponentUpgradeGuidance();
Optional<String> severity = Optional.empty();
Optional<String> policyCategory = Optional.empty();
Optional<IssuePolicyDetails> issuePolicyDetails = alertIssueSource.getPolicyDetails();
Optional<IssueVulnerabilityDetails> vulnerabilityDetails = alertIssueSource.getVulnerabilityDetails();
if (issuePolicyDetails.isPresent()) {
IssuePolicyDetails policyDetails = issuePolicyDetails.get();
severity = Optional.ofNullable(policyDetails.getSeverity().getPolicyLabel());
policyCategory = bomComponent.getRelevantPolicies().stream().filter(policy -> policyDetails.getName().equals(policy.getPolicyName())).findAny().flatMap(ComponentPolicy::getCategory);
}
if (vulnerabilityDetails.isPresent()) {
severity = vulnerabilityDetails.get().getHighestSeverityAddedOrUpdated();
}
return new MessageReplacementValues.Builder(alertIssueSource.getProvider().getLabel(), alertIssueSource.getProject().getValue()).projectVersionName(alertIssueSource.getProjectVersion().map(LinkableItem::getValue).orElse(MessageReplacementValues.DEFAULT_NOTIFICATION_REPLACEMENT_VALUE)).componentName(bomComponent.getComponent().getValue()).componentVersionName(bomComponent.getComponentVersion().map(LinkableItem::getValue).orElse(MessageReplacementValues.DEFAULT_NOTIFICATION_REPLACEMENT_VALUE)).componentUsage(bomComponent.getUsage()).componentLicense(bomComponent.getLicense().getValue()).severity(severity.orElse(MessageReplacementValues.DEFAULT_NOTIFICATION_REPLACEMENT_VALUE)).policyCategory(policyCategory.orElse(MessageReplacementValues.DEFAULT_NOTIFICATION_REPLACEMENT_VALUE)).shortTermUpgradeGuidance(upgradeGuidance.getShortTermUpgradeGuidance().map(LinkableItem::getValue).orElse(MessageReplacementValues.DEFAULT_NOTIFICATION_REPLACEMENT_VALUE)).longTermUpgradeGuidance(upgradeGuidance.getLongTermUpgradeGuidance().map(LinkableItem::getValue).orElse(MessageReplacementValues.DEFAULT_NOTIFICATION_REPLACEMENT_VALUE)).build();
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails in project hub-alert by blackducksoftware.
the class JiraComponentIssueFinder method findIssuesByComponent.
@Override
public List<ProjectIssueSearchResult<String>> findIssuesByComponent(ProviderDetails providerDetails, LinkableItem project, LinkableItem projectVersion, BomComponentDetails originalBomComponent) throws AlertException {
LinkableItem component = originalBomComponent.getComponent();
LinkableItem nullableComponentVersion = originalBomComponent.getComponentVersion().orElse(null);
String jqlString = JqlStringCreator.createBlackDuckComponentIssuesSearchString(jiraProjectKey, providerDetails.getProvider(), project, projectVersion, component, nullableComponentVersion);
List<JiraSearcherResponseModel> issueResponseModels = jqlQueryExecutor.executeQuery(jqlString);
List<ProjectIssueSearchResult<String>> searchResults = new ArrayList<>();
for (JiraSearcherResponseModel model : issueResponseModels) {
IssueBomComponentDetails issueBomComponentDetails = IssueBomComponentDetails.fromBomComponentDetails(originalBomComponent);
ProjectIssueModel projectIssueModel = ProjectIssueModel.bom(providerDetails, project, projectVersion, issueBomComponentDetails);
ProjectIssueSearchResult<String> resultFromExistingIssue = searchResultCreator.createIssueResult(model, projectIssueModel);
searchResults.add(resultFromExistingIssue);
}
return searchResults;
}
Aggregations