@clear-capabilities/agentic-security-scanner 0.174.0 → 0.176.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 (103) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/bin/agentic-security.js +199 -28
  3. package/dist/2066.index.js +850 -0
  4. package/dist/2199.index.js +1 -1
  5. package/dist/2584.index.js +3332 -0
  6. package/dist/2923.index.js +13 -0
  7. package/dist/2946.index.js +81 -0
  8. package/dist/3196.index.js +27 -0
  9. package/dist/3727.index.js +292 -0
  10. package/dist/4168.index.js +509 -0
  11. package/dist/4281.index.js +993 -0
  12. package/dist/4978bec8fdf5c733dc85.json +283 -0
  13. package/dist/5099.index.js +96 -0
  14. package/dist/5616.index.js +1471 -0
  15. package/dist/5620.index.js +2370 -0
  16. package/dist/5817.index.js +714 -0
  17. package/dist/6333.index.js +98 -0
  18. package/dist/6655.index.js +3221 -0
  19. package/dist/7838.index.js +446 -974
  20. package/dist/818.index.js +4 -3
  21. package/dist/83.index.js +159 -0
  22. package/dist/8551.index.js +82 -0
  23. package/dist/8633.index.js +93 -0
  24. package/dist/8714.index.js +76 -76
  25. package/dist/8825.index.js +84 -0
  26. package/dist/932.index.js +186 -0
  27. package/dist/9560.index.js +358 -19
  28. package/dist/9800.index.js +6 -1
  29. package/dist/agentic-security.mjs +10 -10
  30. package/dist/agentic-security.mjs.sha256 +1 -1
  31. package/dist/df1e8683e7eda7b2b79c.js +29 -0
  32. package/package.json +7 -6
  33. package/src/artifact/CLAUDE.md +4 -0
  34. package/src/artifact/artifact-evidence.js +63 -0
  35. package/src/artifact/cosign.js +61 -0
  36. package/src/artifact/engine-source.js +72 -0
  37. package/src/artifact/oci-layout.js +47 -0
  38. package/src/artifact/registry.js +213 -0
  39. package/src/capabilities/tool-registry.js +2 -0
  40. package/src/language/haskell-security-rules.js +1 -1
  41. package/src/language/nixos-hardening.js +37 -0
  42. package/src/lineage/CLAUDE.md +4 -0
  43. package/src/lineage/identity-token.js +11 -0
  44. package/src/lineage/observation-adapters.js +13 -0
  45. package/src/lineage/runtime-edge-states.js +139 -0
  46. package/src/lineage/runtime-explorer-view.js +82 -0
  47. package/src/lineage/runtime-observation.js +11 -0
  48. package/src/mcp/CLAUDE.md +3 -1
  49. package/src/mcp/proof-tools.js +132 -0
  50. package/src/mcp/server.js +1 -1
  51. package/src/mcp/tools.js +3 -1
  52. package/src/posture/CLAUDE.md +23 -0
  53. package/src/posture/artifact-registry.js +4 -0
  54. package/src/posture/dnr/attack-facts.js +31 -0
  55. package/src/posture/dnr/cli.js +138 -0
  56. package/src/posture/dnr/detection-ir.js +123 -0
  57. package/src/posture/dnr/exposure-window.js +134 -0
  58. package/src/posture/dnr/hunt.js +84 -0
  59. package/src/posture/dnr/log-reader.js +189 -0
  60. package/src/posture/dnr/matchers.js +90 -0
  61. package/src/posture/dnr/outputs.js +262 -0
  62. package/src/posture/dnr/payload-classes.js +120 -0
  63. package/src/posture/dnr/redact.js +25 -0
  64. package/src/posture/dnr/store.js +57 -0
  65. package/src/posture/dnr/validate.js +64 -0
  66. package/src/posture/dnr/view.js +51 -0
  67. package/src/posture/evaluation/lab/arm-ollama.js +88 -0
  68. package/src/posture/evaluation/lab/arms.js +142 -0
  69. package/src/posture/evaluation/lab/cli.js +135 -0
  70. package/src/posture/evaluation/lab/dataset.js +139 -0
  71. package/src/posture/evaluation/lab/materialize.js +44 -0
  72. package/src/posture/evaluation/lab/neutralize.js +144 -0
  73. package/src/posture/evaluation/lab/report.js +176 -0
  74. package/src/posture/evaluation/lab/run.js +225 -0
  75. package/src/posture/evaluation/lab/score.js +135 -0
  76. package/src/posture/evaluation/lab/scoreboard.js +48 -0
  77. package/src/posture/evaluation/lab/stats.js +41 -0
  78. package/src/posture/evaluation/lab/store.js +53 -0
  79. package/src/posture/fleet/cli.js +248 -63
  80. package/src/posture/fleet/discover-edges.js +135 -0
  81. package/src/posture/fleet/enterprise-graph.js +148 -0
  82. package/src/posture/fleet/fleet-graph.js +9 -4
  83. package/src/posture/fleet/fleet-manifest.js +50 -5
  84. package/src/posture/fleet/job-runner.js +153 -0
  85. package/src/posture/fleet/job-store.js +136 -0
  86. package/src/posture/fleet/org-health.js +56 -0
  87. package/src/posture/fleet/scan-cache.js +112 -0
  88. package/src/posture/fleet/scan-child.js +29 -0
  89. package/src/posture/proof-fabric/cli.js +34 -6
  90. package/src/posture/proof-fabric/container.js +57 -0
  91. package/src/posture/proof-fabric/fix-proof.js +2 -1
  92. package/src/posture/proof-fabric/generate-python.js +129 -0
  93. package/src/posture/proof-fabric/generate.js +213 -0
  94. package/src/posture/proof-fabric/reproducer.js +3 -0
  95. package/src/posture/proof-fabric/runner.js +20 -11
  96. package/src/posture/proof-fabric/siblings.js +77 -0
  97. package/src/posture/routing/policy-router.js +103 -0
  98. package/src/posture/rule-compiler/cli.js +64 -6
  99. package/src/posture/rule-compiler/corpus.js +10 -2
  100. package/src/posture/rule-compiler/mutation.js +72 -1
  101. package/src/posture/rule-compiler/promotion.js +21 -5
  102. package/src/posture/rule-compiler/proposal.js +132 -0
  103. package/src/posture/rule-compiler/store.js +16 -0
@@ -0,0 +1,714 @@
1
+ export const id = 5817;
2
+ export const ids = [5817,2199];
3
+ export const modules = {
4
+
5
+ /***/ 95817:
6
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
+
8
+ // ESM COMPAT FLAG
9
+ __webpack_require__.r(__webpack_exports__);
10
+
11
+ // EXPORTS
12
+ __webpack_require__.d(__webpack_exports__, {
13
+ cmdProof: () => (/* binding */ cmdProof),
14
+ cmdProve: () => (/* binding */ cmdProve),
15
+ resolveReproducer: () => (/* binding */ resolveReproducer)
16
+ });
17
+
18
+ // EXTERNAL MODULE: external "node:fs"
19
+ var external_node_fs_ = __webpack_require__(73024);
20
+ // EXTERNAL MODULE: external "node:os"
21
+ var external_node_os_ = __webpack_require__(48161);
22
+ // EXTERNAL MODULE: external "node:path"
23
+ var external_node_path_ = __webpack_require__(76760);
24
+ // EXTERNAL MODULE: ./src/posture/state-dir.js
25
+ var state_dir = __webpack_require__(31174);
26
+ // EXTERNAL MODULE: ./src/posture/proof-fabric/orchestrator.js
27
+ var orchestrator = __webpack_require__(3740);
28
+ // EXTERNAL MODULE: ./src/posture/proof-fabric/store.js
29
+ var store = __webpack_require__(62199);
30
+ // EXTERNAL MODULE: ./src/posture/proof-fabric/runner.js + 1 modules
31
+ var runner = __webpack_require__(23081);
32
+ // EXTERNAL MODULE: ./src/posture/proof-fabric/reproducer.js
33
+ var proof_fabric_reproducer = __webpack_require__(37055);
34
+ // EXTERNAL MODULE: external "node:module"
35
+ var external_node_module_ = __webpack_require__(98995);
36
+ // EXTERNAL MODULE: ./node_modules/@babel/parser/lib/index.js
37
+ var lib = __webpack_require__(46411);
38
+ ;// CONCATENATED MODULE: ./src/posture/proof-fabric/generate.js
39
+ // Reproducer generation from a finding's own evidence (PRD 1: `triage exploit --prove` with no hand-written reproducer).
40
+ //
41
+ // What this is: a DETERMINISTIC harness builder for the cases where a harness can be built from the source alone. It reads the
42
+ // flagged file, finds the function around the flagged line, decides how that function is reached, picks the payload for the
43
+ // weakness class, and emits an ordinary reproducer, which then goes through exactly the same runner, oracle, 3-of-3 repetition and
44
+ // independent replay as any other. A generated reproducer is not a verdict; it is a proposal that is either confirmed by execution
45
+ // or not.
46
+ //
47
+ // What this is not: a general exploit generator. It handles JavaScript only, and only code the proof environment can actually load:
48
+ // the file's imports must be Node built-ins or relative files inside the repository (a package from node_modules is not there in
49
+ // the sandbox, so a handler that needs `express` is refused, with the package named). Anything outside that returns `{ ok: false }`
50
+ // with the reason, and nothing is executed.
51
+ //
52
+ // Two shapes:
53
+ // script the file reads `process.argv[2]`: it is run with the payload as its argument;
54
+ // function the file exports (or declares at top level and exports) the function around the flagged line: a generated harness
55
+ // loads it and calls it, filling the tainted parameter with the payload. A parameter that is a request-like object
56
+ // (`req`) gets a stand-in whose `body`/`query`/`params` answer every property with the payload.
57
+ //
58
+ // Weakness classes with a payload and an oracle that can SEE the effect: CWE-78 (a canary file created by the injected command),
59
+ // CWE-22 (a write that lands outside the working directory, only for write sinks), CWE-918 (a request reaching the runner's loopback
60
+ // listener). Others (injection into a database, deserialization, memory safety) need an environment or a native harness this does not
61
+ // build, and are refused by name rather than approximated.
62
+
63
+
64
+
65
+
66
+
67
+
68
+ const CLASSES = {
69
+ 'CWE-78': { name: 'command-injection', payload: 'x; touch {{CANARY:command}}', oracle: { type: 'command_execution', params: { canary: 'command' } } },
70
+ 'CWE-22': { name: 'path-traversal', payload: '../escaped.txt', oracle: { type: 'filesystem_mutation', params: { canary: 'fs' } }, watch: { fs: 'escaped.txt' }, needs: /\b(?:writeFile|writeFileSync|appendFile|appendFileSync|createWriteStream)\b/ },
71
+ 'CWE-918': { name: 'ssrf', payload: '{{CALLBACK_URL}}', oracle: { type: 'outbound_callback' }, network: 'callback' },
72
+ };
73
+ const MAX_SOURCE = 256 * 1024;
74
+ const MAX_FILES = 8;
75
+ const EXTS = ['', '.js', '.mjs', '.cjs', '/index.js'];
76
+ const BUILTINS = new Set(external_node_module_.builtinModules.flatMap((m) => [m, `node:${m}`]));
77
+ const MODULE_SYNTAX = /^\s*(?:import\s[^('"]|import\s*['"{*]|export\s)/m;
78
+
79
+ const fail = (reason, extra = {}) => ({ ok: false, reason, ...extra });
80
+ const normCwe = (c) => { const m = /(\d{1,5})/.exec(String(c ?? '')); return m ? `CWE-${Number(m[1])}` : null; };
81
+
82
+ function inside(root, rel) {
83
+ if (typeof rel !== 'string' || !rel || rel.includes('\0')) return null;
84
+ let real;
85
+ try { real = external_node_fs_.realpathSync(external_node_path_.resolve(root, rel)); } catch { return null; }
86
+ const base = external_node_fs_.realpathSync(root);
87
+ return real === base || real.startsWith(base + external_node_path_.sep) ? real : null;
88
+ }
89
+
90
+ function readSource(root, rel) {
91
+ const real = inside(root, rel);
92
+ if (!real) return null;
93
+ const st = external_node_fs_.statSync(real);
94
+ if (!st.isFile() || st.size > MAX_SOURCE) return null;
95
+ return { real, text: external_node_fs_.readFileSync(real, 'utf8') };
96
+ }
97
+
98
+ function parseSource(text) {
99
+ try { return (0,lib/* parse */.qg)(text, { sourceType: 'unambiguous', errorRecovery: false, plugins: ['topLevelAwait'], allowReturnOutsideFunction: true }); } catch { return null; }
100
+ }
101
+
102
+ function* walk(node, parent = null) {
103
+ if (!node || typeof node !== 'object') return;
104
+ if (Array.isArray(node)) { for (const n of node) yield* walk(n, parent); return; }
105
+ if (typeof node.type !== 'string') return;
106
+ yield { node, parent };
107
+ for (const [k, v] of Object.entries(node)) if (k !== 'loc' && k !== 'leadingComments' && k !== 'trailingComments' && v && typeof v === 'object') yield* walk(v, node);
108
+ }
109
+
110
+ /** Every module this file loads: built-ins pass, relative files are collected, anything else is a dependency the proof cannot provide. */
111
+ function dependencies(ast) {
112
+ const specs = [];
113
+ for (const { node } of walk(ast.program)) {
114
+ if (node.type === 'ImportDeclaration' || ((node.type === 'ExportNamedDeclaration' || node.type === 'ExportAllDeclaration') && node.source)) specs.push(node.source.value);
115
+ else if (node.type === 'CallExpression' && node.callee.type === 'Identifier' && node.callee.name === 'require' && node.arguments[0]?.type === 'StringLiteral') specs.push(node.arguments[0].value);
116
+ else if (node.type === 'ImportExpression' && node.source?.type === 'StringLiteral') specs.push(node.source.value);
117
+ }
118
+ return specs;
119
+ }
120
+
121
+ /** Every function that contains the line, innermost first: the flagged call is often inside a callback of the function that can be called. */
122
+ function functionsAround(ast, line) {
123
+ const all = [];
124
+ for (const { node, parent } of walk(ast.program)) {
125
+ if (!/^(?:FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod|ClassMethod)$/.test(node.type)) continue;
126
+ if (node.loc && node.loc.start.line <= line && node.loc.end.line >= line) all.push({ node, parent });
127
+ }
128
+ return all.sort((a, b) => (a.node.loc.end.line - a.node.loc.start.line) - (b.node.loc.end.line - b.node.loc.start.line) || (b.node.loc.start.line - a.node.loc.start.line));
129
+ }
130
+
131
+ const paramNames = (fn) => fn.params.map((p) => (p.type === 'Identifier' ? p.name : p.type === 'AssignmentPattern' && p.left.type === 'Identifier' ? p.left.name : null));
132
+
133
+ /** How the function is reachable from outside: its exported name, or null. */
134
+ function exportName(ast, fnInfo) {
135
+ const { node, parent } = fnInfo;
136
+ const idName = node.id?.name ?? (parent?.type === 'VariableDeclarator' && parent.id.type === 'Identifier' ? parent.id.name : null);
137
+ let found = null;
138
+ for (const { node: n } of walk(ast.program)) {
139
+ if (n.type === 'ExportNamedDeclaration' && n.declaration) {
140
+ if (n.declaration === node || (n.declaration.type === 'FunctionDeclaration' && n.declaration.id?.name === idName)) found = { kind: 'named', name: idName };
141
+ if (n.declaration.type === 'VariableDeclaration' && n.declaration.declarations.some((d) => d.init === node)) found = { kind: 'named', name: n.declaration.declarations.find((d) => d.init === node).id.name };
142
+ }
143
+ if (n.type === 'ExportNamedDeclaration' && n.specifiers?.length && idName) for (const s of n.specifiers) if (s.local?.name === idName) found = { kind: 'named', name: s.exported.name };
144
+ if (n.type === 'ExportDefaultDeclaration' && (n.declaration === node || n.declaration?.name === idName)) found = { kind: 'default' };
145
+ if (n.type === 'AssignmentExpression' && n.left.type === 'MemberExpression') {
146
+ const l = n.left; const obj = l.object; const prop = l.property?.name ?? l.property?.value;
147
+ const isModuleExports = obj.type === 'Identifier' && obj.name === 'module' && prop === 'exports';
148
+ if (isModuleExports && (n.right === node || (n.right.type === 'Identifier' && n.right.name === idName))) found = { kind: 'module' };
149
+ if (isModuleExports && n.right.type === 'ObjectExpression') for (const p of n.right.properties) if ((p.value === node || p.value?.name === idName || (p.shorthand && p.key.name === idName)) && p.key) found = { kind: 'named', name: p.key.name ?? p.key.value };
150
+ const isExportsProp = (obj.type === 'Identifier' && obj.name === 'exports') || (obj.type === 'MemberExpression' && obj.object?.name === 'module' && obj.property?.name === 'exports');
151
+ if (isExportsProp && prop && (n.right === node || (n.right.type === 'Identifier' && n.right.name === idName))) found = { kind: 'named', name: prop };
152
+ }
153
+ }
154
+ return found;
155
+ }
156
+
157
+ function harness({ esm, entry, exp, args }) {
158
+ const load = esm ? `const mod = await import('./${entry}');` : `import { createRequire } from 'node:module';\nconst require = createRequire(import.meta.url);\nconst mod = require('./${entry}');`;
159
+ const pick = exp.kind === 'named' ? `mod[${JSON.stringify(exp.name)}] ?? mod.default?.[${JSON.stringify(exp.name)}]` : exp.kind === 'default' ? 'mod.default ?? mod' : 'typeof mod === \'function\' ? mod : mod.default';
160
+ return `// Generated by the proof fabric from the finding's own evidence. It loads the flagged function and calls it with the payload.
161
+ ${load}
162
+ const payload = process.argv[2] ?? '';
163
+ const P = new Proxy({}, { get: (_t, k) => (k === Symbol.toPrimitive ? () => payload : k === 'toString' ? () => payload : payload), has: () => true });
164
+ const res = new Proxy(function () {}, { get: () => res, apply: () => res });
165
+ const fn = ${pick};
166
+ if (typeof fn !== 'function') { console.error('the exported value is not a function'); process.exit(3); }
167
+ try { await Promise.race([Promise.resolve(fn(${args.join(', ')})), new Promise((r) => setTimeout(r, 5000))]); } catch (e) { console.error('target threw:', String(e && e.message).slice(0, 200)); }
168
+ `;
169
+ }
170
+
171
+ function generateReproducer({ finding, root }) {
172
+ const cwe = normCwe(finding?.cwe);
173
+ const cls = CLASSES[cwe];
174
+ if (!cls) return fail(`no payload and oracle exist for ${cwe ?? 'this finding'}; supported: ${Object.keys(CLASSES).join(', ')} (others need a database, a deserializer or a native harness)`);
175
+ const rel = String(finding?.file ?? '');
176
+ if (!/\.(?:js|mjs|cjs)$/i.test(rel)) return fail(`no harness builder for ${external_node_path_.extname(rel) || 'this file type'}; JavaScript only`);
177
+ if (!Number.isInteger(finding?.line)) return fail('the finding has no line number');
178
+ const src = readSource(root, rel);
179
+ if (!src) return fail('the flagged file is missing, outside the repository, or too large');
180
+ const ast = parseSource(src.text);
181
+ if (!ast) return fail('the flagged file could not be parsed');
182
+ const lines = src.text.split('\n');
183
+ const sinkLine = lines[finding.line - 1] ?? '';
184
+ if (cls.needs && !cls.needs.test(sinkLine) && !cls.needs.test(lines.slice(Math.max(0, finding.line - 3), finding.line + 2).join('\n'))) return fail(`${cls.name}: the flagged code is not a write, and the oracle can only observe a write (a read leaves no trace unless the program prints it)`);
185
+
186
+ // dependencies the sandbox can satisfy
187
+ const sources = {}; const external = [];
188
+ const entryDir = external_node_path_.dirname(src.real);
189
+ const rootReal = external_node_fs_.realpathSync(root); // the repository root as the filesystem names it (a temp dir can sit behind a symlink)
190
+ const collect = (realFile, ast0, count) => {
191
+ for (const spec of dependencies(ast0)) {
192
+ if (BUILTINS.has(spec)) continue;
193
+ if (!spec.startsWith('.')) { external.push(spec); continue; }
194
+ let found = null;
195
+ for (const e of EXTS) { const cand = inside(root, external_node_path_.relative(rootReal, external_node_path_.resolve(external_node_path_.dirname(realFile), spec + e))); if (cand && external_node_fs_.statSync(cand).isFile()) { found = cand; break; } }
196
+ if (!found) return fail(`the relative import "${spec}" was not found inside the repository`);
197
+ const destRel = external_node_path_.relative(entryDir, found);
198
+ if (destRel.startsWith('..')) return fail(`"${spec}" lives outside the flagged file's directory, which a proof workspace cannot mirror`);
199
+ if (sources[destRel] || found === src.real) continue;
200
+ if (Object.keys(sources).length >= MAX_FILES) return fail(`the file pulls in more than ${MAX_FILES} repository files`);
201
+ const dep = readSource(root, external_node_path_.relative(rootReal, found));
202
+ if (!dep) return fail(`"${spec}" is too large or unreadable`);
203
+ sources[destRel] = external_node_path_.relative(rootReal, found);
204
+ const depAst = parseSource(dep.text);
205
+ if (!depAst) return fail(`"${spec}" could not be parsed`);
206
+ const r = collect(found, depAst, count + 1); if (r) return r;
207
+ }
208
+ return null;
209
+ };
210
+ const bad = collect(src.real, ast, 0);
211
+ if (bad) return bad;
212
+ if (external.length) return fail(`the flagged code needs ${[...new Set(external)].slice(0, 4).join(', ')}, which is not installed in the proof environment; only Node built-ins and repository files can be loaded`, { missing: [...new Set(external)] });
213
+
214
+ const esm = MODULE_SYNTAX.test(src.text) || external_node_path_.extname(rel).toLowerCase() === '.mjs';
215
+ const entry = `target${esm ? '.mjs' : '.cjs'}`;
216
+ sources[entry] = rel;
217
+ const assumptions = [];
218
+ const base = { schema: 'agentic-security/reproducer', version: 1, findingId: String(finding.stableId ?? finding.id ?? 'generated'), lang: 'javascript', oracle: cls.oracle, network: cls.network ?? 'none', ...(cls.watch ? { watch: cls.watch } : {}) };
219
+ if (cls.watch) assumptions.push('the write target is assumed to be one directory below the working directory (the payload is ../escaped.txt); if the code uses another base, the proof will not confirm');
220
+
221
+ // shape 1: a script that reads its payload from argv
222
+ if (/process\.argv\s*\[\s*2\s*\]|process\.argv\.slice\(\s*2\s*\)/.test(src.text) && !/\bmodule\.exports\b|^\s*export\s/m.test(src.text)) {
223
+ const reproducer = { ...base, sources, run: ['{{NODE}}', entry, cls.payload] };
224
+ const errs = (0,proof_fabric_reproducer/* validateReproducer */.mC)(reproducer);
225
+ return errs.length ? fail(`the generated reproducer is invalid: ${errs[0]}`) : { ok: true, reproducer, basis: { shape: 'script', class: cls.name, entry: rel, line: finding.line, assumptions } };
226
+ }
227
+
228
+ // shape 2: an exported function around the flagged line
229
+ const candidates = functionsAround(ast, finding.line);
230
+ if (!candidates.length) return fail('the flagged line is not inside a function, and the file does not read its payload from process.argv[2]');
231
+ let around = null; let exp = null;
232
+ for (const c of candidates) { const e = exportName(ast, c); if (e) { around = c; exp = e; break; } }
233
+ if (!around) return fail('the function around the flagged line is not exported, so nothing outside the file can call it');
234
+ const names = paramNames(around.node);
235
+ if (!names.length) return fail('the function around the flagged line takes no parameters, so the payload has no way in');
236
+ const window = lines.slice(Math.max(0, around.node.loc.start.line - 1), Math.min(lines.length, finding.line + 1)).join('\n');
237
+ const requestLike = names.findIndex((n) => n && /^(?:req|request)$/.test(n) && new RegExp(`\\b${n}\\.(?:body|query|params)\\b`).test(sinkLine));
238
+ const direct = requestLike >= 0 ? -1 : names.findIndex((n) => n && new RegExp(`\\b${n}\\b`).test(sinkLine));
239
+ const fallback = direct < 0 && requestLike < 0 ? names.findIndex((n) => n && new RegExp(`\\b${n}\\b`).test(window)) : -1;
240
+ const idx = requestLike >= 0 ? requestLike : direct >= 0 ? direct : fallback;
241
+ if (idx < 0) return fail('none of the function\'s parameters appears in the flagged code, so there is no tainted parameter to fill');
242
+ if (fallback >= 0) assumptions.push(`the tainted parameter "${names[idx]}" was chosen because it appears in the function body near the flagged line, not on the line itself`);
243
+ const args = names.map((_, i) => (i !== idx ? (/^(?:res|response)$/.test(names[i] ?? '') ? 'res' : 'undefined') : requestLike >= 0 ? '{ body: P, query: P, params: P, headers: P, cookies: P }' : 'payload'));
244
+ const files = { 'harness.mjs': harness({ esm, entry, exp, args }) };
245
+ const reproducer = { ...base, sources, files, run: ['{{NODE}}', 'harness.mjs', cls.payload] };
246
+ const errs = (0,proof_fabric_reproducer/* validateReproducer */.mC)(reproducer);
247
+ return errs.length ? fail(`the generated reproducer is invalid: ${errs[0]}`) : { ok: true, reproducer, basis: { shape: 'function', class: cls.name, entry: rel, line: finding.line, function: names.length ? `${exp.kind === 'named' ? exp.name : exp.kind}(${names.join(', ')})` : exp.kind, taintedParameter: names[idx], requestLike: requestLike >= 0, assumptions } };
248
+ }
249
+
250
+ ;// CONCATENATED MODULE: ./src/posture/proof-fabric/cli.js
251
+ // CLI surface for the proof fabric: `proof show|replay|doctor`, `triage exploit|validate`. Non-interactive by design: no
252
+ // command reads stdin, every run is bounded by the policy timeouts, and a missing reproducer is a typed exit code, not a
253
+ // prompt. Exit codes: 0 confirmed/ok, 1 not confirmed (any reason), 4 usage/precondition.
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+ function loadFinding(root, id) {
266
+ const p = (0,state_dir.statePath)(root, 'last-scan.json');
267
+ if (!external_node_fs_.existsSync(p)) return null;
268
+ const last = JSON.parse(external_node_fs_.readFileSync(p, 'utf8'));
269
+ return (last.findings || []).find((f) => f.id === id || f.stableId === id) ?? null;
270
+ }
271
+
272
+ /**
273
+ * The reproducer for a finding: the one the person or agent supplied (or stored), else one built from the finding's own evidence.
274
+ * A generated reproducer is a proposal; it earns nothing until it is executed, and the result says it was generated.
275
+ */
276
+ function resolveReproducer(root, finding, flagPath) {
277
+ const supplied = loadReproducer(root, finding.stableId ?? finding.id, flagPath) ?? (finding.stableId && finding.id !== finding.stableId ? loadReproducer(root, finding.id, flagPath) : null);
278
+ if (supplied) return { ...supplied, generated: null };
279
+ const g = generateReproducer({ finding, root });
280
+ if (!g.ok) return { reproducer: null, reason: g.reason };
281
+ return { reproducer: g.reproducer, file: null, generated: g.basis };
282
+ }
283
+
284
+ function loadReproducer(root, id, flagPath) {
285
+ const candidates = [flagPath && external_node_path_.resolve(String(flagPath)), (0,state_dir.statePath)(root, 'reproducers', `${(0,store.findingKey)(id)}.json`)].filter(Boolean);
286
+ for (const c of candidates) {
287
+ try { return { reproducer: JSON.parse(external_node_fs_.readFileSync(c, 'utf8')), file: c }; } catch { /* next */ }
288
+ }
289
+ return null;
290
+ }
291
+
292
+ function formatResult(r) {
293
+ const env = r.environment ? `${r.environment.mode} (${r.environment.assurance} assurance)` : 'none';
294
+ return [
295
+ `Finding: ${r.findingId}`,
296
+ `Evidence: ${r.state}`,
297
+ `Oracle: ${r.oracle}`,
298
+ `Reproductions: ${r.attempts?.successes ?? 0}/${r.attempts?.run ?? 0} (required ${r.attempts?.required})`,
299
+ `Independent replay: ${r.independentReplay?.status ?? 'not-run'}`,
300
+ `Environment: ${env}`,
301
+ `Completeness: ${r.completeness}`,
302
+ `Duration: ${(r.timing.proofMs / 1000).toFixed(1)}s`,
303
+ ...(r.degradation?.length ? [`Degraded: ${r.degradation.join(', ')}`] : []),
304
+ ...(r.note ? [`Note: ${r.note}`] : []),
305
+ ].join('\n');
306
+ }
307
+
308
+ async function cmdProve(args, root, { json = false } = {}) {
309
+ const id = String(args._[2] ?? '');
310
+ if (!id) { console.error('usage: triage exploit <finding-id> --prove [--reproducer file] [--attempts N] [--required N]'); return 4; }
311
+ const finding = loadFinding(root, id);
312
+ if (!finding) { console.error(`Finding ${id} not found in last scan.`); return 4; }
313
+ const loaded = resolveReproducer(root, finding, args.flags.reproducer);
314
+ if (!loaded.reproducer) { console.error(`No reproducer for ${id}, and none could be generated from the finding: ${loaded.reason}. Supply one with --reproducer <file> or place it at .agentic-security/reproducers/. Nothing was executed.`); return 4; }
315
+ if (loaded.generated) console.error(`Generated a reproducer from the finding (${loaded.generated.shape}, ${loaded.generated.class}). It is a proposal: it counts only if executing it confirms the exploit.`);
316
+ const errs = (0,proof_fabric_reproducer/* validateReproducer */.mC)(loaded.reproducer);
317
+ if (errs.length) { console.error(`Invalid reproducer: ${errs.join('; ')}`); return 4; }
318
+ const policy = {};
319
+ if (args.flags.attempts) policy.attempts = Number(args.flags.attempts);
320
+ if (args.flags.required) policy.required = Number(args.flags.required);
321
+ if (args.flags.timeout) policy.timeoutMs = Number(args.flags.timeout) * 1000;
322
+ if (args.flags['require-container']) policy.requireContainer = true;
323
+ const ac = new AbortController();
324
+ const onSig = () => ac.abort();
325
+ process.once('SIGINT', onSig);
326
+ let result;
327
+ try { result = await (0,orchestrator/* proveFinding */.kO)({ finding, reproducer: loaded.reproducer, revision: args.flags.revision ?? null, policy, signal: ac.signal, sourceRoot: root }); } finally { process.off('SIGINT', onSig); }
328
+ const saved = (0,store.saveProof)(root, { ...result, reproducer: loaded.reproducer, ...(loaded.generated ? { generatedFrom: loaded.generated } : {}) });
329
+ // Printed output gets the same secret-scrubbing pass as what is persisted (defense in depth: a free-text reason/note
330
+ // field that captured something from stdout/stderr should never reach a terminal unredacted either).
331
+ if (json || args.flags.json) console.log(JSON.stringify((0,store.scrubDeep)({ ...result, stored: saved.ok ? saved.file : null }), null, 2));
332
+ else { console.log(formatResult(result)); if (!saved.ok) console.log(`(proof not stored: ${saved.reason})`); }
333
+ return result.state === 'EXPLOIT_CONFIRMED' ? 0 : 1;
334
+ }
335
+
336
+ async function cmdProof(args, root) {
337
+ const sub = args._[1];
338
+ if (sub === 'doctor') return doctor(args);
339
+ if (sub === 'generate') {
340
+ const gid = String(args._[2] ?? '');
341
+ const finding = gid ? loadFinding(root, gid) : null;
342
+ if (!finding) { console.error(gid ? `Finding ${gid} not found in last scan.` : 'usage: proof generate <finding-id> [--out file]'); return 4; }
343
+ const g = generateReproducer({ finding, root });
344
+ if (!g.ok) { console.error(`No reproducer could be generated: ${g.reason}`); return 1; }
345
+ const text = JSON.stringify({ ...g.reproducer, findingId: gid }, null, 2);
346
+ if (args.flags.out) { external_node_fs_.writeFileSync(external_node_path_.resolve(String(args.flags.out)), `${text}\n`); console.log(`Wrote ${external_node_path_.resolve(String(args.flags.out))} (${g.basis.shape}, ${g.basis.class}). Nothing was executed.`); } else console.log(text);
347
+ for (const a of g.basis.assumptions) console.error(`assumption: ${a}`);
348
+ return 0;
349
+ }
350
+ const id = String(args._[2] ?? '');
351
+ if (!id) { console.error('usage: proof show <finding-id> | proof replay <finding-id> | proof generate <finding-id> | proof doctor'); return 4; }
352
+ if (sub === 'show') {
353
+ const all = (0,store.listProofs)(root, id);
354
+ if (!all.length) { console.error(`No stored proof for ${id}.`); return 4; }
355
+ const latest = all.find((p) => p.record);
356
+ 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.`);
357
+ const good = all.find((p) => p.record && !p.tampered);
358
+ if (!good) { console.error('No intact proof record.'); return 1; }
359
+ if (args.flags.json) console.log(JSON.stringify(good.record, null, 2)); else console.log(formatResult(good.record));
360
+ // the detection generated from this finding's proof (detection-and-response loop), when there is one
361
+ try {
362
+ const det = (await __webpack_require__.e(/* import() */ 8551).then(__webpack_require__.bind(__webpack_require__, 58551))).latestRecord(root, id, 'detection');
363
+ if (det && !args.flags.json) console.log(`Detection: ${det.record.ir?.id ?? 'unknown'} (${det.record.validation?.status ?? 'not validated'}${det.record.enabled ? ', enabled' : ''})`);
364
+ } catch { /* the proof output does not depend on it */ }
365
+ void latest;
366
+ return 0;
367
+ }
368
+ if (sub === 'replay') {
369
+ const stored = (0,store.latestProof)(root, id);
370
+ if (!stored?.record?.reproducer) { console.error(`No stored reproducer for ${id}.`); return 4; }
371
+ const tmpDir = external_node_fs_.mkdtempSync(external_node_path_.join(external_node_os_.tmpdir(), 'proof-replay-'));
372
+ const tmp = external_node_path_.join(tmpDir, 'reproducer.json');
373
+ external_node_fs_.writeFileSync(tmp, JSON.stringify(stored.record.reproducer));
374
+ args.flags.reproducer = tmp;
375
+ args._ = ['triage', 'exploit', id];
376
+ try { return await cmdProve(args, root); } finally { external_node_fs_.rmSync(tmpDir, { recursive: true, force: true }); }
377
+ }
378
+ console.error('usage: proof show|replay <finding-id> | proof doctor');
379
+ return 4;
380
+ }
381
+
382
+ function doctor(args) {
383
+ const tools = (0,runner/* hostTools */.qV)();
384
+ const rows = proof_fabric_reproducer/* LANGUAGES */.Yj.map((l) => ({ lang: l, ...(0,runner/* languageSupport */.ql)(l, tools) }));
385
+ const envs = ['javascript', 'python'].map((l) => ({ lang: l, ...(0,runner/* selectEnvironment */.aP)({ lang: l }) }));
386
+ if (args.flags.json) { console.log(JSON.stringify({ tools, languages: rows, environments: envs }, null, 2)); return 0; }
387
+ console.log('Proof fabric doctor');
388
+ for (const r of rows) console.log(` ${r.lang.padEnd(11)} ${r.supported ? 'supported' : `unsupported (${r.reason})`}`);
389
+ 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}` : ''}`);
390
+ const usable = envs.some((e) => e.mode !== 'unavailable');
391
+ if (!usable) console.log(' RESULT: no execution environment available; proofs will report blocked, never clean.');
392
+ return usable ? 0 : 1;
393
+ }
394
+
395
+
396
+ /***/ }),
397
+
398
+ /***/ 3740:
399
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
400
+
401
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
402
+ /* harmony export */ kO: () => (/* binding */ proveFinding)
403
+ /* harmony export */ });
404
+ /* unused harmony exports independentVerify, applySeverityPolicy, _newRunId */
405
+ /* harmony import */ var node_crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(77598);
406
+ /* harmony import */ var _states_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12090);
407
+ /* harmony import */ var _runner_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(23081);
408
+ /* harmony import */ var _reproducer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(37055);
409
+ /* harmony import */ var _proof_tier_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(40216);
410
+ // Proof orchestration: finding + revision + reproducer + policy -> structured evidence.
411
+ //
412
+ // Rules that make this safe to trust:
413
+ // * The model may propose a reproducer and select an oracle. The oracle (oracles.js) judges. Never a model.
414
+ // * An attempt that did not complete (timeout, build failure, blocked, unsupported, error) is NOT a negative and NOT a
415
+ // positive: it is degraded evidence, it never advances the state, and it makes the result INCOMPLETE.
416
+ // * EXPLOIT_CONFIRMED needs `required` successes in `attempts` completed attempts AND a pass from an independent
417
+ // verifier that receives only {revision, reproducer, findingId, oracle} in a fresh environment.
418
+ // * "Not reproduced" is reported as such; it is never reported as safe.
419
+
420
+
421
+
422
+
423
+
424
+
425
+ const PROOF_POLICY_DEFAULTS = Object.freeze({ attempts: 3, required: 3, independentReplay: true, timeoutMs: 20_000, cpus: 1, memoryMb: 512, network: 'none', requireContainer: false });
426
+ const RESULT_SCHEMA = 'agentic-security/proof-result';
427
+
428
+ function normalizePolicy(p = {}) {
429
+ const x = { ...PROOF_POLICY_DEFAULTS, ...p };
430
+ x.attempts = Math.max(1, Math.min(10, Math.trunc(Number(x.attempts)) || PROOF_POLICY_DEFAULTS.attempts));
431
+ x.required = Math.max(1, Math.min(x.attempts, Math.trunc(Number(x.required)) || x.attempts));
432
+ x.timeoutMs = Math.max(1000, Math.min(120_000, Number(x.timeoutMs) || PROOF_POLICY_DEFAULTS.timeoutMs));
433
+ return x;
434
+ }
435
+
436
+ 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 });
437
+
438
+ /**
439
+ * Independent verifier. Takes a verifierView ONLY; any extra property (a model's reasoning, prior results) is rejected so
440
+ * the isolation of its inputs is checkable rather than a convention.
441
+ */
442
+ async function independentVerify(view, opts = {}) {
443
+ const allowed = new Set(['revision', 'reproducer', 'findingId', 'oracle']);
444
+ const extra = Object.keys(view || {}).filter((k) => !allowed.has(k));
445
+ if (extra.length) return { status: 'rejected', reason: `verifier input must be exactly revision, reproducer, findingId, oracle; got extra: ${extra.join(', ')}` };
446
+ const attempt = await (opts.attemptFn ?? _runner_js__WEBPACK_IMPORTED_MODULE_2__/* .runAttempt */ .Tm)(structuredClone(view.reproducer), { ...opts, preferContainer: opts.preferContainer });
447
+ return { status: attempt.status === 'completed' ? (attempt.oracle?.fired ? 'confirmed' : 'not-reproduced') : 'incomplete', attempt: summarize(attempt), environment: attempt.environment ?? null };
448
+ }
449
+
450
+ /**
451
+ * @param {object} a
452
+ * @param {object} a.finding the finding (id/stableId, severity, proofTier ...)
453
+ * @param {string} [a.revision] commit the proof applies to
454
+ * @param {object} a.reproducer serialized reproducer
455
+ * @param {object} [a.policy]
456
+ * @param {object} [a.deps] test seams: { attemptFn }
457
+ */
458
+ async function proveFinding({ finding, revision = null, reproducer, policy = {}, signal, deps = {}, sourceState = null, sourceRoot = null, overlay = null } = {}) {
459
+ const started = Date.now();
460
+ const pol = normalizePolicy(policy);
461
+ const attemptFn = deps.attemptFn ?? _runner_js__WEBPACK_IMPORTED_MODULE_2__/* .runAttempt */ .Tm;
462
+ const findingId = finding?.stableId ?? finding?.id ?? reproducer?.findingId ?? 'unknown';
463
+ const degradation = [];
464
+ let state = sourceState ?? (0,_states_js__WEBPACK_IMPORTED_MODULE_1__/* .fromProofTier */ .jn)((0,_proof_tier_js__WEBPACK_IMPORTED_MODULE_4__/* .proofTierOf */ .gx)(finding || {}));
465
+ if (state === 'REPRODUCED') state = 'STATICALLY_CORROBORATED'; // an old single-run marker proof must be re-earned here
466
+ const startState = state;
467
+
468
+ const result = (extra) => ({
469
+ 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),
470
+ oracle: reproducer?.oracle?.type ?? null, policy: pol,
471
+ reproducerDigest: reproducer ? safeDigest(reproducer) : null,
472
+ degradation, timing: { proofMs: Date.now() - started }, ...extra,
473
+ });
474
+
475
+ const errs = reproducer ? (0,_reproducer_js__WEBPACK_IMPORTED_MODULE_3__/* .validateReproducer */ .mC)(reproducer) : ['no reproducer supplied'];
476
+ 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' } }); }
477
+
478
+ // A valid reproducer is itself the REPRODUCER_GENERATED rung. Static corroboration is recorded, not required: an exploit
479
+ // that reproduces under an independent oracle is deterministic corroboration in its own right, and a pattern-only finding
480
+ // must not be unable to earn proof merely because the taint engine never saw it. The record says which it was.
481
+ const staticCorroboration = (0,_states_js__WEBPACK_IMPORTED_MODULE_1__/* .stateRank */ .g3)(startState) >= (0,_states_js__WEBPACK_IMPORTED_MODULE_1__/* .stateRank */ .g3)('STATICALLY_CORROBORATED');
482
+ if (!staticCorroboration) degradation.push('no-static-corroboration');
483
+ state = 'REPRODUCER_GENERATED';
484
+
485
+ const attempts = [];
486
+ for (let i = 0; i < pol.attempts; i++) {
487
+ if (signal?.aborted) { degradation.push('cancelled'); break; }
488
+ const a = await attemptFn(structuredClone(reproducer), { limits: { timeoutMs: pol.timeoutMs }, signal, requireContainer: pol.requireContainer, preferContainer: pol.preferContainer, force: pol.force, sourceRoot, overlay });
489
+ attempts.push(a);
490
+ // Stop early once the threshold can no longer be met only if every attempt is a decisive negative; incomplete runs continue.
491
+ }
492
+ const completed = attempts.filter((a) => a.status === 'completed' && !a.oracle?.inconclusive);
493
+ const successes = completed.filter((a) => a.oracle?.fired).length;
494
+ const incomplete = attempts.length - completed.length;
495
+ for (const a of attempts) for (const d of a.degraded || []) if (!degradation.includes(d)) degradation.push(d);
496
+ if (incomplete) degradation.push(`incomplete-attempts:${incomplete}`);
497
+ const env = attempts.find((a) => a.environment)?.environment ?? null;
498
+ const base = {
499
+ environment: env && { mode: env.mode, assurance: env.assurance, backend: env.backend ?? null, note: env.note ?? null },
500
+ build: attempts.some((a) => a.status === 'build-failed') ? 'failed' : attempts.length ? 'ok' : 'not-run',
501
+ attempts: { required: pol.required, run: attempts.length, successes, incomplete, detail: attempts.map(summarize) },
502
+ 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))) },
503
+ };
504
+
505
+ if (successes > 0) {
506
+ const r = (0,_states_js__WEBPACK_IMPORTED_MODULE_1__/* .advance */ .np)(state, 'REPRODUCED'); if (r.ok) state = r.state;
507
+ }
508
+ if (!attempts.length) return result({ ...base, completeness: 'INCOMPLETE', outcome: 'not-run', independentReplay: { status: 'not-run' } });
509
+ if (successes === 0) {
510
+ const decisive = completed.length === attempts.length;
511
+ return result({ ...base, completeness: decisive ? 'FULL' : 'INCOMPLETE', outcome: decisive ? 'not-reproduced' : 'inconclusive', note: 'not reproduced is not proof of safety', independentReplay: { status: 'not-run' } });
512
+ }
513
+ if (successes < pol.required || incomplete) {
514
+ return result({ ...base, completeness: incomplete ? 'INCOMPLETE' : 'DEGRADED', outcome: 'reproduced-below-threshold', independentReplay: { status: 'not-run' } });
515
+ }
516
+
517
+ let independent = { status: 'skipped' };
518
+ if (pol.independentReplay) {
519
+ 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 });
520
+ if (independent.status !== 'confirmed') degradation.push(`independent-replay:${independent.status}`);
521
+ } else degradation.push('independent-replay-disabled');
522
+ if (independent.status === 'confirmed') {
523
+ const r = (0,_states_js__WEBPACK_IMPORTED_MODULE_1__/* .advance */ .np)(state, 'EXPLOIT_CONFIRMED'); if (r.ok) state = r.state;
524
+ }
525
+ const full = state === 'EXPLOIT_CONFIRMED' && base.environment?.assurance !== 'none';
526
+ return result({ ...base, independentReplay: independent, completeness: full ? (base.environment.assurance === 'lower' ? 'DEGRADED' : 'FULL') : 'INCOMPLETE', outcome: full ? 'exploit-confirmed' : 'reproduced-unverified' });
527
+ }
528
+
529
+ const safeDigest = (r) => { try { return (0,_reproducer_js__WEBPACK_IMPORTED_MODULE_3__/* .reproducerDigest */ .we)(r); } catch { return null; } };
530
+
531
+ /** Severity policy: optional, never on by default. Returns the finding unchanged unless the policy asks to demote. */
532
+ function applySeverityPolicy(finding, evidenceState, policy) {
533
+ const req = policy?.criticalRequires;
534
+ if (!Array.isArray(req) || !req.length || finding?.severity !== 'critical') return finding;
535
+ const ok = req.some((s) => stateRankOf(evidenceState ?? 'CANDIDATE') >= stateRankOf(s));
536
+ return ok ? finding : { ...finding, severity: 'high', severityPolicy: { demotedFrom: 'critical', reason: `critical requires ${req.join(' or ')}; evidence state is ${evidenceState ?? 'CANDIDATE'}` } };
537
+ }
538
+ const _newRunId = () => randomBytes(6).toString('hex');
539
+
540
+
541
+ /***/ }),
542
+
543
+ /***/ 12090:
544
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
545
+
546
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
547
+ /* harmony export */ KF: () => (/* binding */ toProofTier),
548
+ /* harmony export */ g3: () => (/* binding */ stateRank),
549
+ /* harmony export */ jn: () => (/* binding */ fromProofTier),
550
+ /* harmony export */ np: () => (/* binding */ advance)
551
+ /* harmony export */ });
552
+ /* unused harmony exports EVIDENCE_STATES, COMPLETENESS */
553
+ // Evidence state ladder for the Universal Exploit Proof Fabric.
554
+ //
555
+ // Evidence state is SEPARATE from severity and confidence. It extends, never replaces, the vocabulary that already
556
+ // exists: `proof-tier.js` (execution-proven / proof-failed / taint-proven / unproven) and the fix-verify legs
557
+ // (`verifiedFull`, `degradedLegs`). `toProofTier` / `fromProofTier` are the explicit bridges.
558
+ //
559
+ // Transitions are guarded: a state can only be reached from the state directly before it (or by dropping back), so no
560
+ // caller can jump a finding to EXPLOIT_CONFIRMED without passing REPRODUCED, or to FIX_VERIFIED without
561
+ // FIX_REPLAY_BLOCKED. A degraded or incomplete run NEVER advances a state.
562
+ const EVIDENCE_STATES = Object.freeze([
563
+ 'CANDIDATE',
564
+ 'STATICALLY_CORROBORATED',
565
+ 'REPRODUCER_GENERATED',
566
+ 'REPRODUCED',
567
+ 'EXPLOIT_CONFIRMED',
568
+ 'FIX_REPLAY_BLOCKED',
569
+ 'FIX_VERIFIED',
570
+ ]);
571
+
572
+ const stateRank = (s) => EVIDENCE_STATES.indexOf(s);
573
+
574
+ const REQUIRES_PREDECESSOR = Object.freeze(Object.fromEntries(EVIDENCE_STATES.map((s, i) => [s, i === 0 ? null : EVIDENCE_STATES[i - 1]])));
575
+
576
+ /**
577
+ * Advance `from` to `to`. Returns { ok, state, reason }. Moving up requires `to` to be exactly the next rung; moving
578
+ * down or staying is always allowed (evidence can be lost, never invented). Unknown states are rejected.
579
+ */
580
+ function advance(from, to) {
581
+ if (!EVIDENCE_STATES.includes(from)) return { ok: false, state: 'CANDIDATE', reason: `unknown current state: ${String(from)}` };
582
+ if (!EVIDENCE_STATES.includes(to)) return { ok: false, state: from, reason: `unknown target state: ${String(to)}` };
583
+ if (stateRank(to) <= stateRank(from)) return { ok: true, state: to, reason: null };
584
+ if (REQUIRES_PREDECESSOR[to] !== from) return { ok: false, state: from, reason: `cannot reach ${to} from ${from}: ${REQUIRES_PREDECESSOR[to]} is required first` };
585
+ return { ok: true, state: to, reason: null };
586
+ }
587
+
588
+ // Bridges to the older vocabulary so existing consumers keep working.
589
+ function toProofTier(state) {
590
+ const r = stateRank(state);
591
+ if (r >= stateRank('EXPLOIT_CONFIRMED')) return 'execution-proven';
592
+ if (r >= stateRank('STATICALLY_CORROBORATED')) return 'taint-proven';
593
+ return 'unproven';
594
+ }
595
+
596
+ function fromProofTier(tier) {
597
+ if (tier === 'taint-proven') return 'STATICALLY_CORROBORATED';
598
+ // execution-proven under the older single-run marker path is one run, not the 3/3 + independent replay the fabric
599
+ // requires, so it maps to REPRODUCED and never to EXPLOIT_CONFIRMED.
600
+ if (tier === 'execution-proven') return 'REPRODUCED';
601
+ return 'CANDIDATE';
602
+ }
603
+
604
+ // Completeness vocabulary shared with fix-verify: FULL only when nothing was skipped.
605
+ const COMPLETENESS = Object.freeze(['FULL', 'DEGRADED', 'INCOMPLETE']);
606
+
607
+
608
+ /***/ }),
609
+
610
+ /***/ 62199:
611
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
612
+
613
+ __webpack_require__.r(__webpack_exports__);
614
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
615
+ /* harmony export */ findingKey: () => (/* binding */ findingKey),
616
+ /* harmony export */ latestProof: () => (/* binding */ latestProof),
617
+ /* harmony export */ listProofs: () => (/* binding */ listProofs),
618
+ /* harmony export */ saveProof: () => (/* binding */ saveProof),
619
+ /* harmony export */ scrubDeep: () => (/* binding */ scrubDeep)
620
+ /* harmony export */ });
621
+ /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73024);
622
+ /* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(76760);
623
+ /* harmony import */ var _state_dir_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(31174);
624
+ /* harmony import */ var _encryption_provider_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(39984);
625
+ /* harmony import */ var _llm_validator_redact_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(65388);
626
+ /* harmony import */ var _reproducer_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(37055);
627
+ // Proof artifact store: `.agentic-security/proofs/<findingKey>/<recordDigest>.json`.
628
+ //
629
+ // Reuses the existing state machinery rather than adding another: `safeWriteState` (refuses unsafe dirs and symlinks),
630
+ // `maybeEncryptForWrite` / `maybeDecryptForRead` (the `proofs` artifact is registered `confidential`), retention
631
+ // (evidence class) and legal holds (a hold on `proofs` blocks purge). Nothing persisted contains a plaintext credential:
632
+ // records are passed through a recursive secret filter first, and the runner never returns its per-run nonce or secrets.
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+ const PROOF_RECORD_SCHEMA = 'agentic-security/proof-record';
641
+ const PROOFS_DIR = 'proofs';
642
+ const MAX_RECORD_BYTES = 512 * 1024;
643
+
644
+ 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)}`;
645
+
646
+ // The shared redactor catches key=value shapes; bare tokens need their own pass, so persisted evidence cannot carry one.
647
+ const BARE_SECRET_RES = [
648
+ /\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,
649
+ /\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,
650
+ /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g, /\bSECRET-[0-9a-f]{24}-[a-z0-9_-]+\b/g,
651
+ ];
652
+ function scrubString(text) {
653
+ let t = String(text);
654
+ try { t = (0,_llm_validator_redact_js__WEBPACK_IMPORTED_MODULE_4__/* .redactSecrets */ .f)(t).text; } catch { return '[unredactable]'; }
655
+ for (const re of BARE_SECRET_RES) t = t.replace(re, '[REDACTED-SECRET]');
656
+ return t;
657
+ }
658
+
659
+ /** Deep-copy `v` with every string passed through the secret redactor. */
660
+ function scrubDeep(v) {
661
+ if (typeof v === 'string') return scrubString(v);
662
+ if (Array.isArray(v)) return v.map(scrubDeep);
663
+ if (v && typeof v === 'object') return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, scrubDeep(x)]));
664
+ return v;
665
+ }
666
+
667
+ function recordDigest(record) {
668
+ const { recordDigest: _omit, ...rest } = record;
669
+ return (0,_reproducer_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .sc)((0,_reproducer_js__WEBPACK_IMPORTED_MODULE_5__/* .canonicalize */ .dw)(rest));
670
+ }
671
+
672
+ function saveProof(scanRoot, record) {
673
+ const safe = scrubDeep(record);
674
+ safe.schema = PROOF_RECORD_SCHEMA;
675
+ safe.recordDigest = recordDigest(safe);
676
+ const text = JSON.stringify(safe, null, 2);
677
+ if (Buffer.byteLength(text) > MAX_RECORD_BYTES) return { ok: false, reason: 'proof record exceeds the size limit' };
678
+ if (!(0,_state_dir_js__WEBPACK_IMPORTED_MODULE_2__.ensureStateDir)(scanRoot)) return { ok: false, reason: 'no safe state directory for this project' };
679
+ const enc = (0,_encryption_provider_js__WEBPACK_IMPORTED_MODULE_3__/* .maybeEncryptForWrite */ .v2)(scanRoot, PROOFS_DIR, text);
680
+ if (!enc.ok) return { ok: false, reason: enc.reason };
681
+ const file = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_2__.statePath)(scanRoot, PROOFS_DIR, findingKey(record.findingId), `${safe.recordDigest}.json`);
682
+ if (!(0,_state_dir_js__WEBPACK_IMPORTED_MODULE_2__.safeWriteState)(file, enc.content)) return { ok: false, reason: 'state write refused' };
683
+ return { ok: true, file, digest: safe.recordDigest, encrypted: enc.encrypted };
684
+ }
685
+
686
+ function readRecord(file) {
687
+ const text = (0,_encryption_provider_js__WEBPACK_IMPORTED_MODULE_3__.maybeDecryptForRead)(node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(file, 'utf8'));
688
+ const rec = JSON.parse(text);
689
+ // A record whose content no longer matches its own digest was modified after it was written.
690
+ if (rec.recordDigest !== recordDigest(rec)) return { tampered: true, record: rec };
691
+ return { tampered: false, record: rec };
692
+ }
693
+
694
+ /** Newest-first records for a finding. Tampered records are returned flagged, never silently dropped or trusted. */
695
+ function listProofs(scanRoot, findingId) {
696
+ const dir = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_2__.statePath)(scanRoot, PROOFS_DIR, findingKey(findingId));
697
+ let names = [];
698
+ try { names = node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(dir).filter((n) => n.endsWith('.json')); } catch { return []; }
699
+ const out = [];
700
+ for (const n of names) {
701
+ const f = node_path__WEBPACK_IMPORTED_MODULE_1__.join(dir, n);
702
+ 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 }); }
703
+ }
704
+ return out.sort((a, b) => b.mtime - a.mtime);
705
+ }
706
+
707
+ function latestProof(scanRoot, findingId) {
708
+ return listProofs(scanRoot, findingId).find((p) => p.record) ?? null;
709
+ }
710
+
711
+
712
+ /***/ })
713
+
714
+ };