use of com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails in project hub-alert by blackducksoftware.
the class ProjectMessageToIssueModelTransformer method createVulnerabilityProjectIssueModel.
private ProjectIssueModel createVulnerabilityProjectIssueModel(ProjectMessage projectMessage, IssueBomComponentDetails issueBomComponent, List<ComponentConcern> vulnerabilityConcerns) {
List<IssueVulnerabilityModel> issueVulnerabilitiesAdded = new LinkedList<>();
List<IssueVulnerabilityModel> issueVulnerabilitiesUpdated = new LinkedList<>();
List<IssueVulnerabilityModel> issueVulnerabilitiesDeleted = new LinkedList<>();
for (ComponentConcern vulnerabilityConcern : vulnerabilityConcerns) {
IssueVulnerabilityModel issueVulnerabilityModel = IssueVulnerabilityModel.fromComponentConcern(vulnerabilityConcern);
ItemOperation vulnOperation = vulnerabilityConcern.getOperation();
if (ItemOperation.ADD.equals(vulnOperation)) {
issueVulnerabilitiesAdded.add(issueVulnerabilityModel);
} else if (ItemOperation.DELETE.equals(vulnOperation)) {
issueVulnerabilitiesDeleted.add(issueVulnerabilityModel);
} else {
issueVulnerabilitiesUpdated.add(issueVulnerabilityModel);
}
}
ComponentVulnerabilities componentVulnerabilities = issueBomComponent.getComponentVulnerabilities();
IssueVulnerabilityDetails vulnerabilityDetails = new IssueVulnerabilityDetails(!componentVulnerabilities.hasVulnerabilities(), issueVulnerabilitiesAdded, issueVulnerabilitiesUpdated, issueVulnerabilitiesDeleted);
return ProjectIssueModel.vulnerability(projectMessage.getProviderDetails(), projectMessage.getProject(), projectMessage.getProjectVersion().orElse(null), issueBomComponent, vulnerabilityDetails);
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails 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.IssueVulnerabilityDetails 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.IssueVulnerabilityDetails 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;
}
use of com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails in project hub-alert by blackducksoftware.
the class ProjectIssueModelConverter method createVulnerabilitySeverityStatusSectionPieces.
private List<String> createVulnerabilitySeverityStatusSectionPieces(ProjectIssueModel projectIssueModel) {
List<String> severityStatusSectionPieces = new LinkedList<>();
String encodedSeverityStatus = formatter.encode(LABEL_SEVERITY_STATUS);
IssueBomComponentDetails bomComponentDetails = projectIssueModel.getBomComponentDetails();
Optional<IssueVulnerabilityDetails> vulnerabilityDetails = projectIssueModel.getVulnerabilityDetails();
if (vulnerabilityDetails.isPresent()) {
ComponentVulnerabilities componentVulnerabilities = bomComponentDetails.getComponentVulnerabilities();
componentVulnerabilities.computeHighestSeverity().map(ComponentConcernSeverity::getVulnerabilityLabel).map(formatter::encode).map(severity -> encodedSeverityStatus + severity).ifPresentOrElse(severityStatusSectionPieces::add, () -> severityStatusSectionPieces.add(encodedSeverityStatus + "None"));
severityStatusSectionPieces.add(formatter.getLineSeparator());
severityStatusSectionPieces.add(formatter.getSectionSeparator());
severityStatusSectionPieces.add(formatter.getLineSeparator());
}
return severityStatusSectionPieces;
}
Aggregations