use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class EmailChannelMessageConverter method convertProjectMessageToChannelMessages.
@Override
protected List<EmailChannelMessageModel> convertProjectMessageToChannelMessages(EmailJobDetailsModel distributionDetails, ProjectMessage projectMessage, List<String> messageChunks) {
String subjectLine = createSubjectLine(distributionDetails, projectMessage);
String messageContent = StringUtils.join(messageChunks, "");
LinkableItem provider = projectMessage.getProvider();
EmailChannelMessageModel model = EmailChannelMessageModel.standardProject(subjectLine, messageContent, provider.getValue(), provider.getUrl().orElse("#"), projectMessage);
return List.of(model);
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class IssueTrackerCallbackInfoCreatorTest method createCallbackInfoWithProjectVersionUrlTest.
@Test
public void createCallbackInfoWithProjectVersionUrlTest() {
LinkableItem projectVersionWithUrl = new LinkableItem("Project Version", "A Project Version", "https://project-version-url");
ProjectIssueModel projectIssueModel = ProjectIssueModel.bom(PROVIDER_DETAILS, TEST_ITEM, projectVersionWithUrl, ISSUE_BOM_COMPONENT_DETAILS);
IssueTrackerCallbackInfoCreator callbackInfoCreator = new IssueTrackerCallbackInfoCreator();
Optional<IssueTrackerCallbackInfo> optionalCallbackInfo = callbackInfoCreator.createCallbackInfo(projectIssueModel);
assertTrue(optionalCallbackInfo.isPresent(), "Expected a callback info to be present because a project-version url was present");
IssueTrackerCallbackInfo callbackInfo = optionalCallbackInfo.get();
assertEquals(PROVIDER_DETAILS.getProviderConfigId(), callbackInfo.getProviderConfigId());
assertEquals(BOM_COMPONENT_DETAILS.getBlackDuckIssuesUrl(), callbackInfo.getCallbackUrl());
assertEquals(projectVersionWithUrl.getUrl().orElse(null), callbackInfo.getBlackDuckProjectVersionUrl());
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem 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.common.message.model.LinkableItem 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.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class IssueVulnerabilityDetailsTest method getHighestVulnerabilityAddedOrUpdatedTest.
@Test
public void getHighestVulnerabilityAddedOrUpdatedTest() {
IssueVulnerabilityModel vuln1 = new IssueVulnerabilityModel(ComponentConcernSeverity.MINOR_MEDIUM, new LinkableItem("", ""));
IssueVulnerabilityModel vuln2 = new IssueVulnerabilityModel(ComponentConcernSeverity.MAJOR_HIGH, new LinkableItem("", ""));
IssueVulnerabilityModel vuln3 = new IssueVulnerabilityModel(ComponentConcernSeverity.BLOCKER, new LinkableItem("", ""));
IssueVulnerabilityModel vuln4 = new IssueVulnerabilityModel(ComponentConcernSeverity.UNSPECIFIED_UNKNOWN, new LinkableItem("", ""));
List<IssueVulnerabilityModel> vulnerabilityModelsAdded = List.of(vuln1, vuln2);
List<IssueVulnerabilityModel> vulnerabilityModelsUpdated = List.of(vuln3, vuln4);
IssueVulnerabilityDetails issueVulnerabilityDetails = new IssueVulnerabilityDetails(false, vulnerabilityModelsAdded, vulnerabilityModelsUpdated, List.of());
assertTrue(issueVulnerabilityDetails.getHighestSeverityAddedOrUpdated().isPresent());
assertEquals("CRITICAL", issueVulnerabilityDetails.getHighestSeverityAddedOrUpdated().get());
}
Aggregations