Search in sources :

Example 21 with SecHubFinding

use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.

the class ReportTrafficLightCalculatorTest method prepareSechubResultWithFindings.

/* +-----------------------------------------------------------------------+ */
/* +............................ Helpers ..................................+ */
/* +-----------------------------------------------------------------------+ */
private SecHubReportModel prepareSechubResultWithFindings(Severity... severities) {
    List<SecHubFinding> findingList = new ArrayList<>();
    for (Severity severity : severities) {
        SecHubFinding finding = new SecHubFinding();
        finding.setSeverity(severity);
        findingList.add(finding);
    }
    SecHubReportModel model = new SecHubReportModel();
    model.getResult().getFindings().addAll(findingList);
    return model;
}
Also used : SecHubReportModel(com.mercedesbenz.sechub.commons.model.SecHubReportModel) SecHubFinding(com.mercedesbenz.sechub.commons.model.SecHubFinding) ArrayList(java.util.ArrayList) Severity(com.mercedesbenz.sechub.commons.model.Severity)

Example 22 with SecHubFinding

use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.

the class ScanSecHubReportTest method scanreport_result_with_report_containing_sechub_report_model_init_and_json_parts_work.

@Test
void scanreport_result_with_report_containing_sechub_report_model_init_and_json_parts_work() {
    /* prepare */
    SecHubReportModel reportModel = new SecHubReportModel();
    SecHubFinding finding = new SecHubFinding();
    finding.setName("finding1");
    reportModel.getResult().getFindings().add(finding);
    reportModel.setStatus(SecHubStatus.FAILED);
    reportModel.getMessages().add(new SecHubMessage(SecHubMessageType.WARNING, "Testwarning"));
    ScanReport report = new ScanReport();
    report.setResult(reportModel.toJSON());
    report.setResultType(ScanReportResultType.MODEL);
    /* execute */
    ScanSecHubReport createdReport = new ScanSecHubReport(report);
    // now we also check if the JSON deserialization /serialization works as
    // expected
    String json = createdReport.toJSON();
    ScanSecHubReport reportToTest = ScanSecHubReport.fromJSONString(json);
    /* test */
    assertEquals(SecHubStatus.FAILED, reportToTest.getStatus());
    // traffic light was not set at all
    assertEquals(null, reportToTest.getTrafficLight());
    assertEquals(1, reportToTest.getMessages().size());
    SecHubMessage message1 = reportToTest.getMessages().iterator().next();
    assertEquals("Testwarning", message1.getText());
    assertEquals(SecHubMessageType.WARNING, message1.getType());
    assertEquals(1, reportToTest.getResult().getFindings().size());
    assertEquals(1, reportToTest.getResult().getCount());
}
Also used : SecHubReportModel(com.mercedesbenz.sechub.commons.model.SecHubReportModel) SecHubMessage(com.mercedesbenz.sechub.commons.model.SecHubMessage) SecHubFinding(com.mercedesbenz.sechub.commons.model.SecHubFinding) Test(org.junit.jupiter.api.Test)

Example 23 with SecHubFinding

use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.

the class ScanSecHubReportTest method scanreport_result_by_simple_result_does_not_recalculate_traffic_light_but_uses_report_traffic_light.

@Test
void scanreport_result_by_simple_result_does_not_recalculate_traffic_light_but_uses_report_traffic_light() {
    /* prepare */
    SecHubResult result = new SecHubResult();
    SecHubFinding finding = new SecHubFinding();
    finding.setName("finding1");
    finding.setSeverity(Severity.CRITICAL);
    result.getFindings().add(finding);
    ScanReport report = new ScanReport();
    report.setResult(result.toJSON());
    report.setTrafficLight(TrafficLight.GREEN);
    report.setResultType(ScanReportResultType.RESULT);
    /* execute */
    ScanSecHubReport createdReport = new ScanSecHubReport(report);
    // now we also check if the JSON deserialization /serialization works as
    // expected
    String json = createdReport.toJSON();
    ScanSecHubReport reportToTest = ScanSecHubReport.fromJSONString(json);
    /* test */
    assertEquals(TrafficLight.GREEN, reportToTest.getTrafficLight());
}
Also used : SecHubFinding(com.mercedesbenz.sechub.commons.model.SecHubFinding) SecHubResult(com.mercedesbenz.sechub.commons.model.SecHubResult) Test(org.junit.jupiter.api.Test)

Example 24 with SecHubFinding

use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.

the class FalsePositiveJobDataConfigMergerTest method sanity_check_for_JSON_example_data.

@Test
public void sanity_check_for_JSON_example_data() {
    /* execute */
    ScanSecHubReport scanSecHubReport = loadScanReport("sechub_result/sechub-report-example1-noscantype.json");
    SecHubFinding secHubFinding = scanSecHubReport.getResult().getFindings().get(1);
    assertEquals(Severity.MEDIUM, secHubFinding.getSeverity());
    Integer cweId = secHubFinding.getCweId();
    assertEquals(Integer.valueOf(1), cweId);
}
Also used : ScanSecHubReport(com.mercedesbenz.sechub.domain.scan.report.ScanSecHubReport) SecHubFinding(com.mercedesbenz.sechub.commons.model.SecHubFinding) Test(org.junit.Test)

Example 25 with SecHubFinding

use of com.mercedesbenz.sechub.commons.model.SecHubFinding in project sechub by mercedes-benz.

the class FalsePositiveMetaDataFactoryTest method createTestFinding.

private SecHubFinding createTestFinding() {
    SecHubFinding finding = new SecHubFinding();
    finding.setCweId(4211);
    finding.setCveId("CVE-4211");
    return finding;
}
Also used : SecHubFinding(com.mercedesbenz.sechub.commons.model.SecHubFinding)

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