@dataparade/cli 0.0.35 → 0.1.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.
Files changed (122) hide show
  1. package/README.md +1 -0
  2. package/dist/package.json +4 -4
  3. package/dist/src/ai-enrichment/pii-signal-rules.d.ts +5 -0
  4. package/dist/src/ai-enrichment/pii-signal-rules.js +2 -3
  5. package/dist/src/ai-enrichment/third-party-data-flow.js +5 -4
  6. package/dist/src/cli.js +9 -3
  7. package/dist/src/facts/build-facts.d.ts +2 -0
  8. package/dist/src/facts/build-facts.js +14 -0
  9. package/dist/src/facts/layout.d.ts +4 -0
  10. package/dist/src/facts/layout.js +5 -1
  11. package/dist/src/facts/scan-stamps.d.ts +7 -0
  12. package/dist/src/facts/scan-stamps.js +30 -0
  13. package/dist/src/facts/schema.d.ts +74 -0
  14. package/dist/src/facts/schema.js +32 -1
  15. package/dist/src/output/scan-output-excludes.js +2 -0
  16. package/dist/src/output/write-scan-knowledge.d.ts +5 -1
  17. package/dist/src/output/write-scan-knowledge.js +21 -0
  18. package/dist/src/threat-model/build-threat-model.d.ts +3 -0
  19. package/dist/src/threat-model/build-threat-model.js +71 -0
  20. package/dist/src/threat-model/carry-forward-person-set-statuses.d.ts +8 -0
  21. package/dist/src/threat-model/carry-forward-person-set-statuses.js +87 -0
  22. package/dist/src/threat-model/io.d.ts +19 -0
  23. package/dist/src/threat-model/io.js +63 -0
  24. package/dist/src/threat-model/schema.d.ts +214 -0
  25. package/dist/src/threat-model/schema.js +75 -0
  26. package/dist/src/ui/scan-progress-renderer.d.ts +8 -1
  27. package/dist/src/ui/scan-progress-renderer.js +20 -1
  28. package/dist/src/upload/collect-scan-sidecars.d.ts +2 -1
  29. package/dist/src/upload/collect-scan-sidecars.js +3 -1
  30. package/dist/tests/cli/cli.spec.js +10 -1
  31. package/dist/tests/helpers/facts-fixture.js +16 -16
  32. package/dist/tests/schema/scan-result.schema.spec.js +1 -1
  33. package/dist/tests/unit/ai-enrichment/third-party-data-flow.spec.js +5 -5
  34. package/dist/tests/unit/core/graph-mapping.spec.js +4 -3
  35. package/dist/tests/unit/discoveries/write-ocsf-discoveries-long-ids.spec.js +3 -3
  36. package/dist/tests/unit/export/export-ocsf.spec.js +4 -4
  37. package/dist/tests/unit/facts/apply-answers.spec.js +20 -20
  38. package/dist/tests/unit/facts/build-facts.spec.js +126 -45
  39. package/dist/tests/unit/facts/identity.spec.js +13 -0
  40. package/dist/tests/unit/facts/scan-stamps.spec.js +32 -0
  41. package/dist/tests/unit/facts/slug.spec.js +2 -0
  42. package/dist/tests/unit/kb/answer-fingerprint.spec.js +9 -9
  43. package/dist/tests/unit/kb/kb-interview-loop.spec.js +3 -3
  44. package/dist/tests/unit/output/scan-output-excludes.spec.js +1 -1
  45. package/dist/tests/unit/threat-model/build-threat-model.spec.d.ts +1 -0
  46. package/dist/tests/unit/threat-model/build-threat-model.spec.js +184 -0
  47. package/dist/tests/unit/threat-model/carry-forward-person-set-statuses.spec.d.ts +1 -0
  48. package/dist/tests/unit/threat-model/carry-forward-person-set-statuses.spec.js +163 -0
  49. package/dist/tests/unit/threat-model/io.spec.d.ts +1 -0
  50. package/dist/tests/unit/threat-model/io.spec.js +103 -0
  51. package/dist/tests/unit/threat-model/schema.spec.d.ts +1 -0
  52. package/dist/tests/unit/threat-model/schema.spec.js +42 -0
  53. package/dist/tests/unit/ui/scan-progress-renderer.spec.js +58 -0
  54. package/dist/tests/unit/upload/collect-scan-sidecars.spec.js +8 -5
  55. package/dist/vendor/scanner/dist/src/analyze/code-navigator.d.ts +1 -1
  56. package/dist/vendor/scanner/dist/src/analyze/code-navigator.js +4 -0
  57. package/dist/vendor/scanner/dist/src/analyze/column-catalog.d.ts +1 -1
  58. package/dist/vendor/scanner/dist/src/analyze/column-catalog.js +2 -2
  59. package/dist/vendor/scanner/dist/src/analyze/concept-profile.d.ts +2 -2
  60. package/dist/vendor/scanner/dist/src/analyze/concept-profile.js +5 -3
  61. package/dist/vendor/scanner/dist/src/core/pipeline/build-scan-personal-data-layers.js +1 -1
  62. package/dist/vendor/scanner/dist/src/core/pipeline/deterministic-scan.js +43 -0
  63. package/dist/vendor/scanner/dist/src/core/pipeline/graph-mapping.js +23 -2
  64. package/dist/vendor/scanner/dist/src/core/pipeline/mixed-app-terraform-scan.js +1 -0
  65. package/dist/vendor/scanner/dist/src/core/pipeline/orchestrator-result.d.ts +2 -2
  66. package/dist/vendor/scanner/dist/src/core/pipeline/terraform-minimal-services.js +1 -0
  67. package/dist/vendor/scanner/dist/src/core/schema/scan-result.schema.d.ts +160 -2
  68. package/dist/vendor/scanner/dist/src/core/schema/scan-result.schema.js +24 -0
  69. package/dist/vendor/scanner/dist/src/core/types/data-flow.d.ts +48 -0
  70. package/dist/vendor/scanner/dist/src/core/types/data-flow.js +53 -0
  71. package/dist/vendor/scanner/dist/src/data-flow/detect.js +1 -0
  72. package/dist/vendor/scanner/dist/src/data-flow/ensure-hub-linked-assets.js +1 -0
  73. package/dist/vendor/scanner/dist/src/data-flow/ensure-manifest-declared-flows.js +1 -0
  74. package/dist/vendor/scanner/dist/src/data-flow/flow-authentication.d.ts +30 -0
  75. package/dist/vendor/scanner/dist/src/data-flow/flow-authentication.js +277 -0
  76. package/dist/vendor/scanner/dist/src/data-flow/flow-builder.js +6 -0
  77. package/dist/vendor/scanner/dist/src/data-flow/flow-controls.d.ts +24 -0
  78. package/dist/vendor/scanner/dist/src/data-flow/flow-controls.js +238 -0
  79. package/dist/vendor/scanner/dist/src/data-flow/flow-data-categories.d.ts +22 -0
  80. package/dist/vendor/scanner/dist/src/data-flow/flow-data-categories.js +69 -0
  81. package/dist/vendor/scanner/dist/src/data-flow/flow-interaction-description.d.ts +13 -0
  82. package/dist/vendor/scanner/dist/src/data-flow/flow-interaction-description.js +263 -0
  83. package/dist/vendor/scanner/dist/src/data-flow/hub-link-policy.d.ts +2 -1
  84. package/dist/vendor/scanner/dist/src/data-flow/hub-link-policy.js +3 -0
  85. package/dist/vendor/scanner/dist/src/data-flow/human-interaction-channels.d.ts +37 -0
  86. package/dist/vendor/scanner/dist/src/data-flow/human-interaction-channels.js +483 -0
  87. package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.d.ts +3 -0
  88. package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.js +12 -17
  89. package/dist/vendor/scanner/dist/src/data-flow/terraform-flows.js +5 -1
  90. package/dist/vendor/scanner/dist/src/data-flow/transformation-patterns.d.ts +5 -1
  91. package/dist/vendor/scanner/dist/src/data-flow/transformation-patterns.js +17 -37
  92. package/dist/vendor/scanner/dist/src/eval/canonical/concept-map.d.ts +36 -5
  93. package/dist/vendor/scanner/dist/src/eval/canonical/concept-map.js +53 -60
  94. package/dist/vendor/scanner/dist/src/eval/canonical/graph/endpoints.js +2 -9
  95. package/dist/vendor/scanner/dist/src/eval/canonical/scanner/personal-data.js +10 -7
  96. package/dist/vendor/scanner/dist/src/graph/build-dataparade-graph.js +3 -1
  97. package/dist/vendor/scanner/dist/src/index.d.ts +6 -0
  98. package/dist/vendor/scanner/dist/src/index.js +16 -1
  99. package/dist/vendor/scanner/dist/src/patterns/engine.js +1 -0
  100. package/dist/vendor/scanner/dist/src/pii-signals/match-pii-signals.d.ts +1 -1
  101. package/dist/vendor/scanner/dist/src/pii-signals/match-pii-signals.js +2 -2
  102. package/dist/vendor/scanner/dist/src/pii-signals/occurrence-group.d.ts +3 -3
  103. package/dist/vendor/scanner/dist/src/pii-signals/occurrence-group.js +12 -11
  104. package/dist/vendor/scanner/dist/src/pii-signals/personal-data-taxonomy.d.ts +44 -0
  105. package/dist/vendor/scanner/dist/src/pii-signals/personal-data-taxonomy.js +167 -0
  106. package/dist/vendor/scanner/dist/src/pii-signals/pii-signal-aliases.js +43 -43
  107. package/dist/vendor/scanner/dist/src/pii-signals/pii-signal-rules.d.ts +12 -1
  108. package/dist/vendor/scanner/dist/src/pii-signals/pii-signal-rules.js +28 -7
  109. package/dist/vendor/scanner/dist/src/pii-signals/signal-token.js +1 -1
  110. package/dist/vendor/scanner/dist/src/threats/stride.d.ts +98 -0
  111. package/dist/vendor/scanner/dist/src/threats/stride.js +179 -0
  112. package/dist/vendor/scanner/package.json +2 -2
  113. package/dist/vendor/scanner/patterns/concept-profiles.yaml +2 -2
  114. package/dist/vendor/scanner/patterns/flow-authentication.rules.yaml +75 -0
  115. package/dist/vendor/scanner/patterns/flow-controls.rules.yaml +68 -0
  116. package/dist/vendor/scanner/patterns/personal-data-taxonomy.yaml +155 -0
  117. package/dist/vendor/scanner/patterns/pii-signals.rules.yaml +38 -49
  118. package/dist/vendor/scanner/patterns/stride.rules.yaml +86 -0
  119. package/package.json +4 -4
  120. package/dist/vendor/scanner/dist/src/eval/canonical/concept-map.validate.d.ts +0 -17
  121. package/dist/vendor/scanner/dist/src/eval/canonical/concept-map.validate.js +0 -108
  122. package/dist/vendor/scanner/patterns/personal-data-concept-map.yaml +0 -76
@@ -12,6 +12,8 @@ describe("dataItemSlugs", () => {
12
12
  expect(slugs.get("../etc/passwd")).toBe("etc-passwd");
13
13
  for (const slug of slugs.values())
14
14
  expect(slug).toMatch(/^[a-z0-9][a-z0-9._-]*$/);
15
+ // Scanner data item names are DPV CURIEs (DATAP-947).
16
+ expect((0, slug_1.dataItemSlugs)(["pd:EmailAddress", "dpx:FirstName"])).toEqual(new Map([["pd:EmailAddress", "pd-emailaddress"], ["dpx:FirstName", "dpx-firstname"]]));
15
17
  });
16
18
  it("gives clashing names a hash of their own name, whatever the order", () => {
17
19
  const one = (0, slug_1.dataItemSlugs)(["Email", "email"]);
@@ -19,11 +19,11 @@ const KEYS = {
19
19
  cmp_user: "app:<unsectioned>|actor|||customer",
20
20
  flow_mail: '["flow/v1","app:backend|asset|service|backend/src/main.ts|backend","app:<unsectioned>|third_party|email||sendgrid","api_call","","",""]',
21
21
  flow_login: '["flow/v1","app:<unsectioned>|actor|||customer","app:backend|asset|service|backend/src/main.ts|backend","api_call","","",""]',
22
- "data_item:email": "email",
23
- "data_item:phone": "phone",
24
- "group:email:customer": "email:customer",
25
- "group:email:staff": "email:staff",
26
- "group:phone:customer": "phone:customer",
22
+ "data_item:pd:EmailAddress": "pd:EmailAddress",
23
+ "data_item:pd:TelephoneNumber": "pd:TelephoneNumber",
24
+ "group:pd:EmailAddress:customer": "pd:EmailAddress:customer",
25
+ "group:pd:EmailAddress:staff": "pd:EmailAddress:staff",
26
+ "group:pd:TelephoneNumber:customer": "pd:TelephoneNumber:customer",
27
27
  };
28
28
  function identity(kind, id) {
29
29
  return { kind, key: KEYS[id] ?? id, parts: {} };
@@ -44,7 +44,7 @@ function keyedFacts(change = () => { }) {
44
44
  }
45
45
  function writeScan(paths, change) {
46
46
  const { facts, files } = keyedFacts(change);
47
- (0, io_1.writeFactsOutput)(paths, facts, new Map(files.map((file) => [`data-items/${file.name}.json`, file])));
47
+ (0, io_1.writeFactsOutput)(paths, facts, new Map(files.map((file) => [facts.dataItems.find((item) => item.id === file.id).file, file])));
48
48
  return facts;
49
49
  }
50
50
  describe("answer fingerprints (DATAP-873)", () => {
@@ -61,8 +61,8 @@ describe("answer fingerprints (DATAP-873)", () => {
61
61
  const { facts } = keyedFacts();
62
62
  expect((0, answer_fingerprint_1.elementOfFact)(facts, "cmp_mail")).toEqual({ subject: "component", key: KEYS.cmp_mail });
63
63
  expect((0, answer_fingerprint_1.elementOfFact)(facts, "flow_mail")).toEqual({ subject: "dataFlow", key: KEYS.flow_mail });
64
- expect((0, answer_fingerprint_1.elementOfFact)(facts, "data_item:email")).toEqual({ subject: "dataItem", key: "email" });
65
- expect((0, answer_fingerprint_1.elementOfFact)(facts, "group:email:staff")).toEqual({ subject: "group", key: "email:staff" });
64
+ expect((0, answer_fingerprint_1.elementOfFact)(facts, "data_item:pd:EmailAddress")).toEqual({ subject: "dataItem", key: "pd:EmailAddress" });
65
+ expect((0, answer_fingerprint_1.elementOfFact)(facts, "group:pd:EmailAddress:staff")).toEqual({ subject: "group", key: "pd:EmailAddress:staff" });
66
66
  expect((0, answer_fingerprint_1.elementOfFact)(facts, "nope")).toBeNull();
67
67
  });
68
68
  it("writes the identity key and fingerprint with each new interview answer", () => {
@@ -87,7 +87,7 @@ describe("answer fingerprints (DATAP-873)", () => {
87
87
  writeScan(paths);
88
88
  const answer = (0, land_1.landReviewAnswer)(paths, { target: "cmp_mail", action: "set", property: "name", value: "SendGrid", reviewer: REVIEWER }).answer;
89
89
  expect(answer.identityKey).toBe(KEYS.cmp_mail);
90
- expect(answer.fingerprint?.handledGroups).toEqual(["email:staff"]);
90
+ expect(answer.fingerprint?.handledGroups).toEqual(["pd:EmailAddress:staff"]);
91
91
  });
92
92
  it("leaves the fields out for a scan without identities", () => {
93
93
  const { facts } = (0, facts_fixture_1.sampleFacts)();
@@ -17,7 +17,7 @@ const REVIEWER = "dev@example.com";
17
17
  function rescan(paths, keepFlows = ["flow_mail", "flow_login"]) {
18
18
  const { facts, files } = (0, facts_fixture_1.sampleFacts)();
19
19
  facts.dataFlows = facts.dataFlows.filter((f) => keepFlows.includes(f.id));
20
- (0, io_1.writeFactsOutput)(paths, facts, new Map(files.map((file) => [`data-items/${file.name}.json`, file])));
20
+ (0, io_1.writeFactsOutput)(paths, facts, new Map(files.map((file) => [facts.dataItems.find((item) => item.id === file.id).file, file])));
21
21
  }
22
22
  describe("live interview loop: brief → land → project", () => {
23
23
  let paths;
@@ -51,7 +51,7 @@ describe("live interview loop: brief → land → project", () => {
51
51
  const sendgrid = { kind: "component", key: "app:<unsectioned>|third_party||src/mail.ts|sendgrid", parts: { name: "sendgrid" } };
52
52
  facts.dataFlows = facts.dataFlows.map((f) => (f.id === "flow_mail" ? { ...f, identity: mail } : f));
53
53
  facts.components = facts.components.map((c) => (c.id === "cmp_mail" ? { ...c, identity: sendgrid } : c));
54
- (0, io_1.writeFactsOutput)(paths, facts, new Map(files.map((file) => [`data-items/${file.name}.json`, file])));
54
+ (0, io_1.writeFactsOutput)(paths, facts, new Map(files.map((file) => [facts.dataItems.find((item) => item.id === file.id).file, file])));
55
55
  const { brief, sha } = (0, brief_1.writeKbBrief)(paths);
56
56
  const flow = brief.flows.find((f) => f.id === "flow_mail");
57
57
  expect(flow.identity).toEqual(mail);
@@ -178,7 +178,7 @@ describe("live interview loop: brief → land → project", () => {
178
178
  expect((0, brief_1.writeKbBrief)(paths).brief.flows.map((f) => f.id)).toEqual(["flow_mail"]);
179
179
  });
180
180
  it("reads a JSON value for lists", () => {
181
- review({ target: "data_item:email", property: "labels", value: '["contact","pii"]' });
181
+ review({ target: "data_item:pd:EmailAddress", property: "labels", value: '["contact","pii"]' });
182
182
  expect((0, kb_store_1.loadKbState)(paths).applied.facts.dataItems[0].labels).toEqual(["contact", "pii"]);
183
183
  });
184
184
  it.each([
@@ -8,7 +8,7 @@ describe("scanOutputExcludes", () => {
8
8
  });
9
9
  it("excludes the scan's own outputs when writing to the repo root", () => {
10
10
  const globs = (0, scan_output_excludes_1.scanOutputExcludes)("/repo", "/repo/dataflow.json");
11
- expect(globs).toEqual(expect.arrayContaining(["dataflow.json", "facts.json", "data-items/**", "graphify.json", "answers.json", "briefs/**", "evidence/**"]));
11
+ expect(globs).toEqual(expect.arrayContaining(["dataflow.json", "facts.json", "threat-model.json", "threat-model.unreadable.json", "data-items/**", "graphify.json", "answers.json", "briefs/**", "evidence/**"]));
12
12
  // Output of CLI 0.0.26 and earlier is still kept out of a rescan.
13
13
  expect(globs).toEqual(expect.arrayContaining(["ocsf-discoveries/**", "graphify-out/**", "dataparade-graph.json"]));
14
14
  });
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const build_threat_model_1 = require("../../../src/threat-model/build-threat-model");
4
+ const schema_1 = require("../../../src/threat-model/schema");
5
+ const apiComponent = {
6
+ id: "cmp_api",
7
+ identity: { kind: "component", key: "app:<unsectioned>|asset|service|src/api.ts|api", parts: {} },
8
+ name: "api",
9
+ type: "asset",
10
+ subType: "service",
11
+ confidence: 1,
12
+ sourceLocations: [],
13
+ codeRefs: [],
14
+ };
15
+ const mailComponent = {
16
+ id: "cmp_mail",
17
+ name: "mail",
18
+ type: "third_party",
19
+ subType: "",
20
+ confidence: 1,
21
+ sourceLocations: [],
22
+ codeRefs: [],
23
+ };
24
+ const databaseComponent = {
25
+ id: "cmp_db",
26
+ name: "db",
27
+ type: "asset",
28
+ subType: "database",
29
+ confidence: 1,
30
+ sourceLocations: [],
31
+ codeRefs: [],
32
+ };
33
+ function mailFlowWith(overrides = {}) {
34
+ return {
35
+ id: "flow_mail",
36
+ identity: { kind: "dataFlow", key: "flow-key", parts: {} },
37
+ sourceComponentId: "cmp_api",
38
+ targetComponentId: "cmp_mail",
39
+ type: "api_call",
40
+ confidence: 1,
41
+ sourceLocations: [],
42
+ codeRefs: [],
43
+ ...overrides,
44
+ };
45
+ }
46
+ function factsWith(dataFlows, scanOverrides = {}) {
47
+ return {
48
+ schemaVersion: 1,
49
+ scan: {
50
+ projectName: "shop",
51
+ scannedAt: "2026-10-09T00:00:00.000Z",
52
+ cliVersion: "0.0.36",
53
+ scannerVersion: "abc",
54
+ ...scanOverrides,
55
+ },
56
+ components: [apiComponent, mailComponent, databaseComponent],
57
+ dataFlows,
58
+ dataItems: [],
59
+ relations: [],
60
+ };
61
+ }
62
+ function categoriesOfElement(threatModel, elementId) {
63
+ return threatModel.threats
64
+ .filter((threat) => threat.elementId === elementId)
65
+ .map((threat) => threat.category)
66
+ .join("");
67
+ }
68
+ function findThreat(threatModel, elementId, category) {
69
+ return threatModel.threats.find((threat) => threat.elementId === elementId && threat.category === category);
70
+ }
71
+ const flowWithTlsAndTimeoutControls = mailFlowWith({
72
+ controls: [
73
+ { control: "tls", effect: "mitigates", filePath: "src/api.ts", line: 2 },
74
+ { control: "timeout", effect: "mitigates", filePath: "src/api.ts", line: 5 },
75
+ ],
76
+ authentication: { status: "none_seen", kinds: [], evidence: [] },
77
+ });
78
+ describe("buildThreatModel", () => {
79
+ it("gives each component and flow its STRIDE categories, unknown without evidence (DATAP-914)", () => {
80
+ const threatModel = (0, build_threat_model_1.buildThreatModel)(factsWith([mailFlowWith()]));
81
+ expect(categoriesOfElement(threatModel, "cmp_api")).toBe("STRIDE");
82
+ expect(categoriesOfElement(threatModel, "cmp_mail")).toBe("SR");
83
+ expect(categoriesOfElement(threatModel, "cmp_db")).toBe("TRID");
84
+ expect(categoriesOfElement(threatModel, "flow_mail")).toBe("TID");
85
+ for (const flowThreat of threatModel.threats.filter((threat) => threat.elementId === "flow_mail")) {
86
+ expect(flowThreat.ruleStatus).toBe("unknown");
87
+ expect(flowThreat.ruleId).toBe("stride/v3/data_flow");
88
+ expect(flowThreat.evidence).toEqual([]);
89
+ expect(flowThreat).not.toHaveProperty("statusRuleId");
90
+ }
91
+ });
92
+ it("sets rule statuses from flow controls, with the evidence lines (DATAP-915)", () => {
93
+ const threatModel = (0, build_threat_model_1.buildThreatModel)(factsWith([flowWithTlsAndTimeoutControls]));
94
+ expect(findThreat(threatModel, "flow_mail", "I")).toEqual({
95
+ id: "threat:flow_mail:stride:I",
96
+ elementId: "flow_mail",
97
+ elementKind: "dataFlow",
98
+ frameworkElementKind: "data_flow",
99
+ elementIdentityKey: "flow-key",
100
+ framework: "stride",
101
+ category: "I",
102
+ ruleStatus: "mitigated",
103
+ ruleId: "stride/v3/data_flow",
104
+ statusRuleId: "stride/v3/data_flow/I",
105
+ evidence: [{ control: "tls", filePath: "src/api.ts", line: 2 }],
106
+ });
107
+ expect(findThreat(threatModel, "cmp_mail", "S")?.ruleStatus).toBe("mitigated");
108
+ expect(findThreat(threatModel, "cmp_mail", "R")?.ruleStatus).toBe("unknown");
109
+ });
110
+ it("opens a threat when a control is weakened", () => {
111
+ const threatModel = (0, build_threat_model_1.buildThreatModel)(factsWith([
112
+ mailFlowWith({
113
+ controls: [{ control: "plaintext_http", effect: "weakens", filePath: "src/api.ts", line: 9 }],
114
+ }),
115
+ ]));
116
+ const informationDisclosureThreat = findThreat(threatModel, "flow_mail", "I");
117
+ expect(informationDisclosureThreat?.ruleStatus).toBe("open");
118
+ expect(informationDisclosureThreat?.statusRuleId).toBeDefined();
119
+ });
120
+ it("names the element by id, kind, framework element kind and identity key", () => {
121
+ const threatModel = (0, build_threat_model_1.buildThreatModel)(factsWith([mailFlowWith()]));
122
+ expect(findThreat(threatModel, "cmp_api", "S")).toMatchObject({
123
+ elementKind: "component",
124
+ frameworkElementKind: "process",
125
+ elementIdentityKey: "app:<unsectioned>|asset|service|src/api.ts|api",
126
+ });
127
+ const mailThreat = findThreat(threatModel, "cmp_mail", "S");
128
+ expect(mailThreat).toMatchObject({ elementKind: "component", frameworkElementKind: "external_entity" });
129
+ expect(mailThreat).not.toHaveProperty("elementIdentityKey");
130
+ expect(findThreat(threatModel, "cmp_db", "T")).toMatchObject({
131
+ elementKind: "component",
132
+ frameworkElementKind: "data_store",
133
+ });
134
+ expect(findThreat(threatModel, "flow_mail", "T")).toMatchObject({
135
+ elementKind: "dataFlow",
136
+ frameworkElementKind: "data_flow",
137
+ });
138
+ });
139
+ it("gives every threat a stable id that is unique in the file", () => {
140
+ const facts = factsWith([mailFlowWith()]);
141
+ const firstThreatIds = (0, build_threat_model_1.buildThreatModel)(facts).threats.map((threat) => threat.id);
142
+ const secondThreatIds = (0, build_threat_model_1.buildThreatModel)(facts).threats.map((threat) => threat.id);
143
+ expect(new Set(firstThreatIds).size).toBe(firstThreatIds.length);
144
+ expect(secondThreatIds).toEqual(firstThreatIds);
145
+ });
146
+ it("copies the scan block of the facts, so the two files can be matched", () => {
147
+ const stamps = {
148
+ scannerCommit: "abc",
149
+ cliVersion: "0.0.36",
150
+ catalogHash: "cat",
151
+ configHash: "cfg",
152
+ aiInference: false,
153
+ structureGraph: false,
154
+ commitSha: null,
155
+ dirty: null,
156
+ rootCommitSha: null,
157
+ scanRoot: null,
158
+ };
159
+ const facts = factsWith([mailFlowWith()], { stamps });
160
+ expect((0, build_threat_model_1.buildThreatModel)(facts).scan).toEqual(facts.scan);
161
+ expect((0, build_threat_model_1.buildThreatModel)(facts).scan.stamps).toEqual(stamps);
162
+ expect((0, build_threat_model_1.buildThreatModel)(factsWith([])).scan.stamps).toBeUndefined();
163
+ });
164
+ it("lists the framework with its rules version and category names", () => {
165
+ const { frameworks } = (0, build_threat_model_1.buildThreatModel)(factsWith([]));
166
+ expect(frameworks).toHaveLength(1);
167
+ expect(frameworks[0]).toMatchObject({ id: "stride", rulesVersion: 3 });
168
+ expect(frameworks[0].categories).toHaveLength(6);
169
+ expect(frameworks[0].categories).toContainEqual({ id: "I", name: "Information disclosure" });
170
+ });
171
+ it("orders component threats before flow threats, in facts order", () => {
172
+ const threatModel = (0, build_threat_model_1.buildThreatModel)(factsWith([mailFlowWith()]));
173
+ const elementIdsInOrder = threatModel.threats
174
+ .map((threat) => threat.elementId)
175
+ .filter((elementId, index, all) => all.indexOf(elementId) === index);
176
+ expect(elementIdsInOrder).toEqual(["cmp_api", "cmp_mail", "cmp_db", "flow_mail"]);
177
+ });
178
+ it("matches the schema and has no person-set statuses", () => {
179
+ const threatModel = (0, build_threat_model_1.buildThreatModel)(factsWith([flowWithTlsAndTimeoutControls]));
180
+ expect(() => schema_1.threatModelFileSchema.parse(threatModel)).not.toThrow();
181
+ expect(threatModel.threats.some((threat) => threat.personSetStatus !== undefined)).toBe(false);
182
+ expect(threatModel.unmatchedPersonSetStatuses).toEqual([]);
183
+ });
184
+ });
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const carry_forward_person_set_statuses_1 = require("../../../src/threat-model/carry-forward-person-set-statuses");
4
+ const schema_1 = require("../../../src/threat-model/schema");
5
+ function buildThreat(overrides = {}) {
6
+ const base = { elementId: "component:api", framework: "stride", category: "spoofing", ...overrides };
7
+ return {
8
+ id: (0, schema_1.threatIdForElementAndCategory)(base),
9
+ elementKind: "component",
10
+ frameworkElementKind: "process",
11
+ ruleStatus: "open",
12
+ ruleId: "rule-spoofing",
13
+ evidence: [],
14
+ ...base,
15
+ };
16
+ }
17
+ function buildThreatModel(threats, scannedAt = "2026-11-01T00:00:00.000Z", unmatchedPersonSetStatuses = []) {
18
+ return {
19
+ schemaVersion: 1,
20
+ scan: { projectName: "demo", scannedAt, cliVersion: "0.0.36", scannerVersion: "1.0.0" },
21
+ frameworks: [{ id: "stride", rulesVersion: 1, categories: [{ id: "spoofing", name: "Spoofing" }] }],
22
+ threats,
23
+ unmatchedPersonSetStatuses,
24
+ };
25
+ }
26
+ const MITIGATED_BY_ALEX = {
27
+ status: "mitigated",
28
+ by: "alex@example.com",
29
+ at: "2026-10-30T10:00:00.000Z",
30
+ note: "Handled by the gateway",
31
+ };
32
+ describe("carryForwardPersonSetStatuses", () => {
33
+ it("returns the fresh threat model unchanged when there is no previous file", () => {
34
+ const fresh = buildThreatModel([buildThreat()]);
35
+ const result = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(fresh, undefined);
36
+ expect(result.threatModel).toBe(fresh);
37
+ expect(result.carriedForwardCount).toBe(0);
38
+ expect(result.unmatchedCount).toBe(0);
39
+ });
40
+ it("keeps a person-set status when the same threat is found again", () => {
41
+ const previous = buildThreatModel([buildThreat({ personSetStatus: MITIGATED_BY_ALEX })]);
42
+ const fresh = buildThreatModel([buildThreat()], "2026-11-02T00:00:00.000Z");
43
+ const result = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(fresh, previous);
44
+ expect(result.threatModel.threats[0].personSetStatus).toEqual(MITIGATED_BY_ALEX);
45
+ expect(result.carriedForwardCount).toBe(1);
46
+ expect(result.unmatchedCount).toBe(0);
47
+ });
48
+ it("never changes the rule status or evidence of the fresh scan", () => {
49
+ const previous = buildThreatModel([
50
+ buildThreat({ ruleStatus: "open", evidence: [], personSetStatus: MITIGATED_BY_ALEX }),
51
+ ]);
52
+ const freshEvidence = [{ control: "mfa", filePath: "src/auth.ts", line: 4 }];
53
+ const fresh = buildThreatModel([buildThreat({ ruleStatus: "mitigated", evidence: freshEvidence })], "2026-11-02T00:00:00.000Z");
54
+ const { threatModel } = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(fresh, previous);
55
+ expect(threatModel.threats[0].ruleStatus).toBe("mitigated");
56
+ expect(threatModel.threats[0].evidence).toEqual(freshEvidence);
57
+ expect(threatModel.scan.scannedAt).toBe("2026-11-02T00:00:00.000Z");
58
+ });
59
+ it("follows an element whose id changed but whose identity key did not", () => {
60
+ const previous = buildThreatModel([
61
+ buildThreat({ elementId: "component:old-id", elementIdentityKey: "service:api", personSetStatus: MITIGATED_BY_ALEX }),
62
+ ]);
63
+ const fresh = buildThreatModel([buildThreat({ elementId: "component:new-id", elementIdentityKey: "service:api" })]);
64
+ const result = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(fresh, previous);
65
+ expect(result.threatModel.threats[0].personSetStatus).toEqual(MITIGATED_BY_ALEX);
66
+ expect(result.unmatchedCount).toBe(0);
67
+ });
68
+ it("falls back to the element id when the element has no identity key", () => {
69
+ const previous = buildThreatModel([buildThreat({ personSetStatus: MITIGATED_BY_ALEX })]);
70
+ const fresh = buildThreatModel([buildThreat({ elementIdentityKey: "service:api" })]);
71
+ const result = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(fresh, previous);
72
+ expect(result.threatModel.threats[0].personSetStatus).toEqual(MITIGATED_BY_ALEX);
73
+ });
74
+ it("does not carry a status to another category or another framework of the same element", () => {
75
+ const previous = buildThreatModel([buildThreat({ personSetStatus: MITIGATED_BY_ALEX })]);
76
+ const fresh = buildThreatModel([
77
+ buildThreat({ category: "tampering" }),
78
+ buildThreat({ framework: "linddun" }),
79
+ ]);
80
+ const result = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(fresh, previous);
81
+ expect(result.threatModel.threats.every((threat) => threat.personSetStatus === undefined)).toBe(true);
82
+ expect(result.carriedForwardCount).toBe(0);
83
+ expect(result.unmatchedCount).toBe(1);
84
+ });
85
+ it("does not carry a component's status to a data flow with the same id", () => {
86
+ const previous = buildThreatModel([buildThreat({ elementId: "shared-id", personSetStatus: MITIGATED_BY_ALEX })]);
87
+ const fresh = buildThreatModel([buildThreat({ elementId: "shared-id", elementKind: "dataFlow" })]);
88
+ const result = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(fresh, previous);
89
+ expect(result.threatModel.threats[0].personSetStatus).toBeUndefined();
90
+ expect(result.unmatchedCount).toBe(1);
91
+ });
92
+ it("moves a person-set status whose threat is gone to unmatchedPersonSetStatuses, with the scan it was last matched in", () => {
93
+ const previous = buildThreatModel([buildThreat({ personSetStatus: MITIGATED_BY_ALEX })], "2026-11-01T00:00:00.000Z");
94
+ const fresh = buildThreatModel([], "2026-11-02T00:00:00.000Z");
95
+ const result = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(fresh, previous);
96
+ expect(result.unmatchedCount).toBe(1);
97
+ expect(result.threatModel.unmatchedPersonSetStatuses).toEqual([
98
+ {
99
+ threatId: previous.threats[0].id,
100
+ elementId: "component:api",
101
+ elementKind: "component",
102
+ framework: "stride",
103
+ category: "spoofing",
104
+ personSetStatus: MITIGATED_BY_ALEX,
105
+ lastMatchedScannedAt: "2026-11-01T00:00:00.000Z",
106
+ },
107
+ ]);
108
+ });
109
+ it("keeps unmatched person-set statuses across later scans", () => {
110
+ const firstScan = buildThreatModel([buildThreat({ personSetStatus: MITIGATED_BY_ALEX })], "2026-11-01T00:00:00.000Z");
111
+ const secondScan = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(buildThreatModel([], "2026-11-02T00:00:00.000Z"), firstScan).threatModel;
112
+ const thirdScan = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(buildThreatModel([], "2026-11-03T00:00:00.000Z"), secondScan);
113
+ expect(thirdScan.unmatchedCount).toBe(1);
114
+ expect(thirdScan.threatModel.unmatchedPersonSetStatuses[0].lastMatchedScannedAt).toBe("2026-11-01T00:00:00.000Z");
115
+ });
116
+ it("re-attaches an unmatched person-set status when its threat comes back", () => {
117
+ const firstScan = buildThreatModel([buildThreat({ personSetStatus: MITIGATED_BY_ALEX })], "2026-11-01T00:00:00.000Z");
118
+ const secondScan = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(buildThreatModel([], "2026-11-02T00:00:00.000Z"), firstScan).threatModel;
119
+ const thirdScan = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(buildThreatModel([buildThreat()], "2026-11-03T00:00:00.000Z"), secondScan);
120
+ expect(thirdScan.threatModel.threats[0].personSetStatus).toEqual(MITIGATED_BY_ALEX);
121
+ expect(thirdScan.threatModel.unmatchedPersonSetStatuses).toEqual([]);
122
+ expect(thirdScan.carriedForwardCount).toBe(1);
123
+ });
124
+ it("prefers the status on a current threat over an older unmatched one for the same threat", () => {
125
+ const olderUnmatched = {
126
+ threatId: (0, schema_1.threatIdForElementAndCategory)({ elementId: "component:api", framework: "stride", category: "spoofing" }),
127
+ elementId: "component:api",
128
+ elementKind: "component",
129
+ framework: "stride",
130
+ category: "spoofing",
131
+ personSetStatus: { status: "open", note: "older" },
132
+ lastMatchedScannedAt: "2026-10-01T00:00:00.000Z",
133
+ };
134
+ const previous = buildThreatModel([buildThreat({ personSetStatus: MITIGATED_BY_ALEX })], "2026-11-01T00:00:00.000Z", [olderUnmatched]);
135
+ const fresh = buildThreatModel([buildThreat()], "2026-11-02T00:00:00.000Z");
136
+ const result = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(fresh, previous);
137
+ expect(result.threatModel.threats[0].personSetStatus).toEqual(MITIGATED_BY_ALEX);
138
+ expect(result.threatModel.unmatchedPersonSetStatuses).toEqual([olderUnmatched]);
139
+ expect(result.carriedForwardCount).toBe(1);
140
+ expect(result.unmatchedCount).toBe(1);
141
+ });
142
+ it("gives the same output for the same inputs, and does not mutate them", () => {
143
+ const previous = buildThreatModel([buildThreat({ personSetStatus: MITIGATED_BY_ALEX }), buildThreat({ elementId: "component:db", personSetStatus: { status: "open" } })], "2026-11-01T00:00:00.000Z");
144
+ const fresh = buildThreatModel([buildThreat()], "2026-11-02T00:00:00.000Z");
145
+ const previousSnapshot = JSON.stringify(previous);
146
+ const freshSnapshot = JSON.stringify(fresh);
147
+ const first = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(fresh, previous);
148
+ const second = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(fresh, previous);
149
+ expect(JSON.stringify(first)).toBe(JSON.stringify(second));
150
+ expect(JSON.stringify(previous)).toBe(previousSnapshot);
151
+ expect(JSON.stringify(fresh)).toBe(freshSnapshot);
152
+ expect(first.threatModel).not.toBe(fresh);
153
+ });
154
+ it("returns a file that matches the schema", () => {
155
+ const previous = buildThreatModel([
156
+ buildThreat({ personSetStatus: MITIGATED_BY_ALEX }),
157
+ buildThreat({ elementId: "component:gone", personSetStatus: { status: "open" } }),
158
+ ]);
159
+ const fresh = buildThreatModel([buildThreat()], "2026-11-02T00:00:00.000Z");
160
+ const { threatModel } = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(fresh, previous);
161
+ expect(schema_1.threatModelFileSchema.safeParse(threatModel).success).toBe(true);
162
+ });
163
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const os_1 = __importDefault(require("os"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const layout_1 = require("../../../src/facts/layout");
10
+ const carry_forward_person_set_statuses_1 = require("../../../src/threat-model/carry-forward-person-set-statuses");
11
+ const io_1 = require("../../../src/threat-model/io");
12
+ const schema_1 = require("../../../src/threat-model/schema");
13
+ function buildThreatModel(scannedAt = "2026-11-01T00:00:00.000Z") {
14
+ const identity = { elementId: "component:api", framework: "stride", category: "spoofing" };
15
+ return {
16
+ schemaVersion: 1,
17
+ scan: { projectName: "demo", scannedAt, cliVersion: "0.0.36", scannerVersion: "1.0.0" },
18
+ frameworks: [{ id: "stride", rulesVersion: 1, categories: [{ id: "spoofing", name: "Spoofing" }] }],
19
+ threats: [
20
+ {
21
+ id: (0, schema_1.threatIdForElementAndCategory)(identity),
22
+ elementKind: "component",
23
+ frameworkElementKind: "process",
24
+ ruleStatus: "open",
25
+ ruleId: "rule-spoofing",
26
+ evidence: [],
27
+ ...identity,
28
+ },
29
+ ],
30
+ unmatchedPersonSetStatuses: [],
31
+ };
32
+ }
33
+ describe("threat model file io", () => {
34
+ let temporaryDirectory;
35
+ let layout;
36
+ beforeEach(() => {
37
+ temporaryDirectory = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "threat-model-io-"));
38
+ layout = (0, layout_1.layoutForDir)(path_1.default.join(temporaryDirectory, ".dataparade"));
39
+ });
40
+ afterEach(() => {
41
+ fs_1.default.rmSync(temporaryDirectory, { recursive: true, force: true });
42
+ });
43
+ it("writes threat-model.json and reads it back", () => {
44
+ const threatModel = buildThreatModel();
45
+ (0, io_1.writeThreatModel)(layout, threatModel);
46
+ expect(fs_1.default.existsSync(layout.threatModelPath)).toBe(true);
47
+ expect(fs_1.default.readFileSync(layout.threatModelPath, "utf8").endsWith("\n")).toBe(true);
48
+ expect((0, io_1.readThreatModel)(layout)).toEqual(threatModel);
49
+ });
50
+ it("refuses to write a threat model that does not match the schema", () => {
51
+ const invalidThreatModel = { ...buildThreatModel(), schemaVersion: 2 };
52
+ expect(() => (0, io_1.writeThreatModel)(layout, invalidThreatModel)).toThrow();
53
+ expect(fs_1.default.existsSync(layout.threatModelPath)).toBe(false);
54
+ });
55
+ it("reports absent when there is no previous threat-model.json", () => {
56
+ expect((0, io_1.readPreviousThreatModelForCarryForward)(layout)).toEqual({ outcome: "absent" });
57
+ });
58
+ it("reads the previous threat model for carry-forward", () => {
59
+ const threatModel = buildThreatModel();
60
+ (0, io_1.writeThreatModel)(layout, threatModel);
61
+ expect((0, io_1.readPreviousThreatModelForCarryForward)(layout)).toEqual({ outcome: "read", threatModel });
62
+ });
63
+ it("keeps an unreadable previous file as threat-model.unreadable.json and reports why", () => {
64
+ const unreadableContents = ["{ not json", JSON.stringify({ ...buildThreatModel(), schemaVersion: 2 })];
65
+ for (const contents of unreadableContents) {
66
+ fs_1.default.rmSync(layout.threatModelUnreadableCopyPath, { force: true });
67
+ fs_1.default.mkdirSync(layout.dir, { recursive: true });
68
+ fs_1.default.writeFileSync(layout.threatModelPath, contents, "utf8");
69
+ const result = (0, io_1.readPreviousThreatModelForCarryForward)(layout);
70
+ if (result.outcome !== "unreadable")
71
+ throw new Error("expected an unreadable outcome");
72
+ expect(result.reason.length).toBeGreaterThan(0);
73
+ expect(result.unreadableCopyPath).toBe(layout.threatModelUnreadableCopyPath);
74
+ expect(fs_1.default.readFileSync(layout.threatModelUnreadableCopyPath, "utf8")).toBe(contents);
75
+ }
76
+ });
77
+ it("readThreatModel says to scan first when the file is missing", () => {
78
+ let caught;
79
+ try {
80
+ (0, io_1.readThreatModel)(layout);
81
+ }
82
+ catch (error) {
83
+ caught = error;
84
+ }
85
+ expect(caught).toBeInstanceOf(io_1.ThreatModelError);
86
+ expect(caught.code).toBe("NO_THREAT_MODEL");
87
+ expect(caught.message).toContain("Scan first");
88
+ });
89
+ it("survives a rescan end to end", () => {
90
+ (0, io_1.writeThreatModel)(layout, buildThreatModel("2026-11-01T00:00:00.000Z"));
91
+ const onDisk = JSON.parse(fs_1.default.readFileSync(layout.threatModelPath, "utf8"));
92
+ onDisk.threats[0].personSetStatus = { status: "mitigated" };
93
+ fs_1.default.writeFileSync(layout.threatModelPath, JSON.stringify(onDisk, null, 2), "utf8");
94
+ const previous = (0, io_1.readPreviousThreatModelForCarryForward)(layout);
95
+ if (previous.outcome !== "read")
96
+ throw new Error("expected the previous file to be read");
97
+ const { threatModel } = (0, carry_forward_person_set_statuses_1.carryForwardPersonSetStatuses)(buildThreatModel("2026-11-05T00:00:00.000Z"), previous.threatModel);
98
+ (0, io_1.writeThreatModel)(layout, threatModel);
99
+ const rewritten = JSON.parse(fs_1.default.readFileSync(layout.threatModelPath, "utf8"));
100
+ expect(rewritten.scan.scannedAt).toBe("2026-11-05T00:00:00.000Z");
101
+ expect(rewritten.threats[0].personSetStatus).toEqual({ status: "mitigated" });
102
+ });
103
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const zod_1 = require("zod");
4
+ const schema_1 = require("../../../src/threat-model/schema");
5
+ describe("threat model schema", () => {
6
+ it("accepts a person-set status with only a status", () => {
7
+ expect(schema_1.personSetThreatStatusSchema.parse({ status: "mitigated" })).toEqual({ status: "mitigated" });
8
+ });
9
+ it("accepts accepted and not_applicable as person-set statuses", () => {
10
+ for (const personSetStatusValue of ["mitigated", "open", "accepted", "not_applicable"]) {
11
+ expect(schema_1.personSetThreatStatusSchema.safeParse({ status: personSetStatusValue }).success).toBe(true);
12
+ }
13
+ });
14
+ it("rejects unknown and other values as a person-set status", () => {
15
+ expect(schema_1.personSetThreatStatusSchema.safeParse({ status: "unknown" }).success).toBe(false);
16
+ expect(schema_1.personSetThreatStatusSchema.safeParse({ status: "ignored" }).success).toBe(false);
17
+ });
18
+ it("keeps framework and category open to other frameworks", () => {
19
+ const parsedThreat = schema_1.threatModelThreatSchema.parse({
20
+ id: "threat:subject_1:linddun:L",
21
+ elementId: "subject_1",
22
+ elementKind: "component",
23
+ frameworkElementKind: "data_subject",
24
+ framework: "linddun",
25
+ category: "L",
26
+ ruleStatus: "unknown",
27
+ ruleId: "linddun/v1/data_subject",
28
+ evidence: [],
29
+ });
30
+ expect(parsedThreat.framework).toBe("linddun");
31
+ expect(parsedThreat.frameworkElementKind).toBe("data_subject");
32
+ });
33
+ it("can be emitted as a JSON Schema", () => {
34
+ const jsonSchema = zod_1.z.toJSONSchema(schema_1.threatModelFileSchema);
35
+ expect(jsonSchema.properties?.threats).toBeDefined();
36
+ });
37
+ it("effectiveThreatStatus prefers the person-set status over the rule status", () => {
38
+ expect((0, schema_1.effectiveThreatStatus)({ ruleStatus: "open", personSetStatus: { status: "mitigated" } })).toBe("mitigated");
39
+ expect((0, schema_1.effectiveThreatStatus)({ ruleStatus: "open" })).toBe("open");
40
+ expect((0, schema_1.effectiveThreatStatus)({ ruleStatus: "open", personSetStatus: { status: "accepted" } })).toBe("accepted");
41
+ });
42
+ });