@mitre/hdf-utilities 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/severity/index.d.ts +29 -0
- package/dist/severity/index.d.ts.map +1 -0
- package/dist/severity/index.js +52 -0
- package/dist/severity/index.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ export { parseXml, buildXml, isValidXml, parseXmlWithArrays, extractTextFromXml,
|
|
|
8
8
|
export { parseCsv, parseCsvArray, buildCsv, buildCsvArray, isValidCsv, sanitizeCsvValue, sanitizeCsvArray, sanitizeCsvObject, extractCsvColumn, findCsvRows, type CsvParseOptions, type CsvBuildOptions, } from './csv/index.js';
|
|
9
9
|
export { findValuesByKey, extractColumn, findRows } from './object/index.js';
|
|
10
10
|
export { stripHtml, parseTimestamp } from './string/index.js';
|
|
11
|
+
export { severityToImpact, impactToSeverity } from './severity/index.js';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAG/G,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,EACN,UAAU,EACV,UAAU,EACV,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,GACd,MAAM,gBAAgB,CAAC;AA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 -14,4 +14,6 @@ export { parseCsv, parseCsvArray, buildCsv, buildCsvArray, isValidCsv, sanitizeC
|
|
|
14
14
|
export { findValuesByKey, extractColumn, findRows } from './object/index.js';
|
|
15
15
|
// String utilities
|
|
16
16
|
export { stripHtml, parseTimestamp } from './string/index.js';
|
|
17
|
+
// Severity/impact mapping
|
|
18
|
+
export { severityToImpact, impactToSeverity } from './severity/index.js';
|
|
17
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,iBAAiB;AACjB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAyB,MAAM,iBAAiB,CAAC;AAE/G,iBAAiB;AACjB,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,EACN,UAAU,EACV,UAAU,GAIX,MAAM,iBAAiB,CAAC;AAEzB,gBAAgB;AAChB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,GACd,MAAM,gBAAgB,CAAC;AAExB,gBAAgB;AAChB,OAAO,EACL,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,GAGZ,MAAM,gBAAgB,CAAC;AAExB,uCAAuC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7E,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,iBAAiB;AACjB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAyB,MAAM,iBAAiB,CAAC;AAE/G,iBAAiB;AACjB,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,EACN,UAAU,EACV,UAAU,GAIX,MAAM,iBAAiB,CAAC;AAEzB,gBAAgB;AAChB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,GACd,MAAM,gBAAgB,CAAC;AAExB,gBAAgB;AAChB,OAAO,EACL,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,GAGZ,MAAM,gBAAgB,CAAC;AAExB,uCAAuC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7E,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE9D,0BAA0B;AAC1B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Severity-to-impact mapping utilities.
|
|
3
|
+
*
|
|
4
|
+
* These define the canonical bidirectional mapping between severity labels
|
|
5
|
+
* (critical, high, medium, low, informational) and HDF impact scores (0.0–1.0),
|
|
6
|
+
* aligned with CVSS 3.x severity bands normalized to 0–1.
|
|
7
|
+
*
|
|
8
|
+
* Threshold ranges (used by impactToSeverity):
|
|
9
|
+
* >=0.9 = critical (CVSS 9.0–10.0)
|
|
10
|
+
* [0.7, 0.9) = high (CVSS 7.0–8.9)
|
|
11
|
+
* [0.4, 0.7) = medium (CVSS 4.0–6.9)
|
|
12
|
+
* (0.0, 0.4) = low (CVSS 0.1–3.9)
|
|
13
|
+
* 0.0 = informational (CVSS 0.0)
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Map a severity string to an impact score.
|
|
17
|
+
*
|
|
18
|
+
* @param severity - Severity level (case-insensitive)
|
|
19
|
+
* @returns Impact score between 0.0 and 1.0; defaults to 0.5 for unrecognized values
|
|
20
|
+
*/
|
|
21
|
+
export declare function severityToImpact(severity: string): number;
|
|
22
|
+
/**
|
|
23
|
+
* Map an impact score to a severity string.
|
|
24
|
+
*
|
|
25
|
+
* @param impact - Impact score (0.0 to 1.0)
|
|
26
|
+
* @returns Severity level string
|
|
27
|
+
*/
|
|
28
|
+
export declare function impactToSeverity(impact: number): string;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/severity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAaH;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMvD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Severity-to-impact mapping utilities.
|
|
3
|
+
*
|
|
4
|
+
* These define the canonical bidirectional mapping between severity labels
|
|
5
|
+
* (critical, high, medium, low, informational) and HDF impact scores (0.0–1.0),
|
|
6
|
+
* aligned with CVSS 3.x severity bands normalized to 0–1.
|
|
7
|
+
*
|
|
8
|
+
* Threshold ranges (used by impactToSeverity):
|
|
9
|
+
* >=0.9 = critical (CVSS 9.0–10.0)
|
|
10
|
+
* [0.7, 0.9) = high (CVSS 7.0–8.9)
|
|
11
|
+
* [0.4, 0.7) = medium (CVSS 4.0–6.9)
|
|
12
|
+
* (0.0, 0.4) = low (CVSS 0.1–3.9)
|
|
13
|
+
* 0.0 = informational (CVSS 0.0)
|
|
14
|
+
*/
|
|
15
|
+
const severityMap = {
|
|
16
|
+
critical: 0.9,
|
|
17
|
+
high: 0.7,
|
|
18
|
+
medium: 0.5,
|
|
19
|
+
low: 0.3,
|
|
20
|
+
info: 0.0,
|
|
21
|
+
none: 0.0,
|
|
22
|
+
informational: 0.0,
|
|
23
|
+
information: 0.0,
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Map a severity string to an impact score.
|
|
27
|
+
*
|
|
28
|
+
* @param severity - Severity level (case-insensitive)
|
|
29
|
+
* @returns Impact score between 0.0 and 1.0; defaults to 0.5 for unrecognized values
|
|
30
|
+
*/
|
|
31
|
+
export function severityToImpact(severity) {
|
|
32
|
+
const normalized = severity.toLowerCase();
|
|
33
|
+
return severityMap[normalized] ?? 0.5;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Map an impact score to a severity string.
|
|
37
|
+
*
|
|
38
|
+
* @param impact - Impact score (0.0 to 1.0)
|
|
39
|
+
* @returns Severity level string
|
|
40
|
+
*/
|
|
41
|
+
export function impactToSeverity(impact) {
|
|
42
|
+
if (impact >= 0.9)
|
|
43
|
+
return 'critical';
|
|
44
|
+
if (impact >= 0.7)
|
|
45
|
+
return 'high';
|
|
46
|
+
if (impact >= 0.4)
|
|
47
|
+
return 'medium';
|
|
48
|
+
if (impact > 0.0)
|
|
49
|
+
return 'low';
|
|
50
|
+
return 'informational';
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/severity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,GAA2B;IAC1C,QAAQ,EAAE,GAAG;IACb,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,GAAG;IACX,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,aAAa,EAAE,GAAG;IAClB,WAAW,EAAE,GAAG;CACjB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC1C,OAAO,WAAW,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,UAAU,CAAC;IACrC,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,MAAM,CAAC;IACjC,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,QAAQ,CAAC;IACnC,IAAI,MAAM,GAAG,GAAG;QAAE,OAAO,KAAK,CAAC;IAC/B,OAAO,eAAe,CAAC;AACzB,CAAC"}
|