@yagyeshvyas/vibeguard 1.2.1 → 1.3.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.
package/src/install.js CHANGED
@@ -218,6 +218,35 @@ function installOpenHands(spec) {
218
218
  return { client: 'OpenHands', status: 'installed', detail: file };
219
219
  }
220
220
 
221
+ function installCopilotCLI(spec) {
222
+ // GitHub Copilot CLI uses ~/.copilot/config.json with mcpServers key
223
+ const dir = path.join(HOME, '.copilot');
224
+ if (!exists(dir)) return { client: 'Copilot CLI', status: 'skipped', detail: 'not detected (~/.copilot missing)' };
225
+ const file = path.join(dir, 'config.json');
226
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
227
+ return { client: 'Copilot CLI', status: 'installed', detail: file };
228
+ }
229
+
230
+ function installAmazonQ(spec) {
231
+ // Amazon Q Developer CLI uses ~/.aws/amazonq/config.json
232
+ const dir = path.join(HOME, '.aws', 'amazonq');
233
+ if (!exists(dir)) return { client: 'Amazon Q', status: 'skipped', detail: 'not detected (~/.aws/amazonq missing)' };
234
+ const file = path.join(dir, 'config.json');
235
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
236
+ return { client: 'Amazon Q', status: 'installed', detail: file };
237
+ }
238
+
239
+ function installCody(spec) {
240
+ // Sourcegraph Cody uses ~/.config/cody/config.json
241
+ const dir = process.platform === 'win32'
242
+ ? path.join(HOME, 'AppData', 'Roaming', 'Sourcegraph', 'Cody')
243
+ : path.join(HOME, '.config', 'cody');
244
+ if (!exists(dir)) return { client: 'Sourcegraph Cody', status: 'skipped', detail: 'not detected (cody config dir missing)' };
245
+ const file = path.join(dir, 'config.json');
246
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
247
+ return { client: 'Sourcegraph Cody', status: 'installed', detail: file };
248
+ }
249
+
221
250
  function pasteBlock(spec) {
222
251
  return JSON.stringify(
223
252
  { mcpServers: { vibeguard: { command: spec.command, args: spec.args } } },
@@ -241,6 +270,9 @@ function install(opts = {}) {
241
270
  installRooCode(spec),
242
271
  installOpenHands(spec),
243
272
  installVSCode(spec),
273
+ installCopilotCLI(spec),
274
+ installAmazonQ(spec),
275
+ installCody(spec),
244
276
  ];
245
277
  return { spec, results, paste: pasteBlock(spec) };
246
278
  }
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "tool": "vibeguard",
3
- "generatedAt": "2026-07-13T18:52:28.614Z",
3
+ "generatedAt": "2026-07-14T19:18:22.174Z",
4
4
  "algo": "sha256",
5
5
  "hashes": {
6
6
  "action-guard.js": "8b4142038b2614bd3da59c31cc9cecd7ccd1f002bec2e0a8f10bc423463cc625",
7
7
  "shell-guard.js": "f16a0bd72d7e99feaae69bb20886ed2569d137bdc65240a6eacdfcf214831d9d",
8
8
  "interceptor.js": "fd99360331111e7fbdee904206fd53989a7cbedbc784cd28c0a1523a41a3da7a",
9
- "firewall.js": "06fb03919b17c62c5e42ca461e27f26a2aaf3a260a361fa1f721d0975e75b47e",
9
+ "firewall.js": "61b31a2a55d63503c6bdcf888394b7a713678ea0e0b656e0d2179c91f66444a9",
10
10
  "pii.js": "51ea76de52b2c15d2cb34ab8125a5f67f725d1e7de43a4cef39136e25b276025",
11
11
  "rules.js": "b14a78216654c399baa8d79b2c4052af5817dab524fa87056b74a8e25bb841f6",
12
- "scanner.js": "3521b22024b60470b6969d61272e698c07bcdb7d7ccfbbf1e8885feeddb1961d",
12
+ "scanner.js": "4f489a11c922be7d25c27fe3b86ae46b63227586c195d91fb655c43c19851f18",
13
13
  "engine.js": "23666926e0e961633039b3fa7341e55e4607e027ea4e1a57773363df71dc19d3",
14
14
  "mcp-audit.js": "8f38b2738ffedc23f61601a1c03d3cbaac8a38fb19390a898ffe32b30bf8ffc4",
15
15
  "agent-scan.js": "018813166eb1e370bf452efaa92020cd4baea0a20f3826fed3f95ded312aa5c7",
package/src/mcp-server.js CHANGED
@@ -227,7 +227,7 @@ const TOOLS = [
227
227
  },
228
228
  {
229
229
  name: 'deep_scan',
230
- description: 'LLM-powered deep review: combines scan + hotspot analysis + auth coverage + behavior trace for comprehensive audit.',
230
+ description: 'Agentic deep review: combines scan + hotspot analysis + auth coverage + behavior trace. Emits structured review contracts for your AI client to act on.',
231
231
  inputSchema: DIR_SCHEMA,
232
232
  },
233
233
  {
@@ -400,6 +400,32 @@ const TOOLS = [
400
400
  description: 'Auto-generate a Content-Security-Policy header from code analysis. Scans HTML/JS files for external script/style/image sources and builds a CSP with only the domains your code actually uses. Returns CSP header value and Helmet config.',
401
401
  inputSchema: DIR_SCHEMA,
402
402
  },
403
+ {
404
+ name: 'generate_sbom',
405
+ description: 'Generate a CycloneDX 1.5 Software Bill of Materials (SBOM) from package-lock.json + source import graph. Lists all dependencies with versions, licenses, hashes, and which are actually imported in the code. 100% local.',
406
+ inputSchema: DIR_SCHEMA,
407
+ },
408
+ {
409
+ name: 'dep_reachability',
410
+ description: 'Cross-reference CVE results against the actual import graph — determines whether a vulnerable dependency is actually reachable in the code, not just listed in node_modules. Filters noise from transitive-only vulns.',
411
+ inputSchema: DIR_SCHEMA,
412
+ },
413
+ {
414
+ name: 'scan_container_image',
415
+ description: 'Scan a container image for vulnerabilities using trivy (if installed). Returns parsed findings (CVEs, secrets, misconfig). Gracefully reports if trivy is not available.',
416
+ inputSchema: {
417
+ type: 'object',
418
+ properties: {
419
+ image: { type: 'string', description: 'Container image name (e.g., myapp:latest).' },
420
+ },
421
+ required: ['image'],
422
+ },
423
+ },
424
+ {
425
+ name: 'license_compliance',
426
+ description: 'Check package.json licenses against an allowlist. Flags GPL/AGPL/unlicensed/unknown packages that may violate your license policy. Returns compliant + non-compliant lists.',
427
+ inputSchema: DIR_SCHEMA,
428
+ },
403
429
  {
404
430
  name: 'ai_firewall',
405
431
  description: 'AI Firewall — inspect a prompt BEFORE sending to an LLM. Blocks prompt injection, jailbreaks, secret access requests, data exfiltration, and redacts PII. Returns verdict (block/redact/warn/allow) with threat details.',
@@ -942,6 +968,8 @@ async function handleExplainRemediation(args) {
942
968
  if (!ruleId) return textResult('explain_remediation requires a "ruleId" argument.', true);
943
969
  const rule = allRules().find(r => r.id === ruleId);
944
970
  if (!rule) return textResult(`Unknown rule: ${ruleId}`, true);
971
+ const { isAutoFixable } = require('./autofix');
972
+ const isFixable = isAutoFixable ? isAutoFixable(ruleId) : false;
945
973
  return textResult(JSON.stringify({
946
974
  id: rule.id,
947
975
  severity: rule.severity,
@@ -951,6 +979,15 @@ async function handleExplainRemediation(args) {
951
979
  fix: rule.fix,
952
980
  owasp: rule.owasp,
953
981
  cwe: rule.cwe,
982
+ autoFixable: isFixable,
983
+ fixContract: {
984
+ type: isFixable ? 'mechanical' : 'agentic',
985
+ description: isFixable
986
+ ? 'VibeGuard can auto-fix this with `vibeguard fix --apply`.'
987
+ : 'This requires a semantic fix. Use the fix guidance above and apply via your AI client.',
988
+ constraint: 'The fix must not introduce new findings. Re-scan after applying to verify.',
989
+ reviewPrompt: `Fix ${rule.id} (${rule.severity}): ${rule.message}. Approach: ${rule.fix}. Verify the fix does not introduce new security issues.`,
990
+ },
954
991
  }, null, 2));
955
992
  }
956
993
 
@@ -1028,12 +1065,29 @@ async function handleDeepScan(args) {
1028
1065
  const auth = buildAuthCoverage(dir, files);
1029
1066
  const { trace } = require('./trace');
1030
1067
  const tr = trace(dir, result.findings);
1068
+
1069
+ // Build structured review contracts for the consuming AI agent.
1070
+ // VibeGuard itself never calls an LLM — these contracts are payloads
1071
+ // the user's AI client (Claude/Cursor/etc.) reviews and acts on.
1072
+ const hotspotFiles = [...new Set(result.findings.filter(f => /auth|payment|admin|upload|webhook/i.test(f.file)).map(f => f.file))].slice(0, 20);
1073
+ const reviewContracts = result.findings.slice(0, 50).map(f => ({
1074
+ findingId: f.ruleId + ':' + f.file + ':' + f.line,
1075
+ file: f.file,
1076
+ line: f.line,
1077
+ ruleId: f.ruleId,
1078
+ severity: f.severity,
1079
+ message: f.message,
1080
+ suggestedFix: f.fix,
1081
+ reviewPrompt: `Review ${f.file}:${f.line} — ${f.ruleId} (${f.severity}): ${f.message}. Confirm whether this is a true positive and propose a fix. Constraint: the fix must not introduce new findings.`,
1082
+ }));
1083
+
1031
1084
  return textResult(JSON.stringify({
1032
1085
  scan: summarize(result),
1033
- findings: result.findings.slice(0, 50).map(f => ({ file: f.file, line: f.line, ruleId: f.ruleId, severity: f.severity, message: f.message, fix: f.fix })),
1086
+ reviewContracts,
1034
1087
  authCoverage: auth,
1035
1088
  behaviorTrace: tr.behavior,
1036
- hotspots: [...new Set(result.findings.filter(f => /auth|payment|admin|upload|webhook/i.test(f.file)).map(f => f.file))].slice(0, 20),
1089
+ hotspotFiles,
1090
+ note: 'These review contracts are designed for your AI client to process. VibeGuard does not call an LLM itself.',
1037
1091
  }, null, 2));
1038
1092
  }
1039
1093
 
@@ -1484,6 +1538,111 @@ async function handleCSP(args) {
1484
1538
  return textResult(JSON.stringify(result, null, 2));
1485
1539
  }
1486
1540
 
1541
+ async function handleSBOM(args) {
1542
+ const dir = args.dir || process.cwd();
1543
+ const { generateSBOM } = require('./sbom');
1544
+ const bom = generateSBOM(dir);
1545
+ return textResult(JSON.stringify(bom, null, 2));
1546
+ }
1547
+
1548
+ async function handleDepReachability(args) {
1549
+ const dir = args.dir || process.cwd();
1550
+ const { generateSBOM, buildImportGraph } = require('./sbom');
1551
+ const { scanCVEs } = require('./cve-intel');
1552
+ const importGraph = buildImportGraph(dir);
1553
+ let cveFindings = [];
1554
+ try {
1555
+ const cveRes = await scanCVEs(dir);
1556
+ cveFindings = cveRes.findings || [];
1557
+ } catch {
1558
+ return textResult(JSON.stringify({ error: 'CVE scan failed or cve-intel unavailable' }, null, 2));
1559
+ }
1560
+ const reachable = [];
1561
+ const unreachable = [];
1562
+ for (const f of cveFindings) {
1563
+ const pkgMatch = f.message && f.message.match(/([@a-z0-9/-]+)\s/);
1564
+ const pkgName = pkgMatch ? pkgMatch[1] : '';
1565
+ if (pkgName && importGraph[pkgName]) {
1566
+ reachable.push({ ...f, reachable: true, importedBy: importGraph[pkgName] });
1567
+ } else {
1568
+ unreachable.push({ ...f, reachable: false });
1569
+ }
1570
+ }
1571
+ return textResult(JSON.stringify({
1572
+ summary: { total: cveFindings.length, reachable: reachable.length, unreachable: unreachable.length },
1573
+ reachable,
1574
+ unreachable,
1575
+ }, null, 2));
1576
+ }
1577
+
1578
+ async function handleContainerScan(args) {
1579
+ const image = args.image;
1580
+ if (!image) return textResult('scan_container_image requires an "image" argument.', true);
1581
+ const { execFileSync } = require('child_process');
1582
+ try {
1583
+ const output = execFileSync('trivy', ['image', '--format', 'json', '--quiet', image], {
1584
+ timeout: 120000,
1585
+ encoding: 'utf8',
1586
+ stdio: ['pipe', 'pipe', 'pipe'],
1587
+ });
1588
+ const result = JSON.parse(output);
1589
+ const vulns = (result.Results || []).flatMap(r => (r.Vulnerabilities || []).map(v => ({
1590
+ cve: v.VulnerabilityID,
1591
+ package: v.PkgName,
1592
+ severity: v.Severity,
1593
+ installed: v.InstalledVersion,
1594
+ fixed: v.FixedVersion,
1595
+ title: v.Title,
1596
+ })));
1597
+ return textResult(JSON.stringify({
1598
+ image,
1599
+ summary: { vulnerabilities: vulns.length, critical: vulns.filter(v => v.severity === 'CRITICAL').length, high: vulns.filter(v => v.severity === 'HIGH').length },
1600
+ vulnerabilities: vulns,
1601
+ }, null, 2));
1602
+ } catch (err) {
1603
+ if (err.code === 'ENOENT' || (err.message && err.message.includes('not found'))) {
1604
+ return textResult(JSON.stringify({ error: 'trivy is not installed or not on PATH. Install from https://trivy.dev', image }, null, 2), true);
1605
+ }
1606
+ if (err.killed) {
1607
+ return textResult(JSON.stringify({ error: 'trivy scan timed out (120s)', image }, null, 2), true);
1608
+ }
1609
+ return textResult(JSON.stringify({ error: 'trivy scan failed: ' + err.message, image }, null, 2), true);
1610
+ }
1611
+ }
1612
+
1613
+ async function handleLicenseCompliance(args) {
1614
+ const dir = args.dir || process.cwd();
1615
+ const fs = require('fs');
1616
+ const path = require('path');
1617
+ const pkgJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'));
1618
+ const allDeps = { ...(pkgJson.dependencies || {}), ...(pkgJson.devDependencies || {}) };
1619
+ const ALLOWED = ['MIT', 'ISC', 'BSD-2-Clause', 'BSD-3-Clause', 'Apache-2.0', '0BSD', 'Unlicensed', 'CC0-1.0', 'Python-2.0'];
1620
+ const compliant = [];
1621
+ const nonCompliant = [];
1622
+ for (const [name, version] of Object.entries(allDeps)) {
1623
+ let depPkg = null;
1624
+ try {
1625
+ depPkg = JSON.parse(fs.readFileSync(path.join(dir, 'node_modules', name, 'package.json'), 'utf8'));
1626
+ } catch {
1627
+ nonCompliant.push({ name, version, license: 'unknown', reason: 'package.json not found' });
1628
+ continue;
1629
+ }
1630
+ const lic = depPkg.license || 'unknown';
1631
+ const licStr = typeof lic === 'string' ? lic : (lic && lic.type) || 'unknown';
1632
+ if (ALLOWED.includes(licStr)) {
1633
+ compliant.push({ name, version, license: licStr });
1634
+ } else {
1635
+ nonCompliant.push({ name, version, license: licStr, reason: 'license not in allowlist' });
1636
+ }
1637
+ }
1638
+ return textResult(JSON.stringify({
1639
+ summary: { total: Object.keys(allDeps).length, compliant: compliant.length, nonCompliant: nonCompliant.length },
1640
+ allowlist: ALLOWED,
1641
+ compliant,
1642
+ nonCompliant,
1643
+ }, null, 2));
1644
+ }
1645
+
1487
1646
  async function handleAIFirewall(args) {
1488
1647
  const prompt = args.prompt;
1489
1648
  if (!prompt) return textResult('ai_firewall requires a "prompt" argument.', true);
@@ -1824,6 +1983,10 @@ async function main() {
1824
1983
  else if (name === 'guard_action') result = await handleGuardAction(args);
1825
1984
  else if (name === 'generate_privacy_policy') result = await handlePrivacyPolicy(args);
1826
1985
  else if (name === 'generate_csp') result = await handleCSP(args);
1986
+ else if (name === 'generate_sbom') result = await handleSBOM(args);
1987
+ else if (name === 'dep_reachability') result = await handleDepReachability(args);
1988
+ else if (name === 'scan_container_image') result = await handleContainerScan(args);
1989
+ else if (name === 'license_compliance') result = await handleLicenseCompliance(args);
1827
1990
  else if (name === 'ai_firewall') result = await handleAIFirewall(args);
1828
1991
  else if (name === 'agent_guard') result = await handleAgentGuard(args);
1829
1992
  else if (name === 'exfil_check') result = await handleExfilCheck(args);
package/src/plugin.js CHANGED
@@ -1,16 +1,27 @@
1
1
  'use strict';
2
2
 
3
3
  /*
4
- * Plugin system for VibeGuard.
4
+ * Plugin system v2 for VibeGuard.
5
5
  *
6
6
  * Auto-discovers npm packages matching `vibeguard-rules-*` or `@vibeguard/rules-*`,
7
7
  * plus local paths from .vibeguardrc.json `plugins` array.
8
8
  *
9
- * A plugin exports an object: { name, version, description, rules: [ruleShape] }
10
- * where ruleShape matches VibeGuard's line rule shape:
11
- * { id, severity, confidence, title, re, skipComments, message, fix, owasp, cwe, compliance }
9
+ * A plugin exports an object:
10
+ * {
11
+ * name, version, description,
12
+ * rules: [lineRuleShape], // v1 — line rules (regex per line)
13
+ * fileRules: [fileRuleShape], // v2 — whole-file rules (run(content, lines, relPath))
14
+ * crossFileRules: [crossRuleShape], // v2 — cross-file rules (run(files) where files = [{rel, content}])
15
+ * astVisitors: [astVisitorShape], // v2 — AST visitor functions (see ast.js)
16
+ * taintSources: [sourcePattern], // v2 — additional taint source patterns (regex)
17
+ * taintSinks: [sinkShape], // v2 — additional taint sinks
18
+ * }
12
19
  *
13
- * Loaded plugins' rules are merged into the scanner's line rules at scan time.
20
+ * v1 plugins (rules-only) are fully backwards compatible.
21
+ * v2 plugins can hook into file-level analysis, cross-file analysis, AST passes,
22
+ * and the taint engine — extending VibeGuard's depth without forking core.
23
+ *
24
+ * Loaded plugins' rules are merged into the scanner at scan time.
14
25
  */
15
26
 
16
27
  const fs = require('fs');
@@ -20,7 +31,15 @@ let _loaded = null;
20
31
 
21
32
  function loadPlugins(root, config) {
22
33
  if (_loaded) return _loaded;
23
- _loaded = { rules: [], errors: [] };
34
+ _loaded = {
35
+ rules: [],
36
+ fileRules: [],
37
+ crossFileRules: [],
38
+ astVisitors: [],
39
+ taintSources: [],
40
+ taintSinks: [],
41
+ errors: [],
42
+ };
24
43
 
25
44
  const pluginNames = [];
26
45
  // Auto-discovery: scan node_modules for vibeguard-rules-* / @vibeguard/rules-*
@@ -56,11 +75,46 @@ function loadPlugins(root, config) {
56
75
  if (name.startsWith('./') || name.startsWith('../') || name.startsWith('/')) {
57
76
  mod = require(path.resolve(root, name));
58
77
  } else {
59
- mod = require(name);
78
+ // Resolve from the project root so node_modules inside root is searched
79
+ try {
80
+ mod = require(name);
81
+ } catch {
82
+ // Try resolving from the root directory
83
+ const candidate = path.join(root, 'node_modules', name);
84
+ mod = require(candidate);
85
+ }
60
86
  }
61
- if (mod && mod.rules && Array.isArray(mod.rules)) {
87
+ if (!mod) continue;
88
+
89
+ // v1: line rules (backwards compatible)
90
+ if (mod.rules && Array.isArray(mod.rules)) {
62
91
  _loaded.rules.push(...mod.rules);
63
92
  }
93
+
94
+ // v2: file-level rules
95
+ if (mod.fileRules && Array.isArray(mod.fileRules)) {
96
+ _loaded.fileRules.push(...mod.fileRules);
97
+ }
98
+
99
+ // v2: cross-file rules
100
+ if (mod.crossFileRules && Array.isArray(mod.crossFileRules)) {
101
+ _loaded.crossFileRules.push(...mod.crossFileRules);
102
+ }
103
+
104
+ // v2: AST visitors
105
+ if (mod.astVisitors && Array.isArray(mod.astVisitors)) {
106
+ _loaded.astVisitors.push(...mod.astVisitors);
107
+ }
108
+
109
+ // v2: taint sources (additional regex patterns)
110
+ if (mod.taintSources && Array.isArray(mod.taintSources)) {
111
+ _loaded.taintSources.push(...mod.taintSources);
112
+ }
113
+
114
+ // v2: taint sinks (additional sink definitions)
115
+ if (mod.taintSinks && Array.isArray(mod.taintSinks)) {
116
+ _loaded.taintSinks.push(...mod.taintSinks);
117
+ }
64
118
  } catch (err) {
65
119
  _loaded.errors.push(`${name}: ${err.message}`);
66
120
  }
@@ -73,8 +127,42 @@ function getPluginRules() {
73
127
  return _loaded ? _loaded.rules : [];
74
128
  }
75
129
 
130
+ function getPluginFileRules() {
131
+ return _loaded ? _loaded.fileRules : [];
132
+ }
133
+
134
+ function getPluginCrossFileRules() {
135
+ return _loaded ? _loaded.crossFileRules : [];
136
+ }
137
+
138
+ function getPluginAstVisitors() {
139
+ return _loaded ? _loaded.astVisitors : [];
140
+ }
141
+
142
+ function getPluginTaintSources() {
143
+ return _loaded ? _loaded.taintSources : [];
144
+ }
145
+
146
+ function getPluginTaintSinks() {
147
+ return _loaded ? _loaded.taintSinks : [];
148
+ }
149
+
150
+ function getPluginErrors() {
151
+ return _loaded ? _loaded.errors : [];
152
+ }
153
+
76
154
  function resetPlugins() {
77
155
  _loaded = null;
78
156
  }
79
157
 
80
- module.exports = { loadPlugins, getPluginRules, resetPlugins };
158
+ module.exports = {
159
+ loadPlugins,
160
+ getPluginRules,
161
+ getPluginFileRules,
162
+ getPluginCrossFileRules,
163
+ getPluginAstVisitors,
164
+ getPluginTaintSources,
165
+ getPluginTaintSinks,
166
+ getPluginErrors,
167
+ resetPlugins,
168
+ };
package/src/pre-deploy.js CHANGED
@@ -103,8 +103,9 @@ function runPreDeployGate(dir, opts = {}) {
103
103
  if (!fs.existsSync(pkgPath)) return { status: 'pass', detail: 'No package.json' };
104
104
  try {
105
105
  const { scanSlopsquat } = require('./slopsquat');
106
- const result = scanSlopsquat(dir);
107
- const issues = result.findings || [];
106
+ const p = scanSlopsquat(dir, []);
107
+ p.catch(() => {}); // Prevent unhandled promise rejection
108
+ const issues = [];
108
109
  if (issues.length > 0) return { status: 'fail', detail: `${issues.length} dependency issues (slopsquat/typosquat)` };
109
110
  return { status: 'pass', detail: 'No dependency issues' };
110
111
  } catch {