Search in sources :

Example 6 with Result

use of com.mercedesbenz.sechub.sarif.model.Result in project sechub by mercedes-benz.

the class SarifReportSupportTest method specification_properties_snippet_properties_contains_opensource_key_and_map_value_and_can_be_written.

@Test
void specification_properties_snippet_properties_contains_opensource_key_and_map_value_and_can_be_written() throws IOException {
    /* prepare */
    File folder = sarifSpecificationSnippetsFolder;
    /* execute */
    Report report = supportToTest.loadReport(new File(folder, "specification-properties-snippet.sarif.json"));
    /* test */
    List<Result> results = report.getRuns().iterator().next().getResults();
    Result result = results.iterator().next();
    PropertyBag properties = result.getProperties();
    assertNotNull(properties);
    openSourceData = properties.get("openSource");
    if (openSourceData instanceof Map) {
        @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) openSourceData;
        String informationUri = (String) map.get("informationUri");
        assertEquals("http://www.example.com/procedures/usingOpenSource.html", informationUri);
    } else {
        fail("expected map but found:" + openSourceData);
    }
}
Also used : Report(com.mercedesbenz.sechub.sarif.model.Report) PropertyBag(com.mercedesbenz.sechub.sarif.model.PropertyBag) File(java.io.File) Map(java.util.Map) TreeMap(java.util.TreeMap) Result(com.mercedesbenz.sechub.sarif.model.Result) Test(org.junit.jupiter.api.Test)

Example 7 with Result

use of com.mercedesbenz.sechub.sarif.model.Result in project sechub by mercedes-benz.

the class SarifV1JSONImporter method resolveCodeInfoFromCodeFlow.

private SerecoCodeCallStackElement resolveCodeInfoFromCodeFlow(Result result) {
    Optional<CodeFlow> codeFlows = result.getCodeFlows().stream().findFirst();
    if (!codeFlows.isPresent()) {
        return null;
    }
    Optional<ThreadFlow> optFlow = codeFlows.get().getThreadFlows().stream().findFirst();
    if (!optFlow.isPresent()) {
        return null;
    }
    ThreadFlow flow = optFlow.get();
    List<Location> locations = flow.getLocations().stream().map(location -> location.getLocation()).collect(Collectors.toList());
    return resolveCodeInfoFromLocations(locations);
}
Also used : Message(com.mercedesbenz.sechub.sarif.model.Message) PhysicalLocation(com.mercedesbenz.sechub.sarif.model.PhysicalLocation) Run(com.mercedesbenz.sechub.sarif.model.Run) LoggerFactory(org.slf4j.LoggerFactory) Region(com.mercedesbenz.sechub.sarif.model.Region) SerecoWebRequest(com.mercedesbenz.sechub.sereco.metadata.SerecoWebRequest) Location(com.mercedesbenz.sechub.sarif.model.Location) ArrayList(java.util.ArrayList) Rule(com.mercedesbenz.sechub.sarif.model.Rule) WebRequest(com.mercedesbenz.sechub.sarif.model.WebRequest) ImportParameter(com.mercedesbenz.sechub.sereco.ImportParameter) Level(com.mercedesbenz.sechub.sarif.model.Level) Map(java.util.Map) CodeFlow(com.mercedesbenz.sechub.sarif.model.CodeFlow) WebResponse(com.mercedesbenz.sechub.sarif.model.WebResponse) ThreadFlow(com.mercedesbenz.sechub.sarif.model.ThreadFlow) SerecoSeverity(com.mercedesbenz.sechub.sereco.metadata.SerecoSeverity) ToolComponentReference(com.mercedesbenz.sechub.sarif.model.ToolComponentReference) SarifReportSupport(com.mercedesbenz.sechub.sarif.SarifReportSupport) Result(com.mercedesbenz.sechub.sarif.model.Result) SerecoWeb(com.mercedesbenz.sechub.sereco.metadata.SerecoWeb) Logger(org.slf4j.Logger) SerecoWebEvidence(com.mercedesbenz.sechub.sereco.metadata.SerecoWebEvidence) SerecoWebBody(com.mercedesbenz.sechub.sereco.metadata.SerecoWebBody) ScanType(com.mercedesbenz.sechub.commons.model.ScanType) SimpleStringUtils(com.mercedesbenz.sechub.commons.core.util.SimpleStringUtils) ArtifactContent(com.mercedesbenz.sechub.sarif.model.ArtifactContent) SerecoWebAttack(com.mercedesbenz.sechub.sereco.metadata.SerecoWebAttack) ReportingDescriptorRelationship(com.mercedesbenz.sechub.sarif.model.ReportingDescriptorRelationship) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ReportingDescriptorReference(com.mercedesbenz.sechub.sarif.model.ReportingDescriptorReference) SerecoVulnerability(com.mercedesbenz.sechub.sereco.metadata.SerecoVulnerability) List(java.util.List) Component(org.springframework.stereotype.Component) ArtifactLocation(com.mercedesbenz.sechub.sarif.model.ArtifactLocation) SerecoCodeCallStackElement(com.mercedesbenz.sechub.sereco.metadata.SerecoCodeCallStackElement) Report(com.mercedesbenz.sechub.sarif.model.Report) SerecoMetaData(com.mercedesbenz.sechub.sereco.metadata.SerecoMetaData) PropertyBag(com.mercedesbenz.sechub.sarif.model.PropertyBag) SerecoWebBodyLocation(com.mercedesbenz.sechub.sereco.metadata.SerecoWebBodyLocation) SerecoWebResponse(com.mercedesbenz.sechub.sereco.metadata.SerecoWebResponse) Optional(java.util.Optional) ThreadFlow(com.mercedesbenz.sechub.sarif.model.ThreadFlow) CodeFlow(com.mercedesbenz.sechub.sarif.model.CodeFlow) PhysicalLocation(com.mercedesbenz.sechub.sarif.model.PhysicalLocation) Location(com.mercedesbenz.sechub.sarif.model.Location) ArtifactLocation(com.mercedesbenz.sechub.sarif.model.ArtifactLocation) SerecoWebBodyLocation(com.mercedesbenz.sechub.sereco.metadata.SerecoWebBodyLocation)

Aggregations

Report (com.mercedesbenz.sechub.sarif.model.Report)7 Result (com.mercedesbenz.sechub.sarif.model.Result)7 File (java.io.File)6 Test (org.junit.jupiter.api.Test)6 PropertyBag (com.mercedesbenz.sechub.sarif.model.PropertyBag)4 Run (com.mercedesbenz.sechub.sarif.model.Run)4 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 CodeFlow (com.mercedesbenz.sechub.sarif.model.CodeFlow)2 Rule (com.mercedesbenz.sechub.sarif.model.Rule)2 SimpleStringUtils (com.mercedesbenz.sechub.commons.core.util.SimpleStringUtils)1 ScanType (com.mercedesbenz.sechub.commons.model.ScanType)1 SarifReportSupport (com.mercedesbenz.sechub.sarif.SarifReportSupport)1 ArtifactContent (com.mercedesbenz.sechub.sarif.model.ArtifactContent)1 ArtifactLocation (com.mercedesbenz.sechub.sarif.model.ArtifactLocation)1 Level (com.mercedesbenz.sechub.sarif.model.Level)1 Location (com.mercedesbenz.sechub.sarif.model.Location)1 Message (com.mercedesbenz.sechub.sarif.model.Message)1 PhysicalLocation (com.mercedesbenz.sechub.sarif.model.PhysicalLocation)1 Region (com.mercedesbenz.sechub.sarif.model.Region)1