@Test public void one_vulnerability_as_code_in_meta_results_in_one_finding() throws Exception { String converted = createMetaDataWithOneVulnerabilityAsCodeFound(); SecHubResult result = transformerToTest.transform(createProductResult(converted)); for (SecHubFinding f : result.getFindings()) { assertEquals(ScanType.CODE_SCAN, f.getType()); } AssertSecHubResult.assertSecHubResult(result).hasFindings(1); SecHubFinding finding1 = result.getFindings().get(0); SecHubCodeCallStack code1 = finding1.getCode(); assertNotNull(code1); assertEquals(Integer.valueOf(1), code1.getLine()); assertEquals(Integer.valueOf(2), code1.getColumn()); assertEquals("Location1", code1.getLocation()); assertEquals("source1", code1.getSource()); assertEquals("relevantPart1", code1.getRelevantPart()); SecHubCodeCallStack code2 = code1.getCalls(); assertNotNull(code2); assertEquals(Integer.valueOf(3), code2.getLine()); assertEquals(Integer.valueOf(4), code2.getColumn()); assertEquals("Location2", code2.getLocation()); assertEquals("source2", code2.getSource()); assertEquals("relevantPart2", code2.getRelevantPart()); }
@Override public SecHubResult transform(ProductResult productResult) throws SecHubExecutionException { String origin = productResult.getResult(); String projectId = productResult.getProjectId(); SerecoMetaData data = JSONConverter.get().fromJSON(SerecoMetaData.class, origin); falsePositiveMarker.markFalsePositives(projectId, data.getVulnerabilities()); SecHubResult result = new SecHubResult(); List<SecHubFinding> findings = result.getFindings(); int findingId = 0; for (SerecoVulnerability v : data.getVulnerabilities()) { findingId++; if (v.isFalsePositive()) { continue; } SecHubFinding finding = new SecHubFinding(); handleClassifications(finding, v, productResult.getSecHubJobUUID()); finding.setDescription(v.getDescription()); finding.setName(v.getType()); finding.setId(findingId); finding.setSeverity(transformSeverity(v.getSeverity())); if (showProductLineResultLink) { finding.setProductResultLink(v.getProductResultLink()); } finding.setCode(convert(v.getCode())); finding.setType(v.getScanType()); findings.add(finding); } return result; }
SerecoReportToSecHubResultTransformer implements ScanReportToSecHubResultTransformer { @Override public SecHubResult transform(ProductResult productResult) throws SecHubExecutionException { String origin = productResult.getResult(); String projectId = productResult.getProjectId(); SerecoMetaData data = JSONConverter.get().fromJSON(SerecoMetaData.class, origin); falsePositiveMarker.markFalsePositives(projectId, data.getVulnerabilities()); SecHubResult result = new SecHubResult(); List<SecHubFinding> findings = result.getFindings(); int findingId = 0; for (SerecoVulnerability v : data.getVulnerabilities()) { findingId++; if (v.isFalsePositive()) { continue; } SecHubFinding finding = new SecHubFinding(); handleClassifications(finding, v, productResult.getSecHubJobUUID()); finding.setDescription(v.getDescription()); finding.setName(v.getType()); finding.setId(findingId); finding.setSeverity(transformSeverity(v.getSeverity())); if (showProductLineResultLink) { finding.setProductResultLink(v.getProductResultLink()); } finding.setCode(convert(v.getCode())); finding.setType(v.getScanType()); findings.add(finding); } return result; } }
SerecoReportToSecHubResultTransformer implements ScanReportToSecHubResultTransformer { @Override public SecHubResult transform(ProductResult productResult) throws SecHubExecutionException { String origin = productResult.getResult(); String projectId = productResult.getProjectId(); SerecoMetaData data = JSONConverter.get().fromJSON(SerecoMetaData.class, origin); falsePositiveMarker.markFalsePositives(projectId, data.getVulnerabilities()); SecHubResult result = new SecHubResult(); List<SecHubFinding> findings = result.getFindings(); int findingId = 0; for (SerecoVulnerability v : data.getVulnerabilities()) { findingId++; if (v.isFalsePositive()) { continue; } SecHubFinding finding = new SecHubFinding(); handleClassifications(finding, v, productResult.getSecHubJobUUID()); finding.setDescription(v.getDescription()); finding.setName(v.getType()); finding.setId(findingId); finding.setSeverity(transformSeverity(v.getSeverity())); if (showProductLineResultLink) { finding.setProductResultLink(v.getProductResultLink()); } finding.setCode(convert(v.getCode())); finding.setType(v.getScanType()); findings.add(finding); } return result; }  }
SerecoReportToSecHubResultTransformer implements ScanReportToSecHubResultTransformer { @Override public SecHubResult transform(ProductResult productResult) throws SecHubExecutionException { String origin = productResult.getResult(); String projectId = productResult.getProjectId(); SerecoMetaData data = JSONConverter.get().fromJSON(SerecoMetaData.class, origin); falsePositiveMarker.markFalsePositives(projectId, data.getVulnerabilities()); SecHubResult result = new SecHubResult(); List<SecHubFinding> findings = result.getFindings(); int findingId = 0; for (SerecoVulnerability v : data.getVulnerabilities()) { findingId++; if (v.isFalsePositive()) { continue; } SecHubFinding finding = new SecHubFinding(); handleClassifications(finding, v, productResult.getSecHubJobUUID()); finding.setDescription(v.getDescription()); finding.setName(v.getType()); finding.setId(findingId); finding.setSeverity(transformSeverity(v.getSeverity())); if (showProductLineResultLink) { finding.setProductResultLink(v.getProductResultLink()); } finding.setCode(convert(v.getCode())); finding.setType(v.getScanType()); findings.add(finding); } return result; }  @Override SecHubResult transform(ProductResult productResult); @Override boolean canTransform(ProductIdentifier productIdentifier); }
SerecoReportToSecHubResultTransformer implements ScanReportToSecHubResultTransformer { @Override public SecHubResult transform(ProductResult productResult) throws SecHubExecutionException { String origin = productResult.getResult(); String projectId = productResult.getProjectId(); SerecoMetaData data = JSONConverter.get().fromJSON(SerecoMetaData.class, origin); falsePositiveMarker.markFalsePositives(projectId, data.getVulnerabilities()); SecHubResult result = new SecHubResult(); List<SecHubFinding> findings = result.getFindings(); int findingId = 0; for (SerecoVulnerability v : data.getVulnerabilities()) { findingId++; if (v.isFalsePositive()) { continue; } SecHubFinding finding = new SecHubFinding(); handleClassifications(finding, v, productResult.getSecHubJobUUID()); finding.setDescription(v.getDescription()); finding.setName(v.getType()); finding.setId(findingId); finding.setSeverity(transformSeverity(v.getSeverity())); if (showProductLineResultLink) { finding.setProductResultLink(v.getProductResultLink()); } finding.setCode(convert(v.getCode())); finding.setType(v.getScanType()); findings.add(finding); } return result; }  @Override SecHubResult transform(ProductResult productResult); @Override boolean canTransform(ProductIdentifier productIdentifier);  }