@clear-capabilities/agentic-security-scanner 0.184.0 → 0.186.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.
Files changed (228) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/bin/agentic-security.js +111 -1
  3. package/dist/1128.index.js +912 -0
  4. package/dist/1665.index.js +828 -0
  5. package/dist/2584.index.js +1 -1
  6. package/dist/4171.index.js +2 -2
  7. package/dist/5752.index.js +466 -0
  8. package/dist/7405.index.js +1 -1
  9. package/dist/8158.index.js +1713 -0
  10. package/dist/8798.index.js +1 -1
  11. package/dist/9382.index.js +2 -2
  12. package/dist/9579.index.js +1 -1
  13. package/dist/agentic-security.mjs +29 -29
  14. package/dist/agentic-security.mjs.sha256 +1 -1
  15. package/dist/{dad58d1113a12c23a142.json → ca62ee93079be4c24eee.json} +29 -12
  16. package/dist/frontend/src/shell.js +12 -2
  17. package/package.json +29 -12
  18. package/src/dataflow/CLAUDE.md +46 -1
  19. package/src/dataflow/access-paths.js +12 -2
  20. package/src/dataflow/backward.js +42 -7
  21. package/src/dataflow/cross-service-taint.js +83 -1
  22. package/src/dataflow/demand-query.js +1168 -0
  23. package/src/dataflow/dep-fingerprint.js +718 -0
  24. package/src/dataflow/engine.js +48 -6
  25. package/src/dataflow/exploit-prover.js +6 -2
  26. package/src/dataflow/ifds-precise.js +22 -0
  27. package/src/dataflow/incremental-replay.js +118 -0
  28. package/src/dataflow/incremental-session.js +257 -0
  29. package/src/dataflow/incremental.js +237 -35
  30. package/src/dataflow/index.js +25 -94
  31. package/src/dataflow/ir-cache.js +268 -0
  32. package/src/dataflow/privacy-taint.js +7 -0
  33. package/src/dataflow/summaries.js +72 -6
  34. package/src/dataflow/tabulation.js +80 -24
  35. package/src/engine.js +113 -8
  36. package/src/graph/CLAUDE.md +31 -0
  37. package/src/graph/adapters/artifact.js +81 -0
  38. package/src/graph/adapters/crossrepo.js +75 -0
  39. package/src/graph/adapters/dataflow.js +76 -0
  40. package/src/graph/adapters/provenance.js +92 -0
  41. package/src/graph/adapters/semantic.js +89 -0
  42. package/src/graph/crosswalk-builders.js +152 -0
  43. package/src/graph/crosswalk.js +146 -0
  44. package/src/graph/index.js +15 -0
  45. package/src/graph/observation.js +57 -0
  46. package/src/graph/refs.js +105 -0
  47. package/src/graph/registry.js +129 -0
  48. package/src/graph/relations.js +81 -0
  49. package/src/graph/scc.js +241 -0
  50. package/src/graph/view.js +254 -0
  51. package/src/ir/CLAUDE.md +4 -0
  52. package/src/ir/callgraph.js +36 -8
  53. package/src/ir/index.js +18 -4
  54. package/src/ir/parser-js.js +10 -0
  55. package/src/language/CLAUDE.md +13 -0
  56. package/src/language/nix-option-types.js +170 -0
  57. package/src/language/nix-script-taint.js +46 -3
  58. package/src/language/nix-secrets.js +20 -2
  59. package/src/lineage/CLAUDE.md +72 -8
  60. package/src/lineage/DESIGN_GRAPH_BUILDER.md +1 -1
  61. package/src/lineage/DESIGN_PATH_PROVENANCE.md +6 -0
  62. package/src/lineage/boundary-contract.js +273 -0
  63. package/src/lineage/completion.js +205 -0
  64. package/src/lineage/continuation.js +140 -0
  65. package/src/lineage/control-credit.js +313 -0
  66. package/src/lineage/correlation.js +199 -0
  67. package/src/lineage/coverage.js +8 -1
  68. package/src/lineage/cross-repo-link.js +22 -0
  69. package/src/lineage/cut-planner.js +548 -0
  70. package/src/lineage/driver.js +219 -66
  71. package/src/lineage/engine.js +166 -21
  72. package/src/lineage/export-json.js +5 -0
  73. package/src/lineage/graph-builder.js +84 -7
  74. package/src/lineage/haskell-view.js +59 -0
  75. package/src/lineage/index.js +3 -0
  76. package/src/lineage/nix-view.js +35 -0
  77. package/src/lineage/owned-build.js +77 -0
  78. package/src/lineage/owned-worker-entry.js +22 -0
  79. package/src/lineage/owned-worker.js +95 -0
  80. package/src/lineage/path-evidence.js +123 -0
  81. package/src/lineage/path-predicates.js +529 -0
  82. package/src/lineage/path-query.js +189 -20
  83. package/src/lineage/path-store.js +191 -17
  84. package/src/lineage/scc-solver.js +186 -0
  85. package/src/lineage/smt-orchestrator.js +174 -0
  86. package/src/lineage/smt-z3-backend.js +294 -0
  87. package/src/lineage/source-seeding.js +36 -2
  88. package/src/lineage/summaries.js +66 -4
  89. package/src/lineage/value-versions.js +130 -0
  90. package/src/lineage/witness-selection.js +95 -0
  91. package/src/pipeline/scan-health.js +18 -0
  92. package/src/posture/CLAUDE.md +17 -0
  93. package/src/posture/business-logic.js +16 -7
  94. package/src/posture/dag-commands.js +442 -0
  95. package/src/posture/evidence-bundle.js +1 -1
  96. package/src/posture/finding-defaults.js +19 -0
  97. package/src/posture/git-history.js +91 -1
  98. package/src/posture/witness-bundle.js +573 -0
  99. package/src/posture/witness-runtime.js +276 -0
  100. package/src/report/index.js +2 -0
  101. package/src/sast/CLAUDE.md +2 -0
  102. package/src/sast/_call-args.js +70 -0
  103. package/src/sast/init-scope.js +87 -0
  104. package/src/sast/listen-bind-address.js +49 -0
  105. package/src/sast/redirect-target.js +106 -0
  106. package/src/sast/reflected-input.js +76 -0
  107. package/src/sast/send-file-root.js +27 -0
  108. package/src/sast/sensitive-data-logging.js +38 -1
  109. package/dist/119.index.js +0 -197
  110. package/dist/128.index.js +0 -129
  111. package/dist/1293.index.js +0 -5689
  112. package/dist/1336.index.js +0 -16182
  113. package/dist/1351.index.js +0 -133
  114. package/dist/1387.index.js +0 -271
  115. package/dist/1437.index.js +0 -23
  116. package/dist/1445.index.js +0 -110
  117. package/dist/1505.index.js +0 -151
  118. package/dist/1557.index.js +0 -293
  119. package/dist/1621.index.js +0 -311
  120. package/dist/1751.index.js +0 -160
  121. package/dist/1765.index.js +0 -727
  122. package/dist/1861.index.js +0 -690
  123. package/dist/1906.index.js +0 -433
  124. package/dist/208.index.js +0 -1631
  125. package/dist/2223.index.js +0 -159
  126. package/dist/2238.index.js +0 -295
  127. package/dist/2530.index.js +0 -152
  128. package/dist/2565.index.js +0 -116
  129. package/dist/2574.index.js +0 -127
  130. package/dist/2620.index.js +0 -345
  131. package/dist/2773.index.js +0 -98
  132. package/dist/2775.index.js +0 -32
  133. package/dist/2966.index.js +0 -171
  134. package/dist/2972.index.js +0 -87
  135. package/dist/2991.index.js +0 -131
  136. package/dist/3063.index.js +0 -833
  137. package/dist/3075.index.js +0 -227
  138. package/dist/3121.index.js +0 -297
  139. package/dist/3314.index.js +0 -263
  140. package/dist/3480.index.js +0 -1822
  141. package/dist/3481.index.js +0 -24
  142. package/dist/3506.index.js +0 -268
  143. package/dist/3533.index.js +0 -591
  144. package/dist/3653.index.js +0 -450
  145. package/dist/3740.index.js +0 -722
  146. package/dist/3822.index.js +0 -131
  147. package/dist/3868.index.js +0 -292
  148. package/dist/3918.index.js +0 -192
  149. package/dist/4090.index.js +0 -288
  150. package/dist/4113.index.js +0 -1286
  151. package/dist/4121.index.js +0 -1190
  152. package/dist/4142.index.js +0 -690
  153. package/dist/4168.index.js +0 -509
  154. package/dist/4281.index.js +0 -993
  155. package/dist/4336.index.js +0 -436
  156. package/dist/4387.index.js +0 -532
  157. package/dist/4413.index.js +0 -302
  158. package/dist/4476.index.js +0 -4510
  159. package/dist/4491.index.js +0 -133
  160. package/dist/4538.index.js +0 -185
  161. package/dist/4684.index.js +0 -319
  162. package/dist/4740.index.js +0 -165
  163. package/dist/4780.index.js +0 -209
  164. package/dist/4802.index.js +0 -225
  165. package/dist/4812.index.js +0 -379
  166. package/dist/4835.index.js +0 -126
  167. package/dist/494.index.js +0 -226
  168. package/dist/4991.index.js +0 -549
  169. package/dist/5199.index.js +0 -305
  170. package/dist/5216.index.js +0 -109
  171. package/dist/5439.index.js +0 -301
  172. package/dist/5443.index.js +0 -97
  173. package/dist/5496.index.js +0 -377
  174. package/dist/5738.index.js +0 -240
  175. package/dist/5801.index.js +0 -588
  176. package/dist/5817.index.js +0 -714
  177. package/dist/5858.index.js +0 -223
  178. package/dist/5933.index.js +0 -143
  179. package/dist/601.index.js +0 -23
  180. package/dist/6173.index.js +0 -273
  181. package/dist/6291.index.js +0 -1871
  182. package/dist/6312.index.js +0 -666
  183. package/dist/634.index.js +0 -16182
  184. package/dist/644.index.js +0 -87
  185. package/dist/6508.index.js +0 -283
  186. package/dist/6560.index.js +0 -645
  187. package/dist/6576.index.js +0 -422
  188. package/dist/6579.index.js +0 -271
  189. package/dist/6655.index.js +0 -3221
  190. package/dist/6745.index.js +0 -305
  191. package/dist/6818.index.js +0 -21642
  192. package/dist/6932.index.js +0 -1190
  193. package/dist/6972.index.js +0 -167
  194. package/dist/6995.index.js +0 -163
  195. package/dist/7249.index.js +0 -191
  196. package/dist/7372.index.js +0 -1197
  197. package/dist/7546.index.js +0 -541
  198. package/dist/76.index.js +0 -448
  199. package/dist/7879.index.js +0 -163
  200. package/dist/8025.index.js +0 -130
  201. package/dist/8054.index.js +0 -248
  202. package/dist/808.index.js +0 -1330
  203. package/dist/8097.index.js +0 -201
  204. package/dist/8126.index.js +0 -191
  205. package/dist/8178.index.js +0 -78
  206. package/dist/8382.index.js +0 -93
  207. package/dist/8408.index.js +0 -261
  208. package/dist/8540.index.js +0 -174
  209. package/dist/8635.index.js +0 -802
  210. package/dist/8688.index.js +0 -410
  211. package/dist/8699.index.js +0 -779
  212. package/dist/8891.index.js +0 -457
  213. package/dist/8916.index.js +0 -885
  214. package/dist/9146.index.js +0 -170
  215. package/dist/9168.index.js +0 -841
  216. package/dist/9292.index.js +0 -369
  217. package/dist/9422.index.js +0 -866
  218. package/dist/9440.index.js +0 -453
  219. package/dist/9479.index.js +0 -152
  220. package/dist/9481.index.js +0 -220
  221. package/dist/9539.index.js +0 -100
  222. package/dist/9547.index.js +0 -103
  223. package/dist/9692.index.js +0 -90
  224. package/dist/9800.index.js +0 -462
  225. package/dist/9899.index.js +0 -138
  226. package/dist/9981.index.js +0 -206
  227. package/dist/999.index.js +0 -117
  228. package/dist/9999.index.js +0 -1698
@@ -1,422 +0,0 @@
1
- export const id = 6576;
2
- export const ids = [6576];
3
- export const modules = {
4
-
5
- /***/ 16576:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
-
9
- // EXPORTS
10
- __webpack_require__.d(__webpack_exports__, {
11
- loadRemoteGraphExport: () => (/* binding */ loadRemoteGraphExport)
12
- });
13
-
14
- // EXTERNAL MODULE: external "node:fs"
15
- var external_node_fs_ = __webpack_require__(73024);
16
- // EXTERNAL MODULE: ./src/lineage/schema.js
17
- var schema = __webpack_require__(61054);
18
- // EXTERNAL MODULE: ./src/lineage/protection.js
19
- var protection = __webpack_require__(59114);
20
- // EXTERNAL MODULE: ./src/lineage/classification.js
21
- var classification = __webpack_require__(3345);
22
- ;// CONCATENATED MODULE: ./src/lineage/validate.js
23
- //
24
- // Structural validator for DataFlowGraph v1 (PRD section 10). Hand-rolled
25
- // rather than a generic JSON-Schema interpreter + a new `ajv`-style
26
- // dependency, matching this codebase's existing preference for
27
- // hand-rolled implementations over new runtime deps (see every parser in
28
- // scanner/src/ir/). scanner/src/lineage/dataflow-graph.schema.json (Task
29
- // 6) is the authoritative JSON Schema document for external interop /
30
- // documentation; this file is what the engine actually calls at graph-
31
- // build phase 12 (PRD 18.3: "Validate the graph contract and freeze it
32
- // before rendering").
33
- //
34
- // Never throws. A malformed top-level input produces one error and
35
- // returns early; a malformed nested entity is skipped for further
36
- // structural checks on ITSELF but does not stop validation of siblings.
37
-
38
-
39
-
40
-
41
-
42
- function _err(errors, path, message) {
43
- errors.push({ path, message });
44
- }
45
-
46
- function _requireArray(graph, key, errors) {
47
- if (!Array.isArray(graph[key])) _err(errors, `$.${key}`, `${key} must be an array`);
48
- }
49
-
50
- function _requireObject(graph, key, errors) {
51
- if (typeof graph[key] !== 'object' || graph[key] === null || Array.isArray(graph[key])) {
52
- _err(errors, `$.${key}`, `${key} must be an object`);
53
- }
54
- }
55
-
56
- const ID_PREFIXES = {
57
- node: /^node:/,
58
- edge: /^edge:/,
59
- data: /^data:/,
60
- flow: /^flow:/,
61
- transform: /^transform:/,
62
- evidence: /^evidence:/,
63
- };
64
-
65
- function _validateNode(node, idx, errors, seenIds) {
66
- const path = (suffix) => `$.nodes[${idx}]${suffix}`;
67
- if (!node || typeof node !== 'object') { _err(errors, path(''), 'node must be an object'); return; }
68
- if (typeof node.id !== 'string' || !node.id) _err(errors, path('.id'), 'node.id is required');
69
- else {
70
- if (!ID_PREFIXES.node.test(node.id)) _err(errors, path('.id'), `node.id must start with "node:"`);
71
- seenIds.add(node.id);
72
- }
73
- if (!schema/* NODE_KINDS */.xA.includes(node.kind)) _err(errors, path('.kind'), `unrecognized node kind "${node.kind}"`);
74
- // node.subtype is optional and may be `null` — an `unsupported`-coverage
75
- // node (e.g. a sink registry decision with `category: null`, PRD 6.4/
76
- // DESIGN_REGISTRIES.md §9.0) legitimately carries no subtype at all,
77
- // either as an absent field or an explicit `null`; only a present,
78
- // non-null, non-string value (a number, object, array, etc.) is invalid.
79
- if (Object.prototype.hasOwnProperty.call(node, 'subtype') && node.subtype !== null && typeof node.subtype !== 'string') {
80
- _err(errors, path('.subtype'), 'node.subtype must be a string or null');
81
- }
82
- if (typeof node.label !== 'string' || !node.label) _err(errors, path('.label'), 'node.label is required');
83
- if (!Array.isArray(node.aliases)) _err(errors, path('.aliases'), 'node.aliases must be an array');
84
- if (!Array.isArray(node.dataElementIds)) _err(errors, path('.dataElementIds'), 'node.dataElementIds must be an array');
85
- if (!Array.isArray(node.evidenceRefs)) _err(errors, path('.evidenceRefs'), 'node.evidenceRefs must be an array');
86
- if (!schema/* COVERAGE_STATUS_VALUES */.R0.includes(node.coverageStatus)) _err(errors, path('.coverageStatus'), `unrecognized coverageStatus "${node.coverageStatus}"`);
87
- if (node.externality && !schema/* EXTERNALITY_VALUES */.TB.includes(node.externality.value)) {
88
- _err(errors, path('.externality.value'), `unrecognized externality "${node.externality.value}"`);
89
- }
90
- // Milestone 2, Sub-project A, increment 1: `node.destination` is `null`
91
- // on every node this increment doesn't resolve — only checked when
92
- // non-null, mirroring `_validateEdge`'s own `edge.protocol` pattern below.
93
- if (node.destination && typeof node.destination === 'object') {
94
- if (!schema/* DESTINATION_RESOLUTION_VALUES */.JU.includes(node.destination.resolutionStatus)) {
95
- _err(errors, path('.destination.resolutionStatus'), `unrecognized destination.resolutionStatus "${node.destination.resolutionStatus}"`);
96
- }
97
- if (node.destination.resolutionStatus !== 'literal' && node.destination.literalValue !== null) {
98
- _err(errors, path('.destination.literalValue'), 'destination.literalValue must be null unless resolutionStatus is "literal"');
99
- }
100
- }
101
- // Milestone 2, Sub-project E, increment 2: `node.storeDetail` is `null`
102
- // on every node this increment doesn't populate — only checked when
103
- // non-null, mirroring `node.destination`'s own "only checked when the
104
- // parent object is present" shape immediately above.
105
- if (node.storeDetail && typeof node.storeDetail === 'object') {
106
- if (node.storeDetail.operation !== null && !schema/* STORE_OPERATION_VALUES */.P4.includes(node.storeDetail.operation)) {
107
- _err(errors, path('.storeDetail.operation'), `unrecognized storeDetail.operation "${node.storeDetail.operation}"`);
108
- }
109
- if (Object.prototype.hasOwnProperty.call(node.storeDetail, 'columns') && !Array.isArray(node.storeDetail.columns)) {
110
- _err(errors, path('.storeDetail.columns'), 'storeDetail.columns must be an array');
111
- } else if (Array.isArray(node.storeDetail.columns)) {
112
- node.storeDetail.columns.forEach((c, i) => {
113
- if (typeof c !== 'string') _err(errors, path(`.storeDetail.columns[${i}]`), 'storeDetail.columns entries must be strings');
114
- });
115
- }
116
- }
117
- // Milestone 2, Sub-project E, increment 3: `node.queueDetail` is `null`
118
- // on every node this increment doesn't populate — only checked when
119
- // non-null, mirroring `node.storeDetail`'s own "only checked when the
120
- // parent object is present" shape immediately above.
121
- if (node.queueDetail && typeof node.queueDetail === 'object') {
122
- if (node.queueDetail.operation !== null && !schema/* QUEUE_OPERATION_VALUES */.hY.includes(node.queueDetail.operation)) {
123
- _err(errors, path('.queueDetail.operation'), `unrecognized queueDetail.operation "${node.queueDetail.operation}"`);
124
- }
125
- if (node.queueDetail.topic !== null && typeof node.queueDetail.topic !== 'string') {
126
- _err(errors, path('.queueDetail.topic'), 'queueDetail.topic must be a string or null');
127
- }
128
- }
129
- }
130
-
131
- function _validateDataElement(de, idx, errors, seenIds) {
132
- const path = (suffix) => `$.dataElements[${idx}]${suffix}`;
133
- if (!de || typeof de !== 'object') { _err(errors, path(''), 'dataElement must be an object'); return; }
134
- if (typeof de.id !== 'string' || !de.id) _err(errors, path('.id'), 'dataElement.id is required');
135
- else {
136
- if (!ID_PREFIXES.data.test(de.id)) _err(errors, path('.id'), `dataElement.id must start with "data:"`);
137
- seenIds.add(de.id);
138
- }
139
- if (typeof de.name !== 'string' || !de.name) _err(errors, path('.name'), 'dataElement.name is required');
140
- if (!Array.isArray(de.dataClasses)) _err(errors, path('.dataClasses'), 'dataElement.dataClasses must be an array');
141
- else {
142
- for (let i = 0; i < de.dataClasses.length; i++) {
143
- const cls = de.dataClasses[i];
144
- if (!classification/* LINEAGE_DATA_CLASSES */.e6.includes(cls)) {
145
- _err(errors, path(`.dataClasses[${i}]`), `unrecognized data class "${cls}"`);
146
- }
147
- }
148
- }
149
- if (!Array.isArray(de.aiContexts)) _err(errors, path('.aiContexts'), 'dataElement.aiContexts must be an array');
150
- else {
151
- for (let i = 0; i < de.aiContexts.length; i++) {
152
- const ctx = de.aiContexts[i];
153
- if (!(0,classification/* isAiContext */.MY)(ctx)) {
154
- _err(errors, path(`.aiContexts[${i}]`), `unrecognized AI processing context "${ctx}"`);
155
- }
156
- }
157
- }
158
- }
159
-
160
- function _validateEdge(edge, idx, errors, nodeIds, dataElementIds) {
161
- const path = (suffix) => `$.edges[${idx}]${suffix}`;
162
- if (!edge || typeof edge !== 'object') { _err(errors, path(''), 'edge must be an object'); return; }
163
- if (typeof edge.id !== 'string' || !edge.id) _err(errors, path('.id'), 'edge.id is required');
164
- else if (!ID_PREFIXES.edge.test(edge.id)) _err(errors, path('.id'), `edge.id must start with "edge:"`);
165
- if (!nodeIds.has(edge.from)) _err(errors, path('.from'), `unknown node id "${edge.from}"`);
166
- if (!nodeIds.has(edge.to)) _err(errors, path('.to'), `unknown node id "${edge.to}"`);
167
- if (edge.relationship !== 'data_flow') _err(errors, path('.relationship'), `unrecognized relationship "${edge.relationship}"`);
168
- if (!Array.isArray(edge.fieldMappings)) _err(errors, path('.fieldMappings'), 'edge.fieldMappings must be an array');
169
- else {
170
- edge.fieldMappings.forEach((fm, i) => {
171
- if (!schema/* MAPPING_TYPES */.$W.includes(fm?.mappingType)) _err(errors, path(`.fieldMappings[${i}].mappingType`), `unrecognized mappingType "${fm?.mappingType}"`);
172
- for (const deId of fm?.dataElementIds || []) {
173
- if (!dataElementIds.has(deId)) _err(errors, path(`.fieldMappings[${i}].dataElementIds`), `unknown dataElement id "${deId}"`);
174
- }
175
- });
176
- }
177
- if (!edge.protection || typeof edge.protection !== 'object') {
178
- _err(errors, path('.protection'), 'edge.protection is required');
179
- } else {
180
- for (const dim of protection/* PROTECTION_DIMENSIONS */.Ai) {
181
- if (!(0,protection/* isValidProtectionDimension */.u9)(edge.protection[dim])) _err(errors, path(`.protection.${dim}`), `invalid protection dimension`);
182
- }
183
- }
184
- if (edge.protocol && typeof edge.protocol === 'object') {
185
- if (!schema/* DESTINATION_RESOLUTION_VALUES */.JU.includes(edge.protocol.destinationResolution)) {
186
- _err(errors, path('.protocol.destinationResolution'), `unrecognized destinationResolution "${edge.protocol.destinationResolution}"`);
187
- }
188
- }
189
- if (!schema/* EDGE_PROVENANCE_VALUES */.L9.includes(edge.provenance)) {
190
- _err(errors, path('.provenance'), `unrecognized provenance "${edge.provenance}"`);
191
- }
192
- }
193
-
194
- function _validateFlow(flow, idx, errors, nodeIds, dataElementIds, edgeIds) {
195
- const path = (suffix) => `$.flows[${idx}]${suffix}`;
196
- if (!flow || typeof flow !== 'object') { _err(errors, path(''), 'flow must be an object'); return; }
197
- if (typeof flow.id !== 'string' || !flow.id) _err(errors, path('.id'), 'flow.id is required');
198
- else if (!ID_PREFIXES.flow.test(flow.id)) _err(errors, path('.id'), `flow.id must start with "flow:"`);
199
- if (!nodeIds.has(flow.source)) _err(errors, path('.source'), `unknown node id "${flow.source}"`);
200
- if (!nodeIds.has(flow.sink)) _err(errors, path('.sink'), `unknown node id "${flow.sink}"`);
201
- for (const deId of flow.dataElementIds || []) {
202
- if (!dataElementIds.has(deId)) _err(errors, path('.dataElementIds'), `unknown dataElement id "${deId}"`);
203
- }
204
- for (const eId of flow.edgeIds || []) {
205
- if (!edgeIds.has(eId)) _err(errors, path('.edgeIds'), `unknown edge id "${eId}"`);
206
- }
207
- if (!schema/* POLICY_STATES */.QA.includes(flow.policyVerdict)) _err(errors, path('.policyVerdict'), `unrecognized policyVerdict "${flow.policyVerdict}"`);
208
- if (!schema/* FLOW_SUMMARY_VALUES */.lw.includes(flow.protectionSummary)) _err(errors, path('.protectionSummary'), `unrecognized protectionSummary "${flow.protectionSummary}"`);
209
- // Milestone 2, Sub-project D, increment 1: `flow.handling` is `null` on
210
- // every flow this increment's own caller chose not to populate — only
211
- // checked when non-null, mirroring `_validateNode`'s own `node.destination`
212
- // pattern above.
213
- if (flow.handling != null && !schema/* HANDLING_VALUES */.DC.includes(flow.handling)) {
214
- _err(errors, path('.handling'), `unrecognized handling "${flow.handling}"`);
215
- }
216
- }
217
-
218
- function _validateTransformation(t, idx, errors) {
219
- const path = (suffix) => `$.transformations[${idx}]${suffix}`;
220
- if (!t || typeof t !== 'object') { _err(errors, path(''), 'transformation must be an object'); return; }
221
- if (typeof t.id !== 'string' || !t.id) _err(errors, path('.id'), 'transformation.id is required');
222
- else if (!ID_PREFIXES.transform.test(t.id)) _err(errors, path('.id'), `transformation.id must start with "transform:"`);
223
- if (!schema/* TRANSFORM_KINDS */.DK.includes(t.kind)) _err(errors, path('.kind'), `unrecognized transformation kind "${t.kind}"`);
224
- if (!schema/* REVERSIBILITY_VALUES */.vw.includes(t.reversibility)) _err(errors, path('.reversibility'), `unrecognized reversibility "${t.reversibility}"`);
225
- }
226
-
227
- function _validateEvidence(e, idx, errors) {
228
- const path = (suffix) => `$.evidence[${idx}]${suffix}`;
229
- if (!e || typeof e !== 'object') { _err(errors, path(''), 'evidence must be an object'); return; }
230
- if (typeof e.id !== 'string' || !e.id) _err(errors, path('.id'), 'evidence.id is required');
231
- else if (!ID_PREFIXES.evidence.test(e.id)) _err(errors, path('.id'), `evidence.id must start with "evidence:"`);
232
- if (!schema/* EVIDENCE_TYPES */.il.includes(e.evidenceType)) _err(errors, path('.evidenceType'), `unrecognized evidenceType "${e.evidenceType}"`);
233
- }
234
-
235
- /**
236
- * Report a validation error for every duplicate id beyond the first
237
- * occurrence in a top-level entity array. Entities with a missing/invalid
238
- * id are skipped here — that is already reported by the per-entity
239
- * structural check, and treating `undefined` as a colliding "id" would be
240
- * noise, not signal.
241
- */
242
- function _checkDuplicateIds(items, key, errors) {
243
- const seenAt = new Map();
244
- items.forEach((item, idx) => {
245
- if (!item || typeof item.id !== 'string' || !item.id) return;
246
- if (seenAt.has(item.id)) {
247
- _err(errors, `$.${key}[${idx}].id`, `duplicate id "${item.id}" (also used at $.${key}[${seenAt.get(item.id)}])`);
248
- } else {
249
- seenAt.set(item.id, idx);
250
- }
251
- });
252
- }
253
-
254
- /**
255
- * Structurally validate a DataFlowGraph v1 envelope. Returns
256
- * `{valid, errors}` and never throws.
257
- */
258
- function validateGraph(graph) {
259
- const errors = [];
260
- if (!graph || typeof graph !== 'object' || Array.isArray(graph)) {
261
- return { valid: false, errors: [{ path: '$', message: 'graph must be an object' }] };
262
- }
263
-
264
- if (graph.schemaVersion !== schema/* SCHEMA_VERSION */.f$) {
265
- _err(errors, '$.schemaVersion', `expected "${schema/* SCHEMA_VERSION */.f$}", got "${graph.schemaVersion}"`);
266
- }
267
- if (typeof graph.graphId !== 'string' || !graph.graphId.startsWith('dfg:')) {
268
- _err(errors, '$.graphId', 'graphId must be a string starting with "dfg:"');
269
- }
270
- for (const key of ['nodes', 'edges', 'dataElements', 'transformations', 'flows', 'controls', 'policies', 'evidence', 'limitations']) {
271
- _requireArray(graph, key, errors);
272
- }
273
- for (const key of ['scope', 'scanHealth', 'taxonomy', 'coverage', 'extensions']) {
274
- _requireObject(graph, key, errors);
275
- }
276
- if (graph.scope && typeof graph.scope === 'object' && !Array.isArray(graph.scope)) {
277
- if (!schema/* GRAPH_SCOPE_SOURCES */.nZ.includes(graph.scope.source)) {
278
- _err(errors, '$.scope.source', `unrecognized scope.source "${graph.scope.source}"`);
279
- }
280
- }
281
-
282
- const nodeIds = new Set();
283
- const dataElementIds = new Set();
284
- const edgeIds = new Set();
285
-
286
- (Array.isArray(graph.nodes) ? graph.nodes : []).forEach((n, i) => _validateNode(n, i, errors, nodeIds));
287
- (Array.isArray(graph.dataElements) ? graph.dataElements : []).forEach((d, i) => _validateDataElement(d, i, errors, dataElementIds));
288
- (Array.isArray(graph.edges) ? graph.edges : []).forEach((e, i) => {
289
- _validateEdge(e, i, errors, nodeIds, dataElementIds);
290
- if (e && typeof e.id === 'string') edgeIds.add(e.id);
291
- });
292
- (Array.isArray(graph.flows) ? graph.flows : []).forEach((f, i) => _validateFlow(f, i, errors, nodeIds, dataElementIds, edgeIds));
293
- (Array.isArray(graph.transformations) ? graph.transformations : []).forEach((t, i) => _validateTransformation(t, i, errors));
294
- (Array.isArray(graph.evidence) ? graph.evidence : []).forEach((e, i) => _validateEvidence(e, i, errors));
295
-
296
- _checkDuplicateIds(Array.isArray(graph.nodes) ? graph.nodes : [], 'nodes', errors);
297
- _checkDuplicateIds(Array.isArray(graph.edges) ? graph.edges : [], 'edges', errors);
298
- _checkDuplicateIds(Array.isArray(graph.dataElements) ? graph.dataElements : [], 'dataElements', errors);
299
- _checkDuplicateIds(Array.isArray(graph.flows) ? graph.flows : [], 'flows', errors);
300
-
301
- return { valid: errors.length === 0, errors };
302
- }
303
-
304
- // EXTERNAL MODULE: ./src/lineage/export-json.js
305
- var export_json = __webpack_require__(63406);
306
- ;// CONCATENATED MODULE: ./src/lineage/federation-loader.js
307
- // federation-loader.js — M5 deliverable #8 (FR-304's "declared" half):
308
- // loadRemoteGraphExport(filePath) reads an exportGraphJSON-shaped file
309
- // (dataflow export --format json's own artifact) — chosen over the
310
- // local server's signed-graph reader (`scanner/src/server/`, whose
311
- // loadSignedGraph is what `agentic-security explore` uses) for the
312
- // cross-machine reason this deliverable's own scoping investigation
313
- // found: loadSignedGraph authenticates against a PER-INSTALL HMAC key,
314
- // which is the wrong trust model for a file that crossed a repo/machine
315
- // boundary in the common case (two repos scanned on two different
316
- // machines sign under two different keys by default, so pointing
317
- // loadSignedGraph at a second repo's checkout would, in the common case,
318
- // correctly report 'tampered' even though nothing was actually
319
- // tampered with). exportGraphJSON's portable, embedded-digest artifact
320
- // is a SELF-CONSISTENCY check instead — never authentication, disclosed
321
- // as such everywhere this module or its callers describe it.
322
- //
323
- // Mirrors that reader's own four-distinct-outcome discipline, with one
324
- // structural difference: a digest mismatch here is NOT a blocking
325
- // failure (`ok:false`) the way all four of its reasons are — it is a
326
- // WARNING the caller must show, never silently swallowed, and does not
327
- // by itself block a --yes write (the operator is explicitly asserting
328
- // this file). `ok:true, digestMatches:false` is therefore a real,
329
- // valid, non-failing outcome; only `missing`/`malformed`/
330
- // `invalid-graph` set `ok:false`.
331
- //
332
- // The self-consistency check recomputes `computeGraphDigest(parsed.graph)`
333
- // and compares it to the file's own embedded `bodyDigest` (final
334
- // whole-branch review, M5 deliverable #8, B1 — NOT `digest`, a real bug
335
- // that survived five clean task-level reviews). `export-json.js`'s
336
- // `digest` field always identifies the SOURCE graph an export was taken
337
- // from, regardless of redaction/filtering — comparing it against a
338
- // recomputation over `parsed.graph` (which IS the redacted/filtered
339
- // `graph:` body under the CLI's own default settings) fails under the
340
- // exact common case a self-consistency check exists to pass: an
341
- // un-tampered, default-redacted export would permanently read
342
- // `digestMatches: false`, and a genuine tamper would be indistinguishable
343
- // from routine redaction. `bodyDigest` identifies the exact bytes this
344
- // file actually contains, which is what a self-consistency check over a
345
- // received file needs.
346
-
347
-
348
-
349
-
350
-
351
- /**
352
- * @param {string} filePath
353
- * @returns {{
354
- * ok: boolean,
355
- * graph: object|null,
356
- * digest: string|null,
357
- * digestMatches: boolean|null,
358
- * reason: 'missing'|'malformed'|'invalid-graph'|'digest-mismatch'|null,
359
- * message: string|null,
360
- * }}
361
- */
362
- function loadRemoteGraphExport(filePath) {
363
- if (!filePath || typeof filePath !== 'string' || !external_node_fs_.existsSync(filePath)) {
364
- return {
365
- ok: false, graph: null, digest: null, digestMatches: null, reason: 'missing',
366
- message: `No remote graph export found at ${filePath}. Run \`dataflow export --format json\` in the remote repository and point --remote-graph at the resulting file.`,
367
- };
368
- }
369
-
370
- let body;
371
- try {
372
- body = external_node_fs_.readFileSync(filePath, 'utf8');
373
- } catch (e) {
374
- return {
375
- ok: false, graph: null, digest: null, digestMatches: null, reason: 'missing',
376
- message: `Remote graph export found at ${filePath} but could not be read: ${e && e.message ? e.message : e}.`,
377
- };
378
- }
379
-
380
- let parsed;
381
- try {
382
- parsed = JSON.parse(body);
383
- } catch (e) {
384
- return {
385
- ok: false, graph: null, digest: null, digestMatches: null, reason: 'malformed',
386
- message: `Remote graph export at ${filePath} is not valid JSON (${e && e.message ? e.message : e}).`,
387
- };
388
- }
389
-
390
- if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)
391
- || typeof parsed.bodyDigest !== 'string' || !parsed.bodyDigest
392
- || !parsed.graph || typeof parsed.graph !== 'object' || Array.isArray(parsed.graph)) {
393
- return {
394
- ok: false, graph: null, digest: null, digestMatches: null, reason: 'malformed',
395
- message: `Remote graph export at ${filePath} does not look like an \`exportGraphJSON\` artifact — expected top-level "bodyDigest" (string) and "graph" (object) fields. Run \`dataflow export --format json\` to produce a valid one.`,
396
- };
397
- }
398
-
399
- const { valid, errors } = validateGraph(parsed.graph);
400
- if (!valid) {
401
- return {
402
- ok: false, graph: null, digest: parsed.bodyDigest, digestMatches: null, reason: 'invalid-graph',
403
- message: `Remote graph export at ${filePath} does not contain a well-formed DataFlowGraph v1 document: ${errors.map((e) => `${e.path}: ${e.message}`).join('; ')}`,
404
- };
405
- }
406
-
407
- const recomputed = (0,export_json.computeGraphDigest)(parsed.graph);
408
- const digestMatches = recomputed === parsed.bodyDigest;
409
- if (!digestMatches) {
410
- return {
411
- ok: true, graph: parsed.graph, digest: parsed.bodyDigest, digestMatches: false, reason: 'digest-mismatch',
412
- message: 'WARNING: the remote export\'s embedded digest does not match its own content (self-consistency check failed) — this is NOT authentication, only a check that the file has not been altered since it was exported. Proceeding is a real trust decision the operator is making explicitly.',
413
- };
414
- }
415
-
416
- return { ok: true, graph: parsed.graph, digest: parsed.bodyDigest, digestMatches: true, reason: null, message: null };
417
- }
418
-
419
-
420
- /***/ })
421
-
422
- };