in DevSkim-VSCode-Plugin/server/src/utility_classes/ruleValidator.ts [708:771]
private validateSeverity(loadedRule): string
{
this.checkValue(loadedRule.severity, loadedRule, "string", "severity value is missing from object", OutputAlert.Error);
let outcome: OutputMessages = Object.create(null);
let severity: string = loadedRule.severity.toLowerCase();
//check if severity is one of the expected values, or a common error that can easily be changed into an expected value
switch (severity)
{
case "critical":
case "important":
case "moderate":
case "best-practice":
case "manual-review":
return severity;
//the schema used to use _ for multiword values, but now uses -. check to see if any of those old values are
//accidentally present
case "manual_review":
outcome.alert = OutputAlert.Warning;
outcome.message = "severities ''manual_review' should be 'manual-review'";
outcome.ruleid = loadedRule.id;
outcome.file = loadedRule.filepath;
this.outputMessages.push(outcome);
this.writeoutNewRules = true;
return "manual-review";
case "best_practice":
outcome.alert = OutputAlert.Warning;
outcome.message = "severities ''best_practice' should be 'best-practice' have been replaced with 'best-practice'";
outcome.ruleid = loadedRule.id;
outcome.file = loadedRule.filepath;
this.outputMessages.push(outcome);
this.writeoutNewRules = true;
return "best-practice";
//we rolled low & defense-in-depth into a single "best-practice" level, but there may still be some old rules
//with the old values
case "low":
case "defense-in-depth":
case "defense_in_depth":
outcome.alert = OutputAlert.Warning;
outcome.message = "severities 'low' and 'defense-in-depth' have been replaced with 'best-practice'";
outcome.ruleid = loadedRule.id;
outcome.file = loadedRule.filepath;
this.outputMessages.push(outcome);
this.writeoutNewRules = true;
return "best-practice";
}
//if we made it this far, severity isn't any value we recognize, and it needs to be. Write an error message and throw an exception
outcome.alert = OutputAlert.Error;
outcome.message = "Unknown severity in rule. Please see documentation at https://github.com/microsoft/devskim/wiki";
outcome.ruleid = loadedRule.id;
outcome.file = loadedRule.filepath;
this.outputMessages.push(outcome);
throw "Unknown severity in rule. Please see documentation at https://github.com/microsoft/devskim/wiki";
}