@yagyeshvyas/vibeguard 1.12.0 → 1.13.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 (113) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +34 -17
  3. package/bin/cli.js +2753 -2753
  4. package/bin/cmd-mcp-firewall.js +1 -0
  5. package/bin/cmd-platform.js +3 -0
  6. package/ci/vibeguard.yml +42 -42
  7. package/package.json +2 -2
  8. package/scripts/counts.js +93 -93
  9. package/scripts/postinstall.js +26 -26
  10. package/src/auto.js +427 -427
  11. package/src/daemon.js +343 -343
  12. package/src/dashboard.js +278 -278
  13. package/src/engine.js +297 -297
  14. package/src/hook.js +151 -151
  15. package/src/install.js +298 -298
  16. package/src/integrity.js +1 -0
  17. package/src/integrity.json +9 -6
  18. package/src/mcp-firewall.js +11 -0
  19. package/src/platform/approval-service.js +124 -0
  20. package/src/platform/approval.js +16 -0
  21. package/src/platform/oauth-server.js +89 -0
  22. package/src/platform/os-sandbox.js +52 -1
  23. package/src/platform/runtime-monitor.js +69 -0
  24. package/src/platform/sandbox-manager.js +5 -0
  25. package/src/plugin.js +182 -182
  26. package/src/privacy-audit.js +272 -272
  27. package/src/repl.js +150 -150
  28. package/src/report.js +331 -331
  29. package/src/rules-pack.js +3068 -3068
  30. package/src/rules.js +1822 -1822
  31. package/src/sbom.js +193 -193
  32. package/src/scanner.js +1032 -1032
  33. package/src/shell-guard.js +302 -302
  34. package/src/slopsquat.js +144 -144
  35. package/src/trace.js +220 -220
  36. package/src/.vibeguard/cache/file-hashes.json +0 -60
  37. package/src/.vibeguard/latest-snapshot.json +0 -36
  38. package/src/.vibeguard/mcp-pins.json +0 -1
  39. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/auto.js +0 -428
  40. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/daemon.js +0 -344
  41. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/dashboard.js +0 -279
  42. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/engine.js +0 -297
  43. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/hook.js +0 -151
  44. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/install.js +0 -299
  45. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/manifest.json +0 -65
  46. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/mcp-server.js +0 -2051
  47. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/plugin.js +0 -168
  48. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/pre-deploy.js +0 -362
  49. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/repl.js +0 -150
  50. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/rules.js +0 -1611
  51. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/sbom.js +0 -164
  52. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/shell-guard.js +0 -292
  53. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/slopsquat.js +0 -144
  54. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/trace.js +0 -220
  55. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/auto.js +0 -428
  56. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/daemon.js +0 -344
  57. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/engine.js +0 -297
  58. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/install.js +0 -299
  59. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/manifest.json +0 -37
  60. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/mcp-server.js +0 -2055
  61. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/plugin.js +0 -168
  62. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/pre-deploy.js +0 -362
  63. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/trace.js +0 -220
  64. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/auto.js +0 -428
  65. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/daemon.js +0 -344
  66. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/dashboard.js +0 -279
  67. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/engine.js +0 -297
  68. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/hook.js +0 -151
  69. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/install.js +0 -299
  70. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/manifest.json +0 -65
  71. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/mcp-server.js +0 -2055
  72. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/plugin.js +0 -168
  73. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/pre-deploy.js +0 -362
  74. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/repl.js +0 -150
  75. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/rules.js +0 -1611
  76. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/sbom.js +0 -164
  77. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/shell-guard.js +0 -292
  78. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/slopsquat.js +0 -144
  79. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/trace.js +0 -220
  80. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/auto.js +0 -428
  81. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/daemon.js +0 -344
  82. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/dashboard.js +0 -279
  83. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/engine.js +0 -297
  84. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/hook.js +0 -151
  85. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/install.js +0 -299
  86. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/manifest.json +0 -65
  87. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/mcp-server.js +0 -2054
  88. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/plugin.js +0 -168
  89. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/pre-deploy.js +0 -362
  90. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/repl.js +0 -150
  91. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/rules.js +0 -1611
  92. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/sbom.js +0 -164
  93. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/shell-guard.js +0 -292
  94. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/slopsquat.js +0 -144
  95. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/trace.js +0 -220
  96. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/auto.js +0 -428
  97. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/daemon.js +0 -344
  98. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/engine.js +0 -297
  99. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/install.js +0 -299
  100. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/manifest.json +0 -37
  101. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/mcp-server.js +0 -2055
  102. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/plugin.js +0 -168
  103. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/pre-deploy.js +0 -362
  104. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/trace.js +0 -220
  105. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/auto.js +0 -428
  106. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/daemon.js +0 -344
  107. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/engine.js +0 -297
  108. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/manifest.json +0 -33
  109. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/mcp-server.js +0 -2055
  110. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/rules.js +0 -1611
  111. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/shell-guard.js +0 -292
  112. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/trace.js +0 -220
  113. package/src/.vibeguard-baseline.json +0 -5226
package/src/plugin.js CHANGED
@@ -1,182 +1,182 @@
1
- 'use strict';
2
-
3
- /*
4
- * Plugin system v2 for VibeGuard.
5
- *
6
- * Auto-discovers npm packages matching `vibeguard-rules-*` or `@vibeguard/rules-*`,
7
- * plus local paths from .vibeguardrc.json `plugins` array.
8
- *
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
- * }
19
- *
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.
25
- */
26
-
27
- const fs = require('fs');
28
- const path = require('path');
29
-
30
- let _loaded = null;
31
-
32
- function loadPlugins(root, config, opts = {}) {
33
- if (_loaded) return _loaded;
34
- _loaded = {
35
- rules: [],
36
- fileRules: [],
37
- crossFileRules: [],
38
- astVisitors: [],
39
- taintSources: [],
40
- taintSinks: [],
41
- errors: [],
42
- trusted: false,
43
- };
44
-
45
- // SECURITY: plugins are target-controlled code. Never auto-execute code from
46
- // the scanned project/repo config. Execution requires an explicit
47
- // operator-controlled trust flag (CLI --trust-plugins or API option), not a
48
- // field the target repository can set.
49
- const trusted = opts.trustPlugins === true;
50
- _loaded.trusted = trusted;
51
- if (!trusted) {
52
- if (config && Array.isArray(config.plugins) && config.plugins.length > 0) {
53
- _loaded.errors.push('project plugins are disabled; re-run with explicit operator trust (--trust-plugins) after review');
54
- }
55
- return _loaded;
56
- }
57
-
58
- const pluginNames = [];
59
- // Auto-discovery: scan node_modules for vibeguard-rules-* / @vibeguard/rules-*
60
- try {
61
- const nmDir = path.join(root, 'node_modules');
62
- if (fs.existsSync(nmDir)) {
63
- for (const entry of fs.readdirSync(nmDir)) {
64
- if (entry.startsWith('vibeguard-rules-')) pluginNames.push(entry);
65
- if (entry.startsWith('@')) {
66
- const scopedDir = path.join(nmDir, entry);
67
- try {
68
- for (const sub of fs.readdirSync(scopedDir)) {
69
- if (entry === '@vibeguard' && sub.startsWith('rules-')) {
70
- pluginNames.push(`${entry}/${sub}`);
71
- }
72
- }
73
- } catch {}
74
- }
75
- }
76
- }
77
- } catch {}
78
-
79
- // Config-specified plugins (only reached after explicit operator trust)
80
- if (config && Array.isArray(config.plugins)) {
81
- for (const p of config.plugins) {
82
- if (typeof p === 'string' && !pluginNames.includes(p)) pluginNames.push(p);
83
- }
84
- }
85
-
86
- for (const name of pluginNames) {
87
- try {
88
- let mod;
89
- if (name.startsWith('./') || name.startsWith('../') || name.startsWith('/')) {
90
- mod = require(path.resolve(root, name));
91
- } else {
92
- // Resolve from the project root so node_modules inside root is searched
93
- try {
94
- mod = require(name);
95
- } catch {
96
- // Try resolving from the root directory
97
- const candidate = path.join(root, 'node_modules', name);
98
- mod = require(candidate);
99
- }
100
- }
101
- if (!mod) continue;
102
-
103
- // v1: line rules (backwards compatible)
104
- if (mod.rules && Array.isArray(mod.rules)) {
105
- _loaded.rules.push(...mod.rules);
106
- }
107
-
108
- // v2: file-level rules
109
- if (mod.fileRules && Array.isArray(mod.fileRules)) {
110
- _loaded.fileRules.push(...mod.fileRules);
111
- }
112
-
113
- // v2: cross-file rules
114
- if (mod.crossFileRules && Array.isArray(mod.crossFileRules)) {
115
- _loaded.crossFileRules.push(...mod.crossFileRules);
116
- }
117
-
118
- // v2: AST visitors
119
- if (mod.astVisitors && Array.isArray(mod.astVisitors)) {
120
- _loaded.astVisitors.push(...mod.astVisitors);
121
- }
122
-
123
- // v2: taint sources (additional regex patterns)
124
- if (mod.taintSources && Array.isArray(mod.taintSources)) {
125
- _loaded.taintSources.push(...mod.taintSources);
126
- }
127
-
128
- // v2: taint sinks (additional sink definitions)
129
- if (mod.taintSinks && Array.isArray(mod.taintSinks)) {
130
- _loaded.taintSinks.push(...mod.taintSinks);
131
- }
132
- } catch (err) {
133
- _loaded.errors.push(`${name}: ${err.message}`);
134
- }
135
- }
136
-
137
- return _loaded;
138
- }
139
-
140
- function getPluginRules() {
141
- return _loaded ? _loaded.rules : [];
142
- }
143
-
144
- function getPluginFileRules() {
145
- return _loaded ? _loaded.fileRules : [];
146
- }
147
-
148
- function getPluginCrossFileRules() {
149
- return _loaded ? _loaded.crossFileRules : [];
150
- }
151
-
152
- function getPluginAstVisitors() {
153
- return _loaded ? _loaded.astVisitors : [];
154
- }
155
-
156
- function getPluginTaintSources() {
157
- return _loaded ? _loaded.taintSources : [];
158
- }
159
-
160
- function getPluginTaintSinks() {
161
- return _loaded ? _loaded.taintSinks : [];
162
- }
163
-
164
- function getPluginErrors() {
165
- return _loaded ? _loaded.errors : [];
166
- }
167
-
168
- function resetPlugins() {
169
- _loaded = null;
170
- }
171
-
172
- module.exports = {
173
- loadPlugins,
174
- getPluginRules,
175
- getPluginFileRules,
176
- getPluginCrossFileRules,
177
- getPluginAstVisitors,
178
- getPluginTaintSources,
179
- getPluginTaintSinks,
180
- getPluginErrors,
181
- resetPlugins,
182
- };
1
+ 'use strict';
2
+
3
+ /*
4
+ * Plugin system v2 for VibeGuard.
5
+ *
6
+ * Auto-discovers npm packages matching `vibeguard-rules-*` or `@vibeguard/rules-*`,
7
+ * plus local paths from .vibeguardrc.json `plugins` array.
8
+ *
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
+ * }
19
+ *
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.
25
+ */
26
+
27
+ const fs = require('fs');
28
+ const path = require('path');
29
+
30
+ let _loaded = null;
31
+
32
+ function loadPlugins(root, config, opts = {}) {
33
+ if (_loaded) return _loaded;
34
+ _loaded = {
35
+ rules: [],
36
+ fileRules: [],
37
+ crossFileRules: [],
38
+ astVisitors: [],
39
+ taintSources: [],
40
+ taintSinks: [],
41
+ errors: [],
42
+ trusted: false,
43
+ };
44
+
45
+ // SECURITY: plugins are target-controlled code. Never auto-execute code from
46
+ // the scanned project/repo config. Execution requires an explicit
47
+ // operator-controlled trust flag (CLI --trust-plugins or API option), not a
48
+ // field the target repository can set.
49
+ const trusted = opts.trustPlugins === true;
50
+ _loaded.trusted = trusted;
51
+ if (!trusted) {
52
+ if (config && Array.isArray(config.plugins) && config.plugins.length > 0) {
53
+ _loaded.errors.push('project plugins are disabled; re-run with explicit operator trust (--trust-plugins) after review');
54
+ }
55
+ return _loaded;
56
+ }
57
+
58
+ const pluginNames = [];
59
+ // Auto-discovery: scan node_modules for vibeguard-rules-* / @vibeguard/rules-*
60
+ try {
61
+ const nmDir = path.join(root, 'node_modules');
62
+ if (fs.existsSync(nmDir)) {
63
+ for (const entry of fs.readdirSync(nmDir)) {
64
+ if (entry.startsWith('vibeguard-rules-')) pluginNames.push(entry);
65
+ if (entry.startsWith('@')) {
66
+ const scopedDir = path.join(nmDir, entry);
67
+ try {
68
+ for (const sub of fs.readdirSync(scopedDir)) {
69
+ if (entry === '@vibeguard' && sub.startsWith('rules-')) {
70
+ pluginNames.push(`${entry}/${sub}`);
71
+ }
72
+ }
73
+ } catch {}
74
+ }
75
+ }
76
+ }
77
+ } catch {}
78
+
79
+ // Config-specified plugins (only reached after explicit operator trust)
80
+ if (config && Array.isArray(config.plugins)) {
81
+ for (const p of config.plugins) {
82
+ if (typeof p === 'string' && !pluginNames.includes(p)) pluginNames.push(p);
83
+ }
84
+ }
85
+
86
+ for (const name of pluginNames) {
87
+ try {
88
+ let mod;
89
+ if (name.startsWith('./') || name.startsWith('../') || name.startsWith('/')) {
90
+ mod = require(path.resolve(root, name));
91
+ } else {
92
+ // Resolve from the project root so node_modules inside root is searched
93
+ try {
94
+ mod = require(name);
95
+ } catch {
96
+ // Try resolving from the root directory
97
+ const candidate = path.join(root, 'node_modules', name);
98
+ mod = require(candidate);
99
+ }
100
+ }
101
+ if (!mod) continue;
102
+
103
+ // v1: line rules (backwards compatible)
104
+ if (mod.rules && Array.isArray(mod.rules)) {
105
+ _loaded.rules.push(...mod.rules);
106
+ }
107
+
108
+ // v2: file-level rules
109
+ if (mod.fileRules && Array.isArray(mod.fileRules)) {
110
+ _loaded.fileRules.push(...mod.fileRules);
111
+ }
112
+
113
+ // v2: cross-file rules
114
+ if (mod.crossFileRules && Array.isArray(mod.crossFileRules)) {
115
+ _loaded.crossFileRules.push(...mod.crossFileRules);
116
+ }
117
+
118
+ // v2: AST visitors
119
+ if (mod.astVisitors && Array.isArray(mod.astVisitors)) {
120
+ _loaded.astVisitors.push(...mod.astVisitors);
121
+ }
122
+
123
+ // v2: taint sources (additional regex patterns)
124
+ if (mod.taintSources && Array.isArray(mod.taintSources)) {
125
+ _loaded.taintSources.push(...mod.taintSources);
126
+ }
127
+
128
+ // v2: taint sinks (additional sink definitions)
129
+ if (mod.taintSinks && Array.isArray(mod.taintSinks)) {
130
+ _loaded.taintSinks.push(...mod.taintSinks);
131
+ }
132
+ } catch (err) {
133
+ _loaded.errors.push(`${name}: ${err.message}`);
134
+ }
135
+ }
136
+
137
+ return _loaded;
138
+ }
139
+
140
+ function getPluginRules() {
141
+ return _loaded ? _loaded.rules : [];
142
+ }
143
+
144
+ function getPluginFileRules() {
145
+ return _loaded ? _loaded.fileRules : [];
146
+ }
147
+
148
+ function getPluginCrossFileRules() {
149
+ return _loaded ? _loaded.crossFileRules : [];
150
+ }
151
+
152
+ function getPluginAstVisitors() {
153
+ return _loaded ? _loaded.astVisitors : [];
154
+ }
155
+
156
+ function getPluginTaintSources() {
157
+ return _loaded ? _loaded.taintSources : [];
158
+ }
159
+
160
+ function getPluginTaintSinks() {
161
+ return _loaded ? _loaded.taintSinks : [];
162
+ }
163
+
164
+ function getPluginErrors() {
165
+ return _loaded ? _loaded.errors : [];
166
+ }
167
+
168
+ function resetPlugins() {
169
+ _loaded = null;
170
+ }
171
+
172
+ module.exports = {
173
+ loadPlugins,
174
+ getPluginRules,
175
+ getPluginFileRules,
176
+ getPluginCrossFileRules,
177
+ getPluginAstVisitors,
178
+ getPluginTaintSources,
179
+ getPluginTaintSinks,
180
+ getPluginErrors,
181
+ resetPlugins,
182
+ };