@clear-capabilities/agentic-security-scanner 0.172.1 → 0.173.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/bin/agentic-security.js +37 -0
  3. package/dist/119.index.js +197 -0
  4. package/dist/128.index.js +129 -0
  5. package/dist/1293.index.js +5689 -0
  6. package/dist/1351.index.js +133 -0
  7. package/dist/1387.index.js +271 -0
  8. package/dist/1437.index.js +23 -0
  9. package/dist/1445.index.js +110 -0
  10. package/dist/1505.index.js +151 -0
  11. package/dist/1557.index.js +293 -0
  12. package/dist/1621.index.js +311 -0
  13. package/dist/1751.index.js +160 -0
  14. package/dist/1765.index.js +727 -0
  15. package/dist/1861.index.js +690 -0
  16. package/dist/1898.index.js +116 -0
  17. package/dist/1906.index.js +433 -0
  18. package/dist/1920.index.js +1 -291
  19. package/dist/208.index.js +1631 -0
  20. package/dist/2199.index.js +0 -239
  21. package/dist/2223.index.js +159 -0
  22. package/dist/2530.index.js +152 -0
  23. package/dist/2565.index.js +116 -0
  24. package/dist/2574.index.js +127 -0
  25. package/dist/2620.index.js +345 -0
  26. package/dist/2773.index.js +98 -0
  27. package/dist/2775.index.js +32 -0
  28. package/dist/2966.index.js +171 -0
  29. package/dist/2972.index.js +87 -0
  30. package/dist/2991.index.js +131 -0
  31. package/dist/3063.index.js +833 -0
  32. package/dist/3075.index.js +227 -0
  33. package/dist/3121.index.js +297 -0
  34. package/dist/3314.index.js +263 -0
  35. package/dist/3480.index.js +1822 -0
  36. package/dist/3481.index.js +24 -0
  37. package/dist/3506.index.js +268 -0
  38. package/dist/3533.index.js +591 -0
  39. package/dist/3653.index.js +450 -0
  40. package/dist/3822.index.js +131 -0
  41. package/dist/3868.index.js +292 -0
  42. package/dist/3917.index.js +152 -0
  43. package/dist/3918.index.js +192 -0
  44. package/dist/4090.index.js +288 -0
  45. package/dist/4121.index.js +1190 -0
  46. package/dist/4142.index.js +0 -239
  47. package/dist/4336.index.js +436 -0
  48. package/dist/4387.index.js +532 -0
  49. package/dist/4413.index.js +302 -0
  50. package/dist/4476.index.js +4510 -0
  51. package/dist/4491.index.js +133 -0
  52. package/dist/4538.index.js +185 -0
  53. package/dist/4684.index.js +319 -0
  54. package/dist/4740.index.js +165 -0
  55. package/dist/4780.index.js +209 -0
  56. package/dist/4802.index.js +225 -0
  57. package/dist/4812.index.js +379 -0
  58. package/dist/4835.index.js +126 -0
  59. package/dist/494.index.js +226 -0
  60. package/dist/4991.index.js +549 -0
  61. package/dist/5199.index.js +305 -0
  62. package/dist/5216.index.js +109 -0
  63. package/dist/5439.index.js +301 -0
  64. package/dist/5443.index.js +97 -0
  65. package/dist/5496.index.js +377 -0
  66. package/dist/550.index.js +2 -1
  67. package/dist/5801.index.js +588 -0
  68. package/dist/5858.index.js +223 -0
  69. package/dist/5933.index.js +143 -0
  70. package/dist/601.index.js +23 -0
  71. package/dist/6173.index.js +273 -0
  72. package/dist/6291.index.js +1871 -0
  73. package/dist/6312.index.js +666 -0
  74. package/dist/634.index.js +16182 -0
  75. package/dist/644.index.js +87 -0
  76. package/dist/6508.index.js +283 -0
  77. package/dist/6560.index.js +645 -0
  78. package/dist/6576.index.js +422 -0
  79. package/dist/6579.index.js +271 -0
  80. package/dist/6745.index.js +305 -0
  81. package/dist/6818.index.js +21642 -0
  82. package/dist/6972.index.js +167 -0
  83. package/dist/6995.index.js +163 -0
  84. package/dist/7249.index.js +191 -0
  85. package/dist/7372.index.js +1197 -0
  86. package/dist/7546.index.js +541 -0
  87. package/dist/76.index.js +448 -0
  88. package/dist/7879.index.js +163 -0
  89. package/dist/8025.index.js +130 -0
  90. package/dist/8054.index.js +248 -0
  91. package/dist/8097.index.js +201 -0
  92. package/dist/8126.index.js +191 -0
  93. package/dist/8178.index.js +78 -0
  94. package/dist/818.index.js +212 -0
  95. package/dist/8382.index.js +93 -0
  96. package/dist/8408.index.js +261 -0
  97. package/dist/8540.index.js +174 -0
  98. package/dist/8635.index.js +802 -0
  99. package/dist/8688.index.js +410 -0
  100. package/dist/8699.index.js +779 -0
  101. package/dist/8891.index.js +457 -0
  102. package/dist/8916.index.js +885 -0
  103. package/dist/9146.index.js +170 -0
  104. package/dist/9168.index.js +841 -0
  105. package/dist/9292.index.js +369 -0
  106. package/dist/9382.index.js +135 -11
  107. package/dist/9422.index.js +866 -0
  108. package/dist/9440.index.js +453 -0
  109. package/dist/9479.index.js +152 -0
  110. package/dist/9481.index.js +220 -0
  111. package/dist/9539.index.js +100 -0
  112. package/dist/9547.index.js +103 -0
  113. package/dist/9560.index.js +41 -61
  114. package/dist/9692.index.js +90 -0
  115. package/dist/9800.index.js +213 -1
  116. package/dist/9899.index.js +138 -0
  117. package/dist/9981.index.js +206 -0
  118. package/dist/999.index.js +117 -0
  119. package/dist/agentic-security.mjs +27 -27
  120. package/dist/agentic-security.mjs.sha256 +1 -1
  121. package/package.json +28 -3
  122. package/src/context-intelligence/candidates.js +2 -1
  123. package/src/context-intelligence/capabilities.js +2 -1
  124. package/src/context-intelligence/cli.js +2 -0
  125. package/src/context-intelligence/config.js +3 -1
  126. package/src/context-intelligence/controls.js +49 -1
  127. package/src/context-intelligence/counterexample.js +200 -0
  128. package/src/context-intelligence/cross-route.js +111 -0
  129. package/src/context-intelligence/findings.js +166 -0
  130. package/src/context-intelligence/invariants.js +197 -0
  131. package/src/context-intelligence/queue.js +6 -1
  132. package/src/context-intelligence/reachability.js +2 -2
  133. package/src/context-intelligence/review.js +68 -4
  134. package/src/dataflow/access-paths.js +11 -0
  135. package/src/dataflow/analysis-limits.js +66 -0
  136. package/src/dataflow/engine.js +272 -20
  137. package/src/dataflow/service-edges.js +174 -0
  138. package/src/dataflow/summaries.js +7 -1
  139. package/src/discovery/judge.js +2 -1
  140. package/src/engine.js +82 -14
  141. package/src/fix/apply-fix-service.js +55 -8
  142. package/src/fix/batch-journal.js +84 -0
  143. package/src/fix/exploit-replay.js +51 -0
  144. package/src/fix/footprint.js +65 -0
  145. package/src/fix/patch-policy.js +49 -0
  146. package/src/fix/secret-persistence.js +39 -0
  147. package/src/fix/test-commands.js +84 -0
  148. package/src/fix/verification-adapters.js +97 -0
  149. package/src/fix/verification-record.js +243 -0
  150. package/src/fix/verify-patch.js +89 -0
  151. package/src/ir/CLAUDE.md +5 -0
  152. package/src/ir/callgraph.js +23 -1
  153. package/src/ir/module-resolver.js +315 -0
  154. package/src/ir/parser-js.js +21 -2
  155. package/src/ir/semantic-graph.js +245 -0
  156. package/src/lineage/build-attested-correlation.js +63 -0
  157. package/src/lineage/deployment-identity.js +76 -0
  158. package/src/mcp/tools.js +13 -34
  159. package/src/pipeline/canonical-output.js +64 -0
  160. package/src/pipeline/detector-runner.js +7 -0
  161. package/src/pipeline/scan-health.js +14 -0
  162. package/src/pipeline/supervised-analyzers.js +125 -0
  163. package/src/pipeline/supervised-child.js +17 -0
  164. package/src/pipeline/telemetry.js +79 -0
  165. package/src/posture/accuracy-scorecard.js +98 -9
  166. package/src/posture/artifact-registry.js +5 -0
  167. package/src/posture/assurance/evidence-registry.js +215 -0
  168. package/src/posture/assurance/release-package-verify.js +135 -0
  169. package/src/posture/assurance/release-package.js +118 -0
  170. package/src/posture/assurance/release-verdict.js +94 -0
  171. package/src/posture/assurance/waiver.js +200 -0
  172. package/src/posture/compliance-truth.js +100 -0
  173. package/src/posture/evaluation/scan-child.js +3 -1
  174. package/src/posture/evaluation/why-missed.js +3 -1
  175. package/src/posture/exploitability-evidence.js +141 -0
  176. package/src/posture/fix-verify.js +4 -2
  177. package/src/posture/fleet/exposure-ranking.js +115 -0
  178. package/src/posture/fleet/service-chain-graph.js +150 -0
  179. package/src/posture/graph-reconciliation.js +154 -0
  180. package/src/posture/provenance/coverage.js +103 -0
  181. package/src/posture/provenance/git-evidence.js +84 -0
  182. package/src/posture/provenance/origin-resolver.js +7 -1
  183. package/src/posture/provenance/predicate-replay.js +14 -4
  184. package/src/posture/runtime-correlation.js +61 -15
  185. package/src/posture/runtime-explanation.js +116 -0
  186. package/src/posture/runtime-trace-ingest.js +194 -0
  187. package/src/posture/scan-checkpoint.js +38 -10
  188. package/src/posture/waf-ingest.js +7 -2
  189. package/src/report/index.js +4 -0
  190. package/src/report/oscal.js +38 -0
  191. package/src/report/perspectives.js +150 -0
  192. package/src/sast/_comment-strip.js +8 -1
  193. package/src/sast/ruby.js +26 -0
  194. package/src/util/string-memo.js +38 -0
@@ -0,0 +1,220 @@
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
+ };
@@ -0,0 +1,100 @@
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
+ };
@@ -0,0 +1,103 @@
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
+ };