@yagyeshvyas/vibeguard 1.3.0 → 1.11.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 (167) hide show
  1. package/.vibeguard-mcp.example.json +51 -0
  2. package/CHANGELOG.md +604 -216
  3. package/MCP-FIREWALL.md +296 -0
  4. package/README.md +355 -31
  5. package/bin/cli.js +355 -27
  6. package/bin/cmd-agent-monitor.js +45 -0
  7. package/bin/cmd-agent-risk.js +64 -0
  8. package/bin/cmd-gif.js +62 -0
  9. package/bin/cmd-git-scan.js +74 -0
  10. package/bin/cmd-llm-proxy.js +164 -0
  11. package/bin/cmd-mcp-firewall.js +191 -0
  12. package/bin/cmd-pentest.js +103 -0
  13. package/bin/cmd-platform.js +137 -0
  14. package/bin/cmd-pr-scan.js +135 -0
  15. package/bin/cmd-sbom-diff.js +38 -0
  16. package/bin/cmd-skill-scan.js +35 -0
  17. package/docs/AISVS.md +25 -0
  18. package/docs/ARCHITECTURE.md +81 -0
  19. package/docs/INSTALLATION.md +139 -0
  20. package/docs/WINDOWS.md +74 -0
  21. package/docs/security-policy.strict.example.json +134 -0
  22. package/docs/security-policy.strict.example.pub.pem +3 -0
  23. package/package.json +45 -7
  24. package/src/.vibeguard/cache/file-hashes.json +60 -0
  25. package/src/.vibeguard/latest-snapshot.json +36 -0
  26. package/src/.vibeguard/mcp-pins.json +1 -0
  27. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/auto.js +428 -0
  28. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/daemon.js +344 -0
  29. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/dashboard.js +279 -0
  30. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/engine.js +297 -0
  31. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/hook.js +151 -0
  32. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/install.js +299 -0
  33. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/manifest.json +65 -0
  34. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/mcp-server.js +2051 -0
  35. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/plugin.js +168 -0
  36. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/pre-deploy.js +362 -0
  37. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/repl.js +150 -0
  38. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/rules.js +1611 -0
  39. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/sbom.js +164 -0
  40. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/shell-guard.js +292 -0
  41. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/slopsquat.js +144 -0
  42. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/trace.js +220 -0
  43. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/auto.js +428 -0
  44. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/daemon.js +344 -0
  45. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/engine.js +297 -0
  46. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/install.js +299 -0
  47. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/manifest.json +37 -0
  48. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/mcp-server.js +2055 -0
  49. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/plugin.js +168 -0
  50. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/pre-deploy.js +362 -0
  51. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/trace.js +220 -0
  52. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/auto.js +428 -0
  53. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/daemon.js +344 -0
  54. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/dashboard.js +279 -0
  55. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/engine.js +297 -0
  56. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/hook.js +151 -0
  57. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/install.js +299 -0
  58. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/manifest.json +65 -0
  59. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/mcp-server.js +2055 -0
  60. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/plugin.js +168 -0
  61. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/pre-deploy.js +362 -0
  62. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/repl.js +150 -0
  63. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/rules.js +1611 -0
  64. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/sbom.js +164 -0
  65. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/shell-guard.js +292 -0
  66. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/slopsquat.js +144 -0
  67. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/trace.js +220 -0
  68. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/auto.js +428 -0
  69. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/daemon.js +344 -0
  70. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/dashboard.js +279 -0
  71. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/engine.js +297 -0
  72. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/hook.js +151 -0
  73. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/install.js +299 -0
  74. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/manifest.json +65 -0
  75. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/mcp-server.js +2054 -0
  76. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/plugin.js +168 -0
  77. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/pre-deploy.js +362 -0
  78. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/repl.js +150 -0
  79. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/rules.js +1611 -0
  80. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/sbom.js +164 -0
  81. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/shell-guard.js +292 -0
  82. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/slopsquat.js +144 -0
  83. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/trace.js +220 -0
  84. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/auto.js +428 -0
  85. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/daemon.js +344 -0
  86. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/engine.js +297 -0
  87. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/install.js +299 -0
  88. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/manifest.json +37 -0
  89. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/mcp-server.js +2055 -0
  90. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/plugin.js +168 -0
  91. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/pre-deploy.js +362 -0
  92. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/trace.js +220 -0
  93. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/auto.js +428 -0
  94. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/daemon.js +344 -0
  95. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/engine.js +297 -0
  96. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/manifest.json +33 -0
  97. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/mcp-server.js +2055 -0
  98. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/rules.js +1611 -0
  99. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/shell-guard.js +292 -0
  100. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/trace.js +220 -0
  101. package/src/.vibeguard-baseline.json +5226 -0
  102. package/src/action-guard.js +84 -6
  103. package/src/agent-monitor.js +262 -0
  104. package/src/agent-policy.js +642 -0
  105. package/src/agent-risk.js +271 -0
  106. package/src/agentic.js +1513 -0
  107. package/src/ast.js +165 -7
  108. package/src/audit-trail.js +212 -67
  109. package/src/auto.js +427 -427
  110. package/src/autofix.js +11 -4
  111. package/src/bundles.js +198 -0
  112. package/src/daemon.js +343 -343
  113. package/src/dashboard.js +278 -278
  114. package/src/engine.js +3 -0
  115. package/src/entropy.js +187 -0
  116. package/src/firewall.js +19 -3
  117. package/src/gif.js +134 -0
  118. package/src/gitscan.js +282 -0
  119. package/src/hook.js +151 -151
  120. package/src/injection-decode.js +136 -0
  121. package/src/install.js +298 -280
  122. package/src/integrity.js +16 -1
  123. package/src/integrity.json +43 -13
  124. package/src/interceptor.js +12 -9
  125. package/src/llm-proxy.js +986 -0
  126. package/src/mcp-audit.js +61 -5
  127. package/src/mcp-firewall.js +971 -0
  128. package/src/mcp-server.js +2500 -2047
  129. package/src/obfuscation.js +315 -0
  130. package/src/owasp-agentic.js +314 -0
  131. package/src/pentest.js +589 -0
  132. package/src/pii.js +4 -0
  133. package/src/platform/aisvs.js +38 -0
  134. package/src/platform/approval.js +187 -0
  135. package/src/platform/canonical.js +73 -0
  136. package/src/platform/contracts.js +158 -0
  137. package/src/platform/delegation.js +73 -0
  138. package/src/platform/http-gateway.js +177 -0
  139. package/src/platform/identity.js +253 -0
  140. package/src/platform/jwt.js +86 -0
  141. package/src/platform/mcp-http-bridge.js +199 -0
  142. package/src/platform/memory-guard.js +64 -0
  143. package/src/platform/os-sandbox.js +144 -0
  144. package/src/platform/policy.js +332 -0
  145. package/src/platform/sandbox-manager.js +92 -0
  146. package/src/platform/signed-audit.js +357 -0
  147. package/src/platform/ssrf.js +129 -0
  148. package/src/plugin.js +182 -168
  149. package/src/pre-deploy.js +170 -55
  150. package/src/privacy-audit.js +272 -272
  151. package/src/repl.js +150 -150
  152. package/src/report.js +7 -1
  153. package/src/routes.js +1210 -0
  154. package/src/rules-2026.js +1407 -0
  155. package/src/rules-pack.js +3068 -3019
  156. package/src/rules.js +376 -60
  157. package/src/sandbox.js +200 -10
  158. package/src/sbom.js +193 -164
  159. package/src/scanner.js +189 -33
  160. package/src/shell-guard.js +11 -0
  161. package/src/skill-scan.js +477 -0
  162. package/src/slopsquat.js +144 -144
  163. package/src/surface.js +408 -0
  164. package/src/taint-ast.js +204 -37
  165. package/src/taint.js +15 -3
  166. package/src/tokenlean.js +579 -0
  167. package/src/trace.js +220 -220
package/src/scanner.js CHANGED
@@ -65,7 +65,7 @@ const SCAN_EXT = new Set([
65
65
  '.json', '.yml', '.yaml', '.toml', '.ini', '.xml',
66
66
  '.env', '.html', '.vue', '.svelte',
67
67
  '.txt', '.md', '.pem', '.key',
68
- '.tf', '.hcl', '.dockerfile',
68
+ '.tf', '.hcl', '.dockerfile', '.rules',
69
69
  ]);
70
70
 
71
71
  // Files without a "normal" extension we still want to read (dotfiles etc.).
@@ -175,6 +175,7 @@ function scanFileContent(absPath, relPath, content, tree, diag) {
175
175
  // regex on every line. Compiled fileFilters are cached on the rule object.
176
176
  const activeRules = [];
177
177
  for (const rule of lineRules) {
178
+ if (!rule.re) continue; // match()-based line rules (no regex) — inert until a line-level match hook exists
178
179
  if (rule.fileFilter) {
179
180
  let ff = rule._ffRe;
180
181
  if (!ff) {
@@ -216,7 +217,12 @@ function scanFileContent(absPath, relPath, content, tree, diag) {
216
217
  // Dataflow/taint analysis: follows user input across lines to a dangerous sink.
217
218
  try {
218
219
  const { analyzeTaint } = require('./taint');
219
- for (const t of analyzeTaint(content, lines, relPath, tree)) findings.push(t);
220
+ // A crash inside the AST pass falls back to regex taint rather than losing
221
+ // the file entirely — but it is recorded, because every dataflow-confirmed
222
+ // finding disappears when that happens and the grade would otherwise look
223
+ // clean. `--strict` turns this into a hard failure.
224
+ const onDegrade = (err) => noteDegraded('taint-ast', err);
225
+ for (const t of analyzeTaint(content, lines, relPath, tree, onDegrade)) findings.push(t);
220
226
  } catch (err) {
221
227
  noteDegraded('taint', err);
222
228
  }
@@ -251,16 +257,43 @@ function scanFileContent(absPath, relPath, content, tree, diag) {
251
257
  noteDegraded('ast', err);
252
258
  }
253
259
 
254
- // File-level rules (need whole-file context).
255
- for (const rule of fileRules) {
256
- let hits = [];
257
- try {
258
- hits = rule.run(content, lines, relPath) || [];
259
- } catch (err) {
260
- noteDegraded(`file-rule:${rule.id || 'unknown'}`, err);
261
- hits = [];
262
- }
263
- for (const h of hits) {
260
+ // Obfuscation / backdoor analysis: decodes encoded payloads and correlates
261
+ // capabilities (exec + net + env) that no honest source file needs. Runs on
262
+ // every text file; the analyzer itself skips minified bundles/lockfiles.
263
+ try {
264
+ const { analyzeObfuscation } = require('./obfuscation');
265
+ for (const o of analyzeObfuscation(content, relPath)) findings.push(o);
266
+ } catch (err) {
267
+ noteDegraded('obfuscation', err);
268
+ }
269
+
270
+ // File-level rules (need whole-file context). Pass prior findings so rules
271
+ // can suppress noise that a line-level rule already reported (e.g. the
272
+ // high-entropy hint shouldn't double-fire on a line a specific secret rule
273
+ // already flagged). Backward compatible: rules that ignore the arg are fine.
274
+ for (const rule of fileRules) {
275
+ let hits = [];
276
+ try {
277
+ if (typeof rule.match === 'function') {
278
+ // Function-based rule (no regex): match(content, ctx) -> [{ index, match }].
279
+ const raw = rule.match(content, { lines, relPath, findings }) || [];
280
+ hits = raw.map((h) => {
281
+ const before = content.slice(0, h.index);
282
+ const ln = before.split('\n').length - 1;
283
+ return {
284
+ line: ln + 1,
285
+ column: before.length - before.lastIndexOf('\n'),
286
+ snippet: redactSnippet((lines[ln] || '').trim(), h.match),
287
+ };
288
+ });
289
+ } else {
290
+ hits = rule.run(content, lines, relPath, findings) || [];
291
+ }
292
+ } catch (err) {
293
+ noteDegraded(`file-rule:${rule.id || 'unknown'}`, err);
294
+ hits = [];
295
+ }
296
+ for (const h of hits) {
264
297
  findings.push(
265
298
  makeFinding(rule, {
266
299
  file: relPath,
@@ -421,11 +454,19 @@ const TIER = ['critical', 'high', 'medium', 'low'];
421
454
  // the grade. This keeps a single heuristic hint from tanking an otherwise clean
422
455
  // project, while confirmed issues still drive the grade hard.
423
456
  function effectiveSeverity(f) {
457
+ let sev = f.severity;
424
458
  if (f.confidence === 'low') {
425
- const i = TIER.indexOf(f.severity);
426
- return TIER[i + 1] || null; // low-confidence 'low' -> null (ignored)
459
+ const i = TIER.indexOf(sev);
460
+ sev = TIER[i + 1] || null; // low-confidence 'low' -> null (ignored)
427
461
  }
428
- return f.severity;
462
+ // Optional reachability weighting: dead-code findings grade one tier lower.
463
+ // A critical sink in code no route imports still lands at 'high' — visible,
464
+ // just not grade-destroying.
465
+ if (f._reachDemote && sev) {
466
+ const idx = TIER.indexOf(sev);
467
+ if (idx >= 0 && idx < TIER.length - 1) sev = TIER[idx + 1];
468
+ }
469
+ return sev;
429
470
  }
430
471
 
431
472
  // Minimal glob -> RegExp: supports *, **, and gitignore-style "**/" (zero+ dirs).
@@ -535,12 +576,33 @@ function computeGrade(findings) {
535
576
  // finding land on the same file:line and describe the same vulnerability category,
536
577
  // keep only the taint finding (higher confidence) and drop the ast.* duplicate.
537
578
  // Map: taint.command-injection ↔ ast.command-injection, etc.
538
- const TAINT_TO_AST = {
539
- 'taint.command-injection': 'ast.command-injection',
540
- 'taint.sql-injection': 'ast.sql-injection',
541
- 'taint.code-injection': 'ast.eval-dynamic',
542
- 'taint.path-traversal': 'ast.path-traversal',
543
- 'taint.ssrf': 'ast.ssrf',
579
+ /*
580
+ * Which lower-fidelity findings a stronger finding supersedes on the same
581
+ * file:line.
582
+ *
583
+ * Two rules that describe the same vulnerability on the same line are one
584
+ * finding reported twice. The higher-fidelity rule wins and the rest are
585
+ * dropped: a taint.* finding proves the path from source to sink, whereas a
586
+ * regex rule only pattern-matched the text; and among overlapping regex rules
587
+ * the higher-confidence, more specific one wins.
588
+ *
589
+ * Keys are the superseding rule; values are every rule it can shadow.
590
+ */
591
+ const TAINT_SUPERSEDES = {
592
+ 'taint.command-injection': ['ast.command-injection'],
593
+ 'taint.sql-injection': [
594
+ 'ast.sql-injection',
595
+ 'code.sql-injection',
596
+ 'db.sql-template-literal',
597
+ 'injection.orm-raw-user',
598
+ ],
599
+ 'taint.code-injection': ['ast.eval-dynamic'],
600
+ 'taint.path-traversal': ['ast.path-traversal', 'upload.filename-path-traversal'],
601
+ 'taint.ssrf': ['ast.ssrf'],
602
+ // Go: three rules match the same `db.Query(fmt.Sprintf(...))` line. Only the
603
+ // high-confidence one is shown by default, so the other two were pure noise
604
+ // for anyone running --all.
605
+ 'go.sql-injection': ['go.sql-format', 'go.sql-fmt-sprintf'],
544
606
  };
545
607
 
546
608
  function dedupeFindings(findings) {
@@ -551,12 +613,11 @@ function dedupeFindings(findings) {
551
613
  }
552
614
  }
553
615
 
554
- // Build a set of taint.* ruleIds that fired, keyed by file:line, so we can
555
- // drop the corresponding ast.* finding on the same file:line.
556
- const taintKeys = new Set();
616
+ // Every (file:line:ruleId) that a dataflow-confirmed finding supersedes.
617
+ const supersededKeys = new Set();
557
618
  for (const f of findings) {
558
- if (TAINT_TO_AST[f.ruleId]) {
559
- taintKeys.add(`${f.file}:${f.line}:${TAINT_TO_AST[f.ruleId]}`);
619
+ for (const shadowed of TAINT_SUPERSEDES[f.ruleId] || []) {
620
+ supersededKeys.add(`${f.file}:${f.line}:${shadowed}`);
560
621
  }
561
622
  }
562
623
 
@@ -569,11 +630,8 @@ function dedupeFindings(findings) {
569
630
  ) {
570
631
  continue; // superseded by a more specific rule
571
632
  }
572
- // Drop ast.* finding when a taint.* finding already covers the same file:line.
573
- const astCounterpart = Object.entries(TAINT_TO_AST).find(([, ast]) => ast === f.ruleId);
574
- if (astCounterpart && taintKeys.has(`${f.file}:${f.line}:${f.ruleId}`)) {
575
- continue; // superseded by the dataflow-confirmed taint finding
576
- }
633
+ // Drop a pattern-match when a dataflow-confirmed finding covers the line.
634
+ if (supersededKeys.has(`${f.file}:${f.line}:${f.ruleId}`)) continue;
577
635
  const key = `${f.ruleId}:${f.file}:${f.line}:${f.column}`;
578
636
  if (seen.has(key)) continue;
579
637
  seen.add(key);
@@ -583,9 +641,14 @@ function dedupeFindings(findings) {
583
641
  }
584
642
 
585
643
  function sortFindings(findings) {
644
+ const reachRank = (f) => (f.surface && f.surface.reach === 'dead' ? 1 : 0);
586
645
  return findings.slice().sort((a, b) => {
587
646
  const s = SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity];
588
647
  if (s !== 0) return s;
648
+ // Live code first: a high finding an entrypoint can reach outranks a high
649
+ // finding in a test fixture or build script at the same severity.
650
+ const r = reachRank(a) - reachRank(b);
651
+ if (r !== 0) return r;
589
652
  if (a.file !== b.file) return a.file < b.file ? -1 : 1;
590
653
  return a.line - b.line;
591
654
  });
@@ -608,7 +671,7 @@ function scan(dir, opts = {}) {
608
671
  try {
609
672
  const { loadPlugins, resetPlugins } = require('./plugin');
610
673
  resetPlugins();
611
- loadPlugins(root, config);
674
+ loadPlugins(root, config, { trustPlugins: opts.trustPlugins === true });
612
675
  } catch { /* plugins are best-effort */ }
613
676
 
614
677
  const allFiles = walk(root, [], null);
@@ -650,6 +713,11 @@ function scan(dir, opts = {}) {
650
713
  const astAvailable = astMod.isAvailable();
651
714
  const diag = { degraded: [] };
652
715
  const parseFailed = []; // JS/TS files acorn IS installed for but couldn't parse
716
+ // Config-ignored paths (rule databases, fixtures, demo code) are not part of
717
+ // the product surface: their findings are filtered anyway, so a parse failure
718
+ // there is not a coverage gap and must not be reported as one.
719
+ const configIgnoreRes = (Array.isArray(config.ignorePaths) ? config.ignorePaths : []).map(globToRe);
720
+ const isConfigIgnored = (rel) => configIgnoreRes.some((re) => re.test(rel));
653
721
 
654
722
  for (const abs of files) {
655
723
  let buf;
@@ -672,7 +740,7 @@ function scan(dir, opts = {}) {
672
740
  if (tree) trees.set(rel, tree);
673
741
  // acorn installed but this file didn't parse → AST rules skipped for it.
674
742
  // (When acorn is absent entirely that's engine-mode, reported separately.)
675
- else if (astAvailable) parseFailed.push(rel);
743
+ else if (astAvailable && !isConfigIgnored(rel)) parseFailed.push(rel);
676
744
  }
677
745
  findings = findings.concat(scanFileContent(abs, rel, content, tree, diag));
678
746
  contents.push({ rel, content, lines: content.split(/\r?\n/) });
@@ -737,6 +805,16 @@ function scan(dir, opts = {}) {
737
805
  }
738
806
  }
739
807
  } catch { /* plugin cross-file rules are best-effort */ }
808
+ // Agentic/MCP posture: configs and tool definitions in the repo (not the
809
+ // developer's laptop). Catches unpinned/remote MCP servers, secrets in config
810
+ // env, tool-description poisoning, destructive tools without confirmation and
811
+ // agent loops without caps.
812
+ try {
813
+ const { analyzeAgentic } = require('./agentic');
814
+ for (const a of analyzeAgentic({ root, files: contents })) findings.push(a);
815
+ } catch (err) {
816
+ diag.degraded.push({ file: '<project>', pass: 'agentic', error: String((err && err.message) || err) });
817
+ }
740
818
  } // end !incremental cross-file block
741
819
 
742
820
  findings = findings.concat(projectScan(root));
@@ -782,6 +860,23 @@ function scan(dir, opts = {}) {
782
860
  }
783
861
  findings = applyConfigFilters(findings, config);
784
862
 
863
+ // Optional baseline filter: attack-surface and `--new-only` consumers want the
864
+ // same "known findings are accepted" view the default scan shows.
865
+ if (opts.baseline) {
866
+ try {
867
+ const { readBaseline } = require('./verify');
868
+ const base = readBaseline(root);
869
+ if (base && Array.isArray(base.findings) && base.findings.length > 0) {
870
+ const seen = new Set(
871
+ base.findings.map((f) => f.fingerprint || `${f.ruleId} ${f.file} ${(f.snippet || '').trim()}`)
872
+ );
873
+ findings = findings.filter((f) => !seen.has(f.fingerprint));
874
+ }
875
+ } catch {
876
+ /* baseline is optional */
877
+ }
878
+ }
879
+
785
880
  // Merge plugin line rules (file/cross-file rules already applied above)
786
881
  try {
787
882
  const { getPluginRules } = require('./plugin');
@@ -829,6 +924,60 @@ function scan(dir, opts = {}) {
829
924
  } catch { /* suppression is best-effort */ }
830
925
  }
831
926
 
927
+ // Optional confidence floor (the CLI's default view excludes low-confidence
928
+ // heuristics). Applied before the surface merge so the entrypoint risks and the
929
+ // printed grade describe the same finding set the user sees.
930
+ if (opts.minConfidence) {
931
+ const order = { low: 0, medium: 1, high: 2 };
932
+ const floor = order[String(opts.minConfidence).toLowerCase()] ?? 0;
933
+ findings = findings.filter((f) => (order[f.confidence] ?? 0) >= floor);
934
+ }
935
+
936
+ // Attack-surface merge: joins entrypoints, reachability and the final finding
937
+ // set. Every finding is annotated with `surface.reach` (direct / imported /
938
+ // dead), which drives `--live`, reachability-first ordering and the optional
939
+ // grade demotion for dead code. Cheap enough to run by default (≈0.2 s per
940
+ // 1000 files); `surface: false` disables it for snippet scanners/tests.
941
+ let surface = null;
942
+ if (opts.surface !== false) {
943
+ try {
944
+ const { buildSurface } = require('./surface');
945
+ // Only files the project actually ships: config-ignored paths (fixtures,
946
+ // rule databases, demo code) must not become "entrypoints".
947
+ const filesForSurface = contents.filter((c) => !isConfigIgnored(c.rel));
948
+ surface = buildSurface({ files: filesForSurface, findings });
949
+ } catch (err) {
950
+ noteDegraded('surface', err);
951
+ }
952
+ }
953
+
954
+ // --live: report only findings an entrypoint can actually reach. Dead tooling
955
+ // and example code stay out of the response entirely (they were never attack
956
+ // surface), and the grade is computed on the live set. If the project exposes
957
+ // no entrypoints at all, reachability says nothing — leave the scan untouched.
958
+ if (opts.liveOnly && surface && surface.stats.entrypoints > 0) {
959
+ findings = findings.filter((f) => !f.surface || f.surface.reach !== 'dead');
960
+ }
961
+
962
+ // Optional reachability-weighted grading: a finding in code no entrypoint
963
+ // imports cannot be exploited through the app, so it counts one tier lower.
964
+ // Off by default because "dead" is a static approximation (dynamic imports,
965
+ // framework conventions) and a project with no entrypoints has no reachability.
966
+ if (opts.reachabilityGrade && surface && surface.stats.entrypoints > 0) {
967
+ for (const f of findings) {
968
+ f._reachDemote = f.surface && f.surface.reach === 'dead';
969
+ }
970
+ }
971
+
972
+ const reach = surface
973
+ ? {
974
+ direct: findings.filter((f) => f.surface && f.surface.reach === 'direct').length,
975
+ imported: findings.filter((f) => f.surface && f.surface.reach === 'imported').length,
976
+ dead: findings.filter((f) => f.surface && f.surface.reach === 'dead').length,
977
+ unanalyzed: findings.filter((f) => !f.surface).length,
978
+ }
979
+ : null;
980
+
832
981
  findings = sortFindings(findings);
833
982
  for (const f of findings) f.fingerprint = fingerprintOf(f);
834
983
 
@@ -859,6 +1008,8 @@ function scan(dir, opts = {}) {
859
1008
  externalInfo,
860
1009
  engine,
861
1010
  diagnostics,
1011
+ surface,
1012
+ reach,
862
1013
  incremental, // null on a full scan; {total, scanned, cached} with --changed
863
1014
  staged, // null unless --staged; {total, scanned}
864
1015
  generatedAt: new Date().toISOString(),
@@ -873,4 +1024,9 @@ module.exports = {
873
1024
  walk,
874
1025
  shouldScanFile,
875
1026
  SKIP_DIRS,
1027
+ // Exported so the benchmark scorer measures exactly what a user sees: the
1028
+ // same supersession relation and the same de-duplication the scan pipeline
1029
+ // applies, rather than a second hand-maintained copy that drifts.
1030
+ TAINT_SUPERSEDES,
1031
+ dedupeFindings,
876
1032
  };
@@ -143,6 +143,17 @@ const DANGEROUS_COMMANDS = [
143
143
  { re: /\bkill(?:\s+-9)?\s+-1\b/i, reason: 'kill -1 kills all processes — system-wide kill', severity: 'critical' },
144
144
  { re: /\bpkill\s+-9\b/i, reason: 'pkill -9 force kills processes — destructive', severity: 'high' },
145
145
  { re: /\biotop\s+--only\b/i, reason: 'iotop in batch mode can cause system instability', severity: 'low' },
146
+ // Windows destructive commands. The shell guard is used by the MCP policy
147
+ // on Windows deployments; a POSIX-only denylist is not enough.
148
+ { re: /\b(?:del|erase)\s+(?:\/[a-z]*[fsq][a-z]*\s+)+/i, reason: 'Windows del/erase with force/recursive flags — destructive', severity: 'critical' },
149
+ { re: /\bRemove-Item\b[^\r\n]*-(?:Recurse|Force)\b/i, reason: 'PowerShell Remove-Item recursive/force — destructive', severity: 'critical' },
150
+ { re: /\bformat\s+[A-Za-z]:/i, reason: 'Windows format of a drive — destructive', severity: 'critical' },
151
+ { re: /\bdiskpart\b/i, reason: 'Windows diskpart — destructive disk operation', severity: 'critical' },
152
+ { re: /\bvssadmin\s+delete\s+shadows\b/i, reason: 'Windows shadow-copy deletion — destructive', severity: 'critical' },
153
+ { re: /\bcipher\s+\/w\b/i, reason: 'Windows cipher /w wipes free space — destructive', severity: 'high' },
154
+ { re: /\bbcdedit\b/i, reason: 'Windows boot configuration modification', severity: 'critical' },
155
+ { re: /\bpowershell(?:\.exe)?\b[^\r\n]*\s-(?:e|ec|enc|encodedcommand)\b/i, reason: 'PowerShell encoded command — obfuscated execution', severity: 'critical' },
156
+ { re: /\b(?:reg\s+delete|wmic\s+.*delete|Set-MpPreference|Add-MpPreference|netsh\s+advfirewall\s+set)\b/i, reason: 'Windows security configuration modification', severity: 'high' },
146
157
  // Anti-evasion: base64 pipe to shell
147
158
  { re: /\|\s*(?:base64|b64)\s+-d\s*\|/i, reason: 'base64 decode piped to shell — obfuscated command execution', severity: 'critical' },
148
159
  { re: /\|\s*(?:sh|bash|zsh|python|python3|node|perl|ruby)\b/i, reason: 'piping to interpreter — potential remote code execution', severity: 'high' },