use of com.mercedesbenz.sechub.sarif.model.PropertyBag in project sechub by mercedes-benz.
the class SarifReportSupportTest method specification_properties_snippet_properties_contains_tags.
@Test
void specification_properties_snippet_properties_contains_tags() 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);
Object tags = properties.get("tags");
assertEquals(Collections.singleton("openSource"), tags);
}
use of com.mercedesbenz.sechub.sarif.model.PropertyBag in project sechub by mercedes-benz.
the class SarifReportSupportTest method specification_properties_snippet_properties_contains_opensource_key_and_map_value.
@Test
void specification_properties_snippet_properties_contains_opensource_key_and_map_value() 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);
}
}
use of com.mercedesbenz.sechub.sarif.model.PropertyBag 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);
}
}
use of com.mercedesbenz.sechub.sarif.model.PropertyBag in project sechub by mercedes-benz.
the class SarifV1JSONImporter method resolveSolution.
private void resolveSolution(Rule rule, ResultData data, Run run) {
PropertyBag ruleProperties = rule.getProperties();
if (ruleProperties == null) {
return;
}
Object solution = ruleProperties.get("solution");
if (!(solution instanceof Map)) {
return;
}
Map<?, ?> solutionAsMap = (Map<?, ?>) solution;
Object solutionText = solutionAsMap.get("text");
if (solutionText == null) {
return;
}
data.solution = solutionText.toString();
}
use of com.mercedesbenz.sechub.sarif.model.PropertyBag 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);
}
Aggregations