diff --git a/libs/inspecjs/src/compat_impl/compat_inspec_1_0.ts b/libs/inspecjs/src/compat_impl/compat_inspec_1_0.ts index 62016cdb81..420ffcaf23 100644 --- a/libs/inspecjs/src/compat_impl/compat_inspec_1_0.ts +++ b/libs/inspecjs/src/compat_impl/compat_inspec_1_0.ts @@ -25,6 +25,20 @@ import { const profileError = 'Profile Error'; +export function impactToSeverity(impact: number): Severity { + if (impact < 0.1) { + return 'none'; + } else if (impact < 0.4) { + return 'low'; + } else if (impact < 0.7) { + return 'medium'; + } else if (impact < 0.9) { + return 'high'; + } else { + return 'critical'; + } +} + abstract class HDFControl10 implements HDFControl { // Declare all properties expected readonly rawNistTags: string[]; @@ -174,17 +188,7 @@ abstract class HDFControl10 implements HDFControl { return raw.tags['severity']; // otherwise, compute severity with impact - if (raw.impact < 0.1) { - return 'none'; - } else if (raw.impact < 0.4) { - return 'low'; - } else if (raw.impact < 0.7) { - return 'medium'; - } else if (raw.impact < 0.9) { - return 'high'; - } else { - return 'critical'; - } + return impactToSeverity(raw.impact); } }