Search in sources :

Example 6 with FalsePositiveMetaData

use of com.mercedesbenz.sechub.domain.scan.project.FalsePositiveMetaData in project sechub by mercedes-benz.

the class SerecoFalsePositiveCodeScanStrategyTest method vulnerability_having_no_relevant_part_will_use_relevant_part_resolver_on_start_and_end.

@Test
public void vulnerability_having_no_relevant_part_will_use_relevant_part_resolver_on_start_and_end() {
    /* prepare */
    /* @formatter:off */
    SerecoVulnerability vulnerability = TestSerecoVulnerabilityBuilder.builder().name("name1").cwe(1).codeScan().location(// here different to false-positive meta data! So may not be found!
    "location1").source("source1").callsCode().callsCode().callsCode().location("location2").source("source2").end().build();
    /* @formatter:on */
    FalsePositiveMetaData metaData = fetchFirstEntryMetaDataOfExample3();
    when(relevantPartResolver.toRelevantPart("source1")).thenReturn("relevant1");
    when(relevantPartResolver.toRelevantPart("source2")).thenReturn("relevant2");
    /* execute */
    boolean isFalsePositive = strategyToTest.isFalsePositive(vulnerability, metaData);
    /* test */
    verify(relevantPartResolver).toRelevantPart("source1");
    verify(relevantPartResolver).toRelevantPart("source2");
    assertTrue(isFalsePositive);
}
Also used : FalsePositiveMetaData(com.mercedesbenz.sechub.domain.scan.project.FalsePositiveMetaData) SerecoVulnerability(com.mercedesbenz.sechub.sereco.metadata.SerecoVulnerability) Test(org.junit.Test)

Example 7 with FalsePositiveMetaData

use of com.mercedesbenz.sechub.domain.scan.project.FalsePositiveMetaData in project sechub by mercedes-benz.

the class SerecoFalsePositiveCodeScanStrategyTest method fetchFirstEntryMetaDataOfExample3.

private FalsePositiveMetaData fetchFirstEntryMetaDataOfExample3() {
    String json = ScanProductSerecoTestFileSupport.getTestfileSupport().loadTestFile("false_positives/scan_false_positive_config_example3.json");
    FalsePositiveProjectConfiguration config = FalsePositiveProjectConfiguration.fromJSONString(json);
    FalsePositiveEntry entry = config.getFalsePositives().get(0);
    // sanity check, means correct entry...
    assertEquals("entry-1", entry.getJobData().getComment());
    FalsePositiveMetaData metaData = entry.getMetaData();
    return metaData;
}
Also used : FalsePositiveEntry(com.mercedesbenz.sechub.domain.scan.project.FalsePositiveEntry) FalsePositiveMetaData(com.mercedesbenz.sechub.domain.scan.project.FalsePositiveMetaData) FalsePositiveProjectConfiguration(com.mercedesbenz.sechub.domain.scan.project.FalsePositiveProjectConfiguration)

Example 8 with FalsePositiveMetaData

use of com.mercedesbenz.sechub.domain.scan.project.FalsePositiveMetaData in project sechub by mercedes-benz.

the class SerecoFalsePositiveCodeScanStrategyTest method vulnerability_is_NOT_found_when_locations_and_relevant_parts_are_same_but_cwe_differs.

@Test
public void vulnerability_is_NOT_found_when_locations_and_relevant_parts_are_same_but_cwe_differs() {
    /* prepare */
    /* @formatter:off */
    SerecoVulnerability vulnerability = TestSerecoVulnerabilityBuilder.builder().name("name1").cwe(4711).codeScan().location("location1").source("source1").relevantPart("relevant1").callsCode().callsCode().callsCode().location("location2").source("source2").relevantPart("relevant2").end().build();
    /* @formatter:on */
    FalsePositiveMetaData metaData = fetchFirstEntryMetaDataOfExample3();
    when(relevantPartResolver.toRelevantPart(any())).thenReturn("");
    /* execute + test */
    assertFalse(strategyToTest.isFalsePositive(vulnerability, metaData));
}
Also used : FalsePositiveMetaData(com.mercedesbenz.sechub.domain.scan.project.FalsePositiveMetaData) SerecoVulnerability(com.mercedesbenz.sechub.sereco.metadata.SerecoVulnerability) Test(org.junit.Test)

Example 9 with FalsePositiveMetaData

use of com.mercedesbenz.sechub.domain.scan.project.FalsePositiveMetaData in project sechub by mercedes-benz.

the class SerecoFalsePositiveCodeScanStrategyTest method vulnerability_is_NOT_found_when_start_location_differs_and_relevant_parts_are_same.

@Test
public void vulnerability_is_NOT_found_when_start_location_differs_and_relevant_parts_are_same() {
    /* prepare */
    /* @formatter:off */
    SerecoVulnerability vulnerability = TestSerecoVulnerabilityBuilder.builder().name("name1").cwe(1).codeScan().location(// here different to false-positive meta data! So may not be found!
    "location-other-1").source("source1").relevantPart("relevant1").callsCode().callsCode().callsCode().location("location2").source("source2").relevantPart("relevant2").end().build();
    /* @formatter:on */
    FalsePositiveMetaData metaData = fetchFirstEntryMetaDataOfExample3();
    when(relevantPartResolver.toRelevantPart(any())).thenReturn("");
    /* execute + test */
    assertFalse(strategyToTest.isFalsePositive(vulnerability, metaData));
}
Also used : FalsePositiveMetaData(com.mercedesbenz.sechub.domain.scan.project.FalsePositiveMetaData) SerecoVulnerability(com.mercedesbenz.sechub.sereco.metadata.SerecoVulnerability) Test(org.junit.Test)

Example 10 with FalsePositiveMetaData

use of com.mercedesbenz.sechub.domain.scan.project.FalsePositiveMetaData in project sechub by mercedes-benz.

the class SerecoFalsePositiveCodeScanStrategyTest method vulnerability_is_found_when_locations_and_relevant_parts_are_same.

@Test
public void vulnerability_is_found_when_locations_and_relevant_parts_are_same() {
    /* prepare */
    /* @formatter:off */
    SerecoVulnerability vulnerability = TestSerecoVulnerabilityBuilder.builder().name("name1").cwe(1).codeScan().location("location1").source("source1").relevantPart("relevant1").callsCode().callsCode().callsCode().location("location2").source("source2").relevantPart("relevant2").end().build();
    /* @formatter:on */
    FalsePositiveMetaData metaData = fetchFirstEntryMetaDataOfExample3();
    when(relevantPartResolver.toRelevantPart(any())).thenReturn("");
    /* execute + test */
    assertTrue(strategyToTest.isFalsePositive(vulnerability, metaData));
}
Also used : FalsePositiveMetaData(com.mercedesbenz.sechub.domain.scan.project.FalsePositiveMetaData) SerecoVulnerability(com.mercedesbenz.sechub.sereco.metadata.SerecoVulnerability) Test(org.junit.Test)

Aggregations

FalsePositiveMetaData (com.mercedesbenz.sechub.domain.scan.project.FalsePositiveMetaData)18 Test (org.junit.Test)13 SerecoVulnerability (com.mercedesbenz.sechub.sereco.metadata.SerecoVulnerability)12 FalsePositiveEntry (com.mercedesbenz.sechub.domain.scan.project.FalsePositiveEntry)4 ArrayList (java.util.ArrayList)4 FalsePositiveProjectConfiguration (com.mercedesbenz.sechub.domain.scan.project.FalsePositiveProjectConfiguration)3 ScanType (com.mercedesbenz.sechub.commons.model.ScanType)1 FalsePositiveCodeMetaData (com.mercedesbenz.sechub.domain.scan.project.FalsePositiveCodeMetaData)1 FalsePositiveCodePartMetaData (com.mercedesbenz.sechub.domain.scan.project.FalsePositiveCodePartMetaData)1 FalsePositiveJobData (com.mercedesbenz.sechub.domain.scan.project.FalsePositiveJobData)1 FalsePositiveWebMetaData (com.mercedesbenz.sechub.domain.scan.project.FalsePositiveWebMetaData)1 FalsePositiveWebRequestMetaData (com.mercedesbenz.sechub.domain.scan.project.FalsePositiveWebRequestMetaData)1 FalsePositiveWebResponseMetaData (com.mercedesbenz.sechub.domain.scan.project.FalsePositiveWebResponseMetaData)1 UseCaseRestDoc (com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc)1 UseCaseUserFetchesFalsePositiveConfigurationOfProject (com.mercedesbenz.sechub.sharedkernel.usecases.user.execute.UseCaseUserFetchesFalsePositiveConfigurationOfProject)1 Date (java.util.Date)1 UUID (java.util.UUID)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1