@clear-capabilities/agentic-security-scanner 0.185.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 (167) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/bin/agentic-security.js +24 -1
  3. package/dist/1128.index.js +25 -21
  4. package/dist/2584.index.js +1 -1
  5. package/dist/4171.index.js +2 -2
  6. package/dist/5752.index.js +466 -0
  7. package/dist/7405.index.js +1 -1
  8. package/dist/8158.index.js +1713 -0
  9. package/dist/8798.index.js +1 -1
  10. package/dist/9382.index.js +2 -2
  11. package/dist/9579.index.js +1 -1
  12. package/dist/agentic-security.mjs +29 -29
  13. package/dist/agentic-security.mjs.sha256 +1 -1
  14. package/dist/{0b301d45b231f144a1b4.json → ca62ee93079be4c24eee.json} +7 -7
  15. package/package.json +7 -7
  16. package/src/dataflow/CLAUDE.md +6 -3
  17. package/src/dataflow/access-paths.js +12 -2
  18. package/src/dataflow/demand-query.js +279 -40
  19. package/src/dataflow/dep-fingerprint.js +1 -1
  20. package/src/dataflow/exploit-prover.js +6 -2
  21. package/src/dataflow/ir-cache.js +268 -0
  22. package/src/dataflow/privacy-taint.js +7 -0
  23. package/src/engine.js +62 -5
  24. package/src/ir/CLAUDE.md +4 -0
  25. package/src/ir/callgraph.js +36 -8
  26. package/src/ir/index.js +18 -4
  27. package/src/ir/parser-js.js +10 -0
  28. package/src/language/CLAUDE.md +13 -0
  29. package/src/language/nix-option-types.js +170 -0
  30. package/src/language/nix-script-taint.js +46 -3
  31. package/src/language/nix-secrets.js +20 -2
  32. package/src/lineage/CLAUDE.md +2 -1
  33. package/src/lineage/smt-orchestrator.js +47 -11
  34. package/src/lineage/smt-z3-backend.js +294 -0
  35. package/src/posture/CLAUDE.md +5 -1
  36. package/src/posture/business-logic.js +16 -7
  37. package/src/posture/dag-commands.js +442 -0
  38. package/src/posture/finding-defaults.js +19 -0
  39. package/src/posture/git-history.js +91 -1
  40. package/src/sast/CLAUDE.md +2 -0
  41. package/src/sast/_call-args.js +70 -0
  42. package/src/sast/init-scope.js +87 -0
  43. package/src/sast/listen-bind-address.js +49 -0
  44. package/src/sast/redirect-target.js +106 -0
  45. package/src/sast/reflected-input.js +76 -0
  46. package/src/sast/send-file-root.js +27 -0
  47. package/src/sast/sensitive-data-logging.js +38 -1
  48. package/dist/119.index.js +0 -197
  49. package/dist/128.index.js +0 -129
  50. package/dist/1293.index.js +0 -5689
  51. package/dist/1336.index.js +0 -16331
  52. package/dist/1351.index.js +0 -133
  53. package/dist/1387.index.js +0 -271
  54. package/dist/1437.index.js +0 -23
  55. package/dist/1445.index.js +0 -110
  56. package/dist/1505.index.js +0 -151
  57. package/dist/1557.index.js +0 -293
  58. package/dist/1621.index.js +0 -311
  59. package/dist/1751.index.js +0 -160
  60. package/dist/1765.index.js +0 -727
  61. package/dist/1861.index.js +0 -690
  62. package/dist/1906.index.js +0 -433
  63. package/dist/208.index.js +0 -1631
  64. package/dist/2223.index.js +0 -159
  65. package/dist/2238.index.js +0 -295
  66. package/dist/2530.index.js +0 -152
  67. package/dist/2565.index.js +0 -116
  68. package/dist/2574.index.js +0 -127
  69. package/dist/2620.index.js +0 -345
  70. package/dist/2773.index.js +0 -98
  71. package/dist/2775.index.js +0 -32
  72. package/dist/2966.index.js +0 -171
  73. package/dist/2972.index.js +0 -87
  74. package/dist/2991.index.js +0 -131
  75. package/dist/3063.index.js +0 -833
  76. package/dist/3075.index.js +0 -227
  77. package/dist/3121.index.js +0 -297
  78. package/dist/3314.index.js +0 -263
  79. package/dist/3480.index.js +0 -1822
  80. package/dist/3481.index.js +0 -24
  81. package/dist/3506.index.js +0 -268
  82. package/dist/3533.index.js +0 -591
  83. package/dist/3653.index.js +0 -450
  84. package/dist/3740.index.js +0 -722
  85. package/dist/3822.index.js +0 -131
  86. package/dist/3868.index.js +0 -292
  87. package/dist/3918.index.js +0 -192
  88. package/dist/4090.index.js +0 -288
  89. package/dist/4113.index.js +0 -1286
  90. package/dist/4121.index.js +0 -1190
  91. package/dist/4142.index.js +0 -690
  92. package/dist/4168.index.js +0 -509
  93. package/dist/4281.index.js +0 -993
  94. package/dist/4336.index.js +0 -436
  95. package/dist/4387.index.js +0 -532
  96. package/dist/4413.index.js +0 -302
  97. package/dist/4476.index.js +0 -4510
  98. package/dist/4491.index.js +0 -133
  99. package/dist/4538.index.js +0 -185
  100. package/dist/4684.index.js +0 -319
  101. package/dist/4740.index.js +0 -165
  102. package/dist/4780.index.js +0 -209
  103. package/dist/4802.index.js +0 -225
  104. package/dist/4812.index.js +0 -379
  105. package/dist/4835.index.js +0 -126
  106. package/dist/494.index.js +0 -226
  107. package/dist/4991.index.js +0 -549
  108. package/dist/5199.index.js +0 -305
  109. package/dist/5216.index.js +0 -109
  110. package/dist/5439.index.js +0 -301
  111. package/dist/5443.index.js +0 -97
  112. package/dist/5496.index.js +0 -377
  113. package/dist/5738.index.js +0 -240
  114. package/dist/5801.index.js +0 -588
  115. package/dist/5817.index.js +0 -714
  116. package/dist/5858.index.js +0 -223
  117. package/dist/5933.index.js +0 -143
  118. package/dist/601.index.js +0 -23
  119. package/dist/6173.index.js +0 -273
  120. package/dist/6291.index.js +0 -1871
  121. package/dist/6312.index.js +0 -666
  122. package/dist/634.index.js +0 -16182
  123. package/dist/644.index.js +0 -87
  124. package/dist/6508.index.js +0 -283
  125. package/dist/6560.index.js +0 -645
  126. package/dist/6576.index.js +0 -422
  127. package/dist/6579.index.js +0 -271
  128. package/dist/6655.index.js +0 -3221
  129. package/dist/6745.index.js +0 -305
  130. package/dist/6818.index.js +0 -21642
  131. package/dist/6932.index.js +0 -1190
  132. package/dist/6972.index.js +0 -167
  133. package/dist/6995.index.js +0 -163
  134. package/dist/7249.index.js +0 -191
  135. package/dist/7372.index.js +0 -1197
  136. package/dist/7546.index.js +0 -541
  137. package/dist/76.index.js +0 -448
  138. package/dist/7879.index.js +0 -163
  139. package/dist/8025.index.js +0 -130
  140. package/dist/8054.index.js +0 -248
  141. package/dist/808.index.js +0 -1330
  142. package/dist/8097.index.js +0 -201
  143. package/dist/8126.index.js +0 -191
  144. package/dist/8178.index.js +0 -78
  145. package/dist/8382.index.js +0 -93
  146. package/dist/8408.index.js +0 -261
  147. package/dist/8540.index.js +0 -174
  148. package/dist/8635.index.js +0 -802
  149. package/dist/8688.index.js +0 -410
  150. package/dist/8699.index.js +0 -779
  151. package/dist/8891.index.js +0 -457
  152. package/dist/8916.index.js +0 -885
  153. package/dist/9146.index.js +0 -170
  154. package/dist/9168.index.js +0 -841
  155. package/dist/9292.index.js +0 -369
  156. package/dist/9422.index.js +0 -866
  157. package/dist/9440.index.js +0 -453
  158. package/dist/9479.index.js +0 -152
  159. package/dist/9481.index.js +0 -220
  160. package/dist/9539.index.js +0 -100
  161. package/dist/9547.index.js +0 -103
  162. package/dist/9692.index.js +0 -90
  163. package/dist/9800.index.js +0 -462
  164. package/dist/9899.index.js +0 -138
  165. package/dist/9981.index.js +0 -206
  166. package/dist/999.index.js +0 -117
  167. package/dist/9999.index.js +0 -1698
@@ -0,0 +1,466 @@
1
+ export const id = 5752;
2
+ export const ids = [5752];
3
+ export const modules = {
4
+
5
+ /***/ 25752:
6
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
+
8
+ __webpack_require__.r(__webpack_exports__);
9
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
+ /* harmony export */ cmdDataflowContracts: () => (/* binding */ cmdDataflowContracts),
11
+ /* harmony export */ cmdDataflowSinkQuery: () => (/* binding */ cmdDataflowSinkQuery),
12
+ /* harmony export */ cmdDataflowView: () => (/* binding */ cmdDataflowView),
13
+ /* harmony export */ cmdWitness: () => (/* binding */ cmdWitness),
14
+ /* harmony export */ planContract: () => (/* binding */ planContract)
15
+ /* harmony export */ });
16
+ /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73024);
17
+ /* harmony import */ var node_fs_promises__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(51455);
18
+ /* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(76760);
19
+ /* harmony import */ var _lineage_completion_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10276);
20
+ // dag-commands.js: explicit, opt-in CLI entry points for the DAG-PRD capabilities that used to be library-only.
21
+ //
22
+ // dataflow view typed graph view over the signed DataFlowGraph (DAG-06) plus SCC condensation (DAG-01)
23
+ // dataflow contracts boundary contracts bound to parser-resolved sites, consumer seeding (DAG-08)
24
+ // dataflow sink-query demand-driven reverse taint for one sink site (DAG-02)
25
+ // dataflow plan-cuts its completion contract (the command itself lives in bin/agentic-security.js) (DAG-09)
26
+ // witness build|verify signed, replayable path witness bundles (DAG-10)
27
+ //
28
+ // Rules every command here follows:
29
+ // * Nothing runs unless the user types the subcommand. A default scan never imports this module, so a default scan's
30
+ // output is unchanged.
31
+ // * Every report carries a completion record with the shared vocabulary complete | partial | cancelled | unavailable |
32
+ // invalid. "No path found" is never reported as "no vulnerability": `negativeClaimAllowed` is false unless the
33
+ // completion envelope proves an exhausted query over a complete model, and even then it is scoped to the modeled graph.
34
+ // * Exit codes: 0 a report was produced (read its completion status), 1 nothing usable could be produced (unavailable or
35
+ // invalid input data, a failed verification), 2 a usage error.
36
+ //
37
+ // Everything is read-only with respect to scan state. The only writes are the files the user names with --output / --out.
38
+
39
+
40
+
41
+
42
+
43
+
44
+ const err = (m) => process.stderr.write(`${m}\n`);
45
+
46
+ /** Write a JSON report to --output, or stdout. Returns an exit code on failure, null on success. */
47
+ async function emit(who, args, text) {
48
+ const out = args.flags.output;
49
+ if (out !== undefined && (typeof out !== 'string' || !out)) { err(`${who}: --output needs a path.`); return 2; }
50
+ if (!out) { process.stdout.write(text); return null; }
51
+ try {
52
+ await node_fs_promises__WEBPACK_IMPORTED_MODULE_1__.mkdir(node_path__WEBPACK_IMPORTED_MODULE_2__.dirname(node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(out)), { recursive: true });
53
+ await node_fs_promises__WEBPACK_IMPORTED_MODULE_1__.writeFile(node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(out), text);
54
+ } catch (e) { err(`${who}: could not write --output: ${e.message}`); return 2; }
55
+ return null;
56
+ }
57
+
58
+ function describe(who, completion) {
59
+ if (completion.status === 'complete') return;
60
+ err(`${who}: completion is ${completion.status}${completion.reasons.length ? ` (${completion.reasons.join(', ')})` : ''}. This is a statement about the modeled scope, not about the software.`);
61
+ }
62
+
63
+ const asInt = (v) => (v === undefined ? undefined : (/^\d+$/.test(String(v)) ? Number(v) : NaN));
64
+
65
+ // ---------------------------------------------------------------------------------------------------------------------
66
+ // plan-cuts completion contract (DAG-09)
67
+ // ---------------------------------------------------------------------------------------------------------------------
68
+
69
+ /**
70
+ * Completion contract for a cut plan. A plan is `complete` only when a finite cut exists AND the graph it was computed over is
71
+ * known complete. `no-flow` is `partial`: no modeled path between the selected sources and sinks is a statement about the
72
+ * model, never evidence of safety. A placement is hypothetical, so a negative claim is never allowed here.
73
+ */
74
+ function planContract(plan) {
75
+ const reasons = [];
76
+ if (plan.status !== 'complete-cut') reasons.push(`plan-${plan.status}`);
77
+ if (plan.status === 'no-flow') reasons.push('no-modeled-path');
78
+ for (const r of plan.completeness?.reasons ?? []) reasons.push(r.replace(/[^\w ,.:()-]/g, '').slice(0, 120));
79
+ const complete = plan.status === 'complete-cut' && plan.completeness?.complete === true && reasons.length === 0;
80
+ const c = (0,_lineage_completion_js__WEBPACK_IMPORTED_MODULE_3__/* .makeCompletion */ .Lv)({ status: complete ? 'complete' : 'partial', modelCoverage: plan.completeness?.complete ? 'complete' : 'partial', reasons, unit: 'cut-plan' });
81
+ return { ...c, negativeClaimAllowed: false, hypothetical: true, verified: false };
82
+ }
83
+
84
+ // ---------------------------------------------------------------------------------------------------------------------
85
+ // shared project loading (source -> IR -> call graph) for the commands that analyse code
86
+ // ---------------------------------------------------------------------------------------------------------------------
87
+
88
+ async function loadProgram(root) {
89
+ const { readTree } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 45950));
90
+ const { buildProjectIR } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 98297));
91
+ const tree = await readTree(root);
92
+ const ir = buildProjectIR(tree.fileContents);
93
+ return { fileContents: tree.fileContents, oversize: tree.oversize || [], perFile: ir.perFile, callGraph: ir.callGraph, cha: ir.cha };
94
+ }
95
+
96
+ // ---------------------------------------------------------------------------------------------------------------------
97
+ // dataflow view
98
+ // ---------------------------------------------------------------------------------------------------------------------
99
+
100
+ /**
101
+ * agentic-security dataflow view [path] [--node <id> [--direction in|out|both] [--relations a,b] [--origins a,b]] [--output <file>]
102
+ * Read-only over the signed lineage graph. Without --node it reports the view identity, counts, completion and the SCC
103
+ * condensation of the data-flow relation. With --node it lists the neighbours the filter allows.
104
+ */
105
+ async function cmdDataflowView(args) {
106
+ const who = 'agentic-security dataflow view';
107
+ const root = node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(args._[2] || '.');
108
+ const f = args.flags;
109
+ for (const k of ['node', 'direction', 'relations', 'origins']) {
110
+ if (f[k] !== undefined && (typeof f[k] !== 'string' || !f[k])) { err(`${who}: --${k} needs a value.`); return 2; }
111
+ }
112
+ const direction = f.direction || 'both';
113
+ if (!['in', 'out', 'both'].includes(direction)) { err(`${who}: --direction must be in, out or both.`); return 2; }
114
+ if (f.node === undefined && (f.direction || f.relations || f.origins)) { err(`${who}: --direction, --relations and --origins apply to --node.`); return 2; }
115
+
116
+ const { loadSignedGraph } = await __webpack_require__.e(/* import() */ 8218).then(__webpack_require__.bind(__webpack_require__, 78218));
117
+ const loaded = loadSignedGraph(root);
118
+ if (!loaded.ok) { err(`${who}: ${loaded.message}`); return 1; }
119
+ const { dataflowView, GraphViewError } = await __webpack_require__.e(/* import() */ 8158).then(__webpack_require__.bind(__webpack_require__, 88158));
120
+ const { computeScc, verifyScc } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 41418));
121
+
122
+ let view;
123
+ try { view = dataflowView(loaded.graph); } catch (e) { err(`${who}: the graph could not be viewed: ${e.message}`); return 1; }
124
+
125
+ const report = {
126
+ schema: 'agentic-security/graph-view-report@1',
127
+ maturity: 'preview',
128
+ identity: view.identity,
129
+ metadata: view.metadata(),
130
+ viewCompletion: view.completion(),
131
+ note: 'A view is a read-only lens over the signed graph. An absent edge means the model has no such edge, not that the software has none.',
132
+ };
133
+ const completion = (0,_lineage_completion_js__WEBPACK_IMPORTED_MODULE_3__.completionOfGraph)(loaded.graph);
134
+
135
+ if (f.node === undefined) {
136
+ const nodeIds = view.entities('node').map((e) => e.localId);
137
+ const edges = view.edges().filter((e) => e.relation === 'data_flow' && e.origin !== 'observed' && e.origin !== 'declared');
138
+ const pairs = edges.map((e) => [e.from.localId, e.to.localId]);
139
+ const known = new Set(nodeIds);
140
+ const scc = computeScc({ nodes: nodeIds, edges: pairs.filter(([a, b]) => known.has(a) && known.has(b)) });
141
+ const verify = verifyScc({ nodes: nodeIds, edges: pairs.filter(([a, b]) => known.has(a) && known.has(b)) }, scc);
142
+ const recursive = scc.components.filter((c) => c.recursive);
143
+ report.condensation = {
144
+ relation: 'data_flow',
145
+ origins: ['code', 'derived', 'schema'],
146
+ nodeCount: nodeIds.length,
147
+ componentCount: scc.components.length,
148
+ cyclicComponentCount: recursive.length,
149
+ cyclicComponents: recursive.slice(0, 20).map((c) => c.members),
150
+ isAcyclic: recursive.length === 0,
151
+ condensationEdgeCount: scc.condensationEdges.length,
152
+ verified: verify.ok === true,
153
+ verificationProblems: verify.problems.slice(0, 5),
154
+ note: 'The raw graph is preserved. The condensation is a derived view, acyclic by construction; a cyclic component is reported, never removed.',
155
+ };
156
+ } else {
157
+ const filter = { relations: f.relations ? f.relations.split(',').map((s) => s.trim()).filter(Boolean) : undefined, origins: f.origins ? f.origins.split(',').map((s) => s.trim()).filter(Boolean) : undefined };
158
+ try {
159
+ const ref = view.ref('node', f.node);
160
+ const lite = (e) => ({ id: e.id, relation: e.relation, origin: e.origin, from: e.from.localId, to: e.to.localId, evidence: e.evidence, unknowns: e.unknowns });
161
+ report.query = {
162
+ node: view.node(ref).summary ?? null, nodeId: f.node, direction, filter,
163
+ incoming: direction === 'out' ? undefined : view.incoming(ref, filter).map(lite),
164
+ outgoing: direction === 'in' ? undefined : view.outgoing(ref, filter).map(lite),
165
+ };
166
+ } catch (e) {
167
+ if (e instanceof GraphViewError) {
168
+ report.completion = (0,_lineage_completion_js__WEBPACK_IMPORTED_MODULE_3__/* .makeCompletion */ .Lv)({ status: 'invalid', reasons: [`graph-view-${String(e.code).toLowerCase()}`], unit: 'graph-view' });
169
+ const code = await emit(who, args, JSON.stringify(report, null, 2) + '\n');
170
+ err(`${who}: ${e.message}`);
171
+ return code ?? 1;
172
+ }
173
+ throw e;
174
+ }
175
+ }
176
+ report.completion = { ...completion, negativeClaimAllowed: false };
177
+ const code = await emit(who, args, JSON.stringify(report, null, 2) + '\n');
178
+ if (code !== null) return code;
179
+ describe(who, completion);
180
+ return 0;
181
+ }
182
+
183
+ // ---------------------------------------------------------------------------------------------------------------------
184
+ // dataflow contracts
185
+ // ---------------------------------------------------------------------------------------------------------------------
186
+
187
+ /**
188
+ * agentic-security dataflow contracts [path] [--contracts <file>] [--output <file>]
189
+ * Binds boundary contracts to parser-resolved sites and runs the taint engine with the consumer fields seeded. A declaration
190
+ * is a MODELED input: every attribution carries modeledInput:true, observed:false, exploited:false. A contract that does not
191
+ * bind becomes a coverage gap and never a finding.
192
+ */
193
+ async function cmdDataflowContracts(args) {
194
+ const who = 'agentic-security dataflow contracts';
195
+ const root = node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(args._[2] || '.');
196
+ const f = args.flags;
197
+ if (f.contracts !== undefined && (typeof f.contracts !== 'string' || !f.contracts)) { err(`${who}: --contracts needs a path.`); return 2; }
198
+ const { BOUNDARY_CONTRACTS_FILENAME, validateBoundaryContract, analyzeServiceBoundaries } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 37387));
199
+ const { statePath } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 31174));
200
+
201
+ const file = f.contracts ? node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(f.contracts) : statePath(root, BOUNDARY_CONTRACTS_FILENAME);
202
+ let text;
203
+ try { text = node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(file, 'utf8'); } catch {
204
+ const completion = (0,_lineage_completion_js__WEBPACK_IMPORTED_MODULE_3__/* .makeCompletion */ .Lv)({ status: 'unavailable', reasons: ['no-contracts-file'], unit: 'boundary-contracts' });
205
+ const code = await emit(who, args, JSON.stringify({ schema: 'agentic-security/boundary-contracts-report@1', maturity: 'preview', contractsFile: file, completion: { ...completion, negativeClaimAllowed: false }, findings: [], note: 'No contracts were read, so nothing was analysed. This says nothing about the software.' }, null, 2) + '\n');
206
+ err(`${who}: no contracts file at ${file}. Pass --contracts <file> or write ${BOUNDARY_CONTRACTS_FILENAME} under the project state directory.`);
207
+ return code ?? 1;
208
+ }
209
+ let contracts;
210
+ try {
211
+ const doc = JSON.parse(text);
212
+ contracts = Array.isArray(doc) ? doc : Array.isArray(doc && doc.contracts) ? doc.contracts : null;
213
+ if (!contracts) throw new Error('expected a JSON array of contracts or { "contracts": [...] }');
214
+ } catch (e) { err(`${who}: ${file} is not a usable contracts document: ${e.message}`); return 2; }
215
+
216
+ const program = await loadProgram(root);
217
+ const { runBoundaryTaint } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 38588));
218
+ const res = runBoundaryTaint(program.perFile, program.callGraph, contracts, { scanRoot: root, engine: { _cha: program.cha || undefined } });
219
+
220
+ const reasons = [];
221
+ if (res.rejected.length) reasons.push('rejected-contracts');
222
+ if (res.gaps.length) reasons.push('unbound-boundary');
223
+ if (res.coverage.truncated) reasons.push('engine-run-budget');
224
+ if (program.oversize.length) reasons.push('oversize-source-skipped');
225
+ if (contracts.length === 0) reasons.push('no-contracts');
226
+ const status = contracts.length === 0 || (res.rejected.length === contracts.length) ? 'unavailable' : reasons.length ? 'partial' : 'complete';
227
+ const completion = { ...(0,_lineage_completion_js__WEBPACK_IMPORTED_MODULE_3__/* .makeCompletion */ .Lv)({ status, reasons, unit: 'boundary-contracts' }), negativeClaimAllowed: false };
228
+
229
+ const valid = contracts.filter((c) => validateBoundaryContract(c).valid);
230
+ const report = {
231
+ schema: 'agentic-security/boundary-contracts-report@1',
232
+ maturity: 'preview',
233
+ contractsFile: file,
234
+ completion,
235
+ coverage: res.coverage,
236
+ bindings: res.bindings.map((b) => ({ contractId: b.contractId, kind: b.kind, persistence: b.persistence, channel: b.channel, file: b.file, line: b.line, param: b.param, seeds: b.seeds, mappedFields: b.mappedFields, evidence: b.evidence })),
237
+ gaps: res.gaps,
238
+ rejected: res.rejected,
239
+ findings: res.findings.map((x) => ({ id: x.id, severity: x.severity, file: x.file, line: x.line, vuln: x.vuln, cwe: x.cwe, boundary: x.boundary })),
240
+ services: analyzeServiceBoundaries(valid),
241
+ notes: [
242
+ 'A contract declaration establishes a modeled untrusted input at the consumer. It does not establish that any value was observed or that the sink is exploited.',
243
+ 'No finding does not mean the consumer is safe: only the declared fields were seeded, only the modeled sinks were checked.',
244
+ ],
245
+ };
246
+ const code = await emit(who, args, JSON.stringify(report, null, 2) + '\n');
247
+ if (code !== null) return code;
248
+ describe(who, completion);
249
+ return status === 'unavailable' ? 1 : 0;
250
+ }
251
+
252
+ // ---------------------------------------------------------------------------------------------------------------------
253
+ // dataflow sink-query
254
+ // ---------------------------------------------------------------------------------------------------------------------
255
+
256
+ /**
257
+ * agentic-security dataflow sink-query [path] (--list | --file <rel> --line <n>) [--mode demand|full|compare]
258
+ * [--arg-index <n>] [--sink-id <id>] [--access-path <p>] [--rule-family <cwe|family>] [--max-work <n>] [--max-caller-depth <n>]
259
+ * [--on-limit full|partial] [--output <file>]
260
+ * Answers "can attacker data reach this sink?" by selecting the backward demand region and running the ordinary forward taint
261
+ * engine over it. The only witness is a finding the forward engine produced. Verdicts: flow-found, no-flow-in-modeled-scope
262
+ * (only when the completion envelope allows a negative claim) and unknown. There is no "safe".
263
+ */
264
+ async function cmdDataflowSinkQuery(args) {
265
+ const who = 'agentic-security dataflow sink-query';
266
+ const root = node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(args._[2] || '.');
267
+ const f = args.flags;
268
+ const mode = f.mode || 'demand';
269
+ if (!['demand', 'full', 'compare'].includes(mode)) { err(`${who}: --mode must be demand, full or compare.`); return 2; }
270
+ for (const k of ['file', 'sink-id', 'access-path', 'rule-family']) {
271
+ if (f[k] !== undefined && (typeof f[k] !== 'string' || !f[k])) { err(`${who}: --${k} needs a value.`); return 2; }
272
+ }
273
+ const nums = { line: asInt(f.line), argIndex: asInt(f['arg-index']), maxWork: asInt(f['max-work']), maxCallerDepth: asInt(f['max-caller-depth']) };
274
+ for (const [k, v] of Object.entries(nums)) if (Number.isNaN(v)) { err(`${who}: --${k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)} must be a non-negative integer.`); return 2; }
275
+ const onLimit = f['on-limit'] || 'full';
276
+ if (!['full', 'partial'].includes(onLimit)) { err(`${who}: --on-limit must be full or partial.`); return 2; }
277
+ if (!f.list && (!f.file || nums.line === undefined)) { err(`Usage: ${who} [path] (--list | --file <rel> --line <n>) [--mode demand|full|compare] [--arg-index <n>] [--sink-id <id>] [--access-path <p>] [--rule-family <f>] [--max-work <n>] [--max-caller-depth <n>] [--on-limit full|partial] [--output <file>]`); return 2; }
278
+
279
+ const program = await loadProgram(root);
280
+ const dq = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 22929));
281
+ if (!program.callGraph || !program.callGraph.functions || program.callGraph.functions.size === 0) {
282
+ const completion = { ...(0,_lineage_completion_js__WEBPACK_IMPORTED_MODULE_3__/* .makeCompletion */ .Lv)({ status: 'unavailable', reasons: ['no-call-graph'], unit: 'demand-query' }), negativeClaimAllowed: false };
283
+ const code = await emit(who, args, JSON.stringify({ schema: 'agentic-security/sink-query-report@1', maturity: 'preview', completion, verdict: 'unknown', note: 'No analyzable functions were found, so nothing was queried.' }, null, 2) + '\n');
284
+ err(`${who}: no analyzable functions under ${root}.`);
285
+ return code ?? 1;
286
+ }
287
+ if (f.list) {
288
+ const sites = dq.enumerateSinkQueries(program.callGraph);
289
+ const code = await emit(who, args, JSON.stringify({ schema: 'agentic-security/sink-query-report@1', maturity: 'preview', sites, count: sites.length, note: 'Sink sites the call graph and catalog recognise. A site that is not listed may still be a sink the catalog does not model.' }, null, 2) + '\n');
290
+ return code ?? 0;
291
+ }
292
+ const query = { file: f.file.replace(/^\.\//, ''), line: nums.line, argIndex: nums.argIndex ?? null, sinkId: f['sink-id'] ?? null, accessPath: f['access-path'] ?? null, ruleFamily: f['rule-family'] ?? null };
293
+ const opts = { cache: false, onLimit, engineOpts: { _cha: program.cha || undefined } };
294
+ if (nums.maxWork !== undefined) opts.maxWork = nums.maxWork;
295
+ if (nums.maxCallerDepth !== undefined) opts.maxCallerDepth = nums.maxCallerDepth;
296
+
297
+ const result = {};
298
+ if (mode === 'demand' || mode === 'compare') result.demand = dq.runDemandSinkQuery(program.perFile, program.callGraph, query, opts);
299
+ if (mode === 'full' || mode === 'compare') result.full = dq.runFullSinkQuery(program.perFile, program.callGraph, query, opts);
300
+ if (mode === 'compare') result.comparison = dq.compareToFull(result.demand, result.full);
301
+ const primary = result.demand || result.full;
302
+ // The full-set run has no frontier, so its completion is the engine's own incomplete list.
303
+ const completion = result.demand
304
+ ? { ...result.demand.completion, negativeClaimAllowed: result.demand.negativeClaimAllowed === true }
305
+ : { ...(0,_lineage_completion_js__WEBPACK_IMPORTED_MODULE_3__/* .makeCompletion */ .Lv)({ status: primary.sites.length === 0 ? 'unavailable' : (primary.engineIncomplete || []).length ? 'partial' : 'complete', reasons: primary.sites.length === 0 ? ['sink-site-not-found'] : (primary.engineIncomplete || []).map((r) => `engine:${r}`), unit: 'full-sink-query' }), negativeClaimAllowed: false };
306
+ const report = {
307
+ schema: 'agentic-security/sink-query-report@1',
308
+ maturity: 'preview',
309
+ optIn: 'explicit subcommand; a default scan never runs this',
310
+ mode,
311
+ query,
312
+ completion,
313
+ verdict: result.demand ? result.demand.verdict : (primary.findings.length ? 'flow-found' : 'unknown'),
314
+ ...result,
315
+ notes: [
316
+ 'A backward and forward intersection is a candidate filter only. The witness is a finding the forward engine produced over the selected region.',
317
+ 'no-flow-in-modeled-scope is scoped to the modeled call graph. It is never a statement that the sink is safe.',
318
+ ],
319
+ };
320
+ const code = await emit(who, args, JSON.stringify(report, null, 2) + '\n');
321
+ if (code !== null) return code;
322
+ describe(who, completion);
323
+ return completion.status === 'unavailable' ? 1 : 0;
324
+ }
325
+
326
+ // ---------------------------------------------------------------------------------------------------------------------
327
+ // witness build | verify
328
+ // ---------------------------------------------------------------------------------------------------------------------
329
+
330
+ function insideRoot(root, rel) {
331
+ const abs = node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(root, rel);
332
+ return abs === root || abs.startsWith(root + node_path__WEBPACK_IMPORTED_MODULE_2__.sep) ? abs : null;
333
+ }
334
+
335
+ /**
336
+ * agentic-security witness build [path] --out <dir> [--sink <pnodeId>] [--list-sinks]
337
+ * Re-runs the field-identity analysis over the project (the hop stream is not persisted by a normal scan), reconstructs a
338
+ * bounded path, and writes <dir>/witness.json (signed with the install's Ed25519 attestation key) plus the artifacts replay
339
+ * needs: <dir>/artifacts/graph.json and <dir>/artifacts/provenance.json. Source blobs are bound by digest and re-read from
340
+ * the project at verify time; they are not copied.
341
+ */
342
+ async function witnessBuild(args) {
343
+ const who = 'agentic-security witness build';
344
+ const root = node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(args._[2] || '.');
345
+ const f = args.flags;
346
+ for (const k of ['out', 'sink']) if (f[k] !== undefined && (typeof f[k] !== 'string' || !f[k])) { err(`${who}: --${k} needs a value.`); return 2; }
347
+ if (!f.out && !f['list-sinks']) { err(`Usage: ${who} [path] --out <dir> [--sink <pnodeId>] | --list-sinks`); return 2; }
348
+
349
+ const program = await loadProgram(root);
350
+ const { buildDataFlowGraph } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 37746));
351
+ const { sinkCandidates, reconstructPaths } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 444));
352
+ const { buildWitnessBundle, signWitnessBundle, exportProvenanceArtifact } = await __webpack_require__.e(/* import() */ 1128).then(__webpack_require__.bind(__webpack_require__, 91128));
353
+ if (!program.callGraph || !program.callGraph.functions || program.callGraph.functions.size === 0) {
354
+ err(`${who}: unavailable: no analyzable functions under ${root}. Nothing was analysed, which says nothing about the software.`);
355
+ return 1;
356
+ }
357
+ const built = buildDataFlowGraph(program.callGraph, { repository: node_path__WEBPACK_IMPORTED_MODULE_2__.basename(root) || 'repo' });
358
+ const { graph, store, hops } = built;
359
+ const incomplete = built.analysisCompletion?.incomplete || [];
360
+ const provenance = exportProvenanceArtifact({ hops, incomplete });
361
+ const sinks = sinkCandidates(store).filter((n) => n.kind === 'escape');
362
+
363
+ if (f['list-sinks']) {
364
+ const code = await emit(who, args, JSON.stringify({ schema: 'agentic-security/witness-sinks@1', maturity: 'preview', sinks: sinks.map((n) => ({ id: n.id, kind: n.kind, scope: n.scope, path: n.path ?? null })) }, null, 2) + '\n');
365
+ return code ?? 0;
366
+ }
367
+ const pool = f.sink ? sinks.filter((n) => n.id === f.sink) : sinks;
368
+ if (f.sink && pool.length === 0) { err(`${who}: invalid: ${f.sink} is not a sink candidate (use --list-sinks).`); return 2; }
369
+
370
+ let chosen = null;
371
+ for (const s of pool) {
372
+ const result = reconstructPaths(store, s.id, {});
373
+ const withEdges = (result.paths || []).filter((p) => (p.edgeIds || []).length > 0);
374
+ const path0 = withEdges.find((p) => p.crossScopeCount > 0) || withEdges[0];
375
+ if (path0) { chosen = { result, path: path0, sink: s }; break; }
376
+ }
377
+ if (!chosen) {
378
+ err(`${who}: unavailable: the analysis found no modeled path to witness (${sinks.length} sink candidate(s)). This is a statement about the model, not evidence that the software is safe.`);
379
+ return 1;
380
+ }
381
+ const sourceBlobs = {};
382
+ for (const [file, content] of Object.entries(program.fileContents)) sourceBlobs[file] = content;
383
+ const b = buildWitnessBundle({ result: chosen.result, path: chosen.path, store, graph, provenance, sourceBlobs });
384
+ if (!b.ok) { err(`${who}: invalid: ${b.reason}`); return 1; }
385
+
386
+ const { ensureKeyPair } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 98317));
387
+ const kp = ensureKeyPair();
388
+ if (kp.created) err(`Generated a new signing key at ${kp.privateKey} (public: ${kp.publicKey}).`);
389
+ const signed = signWitnessBundle(b.bundle, kp.privateKeyPem);
390
+
391
+ const outDir = node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(f.out);
392
+ try {
393
+ node_fs__WEBPACK_IMPORTED_MODULE_0__.mkdirSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(outDir, 'artifacts'), { recursive: true });
394
+ node_fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(outDir, 'witness.json'), JSON.stringify(signed, null, 2) + '\n');
395
+ node_fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(outDir, 'artifacts', 'graph.json'), JSON.stringify(graph));
396
+ node_fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(outDir, 'artifacts', 'provenance.json'), JSON.stringify(provenance));
397
+ } catch (e) { err(`${who}: could not write --out: ${e.message}`); return 2; }
398
+
399
+ const overall = signed.completion?.overall || 'partial';
400
+ console.log(`Wrote ${node_path__WEBPACK_IMPORTED_MODULE_2__.join(outDir, 'witness.json')} (completion: ${overall}).`);
401
+ console.log(`Public key (share this with whoever verifies): ${kp.publicKey}`);
402
+ if (overall !== 'complete') err(`${who}: completion is ${overall}. A partial witness never supports a "no vulnerability" claim.`);
403
+ console.log('A valid signature proves the bundle is unmodified. It does not prove the finding is real or exploitable.');
404
+ return 0;
405
+ }
406
+
407
+ /**
408
+ * agentic-security witness verify <bundle.json> [--public-key <path>] [--artifacts <dir>] [--root <project>] [--json]
409
+ * Integrity check with a public key; with --artifacts also an offline replay of every edge against the recorded artifacts.
410
+ * Source blobs are read from --root (default: none, which fails replay honestly when the bundle binds sources).
411
+ */
412
+ async function witnessVerify(args) {
413
+ const who = 'agentic-security witness verify';
414
+ const f = args.flags;
415
+ const file = f.bundle || args._[2];
416
+ if (!file || typeof file !== 'string') { err(`Usage: ${who} <bundle.json> [--public-key <path>] [--artifacts <dir>] [--root <project>] [--json]`); return 2; }
417
+ const { parseWitnessBundle, verifyWitness } = await __webpack_require__.e(/* import() */ 1128).then(__webpack_require__.bind(__webpack_require__, 91128));
418
+ const { keyPaths } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 98317));
419
+ let text;
420
+ try { text = node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(file), 'utf8'); } catch (e) { err(`${who}: could not read bundle: ${e.message}`); return 2; }
421
+ const parsed = parseWitnessBundle(text);
422
+ if (!parsed.ok) { err(`${who}: invalid: ${parsed.reason}`); return 1; }
423
+ const keyFile = f['public-key'] || keyPaths().publicKey;
424
+ let pub;
425
+ try { pub = node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(keyFile), 'utf8'); } catch { err(`${who}: could not read public key at ${keyFile}. Pass --public-key <path>.`); return 2; }
426
+
427
+ let artifacts = null;
428
+ if (f.artifacts !== undefined) {
429
+ if (typeof f.artifacts !== 'string' || !f.artifacts) { err(`${who}: --artifacts needs a directory.`); return 2; }
430
+ const dir = node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(f.artifacts);
431
+ try {
432
+ artifacts = { graph: JSON.parse(node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(dir, 'graph.json'), 'utf8')), provenance: JSON.parse(node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(dir, 'provenance.json'), 'utf8')), sources: {} };
433
+ } catch (e) { err(`${who}: could not read artifacts in ${dir}: ${e.message}`); return 2; }
434
+ if (f.root) {
435
+ const root = node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(String(f.root));
436
+ for (const s of parsed.bundle.sources || []) {
437
+ const abs = typeof s.file === 'string' ? insideRoot(root, s.file) : null;
438
+ if (!abs) continue;
439
+ try { if (node_fs__WEBPACK_IMPORTED_MODULE_0__.lstatSync(abs).isFile()) artifacts.sources[s.file] = node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(abs); } catch { /* a missing blob fails replay by name */ }
440
+ }
441
+ }
442
+ }
443
+ const res = verifyWitness(parsed.bundle, pub, artifacts);
444
+ if (f.json) process.stdout.write(JSON.stringify({ schema: 'agentic-security/witness-verification@1', verdict: res.verdict, ok: res.ok, signature: res.signature, replay: res.replay, completion: parsed.bundle.completion?.overall ?? null, evidence: parsed.bundle.evidence, statement: res.statement }, null, 2) + '\n');
445
+ else {
446
+ console.log(res.ok ? `VALID (${res.verdict})` : `INVALID (${res.verdict}): ${res.signature.ok ? res.replay.failures.map((x) => `${x.code}: ${x.detail}`).join('; ') : res.signature.reason}`);
447
+ console.log(` bundle completion: ${parsed.bundle.completion?.overall}`);
448
+ for (const [k, v] of Object.entries(parsed.bundle.evidence || {})) console.log(` ${k}: ${v.status}`);
449
+ if (res.verdict === 'integrity-only') console.log(' Replay was not performed. Pass --artifacts <dir> --root <project> to re-derive the path.');
450
+ console.log(` ${res.statement.doesNotProve}`);
451
+ }
452
+ return res.ok ? 0 : 1;
453
+ }
454
+
455
+ async function cmdWitness(args) {
456
+ const sub = args._[1];
457
+ if (sub === 'build') return witnessBuild(args);
458
+ if (sub === 'verify') return witnessVerify(args);
459
+ err(`agentic-security witness: unrecognized sub-command "${sub}"; must be "build" or "verify".`);
460
+ return 2;
461
+ }
462
+
463
+
464
+ /***/ })
465
+
466
+ };
@@ -275,7 +275,7 @@ __webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
275
275
  /* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(76760);
276
276
  /* harmony import */ var _runScan_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(45950);
277
277
  /* harmony import */ var _posture_state_dir_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(31174);
278
- /* harmony import */ var _ir_index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(28149);
278
+ /* harmony import */ var _ir_index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(98297);
279
279
  /* harmony import */ var _discovery_index_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(99579);
280
280
  /* harmony import */ var _build_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(70123);
281
281
  /* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(33238);