use of com.mercedesbenz.sechub.sarif.model.ReportingConfiguration in project sechub by mercedes-benz.
the class SarifReportSupportTest method microsoft_sarif_tutorial_taxonomies_example__result_defaultocnfiguraiton_level.
@Test
void microsoft_sarif_tutorial_taxonomies_example__result_defaultocnfiguraiton_level() throws IOException {
/* prepare */
File codeFlowReportFile = new File(sarifTutorialSamplesFolder, "Taxonomies.sarif");
/* execute */
Report report = supportToTest.loadReport(codeFlowReportFile);
/* test */
List<Run> runs = report.getRuns();
assertEquals(1, runs.size(), "there must be ONE run!");
Run run = runs.iterator().next();
List<Rule> rules = run.getTool().getDriver().getRules();
Map<String, Rule> sortedMap = new TreeMap<>();
for (Rule rule : rules) {
sortedMap.put(rule.getId(), rule);
}
Rule rule1 = sortedMap.get("TUT0001");
assertNotNull(rule1);
ReportingConfiguration defaultConfig1 = rule1.getDefaultConfiguration();
assertNotNull(defaultConfig1);
assertEquals(Level.ERROR, defaultConfig1.getLevel());
Rule rule2 = sortedMap.get("TUT0002");
assertNotNull(rule2);
ReportingConfiguration defaultConfig2 = rule2.getDefaultConfiguration();
assertNotNull(defaultConfig2);
assertEquals(Level.WARNING, defaultConfig2.getLevel());
}
use of com.mercedesbenz.sechub.sarif.model.ReportingConfiguration in project sechub by mercedes-benz.
the class SarifReportSupport method resolveLevel.
/**
* Tries first the result level. If not set, the level will be obtained by
* default configuration if available. If not found {@link Level#NONE} is
* returned
*
* @param result
* @param run
* @return level, never null
*/
public Level resolveLevel(Result result, Run run) {
Level level = result.getLevel();
if (level != null) {
return level;
}
Rule rule = fetchRuleForResult(result, run);
if (rule != null) {
/* @formatter:off
first fetch default from rule
see https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317850
@formatter:on */
ReportingConfiguration defaultConfiguration = rule.getDefaultConfiguration();
if (defaultConfiguration != null) {
level = defaultConfiguration.getLevel();
}
}
if (level == null) {
level = Level.NONE;
}
return level;
}
Aggregations