@zerothreatai/vulnerability-registry 6.0.0 → 7.0.0

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.
@@ -1,11 +1,12 @@
1
1
  import { VULNERABILITY_REGISTRY } from '../index.js';
2
- const ALL_VULNERABILITIES = Object.values(VULNERABILITY_REGISTRY);
2
+ // Lazy getter to avoid circular dependency issues at module load time
3
+ const getAllVulnerabilities = () => Object.values(VULNERABILITY_REGISTRY);
3
4
  const uniqueSorted = (ids) => Array.from(new Set(ids)).sort((a, b) => a - b);
4
- export const allVulnerabilityIds = () => uniqueSorted(ALL_VULNERABILITIES.map(v => v.id));
5
- export const idsByCategory = (category) => uniqueSorted(ALL_VULNERABILITIES.filter(v => v.category === category).map(v => v.id));
5
+ export const allVulnerabilityIds = () => uniqueSorted(getAllVulnerabilities().map(v => v.id));
6
+ export const idsByCategory = (category) => uniqueSorted(getAllVulnerabilities().filter(v => v.category === category).map(v => v.id));
6
7
  export const idsByCodes = (codes) => uniqueSorted(codes
7
8
  .map(code => VULNERABILITY_REGISTRY[code]?.id)
8
9
  .filter((id) => typeof id === 'number'));
9
- export const idsByCodePrefix = (prefixes) => uniqueSorted(ALL_VULNERABILITIES.filter(v => prefixes.some(prefix => v.code.startsWith(prefix)))
10
+ export const idsByCodePrefix = (prefixes) => uniqueSorted(getAllVulnerabilities().filter(v => prefixes.some(prefix => v.code.startsWith(prefix)))
10
11
  .map(v => v.id));
11
12
  export const mergeIds = (...lists) => uniqueSorted(lists.flat());
@@ -2,17 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeIds = exports.idsByCodePrefix = exports.idsByCodes = exports.idsByCategory = exports.allVulnerabilityIds = void 0;
4
4
  const index_js_1 = require("../index.js");
5
- const ALL_VULNERABILITIES = Object.values(index_js_1.VULNERABILITY_REGISTRY);
5
+ // Lazy getter to avoid circular dependency issues at module load time
6
+ const getAllVulnerabilities = () => Object.values(index_js_1.VULNERABILITY_REGISTRY);
6
7
  const uniqueSorted = (ids) => Array.from(new Set(ids)).sort((a, b) => a - b);
7
- const allVulnerabilityIds = () => uniqueSorted(ALL_VULNERABILITIES.map(v => v.id));
8
+ const allVulnerabilityIds = () => uniqueSorted(getAllVulnerabilities().map(v => v.id));
8
9
  exports.allVulnerabilityIds = allVulnerabilityIds;
9
- const idsByCategory = (category) => uniqueSorted(ALL_VULNERABILITIES.filter(v => v.category === category).map(v => v.id));
10
+ const idsByCategory = (category) => uniqueSorted(getAllVulnerabilities().filter(v => v.category === category).map(v => v.id));
10
11
  exports.idsByCategory = idsByCategory;
11
12
  const idsByCodes = (codes) => uniqueSorted(codes
12
13
  .map(code => index_js_1.VULNERABILITY_REGISTRY[code]?.id)
13
14
  .filter((id) => typeof id === 'number'));
14
15
  exports.idsByCodes = idsByCodes;
15
- const idsByCodePrefix = (prefixes) => uniqueSorted(ALL_VULNERABILITIES.filter(v => prefixes.some(prefix => v.code.startsWith(prefix)))
16
+ const idsByCodePrefix = (prefixes) => uniqueSorted(getAllVulnerabilities().filter(v => prefixes.some(prefix => v.code.startsWith(prefix)))
16
17
  .map(v => v.id));
17
18
  exports.idsByCodePrefix = idsByCodePrefix;
18
19
  const mergeIds = (...lists) => uniqueSorted(lists.flat());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerothreatai/vulnerability-registry",
3
- "version": "6.0.0",
3
+ "version": "7.0.0",
4
4
  "description": "Centralized vulnerability definitions, CVSS scores, and references for ZeroThreat scanners",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,16 +1,17 @@
1
1
  import { VULNERABILITY_REGISTRY } from '../index.js';
2
2
  import type { VulnerabilityCategory } from '../types.js';
3
3
 
4
- const ALL_VULNERABILITIES = Object.values(VULNERABILITY_REGISTRY);
4
+ // Lazy getter to avoid circular dependency issues at module load time
5
+ const getAllVulnerabilities = () => Object.values(VULNERABILITY_REGISTRY);
5
6
 
6
7
  const uniqueSorted = (ids: number[]): number[] =>
7
8
  Array.from(new Set(ids)).sort((a, b) => a - b);
8
9
 
9
10
  export const allVulnerabilityIds = (): number[] =>
10
- uniqueSorted(ALL_VULNERABILITIES.map(v => v.id));
11
+ uniqueSorted(getAllVulnerabilities().map(v => v.id));
11
12
 
12
13
  export const idsByCategory = (category: VulnerabilityCategory): number[] =>
13
- uniqueSorted(ALL_VULNERABILITIES.filter(v => v.category === category).map(v => v.id));
14
+ uniqueSorted(getAllVulnerabilities().filter(v => v.category === category).map(v => v.id));
14
15
 
15
16
  export const idsByCodes = (codes: string[]): number[] =>
16
17
  uniqueSorted(
@@ -21,9 +22,10 @@ export const idsByCodes = (codes: string[]): number[] =>
21
22
 
22
23
  export const idsByCodePrefix = (prefixes: string[]): number[] =>
23
24
  uniqueSorted(
24
- ALL_VULNERABILITIES.filter(v => prefixes.some(prefix => v.code.startsWith(prefix)))
25
+ getAllVulnerabilities().filter(v => prefixes.some(prefix => v.code.startsWith(prefix)))
25
26
  .map(v => v.id)
26
27
  );
27
28
 
28
29
  export const mergeIds = (...lists: number[][]): number[] =>
29
30
  uniqueSorted(lists.flat());
31
+