@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.
- package/CHANGELOG.md +11 -0
- package/README.md +18 -2
- package/bin/cli.js +2753 -2753
- package/ci/vibeguard.yml +42 -42
- package/package.json +1 -1
- package/scripts/counts.js +93 -93
- package/scripts/postinstall.js +26 -26
- package/src/auto.js +427 -427
- package/src/daemon.js +343 -343
- package/src/dashboard.js +278 -278
- package/src/engine.js +297 -297
- package/src/hook.js +151 -151
- package/src/install.js +298 -298
- package/src/integrity.json +1 -1
- package/src/plugin.js +182 -182
- package/src/privacy-audit.js +272 -272
- package/src/repl.js +150 -150
- package/src/report.js +331 -331
- package/src/rules-pack.js +3068 -3068
- package/src/rules.js +1822 -1822
- package/src/sbom.js +193 -193
- package/src/scanner.js +1032 -1032
- package/src/shell-guard.js +302 -302
- package/src/slopsquat.js +144 -144
- package/src/trace.js +220 -220
- package/src/.vibeguard/cache/file-hashes.json +0 -60
- package/src/.vibeguard/latest-snapshot.json +0 -36
- package/src/.vibeguard/mcp-pins.json +0 -1
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/auto.js +0 -428
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/daemon.js +0 -344
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/dashboard.js +0 -279
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/engine.js +0 -297
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/hook.js +0 -151
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/install.js +0 -299
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/manifest.json +0 -65
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/mcp-server.js +0 -2051
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/plugin.js +0 -168
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/pre-deploy.js +0 -362
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/repl.js +0 -150
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/rules.js +0 -1611
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/sbom.js +0 -164
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/shell-guard.js +0 -292
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/slopsquat.js +0 -144
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/trace.js +0 -220
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/auto.js +0 -428
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/daemon.js +0 -344
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/engine.js +0 -297
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/install.js +0 -299
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/manifest.json +0 -37
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/mcp-server.js +0 -2055
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/plugin.js +0 -168
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/pre-deploy.js +0 -362
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/trace.js +0 -220
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/auto.js +0 -428
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/daemon.js +0 -344
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/dashboard.js +0 -279
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/engine.js +0 -297
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/hook.js +0 -151
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/install.js +0 -299
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/manifest.json +0 -65
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/mcp-server.js +0 -2055
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/plugin.js +0 -168
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/pre-deploy.js +0 -362
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/repl.js +0 -150
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/rules.js +0 -1611
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/sbom.js +0 -164
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/shell-guard.js +0 -292
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/slopsquat.js +0 -144
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/trace.js +0 -220
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/auto.js +0 -428
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/daemon.js +0 -344
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/dashboard.js +0 -279
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/engine.js +0 -297
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/hook.js +0 -151
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/install.js +0 -299
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/manifest.json +0 -65
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/mcp-server.js +0 -2054
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/plugin.js +0 -168
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/pre-deploy.js +0 -362
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/repl.js +0 -150
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/rules.js +0 -1611
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/sbom.js +0 -164
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/shell-guard.js +0 -292
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/slopsquat.js +0 -144
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/trace.js +0 -220
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/auto.js +0 -428
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/daemon.js +0 -344
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/engine.js +0 -297
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/install.js +0 -299
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/manifest.json +0 -37
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/mcp-server.js +0 -2055
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/plugin.js +0 -168
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/pre-deploy.js +0 -362
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/trace.js +0 -220
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/auto.js +0 -428
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/daemon.js +0 -344
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/engine.js +0 -297
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/manifest.json +0 -33
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/mcp-server.js +0 -2055
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/rules.js +0 -1611
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/shell-guard.js +0 -292
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/trace.js +0 -220
- 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
|
+
};
|