@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/dashboard.js
CHANGED
|
@@ -1,279 +1,279 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* VibeGuard Beautiful Terminal Dashboard.
|
|
5
|
-
*
|
|
6
|
-
* Renders a stunning ASCII dashboard with:
|
|
7
|
-
* - Visual grade meter (A-F) with color
|
|
8
|
-
* - Severity bar chart (critical/high/medium/low)
|
|
9
|
-
* - Top findings table with severity colors
|
|
10
|
-
* - Risk score gauge (0-100)
|
|
11
|
-
* - Category breakdown matrix
|
|
12
|
-
* - Auto-fix summary
|
|
13
|
-
* - Compliance posture
|
|
14
|
-
*
|
|
15
|
-
* Zero dependencies. Pure ASCII art with ANSI colors.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const C = {
|
|
19
|
-
reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m', underline: '\x1b[4m',
|
|
20
|
-
red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m', blue: '\x1b[34m',
|
|
21
|
-
magenta: '\x1b[35m', cyan: '\x1b[36m', white: '\x1b[37m',
|
|
22
|
-
bgRed: '\x1b[41m', bgGreen: '\x1b[42m', bgYellow: '\x1b[43m', bgBlue: '\x1b[44m',
|
|
23
|
-
bgMagenta: '\x1b[45m', bgCyan: '\x1b[46m', bgWhite: '\x1b[47m',
|
|
24
|
-
gray: '\x1b[90m', brightRed: '\x1b[91m', brightGreen: '\x1b[92m',
|
|
25
|
-
brightYellow: '\x1b[93m', brightBlue: '\x1b[94m', brightMagenta: '\x1b[95m',
|
|
26
|
-
brightCyan: '\x1b[96m',
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
function severityColor(sev) {
|
|
30
|
-
return { critical: C.red, high: C.yellow, medium: C.cyan, low: C.gray }[sev] || C.white;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function gradeColor(grade) {
|
|
34
|
-
if (grade === 'A') return C.green;
|
|
35
|
-
if (grade === 'B') return C.green;
|
|
36
|
-
if (grade === 'C') return C.yellow;
|
|
37
|
-
if (grade === 'D') return C.yellow;
|
|
38
|
-
if (grade === 'F') return C.red;
|
|
39
|
-
return C.white;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Render a visual bar: ████████░░░░ 67%
|
|
43
|
-
function bar(count, max, width = 20, color = C.red) {
|
|
44
|
-
if (max === 0) max = 1;
|
|
45
|
-
const filled = Math.round((count / max) * width);
|
|
46
|
-
return color + '█'.repeat(filled) + C.gray + '░'.repeat(width - filled) + C.reset;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Render the grade as a large ASCII art meter
|
|
50
|
-
function gradeMeter(grade) {
|
|
51
|
-
const g = gradeColor(grade);
|
|
52
|
-
const meter = [
|
|
53
|
-
'┌─────────────────────────────────────────────────────────┐',
|
|
54
|
-
'│ │',
|
|
55
|
-
'│' + g + C.bold + ` GRADE: ${grade} ` + C.reset + '│',
|
|
56
|
-
'│ │',
|
|
57
|
-
'└─────────────────────────────────────────────────────────┘',
|
|
58
|
-
];
|
|
59
|
-
return meter.join('\n');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Risk score gauge (0-100)
|
|
63
|
-
function riskGauge(score, level) {
|
|
64
|
-
const colors = { NONE: C.green, LOW: C.green, MEDIUM: C.yellow, HIGH: C.yellow, CRITICAL: C.red };
|
|
65
|
-
const color = colors[level] || C.white;
|
|
66
|
-
const pct = Math.min(100, score);
|
|
67
|
-
const filled = Math.round((pct / 100) * 30);
|
|
68
|
-
const gauge = color + '▰'.repeat(filled) + C.gray + '▱'.repeat(30 - filled) + C.reset;
|
|
69
|
-
return `${C.bold}Risk Score${C.reset} ${gauge} ${color}${C.bold}${score}${C.reset} ${color}(${level})${C.reset}`;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Severity bar chart
|
|
73
|
-
function severityBars(counts) {
|
|
74
|
-
const max = Math.max(counts.critical, counts.high, counts.medium, counts.low, 1);
|
|
75
|
-
const lines = [
|
|
76
|
-
`${C.bold}Severity Distribution${C.reset}`,
|
|
77
|
-
'',
|
|
78
|
-
` ${C.red}Critical ${C.reset} ${bar(counts.critical, max, 25, C.red)} ${C.red}${C.bold}${counts.critical}${C.reset}`,
|
|
79
|
-
` ${C.yellow}High ${C.reset} ${bar(counts.high, max, 25, C.yellow)} ${C.yellow}${C.bold}${counts.high}${C.reset}`,
|
|
80
|
-
` ${C.cyan}Medium ${C.reset} ${bar(counts.medium, max, 25, C.cyan)} ${C.cyan}${C.bold}${counts.medium}${C.reset}`,
|
|
81
|
-
` ${C.gray}Low ${C.reset} ${bar(counts.low, max, 25, C.gray)} ${C.gray}${C.bold}${counts.low}${C.reset}`,
|
|
82
|
-
'',
|
|
83
|
-
];
|
|
84
|
-
return lines.join('\n');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Category breakdown matrix
|
|
88
|
-
function categoryMatrix(findings) {
|
|
89
|
-
const matrix = {};
|
|
90
|
-
for (const f of findings) {
|
|
91
|
-
const cat = f.ruleId.split('.')[0];
|
|
92
|
-
if (!matrix[cat]) matrix[cat] = { critical: 0, high: 0, medium: 0, low: 0, total: 0 };
|
|
93
|
-
matrix[cat][f.severity]++;
|
|
94
|
-
matrix[cat].total++;
|
|
95
|
-
}
|
|
96
|
-
const sorted = Object.entries(matrix).sort((a, b) => b[1].total - a[1].total).slice(0, 12);
|
|
97
|
-
if (sorted.length === 0) return `${C.green}No findings — clean codebase!${C.reset}`;
|
|
98
|
-
const lines = [
|
|
99
|
-
`${C.bold}Category Breakdown${C.reset}`,
|
|
100
|
-
'',
|
|
101
|
-
` ${C.dim}Category Total Crit High Med Low${C.reset}`,
|
|
102
|
-
` ${C.dim}────────────── ───── ──── ──── ──── ───${C.reset}`,
|
|
103
|
-
];
|
|
104
|
-
for (const [cat, c] of sorted) {
|
|
105
|
-
const catColor = c.critical > 0 ? C.red : c.high > 0 ? C.yellow : c.medium > 0 ? C.cyan : C.gray;
|
|
106
|
-
lines.push(
|
|
107
|
-
` ${catColor}${cat.padEnd(14)}${C.reset} ${String(c.total).padStart(5)} ` +
|
|
108
|
-
`${c.critical > 0 ? C.red + String(c.critical).padStart(4) + C.reset : ' 0'} ` +
|
|
109
|
-
`${c.high > 0 ? C.yellow + String(c.high).padStart(4) + C.reset : ' 0'} ` +
|
|
110
|
-
`${c.medium > 0 ? C.cyan + String(c.medium).padStart(4) + C.reset : ' 0'} ` +
|
|
111
|
-
`${c.low > 0 ? C.gray + String(c.low).padStart(4) + C.reset : ' 0'}`
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
return lines.join('\n');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Top findings table
|
|
118
|
-
function topFindings(findings, limit = 10) {
|
|
119
|
-
if (findings.length === 0) return `${C.green}${C.bold}✓ No security issues found — clean codebase!${C.reset}`;
|
|
120
|
-
const sorted = findings.slice().sort((a, b) => {
|
|
121
|
-
const order = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
122
|
-
return (order[a.severity] || 4) - (order[b.severity] || 4);
|
|
123
|
-
}).slice(0, limit);
|
|
124
|
-
const lines = [
|
|
125
|
-
`${C.bold}Top Findings${C.reset}`,
|
|
126
|
-
'',
|
|
127
|
-
];
|
|
128
|
-
for (const f of sorted) {
|
|
129
|
-
const sc = severityColor(f.severity);
|
|
130
|
-
const sevTag = sc + C.bold + `[${f.severity.toUpperCase().padEnd(8)}]` + C.reset;
|
|
131
|
-
lines.push(` ${sevTag} ${C.brightCyan}${f.ruleId}${C.reset}`);
|
|
132
|
-
lines.push(` ${C.dim}${f.file}:${f.line}${C.reset} — ${f.message.slice(0, 70)}`);
|
|
133
|
-
if (f.fix) lines.push(` ${C.green}fix:${C.reset} ${f.fix.slice(0, 70)}`);
|
|
134
|
-
lines.push('');
|
|
135
|
-
}
|
|
136
|
-
if (findings.length > limit) {
|
|
137
|
-
lines.push(` ${C.dim}... and ${findings.length - limit} more findings${C.reset}`);
|
|
138
|
-
}
|
|
139
|
-
return lines.join('\n');
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Auto-fix summary
|
|
143
|
-
function autoFixSummary(findings) {
|
|
144
|
-
try {
|
|
145
|
-
const { isAutoFixable } = require('./autofix');
|
|
146
|
-
const fixable = findings.filter(f => isAutoFixable(f.ruleId));
|
|
147
|
-
if (fixable.length === 0) return '';
|
|
148
|
-
const lines = [
|
|
149
|
-
`${C.green}${C.bold}Auto-Fix Available${C.reset}`,
|
|
150
|
-
'',
|
|
151
|
-
` ${C.green}✓${C.reset} ${fixable.length} of ${findings.length} findings can be auto-fixed`,
|
|
152
|
-
` ${C.dim}Run: vibeguard fix${C.reset}`,
|
|
153
|
-
'',
|
|
154
|
-
];
|
|
155
|
-
return lines.join('\n');
|
|
156
|
-
} catch { return ''; }
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Compliance posture
|
|
160
|
-
function compliancePosture(findings) {
|
|
161
|
-
try {
|
|
162
|
-
const { generateComplianceReport } = require('./compliance');
|
|
163
|
-
const report = generateComplianceReport(findings);
|
|
164
|
-
if (typeof report === 'string') return report;
|
|
165
|
-
const lines = [`${C.bold}Compliance Posture${C.reset}`, ''];
|
|
166
|
-
for (const [framework, data] of Object.entries(report)) {
|
|
167
|
-
const failed = data.failed || data.failures || 0;
|
|
168
|
-
const passed = data.passed || data.pass || 0;
|
|
169
|
-
const status = failed === 0 ? C.green + '✓ PASS' : failed < 3 ? C.yellow + '⚠ REVIEW' : C.red + '✗ FAIL';
|
|
170
|
-
lines.push(` ${status}${C.reset} ${framework.padEnd(12)} ${C.dim}${failed} findings${C.reset}`);
|
|
171
|
-
}
|
|
172
|
-
return lines.join('\n');
|
|
173
|
-
} catch { return `${C.dim}Compliance analysis unavailable${C.reset}`; }
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Full dashboard render
|
|
177
|
-
function renderDashboard(result) {
|
|
178
|
-
const counts = result.counts;
|
|
179
|
-
const weights = { critical: 10, high: 5, medium: 2, low: 1 };
|
|
180
|
-
let score = 0;
|
|
181
|
-
for (const f of result.findings) score += weights[f.severity] || 1;
|
|
182
|
-
const maxScore = result.scannedFiles * 10 || 1;
|
|
183
|
-
const riskPercent = Math.min(100, Math.round((score / maxScore) * 100));
|
|
184
|
-
const riskLevel = score === 0 ? 'NONE' : score < 10 ? 'LOW' : score < 30 ? 'MEDIUM' : score < 60 ? 'HIGH' : 'CRITICAL';
|
|
185
|
-
|
|
186
|
-
const W = 60;
|
|
187
|
-
const border = C.cyan + '═'.repeat(W) + C.reset;
|
|
188
|
-
const borderThin = C.dim + '─'.repeat(W) + C.reset;
|
|
189
|
-
|
|
190
|
-
const sections = [
|
|
191
|
-
'',
|
|
192
|
-
border,
|
|
193
|
-
C.cyan + C.bold + ' VibeGuard Security Dashboard' + C.reset + C.dim + ' — ' + new Date().toISOString().slice(0, 19) + C.reset,
|
|
194
|
-
border,
|
|
195
|
-
'',
|
|
196
|
-
gradeMeter(result.grade),
|
|
197
|
-
'',
|
|
198
|
-
riskGauge(score, riskLevel),
|
|
199
|
-
'',
|
|
200
|
-
borderThin,
|
|
201
|
-
'',
|
|
202
|
-
severityBars(counts),
|
|
203
|
-
borderThin,
|
|
204
|
-
'',
|
|
205
|
-
` ${C.bold}Scan Summary${C.reset}`,
|
|
206
|
-
` ${C.dim}Files scanned:${C.reset} ${result.scannedFiles}`,
|
|
207
|
-
` ${C.dim}Total findings:${C.reset} ${result.findings.length}`,
|
|
208
|
-
` ${C.dim}Grade:${C.reset} ${gradeColor(result.grade)}${C.bold}${result.grade}${C.reset}`,
|
|
209
|
-
'',
|
|
210
|
-
borderThin,
|
|
211
|
-
'',
|
|
212
|
-
categoryMatrix(result.findings),
|
|
213
|
-
'',
|
|
214
|
-
borderThin,
|
|
215
|
-
'',
|
|
216
|
-
topFindings(result.findings),
|
|
217
|
-
autoFixSummary(result.findings),
|
|
218
|
-
borderThin,
|
|
219
|
-
'',
|
|
220
|
-
compliancePosture(result.findings),
|
|
221
|
-
'',
|
|
222
|
-
border,
|
|
223
|
-
C.dim + ' Run "vibeguard scan" for full report | "vibeguard fix" to auto-fix | "vibeguard why <rule>" for details' + C.reset,
|
|
224
|
-
border,
|
|
225
|
-
'',
|
|
226
|
-
];
|
|
227
|
-
|
|
228
|
-
return sections.join('\n');
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// GitHub PR comment format (markdown)
|
|
232
|
-
function renderPRComment(result) {
|
|
233
|
-
const counts = result.counts;
|
|
234
|
-
const gradeEmoji = { A: '🟢', B: '🟢', C: '🟡', D: '🟡', F: '🔴' };
|
|
235
|
-
const emoji = gradeEmoji[result.grade] || '⚪';
|
|
236
|
-
|
|
237
|
-
let md = `## ${emoji} VibeGuard Security Report\n\n`;
|
|
238
|
-
md += `| Metric | Value |\n|--------|-------|\n`;
|
|
239
|
-
md += `| Grade | **${result.grade}** |\n`;
|
|
240
|
-
md += `| Files Scanned | ${result.scannedFiles} |\n`;
|
|
241
|
-
md += `| Total Findings | ${result.findings.length} |\n`;
|
|
242
|
-
md += `| Critical | ${counts.critical} |\n`;
|
|
243
|
-
md += `| High | ${counts.high} |\n`;
|
|
244
|
-
md += `| Medium | ${counts.medium} |\n`;
|
|
245
|
-
md += `| Low | ${counts.low} |\n\n`;
|
|
246
|
-
|
|
247
|
-
if (result.findings.length > 0) {
|
|
248
|
-
md += `### Top Findings\n\n`;
|
|
249
|
-
md += `| Severity | Rule | File:Line | Message |\n`;
|
|
250
|
-
md += `|----------|------|-----------|--------|\n`;
|
|
251
|
-
const sorted = result.findings.slice().sort((a, b) => {
|
|
252
|
-
const order = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
253
|
-
return (order[a.severity] || 4) - (order[b.severity] || 4);
|
|
254
|
-
}).slice(0, 15);
|
|
255
|
-
for (const f of sorted) {
|
|
256
|
-
const sevEmoji = { critical: '🔴', high: '🟠', medium: '🟡', low: '⚪' }[f.severity] || '⚪';
|
|
257
|
-
md += `| ${sevEmoji} ${f.severity} | \`${f.ruleId}\` | \`${f.file}:${f.line}\` | ${f.message.slice(0, 60)} |\n`;
|
|
258
|
-
}
|
|
259
|
-
if (result.findings.length > 15) md += `\n_...and ${result.findings.length - 15} more findings_\n`;
|
|
260
|
-
} else {
|
|
261
|
-
md += `### ✅ No security issues found!\n\nClean codebase. Great job! 🎉\n`;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Auto-fix
|
|
265
|
-
try {
|
|
266
|
-
const { isAutoFixable } = require('./autofix');
|
|
267
|
-
const fixable = result.findings.filter(f => isAutoFixable(f.ruleId));
|
|
268
|
-
if (fixable.length > 0) {
|
|
269
|
-
md += `\n### 🔧 Auto-Fix Available\n\n`;
|
|
270
|
-
md += `${fixable.length} findings can be automatically fixed. Run:\n`;
|
|
271
|
-
md += '```\nvibeguard fix\n```\n';
|
|
272
|
-
}
|
|
273
|
-
} catch {}
|
|
274
|
-
|
|
275
|
-
md += `\n---\n_VibeGuard — Free, zero-dependency security scanner. [Learn more](https://github.com/vibeguard/vibeguard)_\n`;
|
|
276
|
-
return md;
|
|
277
|
-
}
|
|
278
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* VibeGuard Beautiful Terminal Dashboard.
|
|
5
|
+
*
|
|
6
|
+
* Renders a stunning ASCII dashboard with:
|
|
7
|
+
* - Visual grade meter (A-F) with color
|
|
8
|
+
* - Severity bar chart (critical/high/medium/low)
|
|
9
|
+
* - Top findings table with severity colors
|
|
10
|
+
* - Risk score gauge (0-100)
|
|
11
|
+
* - Category breakdown matrix
|
|
12
|
+
* - Auto-fix summary
|
|
13
|
+
* - Compliance posture
|
|
14
|
+
*
|
|
15
|
+
* Zero dependencies. Pure ASCII art with ANSI colors.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const C = {
|
|
19
|
+
reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m', underline: '\x1b[4m',
|
|
20
|
+
red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m', blue: '\x1b[34m',
|
|
21
|
+
magenta: '\x1b[35m', cyan: '\x1b[36m', white: '\x1b[37m',
|
|
22
|
+
bgRed: '\x1b[41m', bgGreen: '\x1b[42m', bgYellow: '\x1b[43m', bgBlue: '\x1b[44m',
|
|
23
|
+
bgMagenta: '\x1b[45m', bgCyan: '\x1b[46m', bgWhite: '\x1b[47m',
|
|
24
|
+
gray: '\x1b[90m', brightRed: '\x1b[91m', brightGreen: '\x1b[92m',
|
|
25
|
+
brightYellow: '\x1b[93m', brightBlue: '\x1b[94m', brightMagenta: '\x1b[95m',
|
|
26
|
+
brightCyan: '\x1b[96m',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function severityColor(sev) {
|
|
30
|
+
return { critical: C.red, high: C.yellow, medium: C.cyan, low: C.gray }[sev] || C.white;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function gradeColor(grade) {
|
|
34
|
+
if (grade === 'A') return C.green;
|
|
35
|
+
if (grade === 'B') return C.green;
|
|
36
|
+
if (grade === 'C') return C.yellow;
|
|
37
|
+
if (grade === 'D') return C.yellow;
|
|
38
|
+
if (grade === 'F') return C.red;
|
|
39
|
+
return C.white;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Render a visual bar: ████████░░░░ 67%
|
|
43
|
+
function bar(count, max, width = 20, color = C.red) {
|
|
44
|
+
if (max === 0) max = 1;
|
|
45
|
+
const filled = Math.round((count / max) * width);
|
|
46
|
+
return color + '█'.repeat(filled) + C.gray + '░'.repeat(width - filled) + C.reset;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Render the grade as a large ASCII art meter
|
|
50
|
+
function gradeMeter(grade) {
|
|
51
|
+
const g = gradeColor(grade);
|
|
52
|
+
const meter = [
|
|
53
|
+
'┌─────────────────────────────────────────────────────────┐',
|
|
54
|
+
'│ │',
|
|
55
|
+
'│' + g + C.bold + ` GRADE: ${grade} ` + C.reset + '│',
|
|
56
|
+
'│ │',
|
|
57
|
+
'└─────────────────────────────────────────────────────────┘',
|
|
58
|
+
];
|
|
59
|
+
return meter.join('\n');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Risk score gauge (0-100)
|
|
63
|
+
function riskGauge(score, level) {
|
|
64
|
+
const colors = { NONE: C.green, LOW: C.green, MEDIUM: C.yellow, HIGH: C.yellow, CRITICAL: C.red };
|
|
65
|
+
const color = colors[level] || C.white;
|
|
66
|
+
const pct = Math.min(100, score);
|
|
67
|
+
const filled = Math.round((pct / 100) * 30);
|
|
68
|
+
const gauge = color + '▰'.repeat(filled) + C.gray + '▱'.repeat(30 - filled) + C.reset;
|
|
69
|
+
return `${C.bold}Risk Score${C.reset} ${gauge} ${color}${C.bold}${score}${C.reset} ${color}(${level})${C.reset}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Severity bar chart
|
|
73
|
+
function severityBars(counts) {
|
|
74
|
+
const max = Math.max(counts.critical, counts.high, counts.medium, counts.low, 1);
|
|
75
|
+
const lines = [
|
|
76
|
+
`${C.bold}Severity Distribution${C.reset}`,
|
|
77
|
+
'',
|
|
78
|
+
` ${C.red}Critical ${C.reset} ${bar(counts.critical, max, 25, C.red)} ${C.red}${C.bold}${counts.critical}${C.reset}`,
|
|
79
|
+
` ${C.yellow}High ${C.reset} ${bar(counts.high, max, 25, C.yellow)} ${C.yellow}${C.bold}${counts.high}${C.reset}`,
|
|
80
|
+
` ${C.cyan}Medium ${C.reset} ${bar(counts.medium, max, 25, C.cyan)} ${C.cyan}${C.bold}${counts.medium}${C.reset}`,
|
|
81
|
+
` ${C.gray}Low ${C.reset} ${bar(counts.low, max, 25, C.gray)} ${C.gray}${C.bold}${counts.low}${C.reset}`,
|
|
82
|
+
'',
|
|
83
|
+
];
|
|
84
|
+
return lines.join('\n');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Category breakdown matrix
|
|
88
|
+
function categoryMatrix(findings) {
|
|
89
|
+
const matrix = {};
|
|
90
|
+
for (const f of findings) {
|
|
91
|
+
const cat = f.ruleId.split('.')[0];
|
|
92
|
+
if (!matrix[cat]) matrix[cat] = { critical: 0, high: 0, medium: 0, low: 0, total: 0 };
|
|
93
|
+
matrix[cat][f.severity]++;
|
|
94
|
+
matrix[cat].total++;
|
|
95
|
+
}
|
|
96
|
+
const sorted = Object.entries(matrix).sort((a, b) => b[1].total - a[1].total).slice(0, 12);
|
|
97
|
+
if (sorted.length === 0) return `${C.green}No findings — clean codebase!${C.reset}`;
|
|
98
|
+
const lines = [
|
|
99
|
+
`${C.bold}Category Breakdown${C.reset}`,
|
|
100
|
+
'',
|
|
101
|
+
` ${C.dim}Category Total Crit High Med Low${C.reset}`,
|
|
102
|
+
` ${C.dim}────────────── ───── ──── ──── ──── ───${C.reset}`,
|
|
103
|
+
];
|
|
104
|
+
for (const [cat, c] of sorted) {
|
|
105
|
+
const catColor = c.critical > 0 ? C.red : c.high > 0 ? C.yellow : c.medium > 0 ? C.cyan : C.gray;
|
|
106
|
+
lines.push(
|
|
107
|
+
` ${catColor}${cat.padEnd(14)}${C.reset} ${String(c.total).padStart(5)} ` +
|
|
108
|
+
`${c.critical > 0 ? C.red + String(c.critical).padStart(4) + C.reset : ' 0'} ` +
|
|
109
|
+
`${c.high > 0 ? C.yellow + String(c.high).padStart(4) + C.reset : ' 0'} ` +
|
|
110
|
+
`${c.medium > 0 ? C.cyan + String(c.medium).padStart(4) + C.reset : ' 0'} ` +
|
|
111
|
+
`${c.low > 0 ? C.gray + String(c.low).padStart(4) + C.reset : ' 0'}`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
return lines.join('\n');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Top findings table
|
|
118
|
+
function topFindings(findings, limit = 10) {
|
|
119
|
+
if (findings.length === 0) return `${C.green}${C.bold}✓ No security issues found — clean codebase!${C.reset}`;
|
|
120
|
+
const sorted = findings.slice().sort((a, b) => {
|
|
121
|
+
const order = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
122
|
+
return (order[a.severity] || 4) - (order[b.severity] || 4);
|
|
123
|
+
}).slice(0, limit);
|
|
124
|
+
const lines = [
|
|
125
|
+
`${C.bold}Top Findings${C.reset}`,
|
|
126
|
+
'',
|
|
127
|
+
];
|
|
128
|
+
for (const f of sorted) {
|
|
129
|
+
const sc = severityColor(f.severity);
|
|
130
|
+
const sevTag = sc + C.bold + `[${f.severity.toUpperCase().padEnd(8)}]` + C.reset;
|
|
131
|
+
lines.push(` ${sevTag} ${C.brightCyan}${f.ruleId}${C.reset}`);
|
|
132
|
+
lines.push(` ${C.dim}${f.file}:${f.line}${C.reset} — ${f.message.slice(0, 70)}`);
|
|
133
|
+
if (f.fix) lines.push(` ${C.green}fix:${C.reset} ${f.fix.slice(0, 70)}`);
|
|
134
|
+
lines.push('');
|
|
135
|
+
}
|
|
136
|
+
if (findings.length > limit) {
|
|
137
|
+
lines.push(` ${C.dim}... and ${findings.length - limit} more findings${C.reset}`);
|
|
138
|
+
}
|
|
139
|
+
return lines.join('\n');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Auto-fix summary
|
|
143
|
+
function autoFixSummary(findings) {
|
|
144
|
+
try {
|
|
145
|
+
const { isAutoFixable } = require('./autofix');
|
|
146
|
+
const fixable = findings.filter(f => isAutoFixable(f.ruleId));
|
|
147
|
+
if (fixable.length === 0) return '';
|
|
148
|
+
const lines = [
|
|
149
|
+
`${C.green}${C.bold}Auto-Fix Available${C.reset}`,
|
|
150
|
+
'',
|
|
151
|
+
` ${C.green}✓${C.reset} ${fixable.length} of ${findings.length} findings can be auto-fixed`,
|
|
152
|
+
` ${C.dim}Run: vibeguard fix${C.reset}`,
|
|
153
|
+
'',
|
|
154
|
+
];
|
|
155
|
+
return lines.join('\n');
|
|
156
|
+
} catch { return ''; }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Compliance posture
|
|
160
|
+
function compliancePosture(findings) {
|
|
161
|
+
try {
|
|
162
|
+
const { generateComplianceReport } = require('./compliance');
|
|
163
|
+
const report = generateComplianceReport(findings);
|
|
164
|
+
if (typeof report === 'string') return report;
|
|
165
|
+
const lines = [`${C.bold}Compliance Posture${C.reset}`, ''];
|
|
166
|
+
for (const [framework, data] of Object.entries(report)) {
|
|
167
|
+
const failed = data.failed || data.failures || 0;
|
|
168
|
+
const passed = data.passed || data.pass || 0;
|
|
169
|
+
const status = failed === 0 ? C.green + '✓ PASS' : failed < 3 ? C.yellow + '⚠ REVIEW' : C.red + '✗ FAIL';
|
|
170
|
+
lines.push(` ${status}${C.reset} ${framework.padEnd(12)} ${C.dim}${failed} findings${C.reset}`);
|
|
171
|
+
}
|
|
172
|
+
return lines.join('\n');
|
|
173
|
+
} catch { return `${C.dim}Compliance analysis unavailable${C.reset}`; }
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Full dashboard render
|
|
177
|
+
function renderDashboard(result) {
|
|
178
|
+
const counts = result.counts;
|
|
179
|
+
const weights = { critical: 10, high: 5, medium: 2, low: 1 };
|
|
180
|
+
let score = 0;
|
|
181
|
+
for (const f of result.findings) score += weights[f.severity] || 1;
|
|
182
|
+
const maxScore = result.scannedFiles * 10 || 1;
|
|
183
|
+
const riskPercent = Math.min(100, Math.round((score / maxScore) * 100));
|
|
184
|
+
const riskLevel = score === 0 ? 'NONE' : score < 10 ? 'LOW' : score < 30 ? 'MEDIUM' : score < 60 ? 'HIGH' : 'CRITICAL';
|
|
185
|
+
|
|
186
|
+
const W = 60;
|
|
187
|
+
const border = C.cyan + '═'.repeat(W) + C.reset;
|
|
188
|
+
const borderThin = C.dim + '─'.repeat(W) + C.reset;
|
|
189
|
+
|
|
190
|
+
const sections = [
|
|
191
|
+
'',
|
|
192
|
+
border,
|
|
193
|
+
C.cyan + C.bold + ' VibeGuard Security Dashboard' + C.reset + C.dim + ' — ' + new Date().toISOString().slice(0, 19) + C.reset,
|
|
194
|
+
border,
|
|
195
|
+
'',
|
|
196
|
+
gradeMeter(result.grade),
|
|
197
|
+
'',
|
|
198
|
+
riskGauge(score, riskLevel),
|
|
199
|
+
'',
|
|
200
|
+
borderThin,
|
|
201
|
+
'',
|
|
202
|
+
severityBars(counts),
|
|
203
|
+
borderThin,
|
|
204
|
+
'',
|
|
205
|
+
` ${C.bold}Scan Summary${C.reset}`,
|
|
206
|
+
` ${C.dim}Files scanned:${C.reset} ${result.scannedFiles}`,
|
|
207
|
+
` ${C.dim}Total findings:${C.reset} ${result.findings.length}`,
|
|
208
|
+
` ${C.dim}Grade:${C.reset} ${gradeColor(result.grade)}${C.bold}${result.grade}${C.reset}`,
|
|
209
|
+
'',
|
|
210
|
+
borderThin,
|
|
211
|
+
'',
|
|
212
|
+
categoryMatrix(result.findings),
|
|
213
|
+
'',
|
|
214
|
+
borderThin,
|
|
215
|
+
'',
|
|
216
|
+
topFindings(result.findings),
|
|
217
|
+
autoFixSummary(result.findings),
|
|
218
|
+
borderThin,
|
|
219
|
+
'',
|
|
220
|
+
compliancePosture(result.findings),
|
|
221
|
+
'',
|
|
222
|
+
border,
|
|
223
|
+
C.dim + ' Run "vibeguard scan" for full report | "vibeguard fix" to auto-fix | "vibeguard why <rule>" for details' + C.reset,
|
|
224
|
+
border,
|
|
225
|
+
'',
|
|
226
|
+
];
|
|
227
|
+
|
|
228
|
+
return sections.join('\n');
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// GitHub PR comment format (markdown)
|
|
232
|
+
function renderPRComment(result) {
|
|
233
|
+
const counts = result.counts;
|
|
234
|
+
const gradeEmoji = { A: '🟢', B: '🟢', C: '🟡', D: '🟡', F: '🔴' };
|
|
235
|
+
const emoji = gradeEmoji[result.grade] || '⚪';
|
|
236
|
+
|
|
237
|
+
let md = `## ${emoji} VibeGuard Security Report\n\n`;
|
|
238
|
+
md += `| Metric | Value |\n|--------|-------|\n`;
|
|
239
|
+
md += `| Grade | **${result.grade}** |\n`;
|
|
240
|
+
md += `| Files Scanned | ${result.scannedFiles} |\n`;
|
|
241
|
+
md += `| Total Findings | ${result.findings.length} |\n`;
|
|
242
|
+
md += `| Critical | ${counts.critical} |\n`;
|
|
243
|
+
md += `| High | ${counts.high} |\n`;
|
|
244
|
+
md += `| Medium | ${counts.medium} |\n`;
|
|
245
|
+
md += `| Low | ${counts.low} |\n\n`;
|
|
246
|
+
|
|
247
|
+
if (result.findings.length > 0) {
|
|
248
|
+
md += `### Top Findings\n\n`;
|
|
249
|
+
md += `| Severity | Rule | File:Line | Message |\n`;
|
|
250
|
+
md += `|----------|------|-----------|--------|\n`;
|
|
251
|
+
const sorted = result.findings.slice().sort((a, b) => {
|
|
252
|
+
const order = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
253
|
+
return (order[a.severity] || 4) - (order[b.severity] || 4);
|
|
254
|
+
}).slice(0, 15);
|
|
255
|
+
for (const f of sorted) {
|
|
256
|
+
const sevEmoji = { critical: '🔴', high: '🟠', medium: '🟡', low: '⚪' }[f.severity] || '⚪';
|
|
257
|
+
md += `| ${sevEmoji} ${f.severity} | \`${f.ruleId}\` | \`${f.file}:${f.line}\` | ${f.message.slice(0, 60)} |\n`;
|
|
258
|
+
}
|
|
259
|
+
if (result.findings.length > 15) md += `\n_...and ${result.findings.length - 15} more findings_\n`;
|
|
260
|
+
} else {
|
|
261
|
+
md += `### ✅ No security issues found!\n\nClean codebase. Great job! 🎉\n`;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Auto-fix
|
|
265
|
+
try {
|
|
266
|
+
const { isAutoFixable } = require('./autofix');
|
|
267
|
+
const fixable = result.findings.filter(f => isAutoFixable(f.ruleId));
|
|
268
|
+
if (fixable.length > 0) {
|
|
269
|
+
md += `\n### 🔧 Auto-Fix Available\n\n`;
|
|
270
|
+
md += `${fixable.length} findings can be automatically fixed. Run:\n`;
|
|
271
|
+
md += '```\nvibeguard fix\n```\n';
|
|
272
|
+
}
|
|
273
|
+
} catch {}
|
|
274
|
+
|
|
275
|
+
md += `\n---\n_VibeGuard — Free, zero-dependency security scanner. [Learn more](https://github.com/vibeguard/vibeguard)_\n`;
|
|
276
|
+
return md;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
279
|
module.exports = { renderDashboard, renderPRComment, gradeMeter, riskGauge, severityBars, categoryMatrix, topFindings, autoFixSummary, compliancePosture };
|