feat(config-audit): export WEIGHTS from severity.mjs (v5 F3 prep)

Promote WEIGHTS const to named export with Object.freeze for downstream
use in scoring.mjs (severity-weighted scoreByArea, F3).

Tests: +2 cases asserting WEIGHTS shape.
This commit is contained in:
Kjell Tore Guttormsen 2026-05-01 06:16:28 +02:00
commit e5efc2ff64
2 changed files with 15 additions and 2 deletions

View file

@ -11,7 +11,7 @@ export const SEVERITY = Object.freeze({
info: 'info',
});
const WEIGHTS = { critical: 25, high: 10, medium: 4, low: 1, info: 0 };
export const WEIGHTS = Object.freeze({ critical: 25, high: 10, medium: 4, low: 1, info: 0 });
/**
* Calculate a 0-100 risk score from severity counts.

View file

@ -1,6 +1,6 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { SEVERITY, riskScore, verdict, riskBand, gradeFromPassRate, QUALITY_CATEGORIES } from '../../scanners/lib/severity.mjs';
import { SEVERITY, WEIGHTS, riskScore, verdict, riskBand, gradeFromPassRate, QUALITY_CATEGORIES } from '../../scanners/lib/severity.mjs';
describe('SEVERITY constants', () => {
it('has all 5 levels', () => {
@ -12,6 +12,19 @@ describe('SEVERITY constants', () => {
});
});
describe('WEIGHTS named export (v5 F3 prep)', () => {
it('exposes critical=25', () => {
assert.strictEqual(WEIGHTS.critical, 25);
});
it('exposes high=10, medium=4, low=1, info=0', () => {
assert.strictEqual(WEIGHTS.high, 10);
assert.strictEqual(WEIGHTS.medium, 4);
assert.strictEqual(WEIGHTS.low, 1);
assert.strictEqual(WEIGHTS.info, 0);
});
});
describe('riskScore', () => {
it('returns 0 for empty counts', () => {
assert.strictEqual(riskScore({}), 0);