@yagyeshvyas/vibeguard 0.1.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/README.md +600 -0
- package/bin/cli.js +1640 -0
- package/ci/vibeguard.yml +41 -0
- package/ci-templates/Jenkinsfile +26 -0
- package/ci-templates/azure-pipelines.yml +29 -0
- package/ci-templates/circleci.yml +24 -0
- package/ci-templates/gitlab.yml +19 -0
- package/hooks/pre-commit +31 -0
- package/package.json +94 -0
- package/src/ai-guard.js +205 -0
- package/src/ast.js +319 -0
- package/src/audit-trail.js +154 -0
- package/src/autofix.js +524 -0
- package/src/badge.js +42 -0
- package/src/behavior.js +205 -0
- package/src/compliance.js +151 -0
- package/src/crosstaint.js +324 -0
- package/src/cve-intel.js +136 -0
- package/src/dashboard.js +279 -0
- package/src/deps.js +159 -0
- package/src/doctor.js +111 -0
- package/src/engine.js +234 -0
- package/src/external.js +160 -0
- package/src/firewall.js +517 -0
- package/src/history.js +87 -0
- package/src/hook.js +151 -0
- package/src/install.js +248 -0
- package/src/interceptor.js +476 -0
- package/src/mcp-server.js +1804 -0
- package/src/net-audit.js +208 -0
- package/src/pii.js +212 -0
- package/src/plugin.js +80 -0
- package/src/policy-gen.js +288 -0
- package/src/pre-deploy.js +282 -0
- package/src/presets.js +113 -0
- package/src/privacy-audit.js +273 -0
- package/src/repl.js +150 -0
- package/src/report.js +312 -0
- package/src/rules-pack.js +2753 -0
- package/src/rules.js +1446 -0
- package/src/sandbox.js +139 -0
- package/src/scanner.js +651 -0
- package/src/secure-prompt.js +140 -0
- package/src/slopsquat.js +144 -0
- package/src/supply-firewall.js +243 -0
- package/src/suppress.js +89 -0
- package/src/taint.js +168 -0
- package/src/trace.js +220 -0
- package/src/urlscan.js +142 -0
- package/src/vault.js +145 -0
- package/src/verify.js +98 -0
- package/src/verifykeys.js +87 -0
package/src/engine.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Engine gaps:
|
|
5
|
+
* 1. Sanitizer recognition — stop taint propagation when a sanitizer is applied
|
|
6
|
+
* 2. Incremental/diff-aware scanning — only scan changed files
|
|
7
|
+
* 3. Auth coverage map — enumerate routes → middleware → guards
|
|
8
|
+
* 4. Python taint — basic Python source-to-sink taint detection
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const crypto = require('crypto');
|
|
14
|
+
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// 1. SANITIZER RECOGNITION
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
const SANITIZERS = {
|
|
20
|
+
xss: [
|
|
21
|
+
'DOMPurify', 'sanitize', 'sanitizeHtml', 'escape', 'escapeHtml',
|
|
22
|
+
'encodeURIComponent', 'encodeURI', 'textEncode', 'he.encode',
|
|
23
|
+
'React.createElement', 'textContent',
|
|
24
|
+
],
|
|
25
|
+
sql: [
|
|
26
|
+
'parameterize', 'prepare', 'placeholder', 'bind', 'sql`', 'sql.query',
|
|
27
|
+
'prisma.$queryRaw', 'pool.query', 'client.query',
|
|
28
|
+
],
|
|
29
|
+
cmd: [
|
|
30
|
+
'execFile', 'spawn', 'shell-quote', 'shellescape', 'sanitizeShell',
|
|
31
|
+
],
|
|
32
|
+
path: [
|
|
33
|
+
'path.resolve', 'path.join', 'path.normalize', 'sanitize',
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
function isSanitized(expr, type) {
|
|
38
|
+
if (!expr || typeof expr !== 'string') return false;
|
|
39
|
+
const sanitizers = SANITIZERS[type] || [];
|
|
40
|
+
return sanitizers.some((s) => expr.includes(s));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// 2. INCREMENTAL / DIFF-AWARE SCANNING
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
const HASH_CACHE_DIR = '.vibeguard/cache';
|
|
48
|
+
|
|
49
|
+
function loadHashCache(root) {
|
|
50
|
+
const p = path.join(root, HASH_CACHE_DIR, 'file-hashes.json');
|
|
51
|
+
if (fs.existsSync(p)) {
|
|
52
|
+
try { return JSON.parse(fs.readFileSync(p, 'utf8')); } catch {}
|
|
53
|
+
}
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function saveHashCache(root, cache) {
|
|
58
|
+
const dir = path.join(root, HASH_CACHE_DIR);
|
|
59
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
60
|
+
fs.writeFileSync(path.join(dir, 'file-hashes.json'), JSON.stringify(cache, null, 2));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function hashContent(content) {
|
|
64
|
+
return crypto.createHash('sha256').update(content).digest('hex');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function getChangedFiles(root, allFiles) {
|
|
68
|
+
const cache = loadHashCache(root);
|
|
69
|
+
const changed = [];
|
|
70
|
+
const newCache = {};
|
|
71
|
+
|
|
72
|
+
for (const file of allFiles) {
|
|
73
|
+
try {
|
|
74
|
+
const content = fs.readFileSync(file, 'utf8');
|
|
75
|
+
const hash = hashContent(content);
|
|
76
|
+
newCache[file] = hash;
|
|
77
|
+
if (cache[file] !== hash) changed.push(file);
|
|
78
|
+
} catch {
|
|
79
|
+
// can't read, skip
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
saveHashCache(root, newCache);
|
|
84
|
+
return { changed, total: allFiles.length, cached: allFiles.length - changed.length };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
// 3. AUTH COVERAGE MAP
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
|
|
91
|
+
const ROUTE_RE = /(?:app|router|server)\.(?:get|post|put|delete|patch|all|use)\s*\(\s*['"`]([^'"`]+)['"`]/gi;
|
|
92
|
+
const MIDDLEWARE_RE = /(?:app|router)\.use\s*\(\s*['"`]([^'"`]+)['"`]/gi;
|
|
93
|
+
const AUTH_GUARD_RE = /(?:requireAuth|withAuth|protect|guard|authMiddleware|isAuthenticated|verifyToken|authenticate|clerkMiddleware|auth\(\)|getServerSession|getSession)/i;
|
|
94
|
+
|
|
95
|
+
function buildAuthCoverage(root, files) {
|
|
96
|
+
const routes = [];
|
|
97
|
+
const middlewares = [];
|
|
98
|
+
|
|
99
|
+
for (const file of files) {
|
|
100
|
+
try {
|
|
101
|
+
const content = fs.readFileSync(file, 'utf8');
|
|
102
|
+
const relPath = path.relative(root, file);
|
|
103
|
+
|
|
104
|
+
let m;
|
|
105
|
+
while ((m = ROUTE_RE.exec(content)) !== null) {
|
|
106
|
+
const routePath = m[1];
|
|
107
|
+
const beforeLines = content.slice(0, m.index).split('\n');
|
|
108
|
+
const lineNum = beforeLines.length;
|
|
109
|
+
const currentLine = content.slice(m.index, m.index + 300).split('\n')[0];
|
|
110
|
+
const hasAuth = AUTH_GUARD_RE.test(currentLine);
|
|
111
|
+
routes.push({
|
|
112
|
+
path: routePath,
|
|
113
|
+
file: relPath,
|
|
114
|
+
line: lineNum,
|
|
115
|
+
protected: hasAuth,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
while ((m = MIDDLEWARE_RE.exec(content)) !== null) {
|
|
120
|
+
const mwPath = m[1];
|
|
121
|
+
const lines = content.slice(0, m.index).split('\n');
|
|
122
|
+
const lineNum = lines.length;
|
|
123
|
+
const surrounding = content.slice(m.index, m.index + 300);
|
|
124
|
+
const isAuth = AUTH_GUARD_RE.test(surrounding);
|
|
125
|
+
if (isAuth) {
|
|
126
|
+
middlewares.push({ path: mwPath, file: relPath, line: lineNum });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} catch {}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const unprotected = routes.filter((r) => !r.protected && r.path.startsWith('/api/'));
|
|
133
|
+
const protectedRoutes = routes.filter((r) => r.protected);
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
totalRoutes: routes.length,
|
|
137
|
+
protectedRoutes: protectedRoutes.length,
|
|
138
|
+
unprotectedRoutes: unprotected.length,
|
|
139
|
+
unprotected,
|
|
140
|
+
middlewares,
|
|
141
|
+
coverage: routes.length > 0 ? Math.round((protectedRoutes.length / routes.length) * 100) : 100,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ---------------------------------------------------------------------------
|
|
146
|
+
// 4. PYTHON TAINT (basic — regex-based, no AST)
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
|
|
149
|
+
const PY_SOURCES = [
|
|
150
|
+
{ re: /request\.(?:form|args|data|json|values|cookies|headers)(?:\.\w+)?\s*\(/g, name: 'request' },
|
|
151
|
+
{ re: /request\.get\s*\(/g, name: 'request' },
|
|
152
|
+
{ re: /\binput\s*\(/g, name: 'input()' },
|
|
153
|
+
{ re: /os\.environ\.get\s*\(/g, name: 'os.environ' },
|
|
154
|
+
{ re: /sys\.argv/g, name: 'sys.argv' },
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
const PY_SINKS = [
|
|
158
|
+
{ re: /cursor\.execute\s*\(/g, name: 'cursor.execute', type: 'sql' },
|
|
159
|
+
{ re: /os\.system\s*\(/g, name: 'os.system', type: 'cmd' },
|
|
160
|
+
{ re: /subprocess\.(?:run|call|Popen)\s*\(/g, name: 'subprocess', type: 'cmd' },
|
|
161
|
+
{ re: /eval\s*\(/g, name: 'eval()', type: 'code' },
|
|
162
|
+
{ re: /exec\s*\(/g, name: 'exec()', type: 'code' },
|
|
163
|
+
{ re: /open\s*\(/g, name: 'open()', type: 'file' },
|
|
164
|
+
{ re: /pickle\.loads?\s*\(/g, name: 'pickle', type: 'deserialization' },
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
function analyzePythonTaint(content, lines, relPath) {
|
|
168
|
+
const findings = [];
|
|
169
|
+
const sources = [];
|
|
170
|
+
const sinks = [];
|
|
171
|
+
|
|
172
|
+
for (let i = 0; i < lines.length; i++) {
|
|
173
|
+
const line = lines[i];
|
|
174
|
+
for (const src of PY_SOURCES) {
|
|
175
|
+
src.re.lastIndex = 0;
|
|
176
|
+
if (src.re.test(line)) {
|
|
177
|
+
sources.push({ line: i + 1, name: src.name, var: extractVarName(line) });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
for (const sink of PY_SINKS) {
|
|
181
|
+
sink.re.lastIndex = 0;
|
|
182
|
+
if (sink.re.test(line)) {
|
|
183
|
+
sinks.push({ line: i + 1, name: sink.name, type: sink.type });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
for (const src of sources) {
|
|
189
|
+
for (const sink of sinks) {
|
|
190
|
+
if (sink.line >= src.line) {
|
|
191
|
+
const varName = src.var;
|
|
192
|
+
if (!varName) continue;
|
|
193
|
+
const linesBetween = lines.slice(src.line - 1, sink.line).join('\n');
|
|
194
|
+
if (linesBetween.includes(varName)) {
|
|
195
|
+
findings.push({
|
|
196
|
+
ruleId: 'py.taint-flow',
|
|
197
|
+
file: relPath,
|
|
198
|
+
line: sink.line,
|
|
199
|
+
column: 1,
|
|
200
|
+
severity: 'high',
|
|
201
|
+
confidence: 'medium',
|
|
202
|
+
title: `Python taint: ${src.name} → ${sink.name}`,
|
|
203
|
+
snippet: lines[sink.line - 1]?.trim().slice(0, 120) || '',
|
|
204
|
+
message: `User input (${src.name} at line ${src.line}) flows to ${sink.name} (line ${sink.line}) without sanitization.`,
|
|
205
|
+
fix: `Sanitize or validate the input before passing it to ${sink.name}.`,
|
|
206
|
+
owasp: 'A03:2025 Injection',
|
|
207
|
+
cwe: sink.type === 'sql' ? 'CWE-89' : sink.type === 'cmd' ? 'CWE-77' : 'CWE-20',
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return findings;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function extractVarName(line) {
|
|
218
|
+
const m = /\b(\w+)\s*=\s*(?:request\.|input\(|os\.environ|sys\.argv)/.exec(line);
|
|
219
|
+
if (m) return m[1];
|
|
220
|
+
const m2 = /\b(?:for\s+)?(\w+)\s+in\s+request\./.exec(line);
|
|
221
|
+
if (m2) return m2[1];
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
module.exports = {
|
|
226
|
+
isSanitized,
|
|
227
|
+
SANITIZERS,
|
|
228
|
+
getChangedFiles,
|
|
229
|
+
loadHashCache,
|
|
230
|
+
saveHashCache,
|
|
231
|
+
hashContent,
|
|
232
|
+
buildAuthCoverage,
|
|
233
|
+
analyzePythonTaint,
|
|
234
|
+
};
|
package/src/external.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Orchestrate best-in-class external scanners when they are installed.
|
|
5
|
+
*
|
|
6
|
+
* VibeGuard's own rules are fast and quiet; deep dataflow/secret engines are a
|
|
7
|
+
* solved problem elsewhere. Rather than reinvent them, `--deep` folds in whatever
|
|
8
|
+
* is available on the machine:
|
|
9
|
+
* - semgrep (deep dataflow / large rule packs)
|
|
10
|
+
* - gitleaks (dedicated secret detection with entropy + rulesets)
|
|
11
|
+
*
|
|
12
|
+
* All runs are opt-in (network/slow) and non-fatal: a missing tool is skipped
|
|
13
|
+
* with a note, never an error.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const { execFileSync, execSync } = require('child_process');
|
|
17
|
+
|
|
18
|
+
const isWin = process.platform === 'win32';
|
|
19
|
+
const TIMEOUT_MS = 180000;
|
|
20
|
+
|
|
21
|
+
function run(cmd, args, cwd) {
|
|
22
|
+
const opts = { cwd, timeout: TIMEOUT_MS, maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true };
|
|
23
|
+
// cmd/args are fixed literals here — no user input reaches the shell path.
|
|
24
|
+
return (isWin ? execSync([cmd, ...args].join(' '), opts) : execFileSync(cmd, args, opts)).toString('utf8');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// -------- Semgrep ----------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
const SEMGREP_SEV = { ERROR: 'high', WARNING: 'medium', INFO: 'low' };
|
|
30
|
+
|
|
31
|
+
function parseSemgrep(json) {
|
|
32
|
+
const out = [];
|
|
33
|
+
const results = (json && json.results) || [];
|
|
34
|
+
for (const r of results) {
|
|
35
|
+
const sev = SEMGREP_SEV[(r.extra && r.extra.severity) || 'WARNING'] || 'medium';
|
|
36
|
+
out.push({
|
|
37
|
+
ruleId: `semgrep.${r.check_id || 'finding'}`.slice(0, 80),
|
|
38
|
+
severity: sev,
|
|
39
|
+
confidence: 'high',
|
|
40
|
+
title: 'Semgrep finding',
|
|
41
|
+
message: (r.extra && r.extra.message) || r.check_id || 'Semgrep finding',
|
|
42
|
+
fix: (r.extra && r.extra.fix) || 'See the Semgrep rule for remediation guidance.',
|
|
43
|
+
file: r.path,
|
|
44
|
+
line: (r.start && r.start.line) || 1,
|
|
45
|
+
column: (r.start && r.start.col) || 1,
|
|
46
|
+
snippet: (r.extra && r.extra.lines ? String(r.extra.lines) : '').slice(0, 120),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function runSemgrep(root) {
|
|
53
|
+
try {
|
|
54
|
+
const out = run('semgrep', ['--config', 'auto', '--json', '--quiet', '--timeout', '60', '.'], root);
|
|
55
|
+
return { findings: parseSemgrep(JSON.parse(out || '{}')), ran: true, note: null };
|
|
56
|
+
} catch (err) {
|
|
57
|
+
if (err && err.stdout) {
|
|
58
|
+
try {
|
|
59
|
+
return { findings: parseSemgrep(JSON.parse(err.stdout.toString('utf8'))), ran: true, note: null };
|
|
60
|
+
} catch { /* fallthrough */ }
|
|
61
|
+
}
|
|
62
|
+
return { findings: [], ran: false, note: `semgrep unavailable (${err.code || err.message})` };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// -------- gitleaks ---------------------------------------------------------
|
|
67
|
+
|
|
68
|
+
function parseGitleaks(json) {
|
|
69
|
+
const out = [];
|
|
70
|
+
const arr = Array.isArray(json) ? json : [];
|
|
71
|
+
for (const g of arr) {
|
|
72
|
+
out.push({
|
|
73
|
+
ruleId: `gitleaks.${g.RuleID || 'secret'}`.slice(0, 80),
|
|
74
|
+
severity: 'critical',
|
|
75
|
+
confidence: 'high',
|
|
76
|
+
title: 'gitleaks secret',
|
|
77
|
+
message: `${g.Description || 'Secret detected'} (${g.RuleID || 'rule'}).`,
|
|
78
|
+
fix: 'Remove the secret, load it from a secrets manager, and rotate it — treat it as compromised.',
|
|
79
|
+
file: g.File,
|
|
80
|
+
line: g.StartLine || 1,
|
|
81
|
+
column: 1,
|
|
82
|
+
snippet: g.Match ? String(g.Match).slice(0, 8) + '****' : 'secret',
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function runGitleaks(root) {
|
|
89
|
+
try {
|
|
90
|
+
// gitleaks v8: scan a directory, no git history, JSON to stdout.
|
|
91
|
+
const out = run('gitleaks', ['dir', '.', '--no-banner', '--report-format', 'json', '--report-path', '-'], root);
|
|
92
|
+
return { findings: parseGitleaks(JSON.parse(out || '[]')), ran: true, note: null };
|
|
93
|
+
} catch (err) {
|
|
94
|
+
if (err && err.stdout) {
|
|
95
|
+
try {
|
|
96
|
+
return { findings: parseGitleaks(JSON.parse(err.stdout.toString('utf8') || '[]')), ran: true, note: null };
|
|
97
|
+
} catch { /* fallthrough */ }
|
|
98
|
+
}
|
|
99
|
+
return { findings: [], ran: false, note: `gitleaks unavailable (${err.code || err.message})` };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// -------- bandit (Python) --------------------------------------------------
|
|
104
|
+
|
|
105
|
+
const BANDIT_SEV = { HIGH: 'high', MEDIUM: 'medium', LOW: 'low' };
|
|
106
|
+
|
|
107
|
+
function parseBandit(json) {
|
|
108
|
+
const out = [];
|
|
109
|
+
const results = (json && json.results) || [];
|
|
110
|
+
for (const r of results) {
|
|
111
|
+
out.push({
|
|
112
|
+
ruleId: `bandit.${r.test_id || 'finding'}`,
|
|
113
|
+
severity: BANDIT_SEV[r.issue_severity] || 'medium',
|
|
114
|
+
confidence: (r.issue_confidence === 'LOW' ? 'low' : 'high'),
|
|
115
|
+
title: 'Bandit (Python) finding',
|
|
116
|
+
message: `${r.issue_text || 'Python security issue'} [${r.test_id || ''}].`,
|
|
117
|
+
fix: 'See the Bandit test docs for remediation.',
|
|
118
|
+
file: r.filename,
|
|
119
|
+
line: r.line_number || 1,
|
|
120
|
+
column: 1,
|
|
121
|
+
snippet: (r.code || '').split('\n')[0].slice(0, 120),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function runBandit(root) {
|
|
128
|
+
const fs = require('fs');
|
|
129
|
+
const path = require('path');
|
|
130
|
+
const hasPy =
|
|
131
|
+
fs.existsSync(path.join(root, 'requirements.txt')) ||
|
|
132
|
+
fs.existsSync(path.join(root, 'pyproject.toml')) ||
|
|
133
|
+
fs.existsSync(path.join(root, 'setup.py'));
|
|
134
|
+
if (!hasPy) return { findings: [], ran: false, note: 'no python project' };
|
|
135
|
+
try {
|
|
136
|
+
let data;
|
|
137
|
+
try {
|
|
138
|
+
data = JSON.parse(run('bandit', ['-r', '.', '-f', 'json', '-q'], root) || '{}');
|
|
139
|
+
} catch (err) {
|
|
140
|
+
if (err && err.stdout) data = JSON.parse(err.stdout.toString('utf8') || '{}');
|
|
141
|
+
else throw err;
|
|
142
|
+
}
|
|
143
|
+
return { findings: parseBandit(data), ran: true, note: null };
|
|
144
|
+
} catch (err) {
|
|
145
|
+
return { findings: [], ran: false, note: `bandit unavailable (${err.code || err.message})` };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function runExternal(root) {
|
|
150
|
+
const sg = runSemgrep(root);
|
|
151
|
+
const gl = runGitleaks(root);
|
|
152
|
+
const bd = runBandit(root);
|
|
153
|
+
return {
|
|
154
|
+
findings: [...sg.findings, ...gl.findings, ...bd.findings],
|
|
155
|
+
ran: { semgrep: sg.ran, gitleaks: gl.ran, bandit: bd.ran },
|
|
156
|
+
notes: [sg.note, gl.note, bd.note].filter(Boolean),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
module.exports = { runExternal, parseSemgrep, parseGitleaks, parseBandit };
|