@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,220 +0,0 @@
1
- export const id = 9481;
2
- export const ids = [9481];
3
- export const modules = {
4
-
5
- /***/ 39481:
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 */ PROOF_MARKER: () => (/* binding */ PROOF_MARKER),
11
- /* harmony export */ WITNESS_STATUS: () => (/* binding */ WITNESS_STATUS),
12
- /* harmony export */ WITNESS_VERSION: () => (/* binding */ WITNESS_VERSION),
13
- /* harmony export */ buildNixScriptWitness: () => (/* binding */ buildNixScriptWitness),
14
- /* harmony export */ haskellRunner: () => (/* binding */ haskellRunner),
15
- /* harmony export */ judgeFixWitness: () => (/* binding */ judgeFixWitness),
16
- /* harmony export */ nixFixWitness: () => (/* binding */ nixFixWitness),
17
- /* harmony export */ nixFlowTarget: () => (/* binding */ nixFlowTarget),
18
- /* harmony export */ runHaskellWitness: () => (/* binding */ runHaskellWitness),
19
- /* harmony export */ runNixScriptWitness: () => (/* binding */ runNixScriptWitness),
20
- /* harmony export */ witnessNixFlow: () => (/* binding */ witnessNixFlow),
21
- /* harmony export */ witnessPayload: () => (/* binding */ witnessPayload)
22
- /* harmony export */ });
23
- /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73024);
24
- /* harmony import */ var node_os__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(48161);
25
- /* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(76760);
26
- /* harmony import */ var node_child_process__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(31421);
27
- /* harmony import */ var _sandbox_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(99583);
28
- /* harmony import */ var _nix_script_taint_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(89928);
29
- // Controlled proof witnesses for Haskell and Nix findings (X-009).
30
- //
31
- // A witness is a small, bounded program that DEMONSTRATES the predicted effect inside the confinement sandbox
32
- // (src/sandbox: writes confined to a temporary root, no network, wall-clock and resource limits, fail-closed when no
33
- // primitive is available). The effect is always the same observable: the witness payload creates the marker file
34
- // `PROVEN` in its working directory. Nothing else counts.
35
- //
36
- // Supported witnesses, stated explicitly:
37
- //
38
- // nix-shell A shell script a Nix expression generates (systemd script, build phase). The generated script text is
39
- // taken from the NIX-003 analysis, the interpolation the finding concerns is replaced by an attacker
40
- // payload shaped for its shell context and passed through the SAME escaping the Nix code applies
41
- // (lib.escapeShellArg), and the script is run for real by the host shell. The payload is only shell
42
- // text: it runs only inside the sandbox, and only `touch PROVEN` is ever asked of it.
43
- // haskell Needs a Haskell toolchain (runghc). Without one the result is `unavailable`, which is neither proof
44
- // nor refutation. This module never installs or downloads a toolchain.
45
- //
46
- // What is NOT proof, ever: a syntax error in the witness, a missing executable, a sandbox that could not start or was
47
- // refused, a timeout or resource limit, or an output cap. Each is reported as `invalid` with its reason and leaves
48
- // the finding's static proof tier unchanged. Only the marker proves; its absence after a clean run is
49
- // `not-reproduced`, which is evidence about THIS witness, not a proof that the code is safe.
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
- const WITNESS_VERSION = 'language-witness/1';
59
- const PROOF_MARKER = 'PROVEN';
60
- const WITNESS_STATUS = Object.freeze(['reproduced', 'not-reproduced', 'invalid', 'unavailable', 'unsupported']);
61
- const SHELLS = new Set(['bash', 'sh', 'dash', 'ash', 'ksh', 'mksh']);
62
- const DEFAULT_TIMEOUT_MS = 20_000;
63
- const MAX_SCRIPT_BYTES = 256 * 1024;
64
-
65
- const shEscape = (s) => `'${String(s).replace(/'/g, `'\\''`)}'`;
66
-
67
- /** The text one placeholder takes in the generated script, given the Nix-side protection and the shell context. */
68
- function witnessPayload(context, protection) {
69
- const cmd = `touch ${PROOF_MARKER}`;
70
- let raw;
71
- if (context === 'single') raw = `'; ${cmd}; echo '`;
72
- else if (context === 'double') raw = `$(${cmd})`;
73
- else raw = `$(${cmd})`;
74
- // escapeShellArg(s) wraps in single quotes at EVALUATION time, before the shell ever sees the text. The shell then
75
- // reads that result inside whatever quote context the script put it in, which is exactly the wrong-context case.
76
- if (protection === 'escapeShellArg') return shEscape(raw);
77
- if (protection === 'escapeShellArgs') return shEscape(raw);
78
- return raw;
79
- }
80
-
81
- const placeholderIndexes = (text) => { const out = []; for (let i = 0; i < text.length; i++) if (text[i] === _nix_script_taint_js__WEBPACK_IMPORTED_MODULE_5__/* .SHELL_PLACEHOLDER */ .v0) out.push(i); return out; };
82
- const indexOfPosition = (text, line, col) => { let l = 1; let i = 0; while (i < text.length && l < line) { if (text[i] === '\n') l++; i++; } return i + col; };
83
-
84
- /**
85
- * Builds a witness for one flow of one generated script.
86
- * @param {{script:{generated:string, shell:string|null, attrPath:string, file:string}, flow:{generatedLocation:{line:number,startColumn:number}, context:string, protection:string|null}}} t
87
- */
88
- function buildNixScriptWitness({ script, flow }) {
89
- if (!script || typeof script.generated !== 'string' || !flow || !flow.generatedLocation) return { status: 'unsupported', reason: 'the flow has no generated-script location' };
90
- const shell = script.shell || 'bash';
91
- if (!SHELLS.has(shell)) return { status: 'unsupported', reason: `shell "${shell}" is not supported by the witness runner` };
92
- if (Buffer.byteLength(script.generated) > MAX_SCRIPT_BYTES) return { status: 'unsupported', reason: 'the generated script exceeds the witness size limit' };
93
- const all = placeholderIndexes(script.generated);
94
- const at = indexOfPosition(script.generated, flow.generatedLocation.line, flow.generatedLocation.startColumn);
95
- const ordinal = all.indexOf(at);
96
- if (ordinal < 0) return { status: 'unsupported', reason: 'the flow location does not match an interpolation in the generated script' };
97
- const payload = witnessPayload(flow.context, flow.protection);
98
- let out = ''; let n = 0;
99
- for (const ch of script.generated) { if (ch === _nix_script_taint_js__WEBPACK_IMPORTED_MODULE_5__/* .SHELL_PLACEHOLDER */ .v0) { out += n === ordinal ? payload : 'benign'; n++; } else out += ch; }
100
- const body = out.replace(/^#!.*\n/, '');
101
- return { status: 'ready', lang: 'nix-shell', shell, ordinal, attrPath: script.attrPath, file: script.file, payload, code: `${body}\n`, context: flow.context, protection: flow.protection || null };
102
- }
103
-
104
- function which(name) {
105
- for (const d of String(process.env.PATH || '').split(node_path__WEBPACK_IMPORTED_MODULE_2__.delimiter)) { const p = node_path__WEBPACK_IMPORTED_MODULE_2__.join(d, name); try { node_fs__WEBPACK_IMPORTED_MODULE_0__.accessSync(p, node_fs__WEBPACK_IMPORTED_MODULE_0__.constants.X_OK); return p; } catch { /* next */ } }
106
- return null;
107
- }
108
-
109
- /** Runs a witness built by buildNixScriptWitness inside the confinement sandbox. Never throws. */
110
- function runNixScriptWitness(w, { timeoutMs = DEFAULT_TIMEOUT_MS, force } = {}) {
111
- const base = { witness: WITNESS_VERSION, lang: 'nix-shell', ran: false, backend: null, marker: PROOF_MARKER };
112
- if (!w || w.status !== 'ready') return { ...base, status: w && w.status === 'unsupported' ? 'unsupported' : 'invalid', reason: (w && w.reason) || 'no witness' };
113
- const shellBin = which(w.shell);
114
- if (!shellBin) return { ...base, status: 'invalid', reason: `executable not found: ${w.shell}` };
115
- if (!(0,_sandbox_index_js__WEBPACK_IMPORTED_MODULE_4__/* .sandboxAvailable */ .$G)()) return { ...base, status: 'invalid', reason: 'no confinement primitive available; refusing to execute' };
116
- let root;
117
- try {
118
- root = node_fs__WEBPACK_IMPORTED_MODULE_0__.realpathSync(node_fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(node_os__WEBPACK_IMPORTED_MODULE_1__.tmpdir(), 'witness-')));
119
- node_fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(root, 'witness.sh'), w.code, 'utf8');
120
- // 1. a witness that does not parse proves nothing in either direction
121
- const syn = (0,_sandbox_index_js__WEBPACK_IMPORTED_MODULE_4__/* .runConfined */ .id)([shellBin, '-n', 'witness.sh'], { root, timeoutMs, force });
122
- if (syn.status === 'disabled' || syn.status === 'error') return { ...base, backend: syn.backend, status: 'invalid', reason: `the sandbox could not run the syntax check (${syn.backend}): ${String(syn.stderr || '').trim() || 'no detail'}` };
123
- if (syn.timedOut) return { ...base, backend: syn.backend, status: 'invalid', reason: 'the syntax check exceeded its time budget', timedOut: true };
124
- if (syn.exitCode !== 0) return { ...base, backend: syn.backend, status: 'invalid', reason: `syntax error in the generated witness: ${String(syn.stderr || '').trim().split('\n')[0] || 'shell rejected it'}` };
125
- // 2. the real run
126
- const r = (0,_sandbox_index_js__WEBPACK_IMPORTED_MODULE_4__/* .runConfined */ .id)([shellBin, 'witness.sh'], { root, timeoutMs, force });
127
- const ran = !r.timedOut && r.status !== 'disabled' && r.status !== 'error';
128
- if (!ran) return { ...base, backend: r.backend, status: 'invalid', reason: r.timedOut ? 'the witness exceeded its time budget' : `the sandbox could not execute it (${r.backend}): ${String(r.stderr || '').trim() || r.status}`, timedOut: !!r.timedOut };
129
- const proven = node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(root, PROOF_MARKER));
130
- return { ...base, ran: true, backend: r.backend, status: proven ? 'reproduced' : 'not-reproduced', exitCode: r.exitCode,
131
- observed: proven ? `the payload created '${PROOF_MARKER}' by running inside the generated script` : null,
132
- reason: proven ? null : 'the script ran and the marker was not created: this witness did not reproduce the effect' };
133
- } catch (e) {
134
- return { ...base, status: 'invalid', reason: `witness harness error: ${String((e && e.message) || e)}` };
135
- } finally { if (root) node_fs__WEBPACK_IMPORTED_MODULE_0__.rmSync(root, { recursive: true, force: true }); }
136
- }
137
-
138
- /** Finds the flow for (attrPath, ordinal) in a fresh analysis of `files`, and builds+runs its witness. */
139
- function witnessNixFlow(files, target, opts = {}) {
140
- const a = (0,_nix_script_taint_js__WEBPACK_IMPORTED_MODULE_5__/* .analyzeNixScripts */ .S3)({ files });
141
- const script = a.scripts.find((s) => s.attrPath === target.attrPath && (!target.file || s.file === target.file));
142
- if (!script) return { status: 'unsupported', ran: false, reason: `no generated script ${target.attrPath}` };
143
- const idx = placeholderIndexes(script.generated);
144
- const flow = a.flows.find((f) => f.attrPath === script.attrPath && f.generatedLocation && idx.indexOf(indexOfPosition(script.generated, f.generatedLocation.line, f.generatedLocation.startColumn)) === target.ordinal);
145
- if (!flow) return { status: 'unsupported', ran: false, reason: `no interpolation #${target.ordinal} in ${target.attrPath}` };
146
- return runNixScriptWitness(buildNixScriptWitness({ script, flow }), opts);
147
- }
148
-
149
- /** The (attrPath, ordinal) of the flow a finding describes, taken from a fresh analysis. */
150
- function nixFlowTarget(files, finding) {
151
- const a = (0,_nix_script_taint_js__WEBPACK_IMPORTED_MODULE_5__/* .analyzeNixScripts */ .S3)({ files });
152
- const flow = a.flows.find((f) => f.file === finding.file && f.line === finding.line && f.attrPath && f.generatedLocation)
153
- || a.flows.find((f) => f.file === finding.file && f.attrPath === finding.attrPath && f.generatedLocation);
154
- if (!flow) return null;
155
- const script = a.scripts.find((s) => s.attrPath === flow.attrPath && s.file === (flow.generatedLocation.file || finding.file));
156
- if (!script) return null;
157
- const ordinal = placeholderIndexes(script.generated).indexOf(indexOfPosition(script.generated, flow.generatedLocation.line, flow.generatedLocation.startColumn));
158
- return ordinal < 0 ? null : { attrPath: script.attrPath, file: script.file, ordinal };
159
- }
160
-
161
- /**
162
- * Before/after judgement for a fix. A fix is witness-verified only when the ORIGINAL reproduced and the PATCHED code
163
- * ran cleanly without reproducing. Anything invalid on either side verifies nothing.
164
- */
165
- function judgeFixWitness(before, after) {
166
- if (!before || before.status !== 'reproduced') return { ok: false, verified: false, reason: `the original code did not reproduce (${(before && before.status) || 'no witness'}${before && before.reason ? `: ${before.reason}` : ''}), so the fix cannot be witness-verified` };
167
- if (!after || after.status === 'invalid' || after.status === 'unavailable' || after.status === 'unsupported') return { ok: false, verified: false, reason: `the patched witness could not be judged (${(after && after.status) || 'no witness'}${after && after.reason ? `: ${after.reason}` : ''})` };
168
- if (after.status === 'reproduced') return { ok: false, verified: false, stillReproduces: true, reason: 'the patched code still reproduces the effect' };
169
- return { ok: true, verified: true, reason: null, note: 'the witness reproduced before the patch and not after; this is evidence about this witness, not a proof of safety' };
170
- }
171
-
172
- // ── Haskell: optional, toolchain-gated ───────────────────────────────────────
173
- /** Whether a Haskell runner exists. Never installs anything. */
174
- function haskellRunner() {
175
- const p = which('runghc') || which('runhaskell');
176
- if (!p) return { available: false, reason: 'no Haskell toolchain (runghc) on PATH; witnesses for Haskell findings are unavailable here' };
177
- // GHC's first start on a cold, loaded machine (a CI runner) has taken more than 10 s; a probe that gives up there reports a toolchain
178
- // that is installed as absent, and the answer then differs between two calls in one run.
179
- const v = (0,node_child_process__WEBPACK_IMPORTED_MODULE_3__.spawnSync)(p, ['--version'], { encoding: 'utf8', timeout: 60_000 });
180
- return v.status === 0 ? { available: true, path: p, version: String(v.stdout || v.stderr).trim() } : { available: false, reason: v.error && v.error.code === 'ETIMEDOUT' ? 'the Haskell runner did not start within 60 s' : 'the Haskell runner did not start' };
181
- }
182
-
183
- /**
184
- * Runs a Haskell program text as a witness. `main` must create PROVEN in its working directory when the effect is
185
- * reproduced. Without a toolchain the answer is `unavailable`: not proof, not refutation.
186
- */
187
- function runHaskellWitness(source, { timeoutMs = 60_000, force } = {}) {
188
- const base = { witness: WITNESS_VERSION, lang: 'haskell', ran: false, backend: null, marker: PROOF_MARKER };
189
- const hr = haskellRunner();
190
- if (!hr.available) return { ...base, status: 'unavailable', reason: hr.reason };
191
- if (!(0,_sandbox_index_js__WEBPACK_IMPORTED_MODULE_4__/* .sandboxAvailable */ .$G)()) return { ...base, status: 'invalid', reason: 'no confinement primitive available; refusing to execute' };
192
- let root;
193
- try {
194
- root = node_fs__WEBPACK_IMPORTED_MODULE_0__.realpathSync(node_fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(node_os__WEBPACK_IMPORTED_MODULE_1__.tmpdir(), 'witness-hs-')));
195
- node_fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(root, 'Witness.hs'), source, 'utf8');
196
- const r = (0,_sandbox_index_js__WEBPACK_IMPORTED_MODULE_4__/* .runConfined */ .id)([hr.path, 'Witness.hs'], { root, timeoutMs, force });
197
- if (r.status === 'disabled' || r.status === 'error') return { ...base, backend: r.backend, status: 'invalid', reason: `the sandbox could not execute it: ${String(r.stderr || '').trim() || r.status}` };
198
- if (r.timedOut) return { ...base, backend: r.backend, status: 'invalid', reason: 'the witness exceeded its time budget', timedOut: true };
199
- if (/error|parse error|Could not find module/i.test(String(r.stderr || '')) && r.exitCode !== 0) return { ...base, backend: r.backend, status: 'invalid', reason: `the program did not compile or run: ${String(r.stderr).trim().split('\n')[0]}` };
200
- const proven = node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(root, PROOF_MARKER));
201
- return { ...base, ran: true, backend: r.backend, status: proven ? 'reproduced' : 'not-reproduced', exitCode: r.exitCode, reason: proven ? null : 'the program ran and the marker was not created' };
202
- } catch (e) {
203
- return { ...base, status: 'invalid', reason: `witness harness error: ${String((e && e.message) || e)}` };
204
- } finally { if (root) node_fs__WEBPACK_IMPORTED_MODULE_0__.rmSync(root, { recursive: true, force: true }); }
205
- }
206
-
207
- /** A `witness` hook for runFixLifecycle over a Nix generated-script finding: runs the original and the patched tree. */
208
- function nixFixWitness(finding, opts = {}) {
209
- return (plan, files, patched) => {
210
- const nixOnly = (t) => Object.fromEntries(Object.entries(t).filter(([p, x]) => /\.nix$/i.test(p) && typeof x === 'string'));
211
- const target = nixFlowTarget(nixOnly(files), finding);
212
- if (!target) return { ok: false, verified: false, reason: 'the finding is not a generated-script interpolation, so no witness applies' };
213
- return judgeFixWitness(witnessNixFlow(nixOnly(files), target, opts), witnessNixFlow(nixOnly(patched), target, opts));
214
- };
215
- }
216
-
217
-
218
- /***/ })
219
-
220
- };
@@ -1,100 +0,0 @@
1
- export const id = 9539;
2
- export const ids = [9539];
3
- export const modules = {
4
-
5
- /***/ 89539:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ diffScenarioGraph: () => (/* binding */ diffScenarioGraph)
10
- /* harmony export */ });
11
- /* unused harmony export WATCHED_SCENARIO_FIELDS */
12
- // scenario-diff.js — M5 deliverable #3a (FR-502): a dedicated
13
- // comparison for a Scenario's own simulated graph delta. Deliberately
14
- // NOT graph-diff.js's computeGraphDiff — see this sub-project's own
15
- // scoping doc for the full reasoning: computeGraphDiff's flow-
16
- // reidentification pairing and causeClassification vocabulary
17
- // (`'application_change'`, `'possible_coverage_regression'`,
18
- // `'reidentified'`) are shaped for a REAL rescan across two commits,
19
- // where the cause of a change is genuinely ambiguous. A Scenario's own
20
- // delta has no such ambiguity — every difference between the base graph
21
- // and a scenario clone IS the declared hypothetical operation that
22
- // produced it — so this module reports only "what differs", with no
23
- // cause classification and no reidentification.
24
-
25
- const WATCHED_SCENARIO_FIELDS = Object.freeze({
26
- // 'destination' + 'storeDetail' are exhaustive by construction, not by
27
- // convention: change_storage_fact/change_governance_fact write into an
28
- // already-watched CONTAINER object, so any field they set is caught
29
- // regardless of key; replace_recipient_fact is the one operation that
30
- // writes directly onto the node's own top level, and scenario-engine.js
31
- // restricts it, at the applier level, to exactly node.destination (any
32
- // other `field` value is skipped, never applied) — so this list never
33
- // needs to name a field replace_recipient_fact could reach beyond
34
- // 'destination'. See scenario-engine.js's _applyReplaceRecipientFact.
35
- node: Object.freeze(['destination', 'storeDetail']),
36
- edge: Object.freeze(['protection.transit', 'protection.atRest', 'protection.handling']),
37
- flow: Object.freeze(['policyVerdict', 'protectionSummary', 'governanceRefs']),
38
- });
39
-
40
- function _get(obj, dottedPath) {
41
- return dottedPath.split('.').reduce((v, k) => (v == null ? v : v[k]), obj);
42
- }
43
-
44
- function _deepEqual(a, b) { return JSON.stringify(a) === JSON.stringify(b); }
45
-
46
- function _byId(arr) { return new Map((arr ?? []).map((x) => [x.id, x])); }
47
-
48
- function _diffKind(beforeArr, afterArr, kind) {
49
- const beforeMap = _byId(beforeArr);
50
- const afterMap = _byId(afterArr);
51
- const changed = [];
52
- const removed = [];
53
- for (const [id, beforeEntity] of beforeMap) {
54
- const afterEntity = afterMap.get(id);
55
- if (!afterEntity) { removed.push(id); continue; }
56
- const changedFields = [];
57
- for (const field of WATCHED_SCENARIO_FIELDS[kind]) {
58
- const before = _get(beforeEntity, field);
59
- const after = _get(afterEntity, field);
60
- if (!_deepEqual(before, after)) changedFields.push({ field, before, after });
61
- }
62
- if (changedFields.length) changed.push({ id, kind, changedFields });
63
- }
64
- return { changed, removed };
65
- }
66
-
67
- // AC-26 ("What-if changes cannot masquerade as implementation"): a
68
- // simulated edge must be LABELED `HYPOTHETICAL`, not merely carry an
69
- // `evidenceGrade: 'assumed'` value a reader has to notice buried inside
70
- // a before/after diff. Mirrors AC-29's own precedent
71
- // (`observation-correlation.js`'s literal `'runtime_observed'` layer
72
- // value) — a named acceptance criterion that specifies an exact string
73
- // gets an exact string in the shipped output, not an inference left to
74
- // the reader.
75
- function _hasAssumedEvidence(changedEntity) {
76
- return changedEntity.changedFields.some((f) => f.after && typeof f.after === 'object' && f.after.evidenceGrade === 'assumed');
77
- }
78
-
79
- /**
80
- * Compare `baseGraph` against `scenarioGraph` (either a real
81
- * applyScenario({graph}) result, or another Scenario's own graph, for a
82
- * scenario-vs-scenario comparison). Never throws — an empty/missing
83
- * entity array on either side is treated as zero entities.
84
- */
85
- function diffScenarioGraph(baseGraph, scenarioGraph) {
86
- const nodeDiff = _diffKind(baseGraph.nodes ?? [], scenarioGraph.nodes ?? [], 'node');
87
- const edgeDiff = _diffKind(baseGraph.edges ?? [], scenarioGraph.edges ?? [], 'edge');
88
- const flowDiff = _diffKind(baseGraph.flows ?? [], scenarioGraph.flows ?? [], 'flow');
89
- const changedEntities = [...nodeDiff.changed, ...edgeDiff.changed, ...flowDiff.changed]
90
- .map((e) => (e.kind === 'edge' && _hasAssumedEvidence(e) ? { ...e, label: 'HYPOTHETICAL' } : e));
91
- return {
92
- changedEntities,
93
- removedEntityIds: [...nodeDiff.removed, ...edgeDiff.removed, ...flowDiff.removed],
94
- };
95
- }
96
-
97
-
98
- /***/ })
99
-
100
- };
@@ -1,103 +0,0 @@
1
- export const id = 9547;
2
- export const ids = [9547];
3
- export const modules = {
4
-
5
- /***/ 89547:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ sweepHaskellSiblings: () => (/* binding */ sweepHaskellSiblings)
10
- /* harmony export */ });
11
- /* unused harmony export HS_SWEEP_VERSION */
12
- /* harmony import */ var _dataflow_catalog_haskell_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(93722);
13
- /* harmony import */ var _lineage_source_seeding_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31284);
14
- // Root-cause sweep for Haskell (X-008). The generic sweep anchors on a `callee(args)` text shape, which Haskell's
15
- // juxtaposition syntax never produces, so a confirmed Haskell finding swept nothing. This sweep works on the IR: for
16
- // each confirmed finding it takes the RESOLVED sink callee from the model catalog and lists every other call of that
17
- // same callee in the project, then accounts for all of them:
18
- //
19
- // found === candidates + mitigated
20
- //
21
- // `found` is every other call site of the callee (the finding's own site, and the sites of other findings in the same
22
- // group, are the origins and are excluded). `mitigated` is a site where a detector already produced a finding for a
23
- // different reason, `candidates` is the rest. A candidate whose argument is a literal constant is flagged
24
- // (`constantArgument`) and stays a candidate: the flag is information, not a verdict. Nothing is dropped.
25
- //
26
- // Resolution is by import-qualified callee, so an unrelated function that merely shares a name is not a sibling.
27
-
28
-
29
-
30
-
31
- const HS_SWEEP_VERSION = 'haskell-sweep/1';
32
- const SAMPLE_LIMIT = 100;
33
- const isHs = (f) => /\.l?hs$/i.test(f || '');
34
- const BY_ID = new Map(_dataflow_catalog_haskell_js__WEBPACK_IMPORTED_MODULE_0__/* .HASKELL_CATALOG */ .R.filter((e) => e.kind === 'sink').map((e) => [e.id, e]));
35
-
36
- const allConstant = (e) => {
37
- let constant = true; let sawLiteral = false;
38
- (0,_lineage_source_seeding_js__WEBPACK_IMPORTED_MODULE_1__/* .walkExpr */ .lN)(e, (x) => {
39
- if (x.kind === 'literal') sawLiteral = true;
40
- else if (x.kind === 'ident' && !(x.hs && x.hs.functionRef)) constant = false;
41
- else if (x.kind === 'member') constant = false;
42
- });
43
- return constant && sawLiteral;
44
- };
45
-
46
- /**
47
- * @param {object[]} findings confirmed findings (only Haskell IR-taint findings are swept)
48
- * @param {{functions: Map}} callGraph the project call graph (ir/index.js buildProjectIR)
49
- */
50
- function sweepHaskellSiblings(findings, callGraph) {
51
- const groups = new Map();
52
- for (const f of findings || []) {
53
- if (!f || !isHs(f.file) || f.parser !== 'IR-TAINT' || !f.sink || !f.sink.label) continue;
54
- const entry = BY_ID.get(f.sink.label);
55
- if (!entry || !entry.match || !entry.match.callee) continue;
56
- const key = entry.match.callee;
57
- if (!groups.has(key)) groups.set(key, { callee: key, entry, findings: [] });
58
- groups.get(key).findings.push(f);
59
- }
60
- const sites = new Map(); // callee -> [{file, line, constantArgument}]
61
- const wanted = new Set(groups.keys());
62
- for (const fn of callGraph && callGraph.functions ? callGraph.functions.values() : []) {
63
- if (!isHs(fn.file) || !fn.cfg) continue;
64
- for (const node of Object.values(fn.cfg.nodes)) {
65
- const visit = (e) => {
66
- if (e.kind === 'call' && typeof e.callee === 'string' && wanted.has(e.callee)) {
67
- const entry = groups.get(e.callee).entry;
68
- const arg = (e.args || [])[entry.argIndex || 0];
69
- if (!sites.has(e.callee)) sites.set(e.callee, []);
70
- sites.get(e.callee).push({ file: fn.file, line: e.line || node.line || null, constantArgument: arg ? allConstant(arg) : false });
71
- }
72
- };
73
- if (node.kind === 'call' && typeof node.callee === 'string' && wanted.has(node.callee)) visit(node);
74
- for (const root of (0,_lineage_source_seeding_js__WEBPACK_IMPORTED_MODULE_1__/* .exprRoots */ .Zf)(node)) (0,_lineage_source_seeding_js__WEBPACK_IMPORTED_MODULE_1__/* .walkExpr */ .lN)(root, visit);
75
- }
76
- }
77
- const covered = new Map(); // "file:line" -> true, any finding at that site
78
- for (const f of findings || []) if (f && f.file && Number.isInteger(f.line)) covered.set(`${f.file}:${f.line}`, true);
79
- const sweeps = [];
80
- const totals = { found: 0, candidates: 0, mitigated: 0 };
81
- for (const [callee, g] of [...groups.entries()].sort((a, b) => (a[0] < b[0] ? -1 : 1))) {
82
- const origin = new Set(g.findings.map((f) => `${f.file}:${f.line}`));
83
- const seen = new Set(); const all = [];
84
- for (const s of sites.get(callee) || []) { const k = `${s.file}:${s.line}`; if (origin.has(k) || seen.has(k)) continue; seen.add(k); all.push(s); }
85
- all.sort((a, b) => (a.file + String(a.line)).localeCompare(b.file + String(b.line), undefined, { numeric: true }));
86
- const instances = all.map((s) => ({ ...s, status: covered.has(`${s.file}:${s.line}`) ? 'mitigated' : 'candidate' }));
87
- const mitigated = instances.filter((i) => i.status === 'mitigated').length;
88
- const candidates = instances.length - mitigated;
89
- sweeps.push({
90
- callee, cwe: g.entry.vuln.cwe, family: g.entry.hs && g.entry.hs.family, origins: [...origin].sort(), findingIds: g.findings.map((f) => f.id).sort(),
91
- found: instances.length, candidates, mitigated, constantArgumentCandidates: instances.filter((i) => i.status === 'candidate' && i.constantArgument).length,
92
- instances: instances.slice(0, SAMPLE_LIMIT), instancesTruncated: instances.length > SAMPLE_LIMIT, remaining: candidates,
93
- note: 'siblings are other calls of the same import-qualified sink; a candidate is unreviewed, not vulnerable',
94
- });
95
- totals.found += instances.length; totals.candidates += candidates; totals.mitigated += mitigated;
96
- }
97
- return { version: HS_SWEEP_VERSION, sweeps, totals };
98
- }
99
-
100
-
101
- /***/ })
102
-
103
- };
@@ -1,90 +0,0 @@
1
- export const id = 9692;
2
- export const ids = [9692];
3
- export const modules = {
4
-
5
- /***/ 99692:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ extractImagePackages: () => (/* binding */ extractImagePackages)
10
- /* harmony export */ });
11
- /* unused harmony exports parseDpkgStatus, parseApkInstalled */
12
- // R8 (PRD §5) — container-image OS-package inventory.
13
- //
14
- // container.js reads the Dockerfile (FROM + apt/apk install lines). This reads
15
- // the ACTUAL installed-package databases from an extracted image filesystem
16
- // (or the host), catching packages baked into the base image that the
17
- // Dockerfile never names. Components flow into the existing OSV pipeline + SBOM.
18
- //
19
- // Pure parsers (unit-tested) + a path-matching extractor. No daemon; reads the
20
- // package-DB files that appear when an image layer/tarball is unpacked.
21
-
22
- // Debian/Ubuntu: /var/lib/dpkg/status — RFC822-style blocks separated by blank
23
- // lines. Only "install ok installed" entries count (not removed/config-files).
24
- function parseDpkgStatus(text) {
25
- const out = [];
26
- for (const block of String(text || '').split(/\n\s*\n/)) {
27
- const name = (block.match(/^Package:\s*(.+)$/m) || [])[1];
28
- const version = (block.match(/^Version:\s*(.+)$/m) || [])[1];
29
- const status = (block.match(/^Status:\s*(.+)$/m) || [])[1] || '';
30
- if (!name || !version) continue;
31
- if (!/\binstalled\b/.test(status)) continue;
32
- out.push({ name: name.trim(), version: version.trim(), ecosystem: 'Debian' });
33
- }
34
- return out;
35
- }
36
-
37
- // Alpine: /lib/apk/db/installed — blocks separated by blank lines; P:=name V:=version.
38
- function parseApkInstalled(text) {
39
- const out = [];
40
- for (const block of String(text || '').split(/\n\s*\n/)) {
41
- const name = (block.match(/^P:(.+)$/m) || [])[1];
42
- const version = (block.match(/^V:(.+)$/m) || [])[1];
43
- if (!name || !version) continue;
44
- out.push({ name: name.trim(), version: version.trim(), ecosystem: 'Alpine' });
45
- }
46
- return out;
47
- }
48
-
49
- const _PURL = { Debian: (n, v) => `pkg:deb/debian/${n}@${v}`, Alpine: (n, v) => `pkg:apk/alpine/${n}@${v}` };
50
-
51
- // File-path tells for an unpacked image. Match on path suffix so it works
52
- // whether the scan root is the rootfs or a subdirectory of it.
53
- function _dbKind(path) {
54
- const p = path.replace(/\\/g, '/');
55
- if (/(?:^|\/)var\/lib\/dpkg\/status$/.test(p)) return 'dpkg';
56
- if (/(?:^|\/)lib\/apk\/db\/installed$/.test(p)) return 'apk';
57
- return null;
58
- }
59
-
60
- /**
61
- * Extract OS-package components from any image package-DBs present in the scanned
62
- * files. Returns components in the engine's component shape so they ride the
63
- * existing OSV/SBOM pipeline. De-dups by ecosystem:name:version.
64
- */
65
- function extractImagePackages(fileContents) {
66
- const comps = [];
67
- const seen = new Set();
68
- for (const [file, content] of Object.entries(fileContents || {})) {
69
- const kind = _dbKind(file);
70
- if (!kind) continue;
71
- const pkgs = kind === 'dpkg' ? parseDpkgStatus(content) : parseApkInstalled(content);
72
- for (const p of pkgs) {
73
- const key = `${p.ecosystem}:${p.name}:${p.version}`;
74
- if (seen.has(key)) continue;
75
- seen.add(key);
76
- comps.push({
77
- name: p.name, version: p.version, group: '', ecosystem: p.ecosystem,
78
- purl: (_PURL[p.ecosystem] || (() => null))(p.name, p.version),
79
- filePath: file, isUnpinned: false, isTransitive: false, isOsPackage: true,
80
- scope: 'required', reachable: true,
81
- });
82
- }
83
- }
84
- return comps;
85
- }
86
-
87
-
88
- /***/ })
89
-
90
- };