use of com.epam.pipeline.entity.scan.Vulnerability in project cloud-pipeline by epam.
the class ToolVulnerabilityDaoTest method testLoadVulnerabilitiesByVersion.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testLoadVulnerabilitiesByVersion() {
Vulnerability prevVulnerability = createVulnerability(tool, PREV, "test1", "feature-1", PREV);
Vulnerability latestVulnerability = createVulnerability(tool, LATEST_VERSION, "test2", "feature-2", LATEST_VERSION);
List<Vulnerability> vulnerabilities = toolVulnerabilityDao.loadVulnerabilities(tool.getId(), PREV);
Assert.assertTrue(vulnerabilities.size() == 1);
Vulnerability loaded = vulnerabilities.get(0);
TestUtils.checkEquals(prevVulnerability, loaded, objectMapper);
vulnerabilities = toolVulnerabilityDao.loadVulnerabilities(tool.getId(), LATEST_VERSION);
Assert.assertTrue(vulnerabilities.size() == 1);
loaded = vulnerabilities.get(0);
TestUtils.checkEquals(latestVulnerability, loaded, objectMapper);
}
use of com.epam.pipeline.entity.scan.Vulnerability in project cloud-pipeline by epam.
the class TestUtils method generateScanResult.
public static void generateScanResult(int criticalVulnerabilitiesCount, int highVulnerabilitiesCount, int mediumVulnerabilitiesCount, ToolVersionScanResult versionScanResult) {
List<Vulnerability> testVulnerabilities = IntStream.range(0, criticalVulnerabilitiesCount).mapToObj(i -> createVulnerability(VulnerabilitySeverity.Critical)).collect(Collectors.toList());
testVulnerabilities.addAll(IntStream.range(0, highVulnerabilitiesCount).mapToObj(i -> createVulnerability(VulnerabilitySeverity.High)).collect(Collectors.toList()));
testVulnerabilities.addAll(IntStream.range(0, mediumVulnerabilitiesCount).mapToObj(i -> createVulnerability(VulnerabilitySeverity.Medium)).collect(Collectors.toList()));
versionScanResult.setVulnerabilities(testVulnerabilities);
versionScanResult.setScanDate(new Date());
versionScanResult.setSuccessScanDate(new Date());
versionScanResult.setStatus(ToolScanStatus.COMPLETED);
}
Aggregations