use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.
the class HTMLScanResultReportModelBuilderTest method code_scan_entries_set_and_right_amount_of_call_stacks_populated.
@Test
public void code_scan_entries_set_and_right_amount_of_call_stacks_populated() {
/* prepare */
SecHubFinding finding = mock(SecHubFinding.class);
SecHubCodeCallStack code1 = mock(SecHubCodeCallStack.class);
SecHubCodeCallStack subCode = mock(SecHubCodeCallStack.class);
when(scanSecHubReport.getTrafficLight()).thenReturn(TrafficLight.RED);
when(scanSecHubReport.getResult()).thenReturn(result);
when(result.getFindings()).thenReturn(Arrays.asList(finding));
when(finding.getCode()).thenReturn(code1);
when(code1.getCalls()).thenReturn(subCode);
/* execute */
Map<String, Object> buildResult = builderToTest.build(scanSecHubReport);
/* test */
assertNotNull(buildResult.get("codeScanEntries"));
assertTrue(buildResult.get("codeScanEntries") instanceof Map<?, ?>);
@SuppressWarnings("unchecked") Map<Integer, List<HTMLScanResultCodeScanEntry>> codeScanEntries = (Map<Integer, List<HTMLScanResultCodeScanEntry>>) buildResult.get("codeScanEntries");
assertNotNull(codeScanEntries.get(0));
List<HTMLScanResultCodeScanEntry> scanEntriesList = codeScanEntries.get(0);
assertTrue(scanEntriesList.size() == 2);
}
use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.
the class HtmlCodeScanDescriptionSupportTest method build_entries__creates_NO_html_scan_entries_when_finding_has_no_code.
@Test
void build_entries__creates_NO_html_scan_entries_when_finding_has_no_code() {
/* prepare */
SecHubFinding finding = new SecHubFinding();
/* execute */
List<HTMLScanResultCodeScanEntry> emptyResult = descriptionSupport.buildEntries(finding);
/* test */
assertTrue(emptyResult.isEmpty());
}
use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.
the class HtmlCodeScanDescriptionSupportTest method test_is_code_scan_with_code_scan_finding.
@Test
void test_is_code_scan_with_code_scan_finding() {
/* prepare */
SecHubFinding finding = new SecHubFinding();
finding.setCode(new SecHubCodeCallStack());
/* test */
assertTrue(descriptionSupport.isCodeScan(finding));
}
use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.
the class FalsePositiveJobDataConfigMerger method addJobDataWithMetaDataToConfig.
public void addJobDataWithMetaDataToConfig(ScanSecHubReport report, FalsePositiveProjectConfiguration config, FalsePositiveJobData falsePositiveJobData, String author) {
SecHubFinding finding = fetchFindingInReportOrFail(report, falsePositiveJobData);
FalsePositiveEntry existingEntry = findExistingFalsePositiveEntryInConfig(config, falsePositiveJobData);
if (existingEntry != null) {
LOG.warn("False positive entry for job:{}, findingId:{} not added, because already existing", falsePositiveJobData.getJobUUID(), falsePositiveJobData.getFindingId());
return;
}
FalsePositiveMetaData metaData = metaDataFactory.createMetaData(finding);
FalsePositiveEntry entry = new FalsePositiveEntry();
entry.setAuthor(author);
entry.setJobData(falsePositiveJobData);
entry.setMetaData(metaData);
config.getFalsePositives().add(entry);
}
use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.
the class ReportTransformationResultMergerTest method result1_result2_merged_contains_all_findings.
@Test
public void result1_result2_merged_contains_all_findings() {
/* prepare */
ReportTransformationResult result1 = new ReportTransformationResult();
SecHubFinding finding1 = new SecHubFinding();
result1.getResult().getFindings().add(finding1);
SecHubFinding finding2 = new SecHubFinding();
ReportTransformationResult result2 = new ReportTransformationResult();
result1.getResult().getFindings().add(finding2);
/* execute */
ReportTransformationResult merged = mergerToTest.merge(result1, result2);
/* test */
List<SecHubFinding> findings = merged.getResult().getFindings();
assertEquals(2, findings.size());
assertTrue(findings.contains(finding1));
assertTrue(findings.contains(finding2));
}
Aggregations