use of com.mercedesbenz.sechub.sarif.model.PhysicalLocation in project sechub by mercedes-benz.
the class SarifV1JSONImporter method handleWebAttack.
private void handleWebAttack(Result result, SerecoWeb serecoWeb) {
List<Location> sarifLocations = result.getLocations();
if (sarifLocations.size() <= 0) {
return;
}
Location sarifLocation = sarifLocations.iterator().next();
PhysicalLocation sarifPhysicalLocation = sarifLocation.getPhysicalLocation();
if (sarifPhysicalLocation == null) {
return;
}
Region sarifRegion = sarifPhysicalLocation.getRegion();
if (sarifRegion == null) {
return;
}
/* evidence */
SerecoWebEvidence serecoWebEvidence = new SerecoWebEvidence();
SerecoWebBodyLocation bodyLocation = new SerecoWebBodyLocation();
bodyLocation.setStartLine(sarifRegion.getStartLine());
serecoWebEvidence.setBodyLocation(bodyLocation);
ArtifactContent sarifSnippet = sarifRegion.getSnippet();
if (sarifSnippet != null) {
serecoWebEvidence.setSnippet(sarifSnippet.getText());
}
/* attack */
SerecoWebAttack serecoAttack = serecoWeb.getAttack();
PropertyBag locationProperties = sarifLocation.getProperties();
if (locationProperties != null) {
Object attack = locationProperties.get("attack");
if (SimpleStringUtils.isNotEmpty(attack)) {
serecoAttack.setVector(attack.toString());
}
}
serecoAttack.setEvidence(serecoWebEvidence);
}
use of com.mercedesbenz.sechub.sarif.model.PhysicalLocation 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;
}
Aggregations