use of com.epam.pipeline.entity.scan.Vulnerability in project cloud-pipeline by epam.
the class ToolVulnerabilityDaoTest method createVulnerability.
private Vulnerability createVulnerability(Tool tool, String version, String name, String feature, String featureVersion) {
Vulnerability vulnerability = buildVulnerability(name, feature, featureVersion);
toolVulnerabilityDao.createVulnerabilityRecords(Collections.singletonList(vulnerability), tool.getId(), version);
return vulnerability;
}
use of com.epam.pipeline.entity.scan.Vulnerability in project cloud-pipeline by epam.
the class ToolVulnerabilityDaoTest method buildVulnerability.
private Vulnerability buildVulnerability(String name, String feature, String featureVersion) {
Vulnerability vulnerability = new Vulnerability();
vulnerability.setCreatedDate(new Date());
vulnerability.setName(name);
vulnerability.setDescription("testDescription");
vulnerability.setLink("///");
vulnerability.setSeverity(VulnerabilitySeverity.High);
vulnerability.setFeature(feature);
vulnerability.setFeatureVersion(featureVersion);
vulnerability.setFixedBy("testFixer");
return vulnerability;
}
use of com.epam.pipeline.entity.scan.Vulnerability in project cloud-pipeline by epam.
the class TestUtils method createVulnerability.
public static Vulnerability createVulnerability(VulnerabilitySeverity severity) {
Vulnerability v = new Vulnerability();
v.setSeverity(severity);
return v;
}
use of com.epam.pipeline.entity.scan.Vulnerability in project cloud-pipeline by epam.
the class AggregatingToolScanManager method convertResults.
private ToolVersionScanResult convertResults(ClairScanResult clairScanResult, DockerComponentScanResult compScanResult, Tool tool, String tag, String digest) {
List<Vulnerability> vulnerabilities = Optional.ofNullable(clairScanResult).map(result -> ListUtils.emptyIfNull(result.getFeatures()).stream()).orElse(Stream.empty()).flatMap(f -> f.getVulnerabilities() != null ? f.getVulnerabilities().stream().map(v -> {
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(v.getName());
vulnerability.setDescription(v.getDescription());
vulnerability.setFixedBy(v.getFixedBy());
vulnerability.setLink(v.getLink());
vulnerability.setSeverity(v.getSeverity());
vulnerability.setFeature(f.getName());
vulnerability.setFeatureVersion(f.getVersion());
return vulnerability;
}) : Stream.empty()).collect(Collectors.toList());
LOGGER.debug("Found: " + vulnerabilities.size() + " vulnerabilities for " + tool.getImage() + ":" + tag);
// Concat dependencies from Clair and DockerCompScan
List<ToolDependency> dependencies = Stream.concat(Optional.ofNullable(compScanResult).map(result -> ListUtils.emptyIfNull(result.getLayers()).stream()).orElse(Stream.empty()).flatMap(l -> l.getDependencies().stream().peek(dependency -> {
dependency.setToolVersion(tag);
dependency.setToolId(tool.getId());
})), Optional.ofNullable(clairScanResult).map(result -> ListUtils.emptyIfNull(result.getFeatures()).stream()).orElse(Stream.empty()).map(f -> new ToolDependency(tool.getId(), tag, f.getName(), f.getVersion(), ToolDependency.Ecosystem.SYSTEM, null))).collect(Collectors.toList());
LOGGER.debug("Found: " + dependencies.size() + " dependencies for " + tool.getImage() + ":" + tag);
return new ToolVersionScanResult(tag, vulnerabilities, dependencies, ToolScanStatus.COMPLETED, clairScanResult.getName(), digest);
}
use of com.epam.pipeline.entity.scan.Vulnerability in project cloud-pipeline by epam.
the class ToolVulnerabilityDaoTest method testLoadVulnerabilities.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testLoadVulnerabilities() {
Vulnerability vulnerability = createVulnerability(tool, LATEST_VERSION);
List<Vulnerability> vulnerabilities = toolVulnerabilityDao.loadVulnerabilities(tool.getId(), LATEST_VERSION);
Assert.assertFalse(vulnerabilities.isEmpty());
Vulnerability loaded = vulnerabilities.get(0);
TestUtils.checkEquals(vulnerability, loaded, objectMapper);
}
Aggregations