@yagyeshvyas/vibeguard 1.3.0 → 1.11.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/.vibeguard-mcp.example.json +51 -0
- package/CHANGELOG.md +604 -216
- package/MCP-FIREWALL.md +296 -0
- package/README.md +355 -31
- package/bin/cli.js +355 -27
- package/bin/cmd-agent-monitor.js +45 -0
- package/bin/cmd-agent-risk.js +64 -0
- package/bin/cmd-gif.js +62 -0
- package/bin/cmd-git-scan.js +74 -0
- package/bin/cmd-llm-proxy.js +164 -0
- package/bin/cmd-mcp-firewall.js +191 -0
- package/bin/cmd-pentest.js +103 -0
- package/bin/cmd-platform.js +137 -0
- package/bin/cmd-pr-scan.js +135 -0
- package/bin/cmd-sbom-diff.js +38 -0
- package/bin/cmd-skill-scan.js +35 -0
- package/docs/AISVS.md +25 -0
- package/docs/ARCHITECTURE.md +81 -0
- package/docs/INSTALLATION.md +139 -0
- package/docs/WINDOWS.md +74 -0
- package/docs/security-policy.strict.example.json +134 -0
- package/docs/security-policy.strict.example.pub.pem +3 -0
- package/package.json +45 -7
- package/src/.vibeguard/cache/file-hashes.json +60 -0
- package/src/.vibeguard/latest-snapshot.json +36 -0
- package/src/.vibeguard/mcp-pins.json +1 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/auto.js +428 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/daemon.js +344 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/dashboard.js +279 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/engine.js +297 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/hook.js +151 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/install.js +299 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/manifest.json +65 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/mcp-server.js +2051 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/plugin.js +168 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/pre-deploy.js +362 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/repl.js +150 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/rules.js +1611 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/sbom.js +164 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/shell-guard.js +292 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/slopsquat.js +144 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/trace.js +220 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/auto.js +428 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/daemon.js +344 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/engine.js +297 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/install.js +299 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/manifest.json +37 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/mcp-server.js +2055 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/plugin.js +168 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/pre-deploy.js +362 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/trace.js +220 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/auto.js +428 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/daemon.js +344 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/dashboard.js +279 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/engine.js +297 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/hook.js +151 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/install.js +299 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/manifest.json +65 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/mcp-server.js +2055 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/plugin.js +168 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/pre-deploy.js +362 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/repl.js +150 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/rules.js +1611 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/sbom.js +164 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/shell-guard.js +292 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/slopsquat.js +144 -0
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/trace.js +220 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/auto.js +428 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/daemon.js +344 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/dashboard.js +279 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/engine.js +297 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/hook.js +151 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/install.js +299 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/manifest.json +65 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/mcp-server.js +2054 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/plugin.js +168 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/pre-deploy.js +362 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/repl.js +150 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/rules.js +1611 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/sbom.js +164 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/shell-guard.js +292 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/slopsquat.js +144 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/trace.js +220 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/auto.js +428 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/daemon.js +344 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/engine.js +297 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/install.js +299 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/manifest.json +37 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/mcp-server.js +2055 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/plugin.js +168 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/pre-deploy.js +362 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/trace.js +220 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/auto.js +428 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/daemon.js +344 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/engine.js +297 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/manifest.json +33 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/mcp-server.js +2055 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/rules.js +1611 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/shell-guard.js +292 -0
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/trace.js +220 -0
- package/src/.vibeguard-baseline.json +5226 -0
- package/src/action-guard.js +84 -6
- package/src/agent-monitor.js +262 -0
- package/src/agent-policy.js +642 -0
- package/src/agent-risk.js +271 -0
- package/src/agentic.js +1513 -0
- package/src/ast.js +165 -7
- package/src/audit-trail.js +212 -67
- package/src/auto.js +427 -427
- package/src/autofix.js +11 -4
- package/src/bundles.js +198 -0
- package/src/daemon.js +343 -343
- package/src/dashboard.js +278 -278
- package/src/engine.js +3 -0
- package/src/entropy.js +187 -0
- package/src/firewall.js +19 -3
- package/src/gif.js +134 -0
- package/src/gitscan.js +282 -0
- package/src/hook.js +151 -151
- package/src/injection-decode.js +136 -0
- package/src/install.js +298 -280
- package/src/integrity.js +16 -1
- package/src/integrity.json +43 -13
- package/src/interceptor.js +12 -9
- package/src/llm-proxy.js +986 -0
- package/src/mcp-audit.js +61 -5
- package/src/mcp-firewall.js +971 -0
- package/src/mcp-server.js +2500 -2047
- package/src/obfuscation.js +315 -0
- package/src/owasp-agentic.js +314 -0
- package/src/pentest.js +589 -0
- package/src/pii.js +4 -0
- package/src/platform/aisvs.js +38 -0
- package/src/platform/approval.js +187 -0
- package/src/platform/canonical.js +73 -0
- package/src/platform/contracts.js +158 -0
- package/src/platform/delegation.js +73 -0
- package/src/platform/http-gateway.js +177 -0
- package/src/platform/identity.js +253 -0
- package/src/platform/jwt.js +86 -0
- package/src/platform/mcp-http-bridge.js +199 -0
- package/src/platform/memory-guard.js +64 -0
- package/src/platform/os-sandbox.js +144 -0
- package/src/platform/policy.js +332 -0
- package/src/platform/sandbox-manager.js +92 -0
- package/src/platform/signed-audit.js +357 -0
- package/src/platform/ssrf.js +129 -0
- package/src/plugin.js +182 -168
- package/src/pre-deploy.js +170 -55
- package/src/privacy-audit.js +272 -272
- package/src/repl.js +150 -150
- package/src/report.js +7 -1
- package/src/routes.js +1210 -0
- package/src/rules-2026.js +1407 -0
- package/src/rules-pack.js +3068 -3019
- package/src/rules.js +376 -60
- package/src/sandbox.js +200 -10
- package/src/sbom.js +193 -164
- package/src/scanner.js +189 -33
- package/src/shell-guard.js +11 -0
- package/src/skill-scan.js +477 -0
- package/src/slopsquat.js +144 -144
- package/src/surface.js +408 -0
- package/src/taint-ast.js +204 -37
- package/src/taint.js +15 -3
- package/src/tokenlean.js +579 -0
- package/src/trace.js +220 -220
package/src/autofix.js
CHANGED
|
@@ -147,10 +147,17 @@ function computeAutoFixes(root, result) {
|
|
|
147
147
|
const lines = before.split(/\r?\n/);
|
|
148
148
|
const idx = f.line - 1;
|
|
149
149
|
if (idx < 0 || idx >= lines.length) continue;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
150
|
+
const line = lines[idx];
|
|
151
|
+
// single-line empty catch: `catch {}` -> `catch (err) { console.error(err); }`
|
|
152
|
+
// `catch (e) {}` -> `catch (e) { console.error(e); }`
|
|
153
|
+
const single = /(\bcatch\s*)(?:\(\s*([A-Za-z_$][\w$]*)\s*\))?(\s*\{\s*\})/.exec(line);
|
|
154
|
+
if (single) {
|
|
155
|
+
const name = single[2] || 'err';
|
|
156
|
+
lines[idx] = line.replace(single[0], `catch (${name}) { console.error(${name}); }`);
|
|
157
|
+
} else if (/(?:^|[^A-Za-z0-9_$])catch\s*\{$/.test(line) && idx + 1 < lines.length && /^\s*\}\s*$/.test(lines[idx + 1])) {
|
|
158
|
+
// multi-line empty catch (`} catch {` + `}`): add binding + log before closing brace
|
|
159
|
+
lines[idx] = line.replace(/(\bcatch\s*)\{$/, '$1(err) {');
|
|
160
|
+
lines.splice(idx + 1, 0, ' console.error(err);');
|
|
154
161
|
} else { continue; }
|
|
155
162
|
const after = lines.join('\n');
|
|
156
163
|
if (!byFile.has(rel)) byFile.set(rel, { file: rel, absFile: abs, ruleId: f.ruleId, description: `Add error logging to empty catch on line ${f.line}`, before, after });
|
package/src/bundles.js
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Build-artifact / bundle scan.
|
|
5
|
+
*
|
|
6
|
+
* Every source scanner in this space reads the repository and skips `dist/`,
|
|
7
|
+
* `build/`, `.next/static` and `out/`. That is exactly where bundlers INLINE the
|
|
8
|
+
* environment: a key that was only ever in a server .env ends up as a literal in
|
|
9
|
+
* `dist/assets/index-*.js`, and `NEXT_PUBLIC_`/VITE_ values are client-visible by
|
|
10
|
+
* design. GitGuardian's 2026 report records AI-service keys at +81% YoY; the
|
|
11
|
+
* documented blind spot is not the commit, it is the artifact.
|
|
12
|
+
*
|
|
13
|
+
* This module reuses the secret rules and entropy engine against build output,
|
|
14
|
+
* adds source-map exposure, and reports whether the finding exists only in the
|
|
15
|
+
* artifact (present in bundle, absent from source) — the strongest signal that
|
|
16
|
+
* a server-only value leaked into the client bundle.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const path = require('path');
|
|
21
|
+
const { secretRules, makeFinding, looksLikePlaceholder, isPublicBaaSKey } = require('./rules');
|
|
22
|
+
const { findHighEntropyTokens } = require('./entropy');
|
|
23
|
+
|
|
24
|
+
const BUILD_DIRS = [
|
|
25
|
+
'dist',
|
|
26
|
+
'build',
|
|
27
|
+
'out',
|
|
28
|
+
'.next/static',
|
|
29
|
+
'public/build',
|
|
30
|
+
'static/js',
|
|
31
|
+
'public/_next',
|
|
32
|
+
'www',
|
|
33
|
+
'public/assets',
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const BUNDLE_EXT = new Set(['.js', '.mjs', '.cjs', '.css', '.map', '.html', '.json', '.txt']);
|
|
37
|
+
const MAX_BYTES = 8 * 1024 * 1024;
|
|
38
|
+
const MAX_LINE = 200_000; // minified bundles ship one enormous line — scan it anyway
|
|
39
|
+
|
|
40
|
+
function walkBuild(dir, out) {
|
|
41
|
+
let entries;
|
|
42
|
+
try {
|
|
43
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
44
|
+
} catch {
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
for (const entry of entries) {
|
|
48
|
+
const full = path.join(dir, entry.name);
|
|
49
|
+
if (entry.isDirectory()) {
|
|
50
|
+
walkBuild(full, out);
|
|
51
|
+
} else if (entry.isFile()) {
|
|
52
|
+
const ext = path.extname(entry.name).toLowerCase();
|
|
53
|
+
if (!BUNDLE_EXT.has(ext)) continue;
|
|
54
|
+
try {
|
|
55
|
+
const st = fs.statSync(full);
|
|
56
|
+
if (st.size > MAX_BYTES) continue;
|
|
57
|
+
} catch {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
out.push(full);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function mask(value) {
|
|
67
|
+
if (!value || value.length < 10) return '****';
|
|
68
|
+
return value.slice(0, 4) + '****' + value.slice(-2);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function scannableLines(content) {
|
|
72
|
+
const lines = content.split(/\r?\n/);
|
|
73
|
+
// A minified line is still worth scanning; just do not let a 10 MB line blow
|
|
74
|
+
// the regex engine with pathological backtracking.
|
|
75
|
+
return lines.map((l) => (l.length > MAX_LINE ? l.slice(0, MAX_LINE) : l));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function scanBundles(root, opts = {}) {
|
|
79
|
+
const candidates = opts.dirs && opts.dirs.length ? opts.dirs : BUILD_DIRS;
|
|
80
|
+
const dirs = [];
|
|
81
|
+
for (const d of candidates) {
|
|
82
|
+
const abs = path.resolve(root, d);
|
|
83
|
+
try {
|
|
84
|
+
if (fs.statSync(abs).isDirectory()) dirs.push(abs);
|
|
85
|
+
} catch {
|
|
86
|
+
/* absent build dir is normal */
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const findings = [];
|
|
91
|
+
const notes = [];
|
|
92
|
+
const files = [];
|
|
93
|
+
for (const dir of dirs) walkBuild(dir, files);
|
|
94
|
+
|
|
95
|
+
const seen = new Set();
|
|
96
|
+
const push = (f) => {
|
|
97
|
+
const key = `${f.ruleId}:${f.file}:${f.line}:${(f.snippet || '').slice(0, 40)}`;
|
|
98
|
+
if (seen.has(key)) return;
|
|
99
|
+
seen.add(key);
|
|
100
|
+
findings.push(f);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
for (const abs of files) {
|
|
104
|
+
let content;
|
|
105
|
+
try {
|
|
106
|
+
content = fs.readFileSync(abs, 'utf8');
|
|
107
|
+
} catch {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (content.includes('\u0000')) continue; // binary
|
|
111
|
+
const rel = path.relative(root, abs).split(path.sep).join('/');
|
|
112
|
+
|
|
113
|
+
// 1) Source maps shipped to production: readable original source for anyone.
|
|
114
|
+
if (abs.endsWith('.map')) {
|
|
115
|
+
push({
|
|
116
|
+
ruleId: 'bundle.sourcemap-exposed',
|
|
117
|
+
severity: 'medium',
|
|
118
|
+
confidence: 'high',
|
|
119
|
+
title: 'Source map shipped in the build output',
|
|
120
|
+
message: `${rel} exposes original source and strings to anyone who opens devtools. Secrets inlined in the bundle are recoverable even after a rotation of the variable name.`,
|
|
121
|
+
fix: 'Disable production source maps (Vite: build.sourcemap=false, Next: productionBrowserSourceMaps=false) or upload them to your error tracker and delete them from the served artifact.',
|
|
122
|
+
file: rel,
|
|
123
|
+
line: 1,
|
|
124
|
+
column: 1,
|
|
125
|
+
snippet: rel,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const lines = scannableLines(content);
|
|
130
|
+
|
|
131
|
+
// 2) Known secret formats, using the same rules the source scan uses.
|
|
132
|
+
for (let i = 0; i < lines.length; i++) {
|
|
133
|
+
const line = lines[i];
|
|
134
|
+
if (!line || line.length < 8) continue;
|
|
135
|
+
for (const rule of secretRules) {
|
|
136
|
+
if (!rule.re) continue;
|
|
137
|
+
const re = rule.re.flags.includes('g') ? rule.re : new RegExp(rule.re.source, rule.re.flags + 'g');
|
|
138
|
+
re.lastIndex = 0;
|
|
139
|
+
let m;
|
|
140
|
+
while ((m = re.exec(line)) !== null) {
|
|
141
|
+
const value = m[1] || m[0];
|
|
142
|
+
if (looksLikePlaceholder(value)) continue;
|
|
143
|
+
if (isPublicBaaSKey(line, value)) continue;
|
|
144
|
+
if (rule.id === 'secret.generic-credential') continue; // bundle entropy pass covers this
|
|
145
|
+
push(makeFinding(rule, {
|
|
146
|
+
file: rel,
|
|
147
|
+
line: i + 1,
|
|
148
|
+
column: m.index + 1,
|
|
149
|
+
snippet: mask(value),
|
|
150
|
+
message: `A ${rule.id.replace('secret.', '').replace(/-/g, ' ')} appears in the BUILD artifact (not just source). This value is served to the browser and is public until rotated.`,
|
|
151
|
+
}));
|
|
152
|
+
if (re.lastIndex === m.index) re.lastIndex++;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 3) Entropy pass for opaque tokens the named rules do not cover.
|
|
158
|
+
const tokens = findHighEntropyTokens(content);
|
|
159
|
+
for (const t of tokens.slice(0, 20)) {
|
|
160
|
+
if (looksLikePlaceholder(t.match)) continue;
|
|
161
|
+
if (isPublicBaaSKey('', t.match)) continue;
|
|
162
|
+
const lineNo = content.slice(0, t.index).split('\n').length;
|
|
163
|
+
push({
|
|
164
|
+
ruleId: 'bundle.high-entropy-token',
|
|
165
|
+
severity: 'high',
|
|
166
|
+
confidence: 'low',
|
|
167
|
+
title: 'High-entropy token inlined in a build artifact',
|
|
168
|
+
message: `A high-entropy string (${t.reason}) is embedded in ${rel}. It may be a build hash, or an inlined API key/telemetry token — review before the artifact is served.`,
|
|
169
|
+
fix: 'Identify the value. If it is a credential, rotate it and move it server-side so the bundler cannot inline it (never reference it from client modules).',
|
|
170
|
+
file: rel,
|
|
171
|
+
line: lineNo,
|
|
172
|
+
column: 1,
|
|
173
|
+
snippet: mask(t.match),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (dirs.length === 0) {
|
|
179
|
+
notes.push('no build output found (looked for: ' + candidates.join(', ') + ')');
|
|
180
|
+
} else if (dirs.length > 0 && files.length === 0) {
|
|
181
|
+
notes.push('build directories exist but contain no scannable artifacts');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
findings.sort((a, b) => {
|
|
185
|
+
const order = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
186
|
+
return (order[a.severity] ?? 9) - (order[b.severity] ?? 9) || a.file.localeCompare(b.file) || a.line - b.line;
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
root,
|
|
191
|
+
dirs: dirs.map((d) => path.relative(root, d).split(path.sep).join('/') || '.'),
|
|
192
|
+
scannedFiles: files.length,
|
|
193
|
+
findings,
|
|
194
|
+
notes,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
module.exports = { scanBundles, BUILD_DIRS };
|