Search in sources :

Example 1 with ArtifactLocation

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

the class SarifV1JSONImporter method callStackListFromLocations.

private List<SerecoCodeCallStackElement> callStackListFromLocations(List<Location> locations) {
    List<SerecoCodeCallStackElement> callstack = new ArrayList<>();
    if (locations == null) {
        return callstack;
    }
    locations.forEach(location -> {
        PhysicalLocation physicalLocation = location.getPhysicalLocation();
        if (physicalLocation != null) {
            SerecoCodeCallStackElement subCode = new SerecoCodeCallStackElement();
            ArtifactLocation artifactLocation = physicalLocation.getArtifactLocation();
            if (artifactLocation != null) {
                subCode.setLocation(artifactLocation.getUri());
            }
            Region region = physicalLocation.getRegion();
            if (region != null) {
                subCode.setLine(region.getStartLine());
                subCode.setColumn(region.getStartColumn());
                ArtifactContent snippet = region.getSnippet();
                if (snippet != null) {
                    String text = snippet.getText();
                    if (text != null) {
                        text = text.trim();
                    }
                    subCode.setSource(text);
                }
            }
            callstack.add(subCode);
        }
    });
    return callstack;
}
Also used : ArtifactContent(com.mercedesbenz.sechub.sarif.model.ArtifactContent) SerecoCodeCallStackElement(com.mercedesbenz.sechub.sereco.metadata.SerecoCodeCallStackElement) ArrayList(java.util.ArrayList) ArtifactLocation(com.mercedesbenz.sechub.sarif.model.ArtifactLocation) Region(com.mercedesbenz.sechub.sarif.model.Region) PhysicalLocation(com.mercedesbenz.sechub.sarif.model.PhysicalLocation)

Aggregations

ArtifactContent (com.mercedesbenz.sechub.sarif.model.ArtifactContent)1 ArtifactLocation (com.mercedesbenz.sechub.sarif.model.ArtifactLocation)1 PhysicalLocation (com.mercedesbenz.sechub.sarif.model.PhysicalLocation)1 Region (com.mercedesbenz.sechub.sarif.model.Region)1 SerecoCodeCallStackElement (com.mercedesbenz.sechub.sereco.metadata.SerecoCodeCallStackElement)1 ArrayList (java.util.ArrayList)1