Search in sources :

Example 16 with SecHubFinding

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);
}
Also used : SecHubFinding(com.mercedesbenz.sechub.commons.model.SecHubFinding) ArrayList(java.util.ArrayList) List(java.util.List) SecHubCodeCallStack(com.mercedesbenz.sechub.commons.model.SecHubCodeCallStack) Map(java.util.Map) Test(org.junit.Test)

Example 17 with SecHubFinding

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());
}
Also used : SecHubFinding(com.mercedesbenz.sechub.commons.model.SecHubFinding) Test(org.junit.jupiter.api.Test)

Example 18 with SecHubFinding

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));
}
Also used : SecHubFinding(com.mercedesbenz.sechub.commons.model.SecHubFinding) SecHubCodeCallStack(com.mercedesbenz.sechub.commons.model.SecHubCodeCallStack) Test(org.junit.jupiter.api.Test)

Example 19 with SecHubFinding

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);
}
Also used : SecHubFinding(com.mercedesbenz.sechub.commons.model.SecHubFinding)

Example 20 with SecHubFinding

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));
}
Also used : SecHubFinding(com.mercedesbenz.sechub.commons.model.SecHubFinding) Test(org.junit.Test)

Aggregations

SecHubFinding (com.mercedesbenz.sechub.commons.model.SecHubFinding)29 Test (org.junit.jupiter.api.Test)12 SecHubResult (com.mercedesbenz.sechub.commons.model.SecHubResult)8 SecHubCodeCallStack (com.mercedesbenz.sechub.commons.model.SecHubCodeCallStack)6 Test (org.junit.Test)6 ReportTransformationResult (com.mercedesbenz.sechub.domain.scan.ReportTransformationResult)3 SecHubReportModel (com.mercedesbenz.sechub.commons.model.SecHubReportModel)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 UUID (java.util.UUID)2 ScanType (com.mercedesbenz.sechub.commons.model.ScanType)1 SecHubMessage (com.mercedesbenz.sechub.commons.model.SecHubMessage)1 Severity (com.mercedesbenz.sechub.commons.model.Severity)1 TrafficLight (com.mercedesbenz.sechub.commons.model.TrafficLight)1 SecHubReportWeb (com.mercedesbenz.sechub.commons.model.web.SecHubReportWeb)1 SecHubReportWebEvidence (com.mercedesbenz.sechub.commons.model.web.SecHubReportWebEvidence)1 SecHubReportWebRequest (com.mercedesbenz.sechub.commons.model.web.SecHubReportWebRequest)1 SecHubReportWebResponse (com.mercedesbenz.sechub.commons.model.web.SecHubReportWebResponse)1 AssertSecHubResult (com.mercedesbenz.sechub.domain.scan.AssertSecHubResult)1