@yagyeshvyas/vibeguard 1.13.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 (103) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +18 -2
  3. package/bin/cli.js +2753 -2753
  4. package/ci/vibeguard.yml +42 -42
  5. package/package.json +1 -1
  6. package/scripts/counts.js +93 -93
  7. package/scripts/postinstall.js +26 -26
  8. package/src/auto.js +427 -427
  9. package/src/daemon.js +343 -343
  10. package/src/dashboard.js +278 -278
  11. package/src/engine.js +297 -297
  12. package/src/hook.js +151 -151
  13. package/src/install.js +298 -298
  14. package/src/integrity.json +1 -1
  15. package/src/plugin.js +182 -182
  16. package/src/privacy-audit.js +272 -272
  17. package/src/repl.js +150 -150
  18. package/src/report.js +331 -331
  19. package/src/rules-pack.js +3068 -3068
  20. package/src/rules.js +1822 -1822
  21. package/src/sbom.js +193 -193
  22. package/src/scanner.js +1032 -1032
  23. package/src/shell-guard.js +302 -302
  24. package/src/slopsquat.js +144 -144
  25. package/src/trace.js +220 -220
  26. package/src/.vibeguard/cache/file-hashes.json +0 -60
  27. package/src/.vibeguard/latest-snapshot.json +0 -36
  28. package/src/.vibeguard/mcp-pins.json +0 -1
  29. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/auto.js +0 -428
  30. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/daemon.js +0 -344
  31. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/dashboard.js +0 -279
  32. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/engine.js +0 -297
  33. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/hook.js +0 -151
  34. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/install.js +0 -299
  35. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/manifest.json +0 -65
  36. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/mcp-server.js +0 -2051
  37. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/plugin.js +0 -168
  38. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/pre-deploy.js +0 -362
  39. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/repl.js +0 -150
  40. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/rules.js +0 -1611
  41. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/sbom.js +0 -164
  42. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/shell-guard.js +0 -292
  43. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/slopsquat.js +0 -144
  44. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/trace.js +0 -220
  45. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/auto.js +0 -428
  46. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/daemon.js +0 -344
  47. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/engine.js +0 -297
  48. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/install.js +0 -299
  49. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/manifest.json +0 -37
  50. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/mcp-server.js +0 -2055
  51. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/plugin.js +0 -168
  52. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/pre-deploy.js +0 -362
  53. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/trace.js +0 -220
  54. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/auto.js +0 -428
  55. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/daemon.js +0 -344
  56. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/dashboard.js +0 -279
  57. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/engine.js +0 -297
  58. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/hook.js +0 -151
  59. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/install.js +0 -299
  60. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/manifest.json +0 -65
  61. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/mcp-server.js +0 -2055
  62. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/plugin.js +0 -168
  63. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/pre-deploy.js +0 -362
  64. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/repl.js +0 -150
  65. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/rules.js +0 -1611
  66. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/sbom.js +0 -164
  67. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/shell-guard.js +0 -292
  68. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/slopsquat.js +0 -144
  69. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/trace.js +0 -220
  70. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/auto.js +0 -428
  71. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/daemon.js +0 -344
  72. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/dashboard.js +0 -279
  73. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/engine.js +0 -297
  74. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/hook.js +0 -151
  75. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/install.js +0 -299
  76. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/manifest.json +0 -65
  77. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/mcp-server.js +0 -2054
  78. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/plugin.js +0 -168
  79. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/pre-deploy.js +0 -362
  80. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/repl.js +0 -150
  81. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/rules.js +0 -1611
  82. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/sbom.js +0 -164
  83. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/shell-guard.js +0 -292
  84. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/slopsquat.js +0 -144
  85. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/trace.js +0 -220
  86. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/auto.js +0 -428
  87. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/daemon.js +0 -344
  88. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/engine.js +0 -297
  89. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/install.js +0 -299
  90. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/manifest.json +0 -37
  91. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/mcp-server.js +0 -2055
  92. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/plugin.js +0 -168
  93. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/pre-deploy.js +0 -362
  94. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/trace.js +0 -220
  95. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/auto.js +0 -428
  96. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/daemon.js +0 -344
  97. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/engine.js +0 -297
  98. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/manifest.json +0 -33
  99. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/mcp-server.js +0 -2055
  100. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/rules.js +0 -1611
  101. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/shell-guard.js +0 -292
  102. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/trace.js +0 -220
  103. 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
+ };