@clear-capabilities/agentic-security-scanner 0.166.0 → 0.168.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 (39) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/bin/agentic-security.js +40 -4
  3. package/dist/2199.index.js +348 -0
  4. package/dist/3736.index.js +2 -1
  5. package/dist/3740.index.js +722 -0
  6. package/dist/4113.index.js +1 -1
  7. package/dist/4142.index.js +929 -0
  8. package/dist/5738.index.js +240 -0
  9. package/dist/6932.index.js +1190 -0
  10. package/dist/7838.index.js +1 -1
  11. package/dist/808.index.js +1330 -0
  12. package/dist/818.index.js +93 -0
  13. package/dist/9800.index.js +245 -0
  14. package/dist/9999.index.js +2 -2
  15. package/dist/agentic-security.mjs +2 -2
  16. package/dist/agentic-security.mjs.sha256 +1 -1
  17. package/package.json +2 -2
  18. package/src/posture/artifact-registry.js +6 -0
  19. package/src/posture/fleet/cli.js +103 -0
  20. package/src/posture/fleet/fleet-graph.js +142 -0
  21. package/src/posture/fleet/fleet-manifest.js +77 -0
  22. package/src/posture/proof-fabric/cli.js +115 -0
  23. package/src/posture/proof-fabric/fix-proof.js +73 -0
  24. package/src/posture/proof-fabric/oracles.js +101 -0
  25. package/src/posture/proof-fabric/orchestrator.js +129 -0
  26. package/src/posture/proof-fabric/reproducer.js +108 -0
  27. package/src/posture/proof-fabric/runner.js +243 -0
  28. package/src/posture/proof-fabric/states.js +53 -0
  29. package/src/posture/proof-fabric/store.js +83 -0
  30. package/src/posture/rule-compiler/cli.js +141 -0
  31. package/src/posture/rule-compiler/corpus.js +61 -0
  32. package/src/posture/rule-compiler/eligibility.js +25 -0
  33. package/src/posture/rule-compiler/ir.js +87 -0
  34. package/src/posture/rule-compiler/lifecycle.js +57 -0
  35. package/src/posture/rule-compiler/mutation.js +60 -0
  36. package/src/posture/rule-compiler/promotion.js +47 -0
  37. package/src/posture/rule-compiler/store.js +96 -0
  38. package/src/sandbox/backend-userspace.js +7 -1
  39. package/src/sandbox/trust-boundary.js +2 -1
@@ -0,0 +1,240 @@
1
+ export const id = 5738;
2
+ export const ids = [5738];
3
+ export const modules = {
4
+
5
+ /***/ 35738:
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
+ formatResult: () => (/* binding */ formatResult),
16
+ loadReproducerFor: () => (/* binding */ loadReproducerFor)
17
+ });
18
+
19
+ // EXTERNAL MODULE: external "node:fs"
20
+ var external_node_fs_ = __webpack_require__(73024);
21
+ // EXTERNAL MODULE: external "node:os"
22
+ var external_node_os_ = __webpack_require__(48161);
23
+ // EXTERNAL MODULE: external "node:path"
24
+ var external_node_path_ = __webpack_require__(76760);
25
+ // EXTERNAL MODULE: ./src/posture/state-dir.js
26
+ var state_dir = __webpack_require__(31174);
27
+ // EXTERNAL MODULE: ./src/posture/proof-fabric/orchestrator.js
28
+ var orchestrator = __webpack_require__(3740);
29
+ // EXTERNAL MODULE: ./src/posture/encryption-provider.js
30
+ var encryption_provider = __webpack_require__(39984);
31
+ // EXTERNAL MODULE: ./src/llm-validator/redact.js
32
+ var redact = __webpack_require__(65388);
33
+ // EXTERNAL MODULE: ./src/posture/proof-fabric/reproducer.js
34
+ var reproducer = __webpack_require__(37055);
35
+ ;// CONCATENATED MODULE: ./src/posture/proof-fabric/store.js
36
+ // Proof artifact store: `.agentic-security/proofs/<findingKey>/<recordDigest>.json`.
37
+ //
38
+ // Reuses the existing state machinery rather than adding another: `safeWriteState` (refuses unsafe dirs and symlinks),
39
+ // `maybeEncryptForWrite` / `maybeDecryptForRead` (the `proofs` artifact is registered `confidential`), retention
40
+ // (evidence class) and legal holds (a hold on `proofs` blocks purge). Nothing persisted contains a plaintext credential:
41
+ // records are passed through a recursive secret filter first, and the runner never returns its per-run nonce or secrets.
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+ const PROOF_RECORD_SCHEMA = 'agentic-security/proof-record';
50
+ const PROOFS_DIR = 'proofs';
51
+ const MAX_RECORD_BYTES = 512 * 1024;
52
+
53
+ const findingKey = (id) => `${String(id).replace(/[^A-Za-z0-9._-]/g, '_').slice(0, 80)}-${(0,reproducer/* sha256 */.sc)(String(id)).slice(0, 8)}`;
54
+
55
+ // The shared redactor catches key=value shapes; bare tokens need their own pass, so persisted evidence cannot carry one.
56
+ const BARE_SECRET_RES = [
57
+ /\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,
58
+ /\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,
59
+ /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g, /\bSECRET-[0-9a-f]{24}-[a-z0-9_-]+\b/g,
60
+ ];
61
+ function scrubString(text) {
62
+ let t = String(text);
63
+ try { t = (0,redact/* redactSecrets */.f)(t).text; } catch { return '[unredactable]'; }
64
+ for (const re of BARE_SECRET_RES) t = t.replace(re, '[REDACTED-SECRET]');
65
+ return t;
66
+ }
67
+
68
+ /** Deep-copy `v` with every string passed through the secret redactor. */
69
+ function scrubDeep(v) {
70
+ if (typeof v === 'string') return scrubString(v);
71
+ if (Array.isArray(v)) return v.map(scrubDeep);
72
+ if (v && typeof v === 'object') return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, scrubDeep(x)]));
73
+ return v;
74
+ }
75
+
76
+ function recordDigest(record) {
77
+ const { recordDigest: _omit, ...rest } = record;
78
+ return (0,reproducer/* sha256 */.sc)((0,reproducer/* canonicalize */.dw)(rest));
79
+ }
80
+
81
+ function saveProof(scanRoot, record) {
82
+ const safe = scrubDeep(record);
83
+ safe.schema = PROOF_RECORD_SCHEMA;
84
+ safe.recordDigest = recordDigest(safe);
85
+ const text = JSON.stringify(safe, null, 2);
86
+ if (Buffer.byteLength(text) > MAX_RECORD_BYTES) return { ok: false, reason: 'proof record exceeds the size limit' };
87
+ if (!(0,state_dir/* ensureStateDir */.xH)(scanRoot)) return { ok: false, reason: 'no safe state directory for this project' };
88
+ const enc = (0,encryption_provider/* maybeEncryptForWrite */.v2)(scanRoot, PROOFS_DIR, text);
89
+ if (!enc.ok) return { ok: false, reason: enc.reason };
90
+ const file = (0,state_dir.statePath)(scanRoot, PROOFS_DIR, findingKey(record.findingId), `${safe.recordDigest}.json`);
91
+ if (!(0,state_dir/* safeWriteState */.Ep)(file, enc.content)) return { ok: false, reason: 'state write refused' };
92
+ return { ok: true, file, digest: safe.recordDigest, encrypted: enc.encrypted };
93
+ }
94
+
95
+ function readRecord(file) {
96
+ const text = (0,encryption_provider.maybeDecryptForRead)(external_node_fs_.readFileSync(file, 'utf8'));
97
+ const rec = JSON.parse(text);
98
+ // A record whose content no longer matches its own digest was modified after it was written.
99
+ if (rec.recordDigest !== recordDigest(rec)) return { tampered: true, record: rec };
100
+ return { tampered: false, record: rec };
101
+ }
102
+
103
+ /** Newest-first records for a finding. Tampered records are returned flagged, never silently dropped or trusted. */
104
+ function listProofs(scanRoot, findingId) {
105
+ const dir = (0,state_dir.statePath)(scanRoot, PROOFS_DIR, findingKey(findingId));
106
+ let names = [];
107
+ try { names = external_node_fs_.readdirSync(dir).filter((n) => n.endsWith('.json')); } catch { return []; }
108
+ const out = [];
109
+ for (const n of names) {
110
+ const f = external_node_path_.join(dir, n);
111
+ try { const { tampered, record } = readRecord(f); out.push({ file: f, tampered, record, mtime: external_node_fs_.statSync(f).mtimeMs }); } catch { out.push({ file: f, tampered: true, record: null, mtime: 0 }); }
112
+ }
113
+ return out.sort((a, b) => b.mtime - a.mtime);
114
+ }
115
+
116
+ function latestProof(scanRoot, findingId) {
117
+ return listProofs(scanRoot, findingId).find((p) => p.record) ?? null;
118
+ }
119
+
120
+ // EXTERNAL MODULE: ./src/posture/proof-fabric/runner.js
121
+ var runner = __webpack_require__(2998);
122
+ ;// CONCATENATED MODULE: ./src/posture/proof-fabric/cli.js
123
+ // CLI surface for the proof fabric: `proof show|replay|doctor`, `triage exploit|validate`. Non-interactive by design: no
124
+ // command reads stdin, every run is bounded by the policy timeouts, and a missing reproducer is a typed exit code, not a
125
+ // prompt. Exit codes: 0 confirmed/ok, 1 not confirmed (any reason), 4 usage/precondition.
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+ function loadFinding(root, id) {
137
+ const p = (0,state_dir.statePath)(root, 'last-scan.json');
138
+ if (!external_node_fs_.existsSync(p)) return null;
139
+ const last = JSON.parse(external_node_fs_.readFileSync(p, 'utf8'));
140
+ return (last.findings || []).find((f) => f.id === id || f.stableId === id) ?? null;
141
+ }
142
+
143
+ function loadReproducerFor(root, id, flagPath) { return loadReproducer(root, id, flagPath); }
144
+
145
+ function loadReproducer(root, id, flagPath) {
146
+ const candidates = [flagPath && external_node_path_.resolve(String(flagPath)), (0,state_dir.statePath)(root, 'reproducers', `${findingKey(id)}.json`)].filter(Boolean);
147
+ for (const c of candidates) {
148
+ try { return { reproducer: JSON.parse(external_node_fs_.readFileSync(c, 'utf8')), file: c }; } catch { /* next */ }
149
+ }
150
+ return null;
151
+ }
152
+
153
+ function formatResult(r) {
154
+ const env = r.environment ? `${r.environment.mode} (${r.environment.assurance} assurance)` : 'none';
155
+ return [
156
+ `Finding: ${r.findingId}`,
157
+ `Evidence: ${r.state}`,
158
+ `Oracle: ${r.oracle}`,
159
+ `Reproductions: ${r.attempts?.successes ?? 0}/${r.attempts?.run ?? 0} (required ${r.attempts?.required})`,
160
+ `Independent replay: ${r.independentReplay?.status ?? 'not-run'}`,
161
+ `Environment: ${env}`,
162
+ `Completeness: ${r.completeness}`,
163
+ `Duration: ${(r.timing.proofMs / 1000).toFixed(1)}s`,
164
+ ...(r.degradation?.length ? [`Degraded: ${r.degradation.join(', ')}`] : []),
165
+ ...(r.note ? [`Note: ${r.note}`] : []),
166
+ ].join('\n');
167
+ }
168
+
169
+ async function cmdProve(args, root, { json = false } = {}) {
170
+ const id = String(args._[2] ?? '');
171
+ if (!id) { console.error('usage: triage exploit <finding-id> --prove [--reproducer file] [--attempts N] [--required N]'); return 4; }
172
+ const finding = loadFinding(root, id);
173
+ if (!finding) { console.error(`Finding ${id} not found in last scan.`); return 4; }
174
+ const loaded = loadReproducer(root, id, args.flags.reproducer);
175
+ 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; }
176
+ const errs = (0,reproducer/* validateReproducer */.mC)(loaded.reproducer);
177
+ if (errs.length) { console.error(`Invalid reproducer: ${errs.join('; ')}`); return 4; }
178
+ const policy = {};
179
+ if (args.flags.attempts) policy.attempts = Number(args.flags.attempts);
180
+ if (args.flags.required) policy.required = Number(args.flags.required);
181
+ if (args.flags.timeout) policy.timeoutMs = Number(args.flags.timeout) * 1000;
182
+ if (args.flags['require-container']) policy.requireContainer = true;
183
+ const ac = new AbortController();
184
+ const onSig = () => ac.abort();
185
+ process.once('SIGINT', onSig);
186
+ let result;
187
+ try { result = await (0,orchestrator/* proveFinding */.kO)({ finding, reproducer: loaded.reproducer, revision: args.flags.revision ?? null, policy, signal: ac.signal }); } finally { process.off('SIGINT', onSig); }
188
+ const saved = saveProof(root, { ...result, reproducer: loaded.reproducer });
189
+ if (json || args.flags.json) console.log(JSON.stringify({ ...result, stored: saved.ok ? saved.file : null }, null, 2));
190
+ else { console.log(formatResult(result)); if (!saved.ok) console.log(`(proof not stored: ${saved.reason})`); }
191
+ return result.state === 'EXPLOIT_CONFIRMED' ? 0 : 1;
192
+ }
193
+
194
+ async function cmdProof(args, root) {
195
+ const sub = args._[1];
196
+ if (sub === 'doctor') return doctor(args);
197
+ const id = String(args._[2] ?? '');
198
+ if (!id) { console.error('usage: proof show <finding-id> | proof replay <finding-id> | proof doctor'); return 4; }
199
+ if (sub === 'show') {
200
+ const all = listProofs(root, id);
201
+ if (!all.length) { console.error(`No stored proof for ${id}.`); return 4; }
202
+ const latest = all.find((p) => p.record);
203
+ 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.`);
204
+ const good = all.find((p) => p.record && !p.tampered);
205
+ if (!good) { console.error('No intact proof record.'); return 1; }
206
+ if (args.flags.json) console.log(JSON.stringify(good.record, null, 2)); else console.log(formatResult(good.record));
207
+ void latest;
208
+ return 0;
209
+ }
210
+ if (sub === 'replay') {
211
+ const stored = latestProof(root, id);
212
+ if (!stored?.record?.reproducer) { console.error(`No stored reproducer for ${id}.`); return 4; }
213
+ const tmpDir = external_node_fs_.mkdtempSync(external_node_path_.join(external_node_os_.tmpdir(), 'proof-replay-'));
214
+ const tmp = external_node_path_.join(tmpDir, 'reproducer.json');
215
+ external_node_fs_.writeFileSync(tmp, JSON.stringify(stored.record.reproducer));
216
+ args.flags.reproducer = tmp;
217
+ args._ = ['triage', 'exploit', id];
218
+ try { return await cmdProve(args, root); } finally { external_node_fs_.rmSync(tmpDir, { recursive: true, force: true }); }
219
+ }
220
+ console.error('usage: proof show|replay <finding-id> | proof doctor');
221
+ return 4;
222
+ }
223
+
224
+ function doctor(args) {
225
+ const tools = (0,runner/* hostTools */.qV)();
226
+ const rows = reproducer/* LANGUAGES */.Yj.map((l) => ({ lang: l, ...(0,runner/* languageSupport */.ql)(l, tools) }));
227
+ const envs = ['javascript', 'python'].map((l) => ({ lang: l, ...(0,runner/* selectEnvironment */.aP)({ lang: l }) }));
228
+ if (args.flags.json) { console.log(JSON.stringify({ tools, languages: rows, environments: envs }, null, 2)); return 0; }
229
+ console.log('Proof fabric doctor');
230
+ for (const r of rows) console.log(` ${r.lang.padEnd(11)} ${r.supported ? 'supported' : `unsupported (${r.reason})`}`);
231
+ 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}` : ''}`);
232
+ const usable = envs.some((e) => e.mode !== 'unavailable');
233
+ if (!usable) console.log(' RESULT: no execution environment available; proofs will report blocked, never clean.');
234
+ return usable ? 0 : 1;
235
+ }
236
+
237
+
238
+ /***/ })
239
+
240
+ };