@Test public void report_example1_add_job_data_already_contained_does_not_change() { UUID jobUUID = UUID.fromString("f1d02a9d-5e1b-4f52-99e5-401854ccf936"); ScanReportResult scanReportResult = loadScanReport("sechub_result/sechub-report-example1-noscantype.json"); FalsePositiveJobData falsePositiveJobData = new FalsePositiveJobData(); falsePositiveJobData.setComment("comment1"); falsePositiveJobData.setFindingId(2); falsePositiveJobData.setJobUUID(jobUUID); toTest.addJobDataWithMetaDataToConfig(scanReportResult, config, falsePositiveJobData, TEST_AUTHOR); FalsePositiveJobData falsePositiveJobData2 = new FalsePositiveJobData(); falsePositiveJobData2.setComment("comment2"); falsePositiveJobData2.setFindingId(2); falsePositiveJobData2.setJobUUID(jobUUID); toTest.addJobDataWithMetaDataToConfig(scanReportResult, config, falsePositiveJobData2, TEST_AUTHOR); List<FalsePositiveEntry> falsePositives = config.getFalsePositives(); assertNotNull(falsePositives); assertEquals(1,falsePositives.size()); FalsePositiveEntry fp1 = falsePositives.iterator().next(); FalsePositiveJobData jobData = fp1.getJobData(); assertEquals("comment1", jobData.getComment()); }
public void addJobDataWithMetaDataToConfig(ScanReportResult scanReportResult, FalsePositiveProjectConfiguration config, FalsePositiveJobData falsePositiveJobData, String author) { SecHubFinding finding = fetchFindingInReportOrFail(scanReportResult, 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 = createMetaData(finding); FalsePositiveEntry entry = new FalsePositiveEntry(); entry.setAuthor(author); entry.setJobData(falsePositiveJobData); entry.setMetaData(metaData); config.getFalsePositives().add(entry); }
FalsePositiveJobDataConfigMerger { public void addJobDataWithMetaDataToConfig(ScanReportResult scanReportResult, FalsePositiveProjectConfiguration config, FalsePositiveJobData falsePositiveJobData, String author) { SecHubFinding finding = fetchFindingInReportOrFail(scanReportResult, 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 = createMetaData(finding); FalsePositiveEntry entry = new FalsePositiveEntry(); entry.setAuthor(author); entry.setJobData(falsePositiveJobData); entry.setMetaData(metaData); config.getFalsePositives().add(entry); } }
FalsePositiveJobDataConfigMerger { public void addJobDataWithMetaDataToConfig(ScanReportResult scanReportResult, FalsePositiveProjectConfiguration config, FalsePositiveJobData falsePositiveJobData, String author) { SecHubFinding finding = fetchFindingInReportOrFail(scanReportResult, 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 = createMetaData(finding); FalsePositiveEntry entry = new FalsePositiveEntry(); entry.setAuthor(author); entry.setJobData(falsePositiveJobData); entry.setMetaData(metaData); config.getFalsePositives().add(entry); }  }
FalsePositiveJobDataConfigMerger { public void addJobDataWithMetaDataToConfig(ScanReportResult scanReportResult, FalsePositiveProjectConfiguration config, FalsePositiveJobData falsePositiveJobData, String author) { SecHubFinding finding = fetchFindingInReportOrFail(scanReportResult, 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 = createMetaData(finding); FalsePositiveEntry entry = new FalsePositiveEntry(); entry.setAuthor(author); entry.setJobData(falsePositiveJobData); entry.setMetaData(metaData); config.getFalsePositives().add(entry); }  void addJobDataWithMetaDataToConfig(ScanReportResult scanReportResult, FalsePositiveProjectConfiguration config,
            FalsePositiveJobData falsePositiveJobData, String author); void removeJobDataWithMetaDataFromConfig(FalsePositiveProjectConfiguration config, FalsePositiveJobData jobDataToRemove); }
FalsePositiveJobDataConfigMerger { public void addJobDataWithMetaDataToConfig(ScanReportResult scanReportResult, FalsePositiveProjectConfiguration config, FalsePositiveJobData falsePositiveJobData, String author) { SecHubFinding finding = fetchFindingInReportOrFail(scanReportResult, 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 = createMetaData(finding); FalsePositiveEntry entry = new FalsePositiveEntry(); entry.setAuthor(author); entry.setJobData(falsePositiveJobData); entry.setMetaData(metaData); config.getFalsePositives().add(entry); }  void addJobDataWithMetaDataToConfig(ScanReportResult scanReportResult, FalsePositiveProjectConfiguration config,
            FalsePositiveJobData falsePositiveJobData, String author); void removeJobDataWithMetaDataFromConfig(FalsePositiveProjectConfiguration config, FalsePositiveJobData jobDataToRemove);  }