Skip to content

Commit

Permalink
export inspecJS function for converting impact into severity
Browse files Browse the repository at this point in the history
Signed-off-by: Kaden Emley <[email protected]>
  • Loading branch information
kemley76 committed Jul 10, 2024
1 parent d929425 commit 5577f51
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions libs/inspecjs/src/compat_impl/compat_inspec_1_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 5577f51

Please sign in to comment.