use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities in project hub-alert by blackducksoftware.
the class BlackDuckMessageBomComponentDetailsCreator method createBomComponentDetails.
public BomComponentDetails createBomComponentDetails(ProjectVersionComponentVersionView bomComponent, List<ComponentConcern> componentConcerns, ComponentUpgradeGuidance componentUpgradeGuidance, List<LinkableItem> additionalAttributes) throws IntegrationException {
LinkableItem component;
LinkableItem componentVersion = null;
// FIXME using this query link only in a successful result and not in an unsuccessful result leads to inconsistent values in our custom fields which leads to inconsistent search results (bug).
String componentQueryLink = BlackDuckMessageLinkUtils.createComponentQueryLink(bomComponent);
String componentVersionUrl = bomComponent.getComponentVersion();
if (StringUtils.isNotBlank(componentVersionUrl)) {
component = new LinkableItem(BlackDuckMessageLabels.LABEL_COMPONENT, bomComponent.getComponentName());
componentVersion = new LinkableItem(BlackDuckMessageLabels.LABEL_COMPONENT_VERSION, bomComponent.getComponentVersionName(), componentQueryLink);
} else {
component = new LinkableItem(BlackDuckMessageLabels.LABEL_COMPONENT, bomComponent.getComponentName(), componentQueryLink);
}
ComponentVulnerabilities componentVulnerabilities = retrieveComponentVulnerabilities(bomComponent);
List<ComponentPolicy> componentPolicies = retrieveComponentPolicies(bomComponent, componentConcerns);
LinkableItem licenseInfo = BlackDuckMessageAttributesUtils.extractLicense(bomComponent);
String usageInfo = BlackDuckMessageAttributesUtils.extractUsage(bomComponent);
String issuesUrl = BlackDuckMessageAttributesUtils.extractIssuesUrl(bomComponent).orElse(null);
return new BomComponentDetails(component, componentVersion, componentVulnerabilities, componentPolicies, componentConcerns, licenseInfo, usageInfo, componentUpgradeGuidance, additionalAttributes, issuesUrl);
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities in project hub-alert by blackducksoftware.
the class BlackDuckComponentVulnerabilityDetailsCreator method toComponentVulnerabilities.
public ComponentVulnerabilities toComponentVulnerabilities(List<BlackDuckProjectVersionComponentVulnerabilitiesView> vulnerabilities) {
List<LinkableItem> criticalVulns = new LinkedList<>();
List<LinkableItem> highVulns = new LinkedList<>();
List<LinkableItem> mediumVulns = new LinkedList<>();
List<LinkableItem> lowVulns = new LinkedList<>();
for (BlackDuckProjectVersionComponentVulnerabilitiesView vulnerability : vulnerabilities) {
if (requiresRemediation(vulnerability)) {
AlertVulnerability alertVulnerability = toAlertVulnerabilityView(vulnerability);
VulnerabilitySeverityType severity = alertVulnerability.severity;
LinkableItem vulnerabilityInfo = alertVulnerability.vulnerabilityInfo;
if (VulnerabilitySeverityType.CRITICAL.equals(severity)) {
criticalVulns.add(vulnerabilityInfo);
} else if (VulnerabilitySeverityType.HIGH.equals(severity)) {
highVulns.add(vulnerabilityInfo);
} else if (VulnerabilitySeverityType.MEDIUM.equals(severity)) {
mediumVulns.add(vulnerabilityInfo);
} else if (VulnerabilitySeverityType.LOW.equals(severity)) {
lowVulns.add(vulnerabilityInfo);
}
}
}
return new ComponentVulnerabilities(criticalVulns, highVulns, mediumVulns, lowVulns);
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities 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;
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities in project hub-alert by blackducksoftware.
the class BomComponentDetailConverterTest method createComponentVulnerabilities.
private static ComponentVulnerabilities createComponentVulnerabilities() {
LinkableItem vulnerability1 = creatVulnerabilityLinkableItem("CVE-001");
LinkableItem vulnerability2 = creatVulnerabilityLinkableItem("CVE-002");
LinkableItem vulnerability3 = creatVulnerabilityLinkableItem("CVE-003");
LinkableItem vulnerability4 = creatVulnerabilityLinkableItem("CVE-004");
LinkableItem vulnerability5 = creatVulnerabilityLinkableItem("CVE-005");
LinkableItem vulnerability6 = creatVulnerabilityLinkableItem("CVE-006");
return new ComponentVulnerabilities(List.of(), List.of(vulnerability1), List.of(vulnerability2, vulnerability3), List.of(vulnerability4, vulnerability5, vulnerability6));
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities in project hub-alert by blackducksoftware.
the class ProjectMessageConverterTest method createComponentVulnerabilities.
private static ComponentVulnerabilities createComponentVulnerabilities() {
LinkableItem vuln1 = createComponentVulnerability("CVE-123");
LinkableItem vuln2 = createComponentVulnerability("CVE-135");
LinkableItem vuln3 = createComponentVulnerability("CVE-007");
LinkableItem vuln4 = createComponentVulnerability("CVE-099");
LinkableItem vuln5 = createComponentVulnerability("CVE-230");
return new ComponentVulnerabilities(List.of(vuln1), List.of(vuln3, vuln4), List.of(), List.of(vuln2, vuln5));
}
Aggregations