@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,462 +0,0 @@
1
- export const id = 9800;
2
- export const ids = [9800,2199];
3
- export const modules = {
4
-
5
- /***/ 59800:
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 */ cmdProof: () => (/* binding */ cmdProof),
11
- /* harmony export */ cmdProve: () => (/* binding */ cmdProve),
12
- /* harmony export */ loadReproducerFor: () => (/* binding */ loadReproducerFor)
13
- /* harmony export */ });
14
- /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73024);
15
- /* harmony import */ var node_os__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(48161);
16
- /* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(76760);
17
- /* harmony import */ var _state_dir_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(31174);
18
- /* harmony import */ var _orchestrator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3740);
19
- /* harmony import */ var _store_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(62199);
20
- /* harmony import */ var _runner_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(2998);
21
- /* harmony import */ var _reproducer_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(37055);
22
- // CLI surface for the proof fabric: `proof show|replay|doctor`, `triage exploit|validate`. Non-interactive by design: no
23
- // command reads stdin, every run is bounded by the policy timeouts, and a missing reproducer is a typed exit code, not a
24
- // prompt. Exit codes: 0 confirmed/ok, 1 not confirmed (any reason), 4 usage/precondition.
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
- function loadFinding(root, id) {
36
- const p = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_3__.statePath)(root, 'last-scan.json');
37
- if (!node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(p)) return null;
38
- const last = JSON.parse(node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(p, 'utf8'));
39
- return (last.findings || []).find((f) => f.id === id || f.stableId === id) ?? null;
40
- }
41
-
42
- function loadReproducerFor(root, id, flagPath) { return loadReproducer(root, id, flagPath); }
43
-
44
- function loadReproducer(root, id, flagPath) {
45
- const candidates = [flagPath && node_path__WEBPACK_IMPORTED_MODULE_2__.resolve(String(flagPath)), (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_3__.statePath)(root, 'reproducers', `${(0,_store_js__WEBPACK_IMPORTED_MODULE_5__.findingKey)(id)}.json`)].filter(Boolean);
46
- for (const c of candidates) {
47
- try { return { reproducer: JSON.parse(node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(c, 'utf8')), file: c }; } catch { /* next */ }
48
- }
49
- return null;
50
- }
51
-
52
- function formatResult(r) {
53
- const env = r.environment ? `${r.environment.mode} (${r.environment.assurance} assurance)` : 'none';
54
- return [
55
- `Finding: ${r.findingId}`,
56
- `Evidence: ${r.state}`,
57
- `Oracle: ${r.oracle}`,
58
- `Reproductions: ${r.attempts?.successes ?? 0}/${r.attempts?.run ?? 0} (required ${r.attempts?.required})`,
59
- `Independent replay: ${r.independentReplay?.status ?? 'not-run'}`,
60
- `Environment: ${env}`,
61
- `Completeness: ${r.completeness}`,
62
- `Duration: ${(r.timing.proofMs / 1000).toFixed(1)}s`,
63
- ...(r.degradation?.length ? [`Degraded: ${r.degradation.join(', ')}`] : []),
64
- ...(r.note ? [`Note: ${r.note}`] : []),
65
- ].join('\n');
66
- }
67
-
68
- async function cmdProve(args, root, { json = false } = {}) {
69
- const id = String(args._[2] ?? '');
70
- if (!id) { console.error('usage: triage exploit <finding-id> --prove [--reproducer file] [--attempts N] [--required N]'); return 4; }
71
- const finding = loadFinding(root, id);
72
- if (!finding) { console.error(`Finding ${id} not found in last scan.`); return 4; }
73
- const loaded = loadReproducer(root, id, args.flags.reproducer);
74
- if (!loaded) { console.error(`No reproducer for ${id}. Supply one with --reproducer <file> or place it at .agentic-security/reproducers/. Nothing was executed.`); return 4; }
75
- const errs = (0,_reproducer_js__WEBPACK_IMPORTED_MODULE_7__/* .validateReproducer */ .mC)(loaded.reproducer);
76
- if (errs.length) { console.error(`Invalid reproducer: ${errs.join('; ')}`); return 4; }
77
- const policy = {};
78
- if (args.flags.attempts) policy.attempts = Number(args.flags.attempts);
79
- if (args.flags.required) policy.required = Number(args.flags.required);
80
- if (args.flags.timeout) policy.timeoutMs = Number(args.flags.timeout) * 1000;
81
- if (args.flags['require-container']) policy.requireContainer = true;
82
- const ac = new AbortController();
83
- const onSig = () => ac.abort();
84
- process.once('SIGINT', onSig);
85
- let result;
86
- try { result = await (0,_orchestrator_js__WEBPACK_IMPORTED_MODULE_4__/* .proveFinding */ .kO)({ finding, reproducer: loaded.reproducer, revision: args.flags.revision ?? null, policy, signal: ac.signal, sourceRoot: root }); } finally { process.off('SIGINT', onSig); }
87
- const saved = (0,_store_js__WEBPACK_IMPORTED_MODULE_5__.saveProof)(root, { ...result, reproducer: loaded.reproducer });
88
- // Printed output gets the same secret-scrubbing pass as what is persisted (defense in depth: a free-text reason/note
89
- // field that captured something from stdout/stderr should never reach a terminal unredacted either).
90
- if (json || args.flags.json) console.log(JSON.stringify((0,_store_js__WEBPACK_IMPORTED_MODULE_5__.scrubDeep)({ ...result, stored: saved.ok ? saved.file : null }), null, 2));
91
- else { console.log(formatResult(result)); if (!saved.ok) console.log(`(proof not stored: ${saved.reason})`); }
92
- return result.state === 'EXPLOIT_CONFIRMED' ? 0 : 1;
93
- }
94
-
95
- async function cmdProof(args, root) {
96
- const sub = args._[1];
97
- if (sub === 'doctor') return doctor(args);
98
- const id = String(args._[2] ?? '');
99
- if (!id) { console.error('usage: proof show <finding-id> | proof replay <finding-id> | proof doctor'); return 4; }
100
- if (sub === 'show') {
101
- const all = (0,_store_js__WEBPACK_IMPORTED_MODULE_5__.listProofs)(root, id);
102
- if (!all.length) { console.error(`No stored proof for ${id}.`); return 4; }
103
- const latest = all.find((p) => p.record);
104
- if (all.some((p) => p.tampered)) console.error(`WARNING: ${all.filter((p) => p.tampered).length} stored record(s) failed their integrity check and are not trusted.`);
105
- const good = all.find((p) => p.record && !p.tampered);
106
- if (!good) { console.error('No intact proof record.'); return 1; }
107
- if (args.flags.json) console.log(JSON.stringify(good.record, null, 2)); else console.log(formatResult(good.record));
108
- // the detection generated from this finding's proof (detection-and-response loop), when there is one
109
- try {
110
- const det = (await __webpack_require__.e(/* import() */ 8551).then(__webpack_require__.bind(__webpack_require__, 58551))).latestRecord(root, id, 'detection');
111
- if (det && !args.flags.json) console.log(`Detection: ${det.record.ir?.id ?? 'unknown'} (${det.record.validation?.status ?? 'not validated'}${det.record.enabled ? ', enabled' : ''})`);
112
- } catch { /* the proof output does not depend on it */ }
113
- void latest;
114
- return 0;
115
- }
116
- if (sub === 'replay') {
117
- const stored = (0,_store_js__WEBPACK_IMPORTED_MODULE_5__.latestProof)(root, id);
118
- if (!stored?.record?.reproducer) { console.error(`No stored reproducer for ${id}.`); return 4; }
119
- const tmpDir = node_fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(node_path__WEBPACK_IMPORTED_MODULE_2__.join(node_os__WEBPACK_IMPORTED_MODULE_1__.tmpdir(), 'proof-replay-'));
120
- const tmp = node_path__WEBPACK_IMPORTED_MODULE_2__.join(tmpDir, 'reproducer.json');
121
- node_fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(tmp, JSON.stringify(stored.record.reproducer));
122
- args.flags.reproducer = tmp;
123
- args._ = ['triage', 'exploit', id];
124
- try { return await cmdProve(args, root); } finally { node_fs__WEBPACK_IMPORTED_MODULE_0__.rmSync(tmpDir, { recursive: true, force: true }); }
125
- }
126
- console.error('usage: proof show|replay <finding-id> | proof doctor');
127
- return 4;
128
- }
129
-
130
- function doctor(args) {
131
- const tools = (0,_runner_js__WEBPACK_IMPORTED_MODULE_6__/* .hostTools */ .qV)();
132
- const rows = _reproducer_js__WEBPACK_IMPORTED_MODULE_7__/* .LANGUAGES */ .Yj.map((l) => ({ lang: l, ...(0,_runner_js__WEBPACK_IMPORTED_MODULE_6__/* .languageSupport */ .ql)(l, tools) }));
133
- const envs = ['javascript', 'python'].map((l) => ({ lang: l, ...(0,_runner_js__WEBPACK_IMPORTED_MODULE_6__/* .selectEnvironment */ .aP)({ lang: l }) }));
134
- if (args.flags.json) { console.log(JSON.stringify({ tools, languages: rows, environments: envs }, null, 2)); return 0; }
135
- console.log('Proof fabric doctor');
136
- for (const r of rows) console.log(` ${r.lang.padEnd(11)} ${r.supported ? 'supported' : `unsupported (${r.reason})`}`);
137
- for (const e of envs) console.log(` environment for ${e.lang}: ${e.mode}, ${e.assurance} assurance${e.reason ? ` (${e.reason})` : ''}${e.containerSkipped ? `; container skipped: ${e.containerSkipped}` : ''}`);
138
- const usable = envs.some((e) => e.mode !== 'unavailable');
139
- if (!usable) console.log(' RESULT: no execution environment available; proofs will report blocked, never clean.');
140
- return usable ? 0 : 1;
141
- }
142
-
143
-
144
- /***/ }),
145
-
146
- /***/ 3740:
147
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
148
-
149
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
150
- /* harmony export */ kO: () => (/* binding */ proveFinding)
151
- /* harmony export */ });
152
- /* unused harmony exports independentVerify, applySeverityPolicy, _newRunId */
153
- /* harmony import */ var node_crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(77598);
154
- /* harmony import */ var _states_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12090);
155
- /* harmony import */ var _runner_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2998);
156
- /* harmony import */ var _reproducer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(37055);
157
- /* harmony import */ var _proof_tier_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(40216);
158
- // Proof orchestration: finding + revision + reproducer + policy -> structured evidence.
159
- //
160
- // Rules that make this safe to trust:
161
- // * The model may propose a reproducer and select an oracle. The oracle (oracles.js) judges. Never a model.
162
- // * An attempt that did not complete (timeout, build failure, blocked, unsupported, error) is NOT a negative and NOT a
163
- // positive: it is degraded evidence, it never advances the state, and it makes the result INCOMPLETE.
164
- // * EXPLOIT_CONFIRMED needs `required` successes in `attempts` completed attempts AND a pass from an independent
165
- // verifier that receives only {revision, reproducer, findingId, oracle} in a fresh environment.
166
- // * "Not reproduced" is reported as such; it is never reported as safe.
167
-
168
-
169
-
170
-
171
-
172
-
173
- const PROOF_POLICY_DEFAULTS = Object.freeze({ attempts: 3, required: 3, independentReplay: true, timeoutMs: 20_000, cpus: 1, memoryMb: 512, network: 'none', requireContainer: false });
174
- const RESULT_SCHEMA = 'agentic-security/proof-result';
175
-
176
- function normalizePolicy(p = {}) {
177
- const x = { ...PROOF_POLICY_DEFAULTS, ...p };
178
- x.attempts = Math.max(1, Math.min(10, Math.trunc(Number(x.attempts)) || PROOF_POLICY_DEFAULTS.attempts));
179
- x.required = Math.max(1, Math.min(x.attempts, Math.trunc(Number(x.required)) || x.attempts));
180
- x.timeoutMs = Math.max(1000, Math.min(120_000, Number(x.timeoutMs) || PROOF_POLICY_DEFAULTS.timeoutMs));
181
- return x;
182
- }
183
-
184
- const summarize = (a) => ({ status: a.status, fired: a.oracle?.fired === true, inconclusive: a.oracle?.inconclusive === true, reason: a.oracle?.reason ?? a.reasons?.[0] ?? null, durationMs: a.durationMs, degraded: a.degraded });
185
-
186
- /**
187
- * Independent verifier. Takes a verifierView ONLY; any extra property (a model's reasoning, prior results) is rejected so
188
- * the isolation of its inputs is checkable rather than a convention.
189
- */
190
- async function independentVerify(view, opts = {}) {
191
- const allowed = new Set(['revision', 'reproducer', 'findingId', 'oracle']);
192
- const extra = Object.keys(view || {}).filter((k) => !allowed.has(k));
193
- if (extra.length) return { status: 'rejected', reason: `verifier input must be exactly revision, reproducer, findingId, oracle; got extra: ${extra.join(', ')}` };
194
- const attempt = await (opts.attemptFn ?? _runner_js__WEBPACK_IMPORTED_MODULE_2__/* .runAttempt */ .Tm)(structuredClone(view.reproducer), { ...opts, preferContainer: opts.preferContainer });
195
- return { status: attempt.status === 'completed' ? (attempt.oracle?.fired ? 'confirmed' : 'not-reproduced') : 'incomplete', attempt: summarize(attempt), environment: attempt.environment ?? null };
196
- }
197
-
198
- /**
199
- * @param {object} a
200
- * @param {object} a.finding the finding (id/stableId, severity, proofTier ...)
201
- * @param {string} [a.revision] commit the proof applies to
202
- * @param {object} a.reproducer serialized reproducer
203
- * @param {object} [a.policy]
204
- * @param {object} [a.deps] test seams: { attemptFn }
205
- */
206
- async function proveFinding({ finding, revision = null, reproducer, policy = {}, signal, deps = {}, sourceState = null, sourceRoot = null, overlay = null } = {}) {
207
- const started = Date.now();
208
- const pol = normalizePolicy(policy);
209
- const attemptFn = deps.attemptFn ?? _runner_js__WEBPACK_IMPORTED_MODULE_2__/* .runAttempt */ .Tm;
210
- const findingId = finding?.stableId ?? finding?.id ?? reproducer?.findingId ?? 'unknown';
211
- const degradation = [];
212
- let state = sourceState ?? (0,_states_js__WEBPACK_IMPORTED_MODULE_1__/* .fromProofTier */ .jn)((0,_proof_tier_js__WEBPACK_IMPORTED_MODULE_4__/* .proofTierOf */ .gx)(finding || {}));
213
- if (state === 'REPRODUCED') state = 'STATICALLY_CORROBORATED'; // an old single-run marker proof must be re-earned here
214
- const startState = state;
215
-
216
- const result = (extra) => ({
217
- schema: RESULT_SCHEMA, version: 1, findingId, revision, startState, state, staticCorroboration: (0,_states_js__WEBPACK_IMPORTED_MODULE_1__/* .stateRank */ .g3)(startState) >= 1, tier: (0,_states_js__WEBPACK_IMPORTED_MODULE_1__/* .toProofTier */ .KF)(state),
218
- oracle: reproducer?.oracle?.type ?? null, policy: pol,
219
- reproducerDigest: reproducer ? safeDigest(reproducer) : null,
220
- degradation, timing: { proofMs: Date.now() - started }, ...extra,
221
- });
222
-
223
- const errs = reproducer ? (0,_reproducer_js__WEBPACK_IMPORTED_MODULE_3__/* .validateReproducer */ .mC)(reproducer) : ['no reproducer supplied'];
224
- if (errs.length) { degradation.push('invalid-reproducer'); return result({ completeness: 'INCOMPLETE', outcome: 'invalid-reproducer', reasons: errs, attempts: { required: pol.required, run: 0, successes: 0, incomplete: 0 }, independentReplay: { status: 'not-run' } }); }
225
-
226
- // A valid reproducer is itself the REPRODUCER_GENERATED rung. Static corroboration is recorded, not required: an exploit
227
- // that reproduces under an independent oracle is deterministic corroboration in its own right, and a pattern-only finding
228
- // must not be unable to earn proof merely because the taint engine never saw it. The record says which it was.
229
- const staticCorroboration = (0,_states_js__WEBPACK_IMPORTED_MODULE_1__/* .stateRank */ .g3)(startState) >= (0,_states_js__WEBPACK_IMPORTED_MODULE_1__/* .stateRank */ .g3)('STATICALLY_CORROBORATED');
230
- if (!staticCorroboration) degradation.push('no-static-corroboration');
231
- state = 'REPRODUCER_GENERATED';
232
-
233
- const attempts = [];
234
- for (let i = 0; i < pol.attempts; i++) {
235
- if (signal?.aborted) { degradation.push('cancelled'); break; }
236
- const a = await attemptFn(structuredClone(reproducer), { limits: { timeoutMs: pol.timeoutMs }, signal, requireContainer: pol.requireContainer, preferContainer: pol.preferContainer, force: pol.force, sourceRoot, overlay });
237
- attempts.push(a);
238
- // Stop early once the threshold can no longer be met only if every attempt is a decisive negative; incomplete runs continue.
239
- }
240
- const completed = attempts.filter((a) => a.status === 'completed' && !a.oracle?.inconclusive);
241
- const successes = completed.filter((a) => a.oracle?.fired).length;
242
- const incomplete = attempts.length - completed.length;
243
- for (const a of attempts) for (const d of a.degraded || []) if (!degradation.includes(d)) degradation.push(d);
244
- if (incomplete) degradation.push(`incomplete-attempts:${incomplete}`);
245
- const env = attempts.find((a) => a.environment)?.environment ?? null;
246
- const base = {
247
- environment: env && { mode: env.mode, assurance: env.assurance, backend: env.backend ?? null, note: env.note ?? null },
248
- build: attempts.some((a) => a.status === 'build-failed') ? 'failed' : attempts.length ? 'ok' : 'not-run',
249
- attempts: { required: pol.required, run: attempts.length, successes, incomplete, detail: attempts.map(summarize) },
250
- artifactHashes: { reproducer: safeDigest(reproducer), observations: (0,_reproducer_js__WEBPACK_IMPORTED_MODULE_3__/* .sha256 */ .sc)((0,_reproducer_js__WEBPACK_IMPORTED_MODULE_3__/* .canonicalize */ .dw)(attempts.map((a) => a.observation ?? null))) },
251
- };
252
-
253
- if (successes > 0) {
254
- const r = (0,_states_js__WEBPACK_IMPORTED_MODULE_1__/* .advance */ .np)(state, 'REPRODUCED'); if (r.ok) state = r.state;
255
- }
256
- if (!attempts.length) return result({ ...base, completeness: 'INCOMPLETE', outcome: 'not-run', independentReplay: { status: 'not-run' } });
257
- if (successes === 0) {
258
- const decisive = completed.length === attempts.length;
259
- return result({ ...base, completeness: decisive ? 'FULL' : 'INCOMPLETE', outcome: decisive ? 'not-reproduced' : 'inconclusive', note: 'not reproduced is not proof of safety', independentReplay: { status: 'not-run' } });
260
- }
261
- if (successes < pol.required || incomplete) {
262
- return result({ ...base, completeness: incomplete ? 'INCOMPLETE' : 'DEGRADED', outcome: 'reproduced-below-threshold', independentReplay: { status: 'not-run' } });
263
- }
264
-
265
- let independent = { status: 'skipped' };
266
- if (pol.independentReplay) {
267
- independent = await independentVerify((0,_reproducer_js__WEBPACK_IMPORTED_MODULE_3__/* .verifierView */ .IW)({ revision, reproducer, findingId, oracle: reproducer.oracle }), { attemptFn, limits: { timeoutMs: pol.timeoutMs }, signal, requireContainer: pol.requireContainer, force: pol.force, sourceRoot, overlay });
268
- if (independent.status !== 'confirmed') degradation.push(`independent-replay:${independent.status}`);
269
- } else degradation.push('independent-replay-disabled');
270
- if (independent.status === 'confirmed') {
271
- const r = (0,_states_js__WEBPACK_IMPORTED_MODULE_1__/* .advance */ .np)(state, 'EXPLOIT_CONFIRMED'); if (r.ok) state = r.state;
272
- }
273
- const full = state === 'EXPLOIT_CONFIRMED' && base.environment?.assurance !== 'none';
274
- return result({ ...base, independentReplay: independent, completeness: full ? (base.environment.assurance === 'lower' ? 'DEGRADED' : 'FULL') : 'INCOMPLETE', outcome: full ? 'exploit-confirmed' : 'reproduced-unverified' });
275
- }
276
-
277
- const safeDigest = (r) => { try { return (0,_reproducer_js__WEBPACK_IMPORTED_MODULE_3__/* .reproducerDigest */ .we)(r); } catch { return null; } };
278
-
279
- /** Severity policy: optional, never on by default. Returns the finding unchanged unless the policy asks to demote. */
280
- function applySeverityPolicy(finding, evidenceState, policy) {
281
- const req = policy?.criticalRequires;
282
- if (!Array.isArray(req) || !req.length || finding?.severity !== 'critical') return finding;
283
- const ok = req.some((s) => stateRankOf(evidenceState ?? 'CANDIDATE') >= stateRankOf(s));
284
- return ok ? finding : { ...finding, severity: 'high', severityPolicy: { demotedFrom: 'critical', reason: `critical requires ${req.join(' or ')}; evidence state is ${evidenceState ?? 'CANDIDATE'}` } };
285
- }
286
- const _newRunId = () => randomBytes(6).toString('hex');
287
-
288
-
289
- /***/ }),
290
-
291
- /***/ 12090:
292
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
293
-
294
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
295
- /* harmony export */ KF: () => (/* binding */ toProofTier),
296
- /* harmony export */ g3: () => (/* binding */ stateRank),
297
- /* harmony export */ jn: () => (/* binding */ fromProofTier),
298
- /* harmony export */ np: () => (/* binding */ advance)
299
- /* harmony export */ });
300
- /* unused harmony exports EVIDENCE_STATES, COMPLETENESS */
301
- // Evidence state ladder for the Universal Exploit Proof Fabric.
302
- //
303
- // Evidence state is SEPARATE from severity and confidence. It extends, never replaces, the vocabulary that already
304
- // exists: `proof-tier.js` (execution-proven / proof-failed / taint-proven / unproven) and the fix-verify legs
305
- // (`verifiedFull`, `degradedLegs`). `toProofTier` / `fromProofTier` are the explicit bridges.
306
- //
307
- // Transitions are guarded: a state can only be reached from the state directly before it (or by dropping back), so no
308
- // caller can jump a finding to EXPLOIT_CONFIRMED without passing REPRODUCED, or to FIX_VERIFIED without
309
- // FIX_REPLAY_BLOCKED. A degraded or incomplete run NEVER advances a state.
310
- const EVIDENCE_STATES = Object.freeze([
311
- 'CANDIDATE',
312
- 'STATICALLY_CORROBORATED',
313
- 'REPRODUCER_GENERATED',
314
- 'REPRODUCED',
315
- 'EXPLOIT_CONFIRMED',
316
- 'FIX_REPLAY_BLOCKED',
317
- 'FIX_VERIFIED',
318
- ]);
319
-
320
- const stateRank = (s) => EVIDENCE_STATES.indexOf(s);
321
-
322
- const REQUIRES_PREDECESSOR = Object.freeze(Object.fromEntries(EVIDENCE_STATES.map((s, i) => [s, i === 0 ? null : EVIDENCE_STATES[i - 1]])));
323
-
324
- /**
325
- * Advance `from` to `to`. Returns { ok, state, reason }. Moving up requires `to` to be exactly the next rung; moving
326
- * down or staying is always allowed (evidence can be lost, never invented). Unknown states are rejected.
327
- */
328
- function advance(from, to) {
329
- if (!EVIDENCE_STATES.includes(from)) return { ok: false, state: 'CANDIDATE', reason: `unknown current state: ${String(from)}` };
330
- if (!EVIDENCE_STATES.includes(to)) return { ok: false, state: from, reason: `unknown target state: ${String(to)}` };
331
- if (stateRank(to) <= stateRank(from)) return { ok: true, state: to, reason: null };
332
- if (REQUIRES_PREDECESSOR[to] !== from) return { ok: false, state: from, reason: `cannot reach ${to} from ${from}: ${REQUIRES_PREDECESSOR[to]} is required first` };
333
- return { ok: true, state: to, reason: null };
334
- }
335
-
336
- // Bridges to the older vocabulary so existing consumers keep working.
337
- function toProofTier(state) {
338
- const r = stateRank(state);
339
- if (r >= stateRank('EXPLOIT_CONFIRMED')) return 'execution-proven';
340
- if (r >= stateRank('STATICALLY_CORROBORATED')) return 'taint-proven';
341
- return 'unproven';
342
- }
343
-
344
- function fromProofTier(tier) {
345
- if (tier === 'taint-proven') return 'STATICALLY_CORROBORATED';
346
- // execution-proven under the older single-run marker path is one run, not the 3/3 + independent replay the fabric
347
- // requires, so it maps to REPRODUCED and never to EXPLOIT_CONFIRMED.
348
- if (tier === 'execution-proven') return 'REPRODUCED';
349
- return 'CANDIDATE';
350
- }
351
-
352
- // Completeness vocabulary shared with fix-verify: FULL only when nothing was skipped.
353
- const COMPLETENESS = Object.freeze(['FULL', 'DEGRADED', 'INCOMPLETE']);
354
-
355
-
356
- /***/ }),
357
-
358
- /***/ 62199:
359
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
360
-
361
- __webpack_require__.r(__webpack_exports__);
362
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
363
- /* harmony export */ findingKey: () => (/* binding */ findingKey),
364
- /* harmony export */ latestProof: () => (/* binding */ latestProof),
365
- /* harmony export */ listProofs: () => (/* binding */ listProofs),
366
- /* harmony export */ saveProof: () => (/* binding */ saveProof),
367
- /* harmony export */ scrubDeep: () => (/* binding */ scrubDeep)
368
- /* harmony export */ });
369
- /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73024);
370
- /* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(76760);
371
- /* harmony import */ var _state_dir_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(31174);
372
- /* harmony import */ var _encryption_provider_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(39984);
373
- /* harmony import */ var _llm_validator_redact_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(65388);
374
- /* harmony import */ var _reproducer_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(37055);
375
- // Proof artifact store: `.agentic-security/proofs/<findingKey>/<recordDigest>.json`.
376
- //
377
- // Reuses the existing state machinery rather than adding another: `safeWriteState` (refuses unsafe dirs and symlinks),
378
- // `maybeEncryptForWrite` / `maybeDecryptForRead` (the `proofs` artifact is registered `confidential`), retention
379
- // (evidence class) and legal holds (a hold on `proofs` blocks purge). Nothing persisted contains a plaintext credential:
380
- // records are passed through a recursive secret filter first, and the runner never returns its per-run nonce or secrets.
381
-
382
-
383
-
384
-
385
-
386
-
387
-
388
- const PROOF_RECORD_SCHEMA = 'agentic-security/proof-record';
389
- const PROOFS_DIR = 'proofs';
390
- const MAX_RECORD_BYTES = 512 * 1024;
391
-
392
- const findingKey = (id) => `${String(id).replace(/[^A-Za-z0-9._-]/g, '_').slice(0, 80)}-${(0,_reproducer_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .sc)(String(id)).slice(0, 8)}`;
393
-
394
- // The shared redactor catches key=value shapes; bare tokens need their own pass, so persisted evidence cannot carry one.
395
- const BARE_SECRET_RES = [
396
- /\b(?:ghp|gho|ghu|ghs|ghr|github_pat)_[A-Za-z0-9_]{20,}\b/g, /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g, /\bsk-[A-Za-z0-9_-]{20,}\b/g,
397
- /\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g, /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,
398
- /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g, /\bSECRET-[0-9a-f]{24}-[a-z0-9_-]+\b/g,
399
- ];
400
- function scrubString(text) {
401
- let t = String(text);
402
- try { t = (0,_llm_validator_redact_js__WEBPACK_IMPORTED_MODULE_4__/* .redactSecrets */ .f)(t).text; } catch { return '[unredactable]'; }
403
- for (const re of BARE_SECRET_RES) t = t.replace(re, '[REDACTED-SECRET]');
404
- return t;
405
- }
406
-
407
- /** Deep-copy `v` with every string passed through the secret redactor. */
408
- function scrubDeep(v) {
409
- if (typeof v === 'string') return scrubString(v);
410
- if (Array.isArray(v)) return v.map(scrubDeep);
411
- if (v && typeof v === 'object') return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, scrubDeep(x)]));
412
- return v;
413
- }
414
-
415
- function recordDigest(record) {
416
- const { recordDigest: _omit, ...rest } = record;
417
- return (0,_reproducer_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .sc)((0,_reproducer_js__WEBPACK_IMPORTED_MODULE_5__/* .canonicalize */ .dw)(rest));
418
- }
419
-
420
- function saveProof(scanRoot, record) {
421
- const safe = scrubDeep(record);
422
- safe.schema = PROOF_RECORD_SCHEMA;
423
- safe.recordDigest = recordDigest(safe);
424
- const text = JSON.stringify(safe, null, 2);
425
- if (Buffer.byteLength(text) > MAX_RECORD_BYTES) return { ok: false, reason: 'proof record exceeds the size limit' };
426
- if (!(0,_state_dir_js__WEBPACK_IMPORTED_MODULE_2__/* .ensureStateDir */ .xH)(scanRoot)) return { ok: false, reason: 'no safe state directory for this project' };
427
- const enc = (0,_encryption_provider_js__WEBPACK_IMPORTED_MODULE_3__/* .maybeEncryptForWrite */ .v2)(scanRoot, PROOFS_DIR, text);
428
- if (!enc.ok) return { ok: false, reason: enc.reason };
429
- const file = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_2__.statePath)(scanRoot, PROOFS_DIR, findingKey(record.findingId), `${safe.recordDigest}.json`);
430
- if (!(0,_state_dir_js__WEBPACK_IMPORTED_MODULE_2__.safeWriteState)(file, enc.content)) return { ok: false, reason: 'state write refused' };
431
- return { ok: true, file, digest: safe.recordDigest, encrypted: enc.encrypted };
432
- }
433
-
434
- function readRecord(file) {
435
- const text = (0,_encryption_provider_js__WEBPACK_IMPORTED_MODULE_3__.maybeDecryptForRead)(node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(file, 'utf8'));
436
- const rec = JSON.parse(text);
437
- // A record whose content no longer matches its own digest was modified after it was written.
438
- if (rec.recordDigest !== recordDigest(rec)) return { tampered: true, record: rec };
439
- return { tampered: false, record: rec };
440
- }
441
-
442
- /** Newest-first records for a finding. Tampered records are returned flagged, never silently dropped or trusted. */
443
- function listProofs(scanRoot, findingId) {
444
- const dir = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_2__.statePath)(scanRoot, PROOFS_DIR, findingKey(findingId));
445
- let names = [];
446
- try { names = node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(dir).filter((n) => n.endsWith('.json')); } catch { return []; }
447
- const out = [];
448
- for (const n of names) {
449
- const f = node_path__WEBPACK_IMPORTED_MODULE_1__.join(dir, n);
450
- try { const { tampered, record } = readRecord(f); out.push({ file: f, tampered, record, mtime: node_fs__WEBPACK_IMPORTED_MODULE_0__.statSync(f).mtimeMs }); } catch { out.push({ file: f, tampered: true, record: null, mtime: 0 }); }
451
- }
452
- return out.sort((a, b) => b.mtime - a.mtime);
453
- }
454
-
455
- function latestProof(scanRoot, findingId) {
456
- return listProofs(scanRoot, findingId).find((p) => p.record) ?? null;
457
- }
458
-
459
-
460
- /***/ })
461
-
462
- };
@@ -1,138 +0,0 @@
1
- export const id = 9899;
2
- export const ids = [9899];
3
- export const modules = {
4
-
5
- /***/ 99899:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ validateOsvFunctionsExist: () => (/* binding */ validateOsvFunctionsExist)
10
- /* harmony export */ });
11
- /* unused harmony export extractPythonPackageFunctions */
12
- /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73024);
13
- /* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(76760);
14
- /* harmony import */ var node_child_process__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(31421);
15
- /* harmony import */ var _ir_parser_py_cst_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(71349);
16
- // Python package function extraction via the CST parser.
17
- //
18
- // Locates an installed Python package in site-packages or .venv,
19
- // parses its source files via the Python CST parser, and returns
20
- // a map of exported function names. Used by markUsedVulnFunctions
21
- // to validate that OSV-named vulnerable functions actually exist
22
- // in the installed version.
23
-
24
-
25
-
26
-
27
-
28
-
29
- const VENV_DIRS = ['.venv', 'venv', '.env', 'env'];
30
-
31
- function _findSitePackages(scanRoot) {
32
- for (const vdir of VENV_DIRS) {
33
- const base = node_path__WEBPACK_IMPORTED_MODULE_1__.join(scanRoot || '.', vdir);
34
- if (!node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(base)) continue;
35
- const lib = node_path__WEBPACK_IMPORTED_MODULE_1__.join(base, 'lib');
36
- if (!node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(lib)) continue;
37
- const pydirs = node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(lib).filter(d => d.startsWith('python'));
38
- for (const pydir of pydirs) {
39
- const sp = node_path__WEBPACK_IMPORTED_MODULE_1__.join(lib, pydir, 'site-packages');
40
- if (node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(sp)) return sp;
41
- }
42
- }
43
- // Fallback: ask python3 directly
44
- try {
45
- const out = (0,node_child_process__WEBPACK_IMPORTED_MODULE_2__.execFileSync)('python3', ['-c', 'import site; print(site.getsitepackages()[0])'], {
46
- encoding: 'utf8', timeout: 5000,
47
- }).trim();
48
- if (out && node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(out)) return out;
49
- } catch { /* no python3 or no site-packages */ }
50
- return null;
51
- }
52
-
53
- function _findPackageDir(sitePackages, packageName) {
54
- if (!sitePackages) return null;
55
- const normalized = packageName.replace(/-/g, '_').toLowerCase();
56
- const candidates = [
57
- normalized,
58
- packageName.toLowerCase(),
59
- packageName,
60
- ];
61
- for (const name of candidates) {
62
- const dir = node_path__WEBPACK_IMPORTED_MODULE_1__.join(sitePackages, name);
63
- if (node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(dir) && node_fs__WEBPACK_IMPORTED_MODULE_0__.statSync(dir).isDirectory()) return dir;
64
- }
65
- return null;
66
- }
67
-
68
- function _readPyFilesFromDir(dir, maxFiles = 50) {
69
- const entries = [];
70
- try {
71
- const files = node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(dir, { recursive: true })
72
- .filter(f => f.endsWith('.py'))
73
- .slice(0, maxFiles);
74
- for (const f of files) {
75
- const fp = node_path__WEBPACK_IMPORTED_MODULE_1__.join(dir, f);
76
- try {
77
- const content = node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(fp, 'utf8');
78
- if (content.length < 1_000_000) {
79
- entries.push({ file: f, content });
80
- }
81
- } catch { /* skip unreadable files */ }
82
- }
83
- } catch { /* dir not readable */ }
84
- return entries;
85
- }
86
-
87
- function extractPythonPackageFunctions(packageName, scanRoot) {
88
- const cap = (0,_ir_parser_py_cst_js__WEBPACK_IMPORTED_MODULE_3__/* .probePythonAvailable */ .w4)();
89
- if (!cap.ok) return null;
90
-
91
- const sitePackages = _findSitePackages(scanRoot);
92
- const pkgDir = _findPackageDir(sitePackages, packageName);
93
- if (!pkgDir) return null;
94
-
95
- const pyFiles = _readPyFilesFromDir(pkgDir);
96
- if (!pyFiles.length) return null;
97
-
98
- const batch = (0,_ir_parser_py_cst_js__WEBPACK_IMPORTED_MODULE_3__/* .parsePythonFilesBatch */ .H2)(pyFiles);
99
- if (!batch || !Array.isArray(batch)) return null;
100
-
101
- const functionMap = new Map();
102
- for (const fileIR of batch) {
103
- if (!fileIR || !fileIR.functions) continue;
104
- for (const fn of fileIR.functions) {
105
- if (fn.name && !fn.name.startsWith('_')) {
106
- functionMap.set(fn.name, {
107
- file: fileIR.file,
108
- line: fn.line,
109
- qid: fn.qid,
110
- params: fn.params,
111
- });
112
- }
113
- }
114
- }
115
- return functionMap;
116
- }
117
-
118
- function validateOsvFunctionsExist(packageName, osvFunctions, scanRoot) {
119
- if (!osvFunctions || !osvFunctions.length) return { validated: [], missing: [] };
120
- const fnMap = extractPythonPackageFunctions(packageName, scanRoot);
121
- if (!fnMap) return { validated: osvFunctions, missing: [] };
122
- const validated = [];
123
- const missing = [];
124
- for (const fn of osvFunctions) {
125
- const shortFn = fn.includes('.') ? fn.split('.').pop() : fn;
126
- if (fnMap.has(shortFn) || fnMap.has(fn)) {
127
- validated.push(shortFn);
128
- } else {
129
- missing.push(fn);
130
- }
131
- }
132
- return { validated, missing };
133
- }
134
-
135
-
136
- /***/ })
137
-
138
- };