use of com.synopsys.integration.alert.processor.api.extract.model.project.AbstractBomComponentDetails in project hub-alert by blackducksoftware.
the class BomComponentDetailConverterTest method createBomComponentDetails.
private static AbstractBomComponentDetails createBomComponentDetails() {
ComponentPolicy componentPolicy1 = new ComponentPolicy("A Black Duck Policy", ComponentConcernSeverity.MAJOR_HIGH, true, false, null, "Uncategorized");
ComponentPolicy componentPolicy2 = new ComponentPolicy("A Different Black Duck Policy", ComponentConcernSeverity.UNSPECIFIED_UNKNOWN, false, true, null, "Uncategorized");
LinkableItem shortTermUpgradeGuidance = new LinkableItem("Upgrade Guidance - Short Term", "1.0");
LinkableItem longTermUpgradeGuidance = new LinkableItem("Upgrade Guidance - Long Term", "2.0");
ComponentUpgradeGuidance componentUpgradeGuidance = new ComponentUpgradeGuidance(shortTermUpgradeGuidance, longTermUpgradeGuidance);
LinkableItem attribute1 = new LinkableItem("Attribute", "Number 1");
LinkableItem attribute2 = new LinkableItem("Attribute", "Number 2");
return new AbstractBomComponentDetails(new LinkableItem("Component", "A BOM Component"), new LinkableItem("Component Version", "A BOM Component Version"), createComponentVulnerabilities(), List.of(componentPolicy1, componentPolicy2), new LinkableItem("License", "A Software License"), "Example Usage", componentUpgradeGuidance, List.of(attribute1, attribute2), "https://a-blackduck-url") {
};
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.AbstractBomComponentDetails in project hub-alert by blackducksoftware.
the class ProjectIssueModelConverterTest method toIssueCommentModelWithEmptyVulnerabilitySeverityTest.
@Test
public void toIssueCommentModelWithEmptyVulnerabilitySeverityTest() {
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(), List.of(), List.of(), List.of());
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("None"), "Expected missing vulnerability severity to return Severity Status: None");
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.AbstractBomComponentDetails in project hub-alert by blackducksoftware.
the class ProjectIssueModelConverterTest method toIssueCreationModelWithVulnerabilitySeverityTest.
@Test
public void toIssueCreationModelWithVulnerabilitySeverityTest() {
MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
ProjectIssueModelConverter converter = new ProjectIssueModelConverter(formatter);
IssueVulnerabilityModel vuln = createIssueVulnerability(ComponentConcernSeverity.MAJOR_HIGH, "CVE-13579", "https://a-url");
IssueVulnerabilityDetails vulnerabilityDetails = new IssueVulnerabilityDetails(false, List.of(), List.of(vuln), 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);
IssueCreationModel issueCreationModel = converter.toIssueCreationModel(projectIssueModel, "jobName");
assertTrue(issueCreationModel.getDescription().contains(ComponentConcernSeverity.CRITICAL.getVulnerabilityLabel()), "Expected highest vulnerability severity in the description to be CRITICAL");
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.AbstractBomComponentDetails 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");
}
Aggregations