Search in sources :

Example 1 with Level

use of com.mercedesbenz.sechub.sarif.model.Level 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;
}
Also used : Level(com.mercedesbenz.sechub.sarif.model.Level) Rule(com.mercedesbenz.sechub.sarif.model.Rule) ReportingConfiguration(com.mercedesbenz.sechub.sarif.model.ReportingConfiguration)

Aggregations

Level (com.mercedesbenz.sechub.sarif.model.Level)1 ReportingConfiguration (com.mercedesbenz.sechub.sarif.model.ReportingConfiguration)1 Rule (com.mercedesbenz.sechub.sarif.model.Rule)1