@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/bin/cli.js
CHANGED
|
@@ -23,7 +23,7 @@ const {
|
|
|
23
23
|
} = require('../src/report');
|
|
24
24
|
|
|
25
25
|
// Flags that take a value (support both --flag=value and --flag value).
|
|
26
|
-
const VALUE_FLAGS = new Set(['fail-on', 'scope', 'focus', 'model', 'since', 'base', 'o', 'output', 'file', 'types', 'min-confidence', 'trust', 'allow']);
|
|
26
|
+
const VALUE_FLAGS = new Set(['fail-on', 'scope', 'focus', 'model', 'since', 'base', 'o', 'output', 'file', 'types', 'min-confidence', 'trust', 'allow', 'save', 'max-blobs', 'max-commits', 'port', 'upstream', 'mode', 'api-key', 'token', 'token-header', 'timeout', 'pentest-url', 'pentest-verify-ssrf', 'budget', 'server', 'exec', 'command', 'policy', 'audit', 'check', 'tool', 'args', 'isolation', 'frameworks', 'framework', 'interval', 'dir', 'memory', 'pub', 'key', 'key-id', 'out', 'max-blocks', 'token-pub', 'token-issuer', 'token-tenant', 'token-key-id', 'approval-token', 'approval-pub', 'approval-issuer', 'approval-tenant', 'approval-key-id']);
|
|
27
27
|
|
|
28
28
|
function parseArgs(argv) {
|
|
29
29
|
const args = { _: [], flags: {} };
|
|
@@ -58,7 +58,7 @@ Usage:
|
|
|
58
58
|
vibeguard pre-deploy [dir] 13-gate deployment check.
|
|
59
59
|
vibeguard dashboard [dir] Visual terminal dashboard.
|
|
60
60
|
vibeguard mcp MCP server (for Claude Code, Cursor, etc.).
|
|
61
|
-
vibeguard auto [dir] One-command
|
|
61
|
+
vibeguard auto [dir] One-command layered protection (daemon + hooks).
|
|
62
62
|
vibeguard auto --stop Turn off, restore backups.
|
|
63
63
|
vibeguard auto --status Show what's active.
|
|
64
64
|
|
|
@@ -78,6 +78,22 @@ Advanced:
|
|
|
78
78
|
vibeguard badge [dir] Award badge SVG (zero critical+high).
|
|
79
79
|
vibeguard init-ci [dir] Write GitHub Actions workflow.
|
|
80
80
|
vibeguard mcp-audit [dir] Audit configured MCP servers (injection, rug-pull, secrets). --pin to re-baseline.
|
|
81
|
+
vibeguard mcp-firewall --server <name> Proxy an MCP server; block poisoned tools/calls in real time.
|
|
82
|
+
vibeguard mcp-firewall --exec "<cmd>" Proxy an ad-hoc MCP server command.
|
|
83
|
+
vibeguard mcp-firewall --init Write a default .vibeguard-mcp.json policy.
|
|
84
|
+
vibeguard mcp-firewall --selftest Run the offline firewall checks.
|
|
85
|
+
vibeguard mcp-firewall --check '<json>' Evaluate one tool call against policy.
|
|
86
|
+
vibeguard mcp-firewall --status Summarize the firewall audit log.
|
|
87
|
+
vibeguard policy validate <file> Validate a signed policy v2.
|
|
88
|
+
vibeguard policy sign <file> Sign a policy v2 with Ed25519.
|
|
89
|
+
vibeguard audit verify <log> Verify signed audit events/checkpoints.
|
|
90
|
+
vibeguard sandbox backends Show isolation backends.
|
|
91
|
+
vibeguard sandbox verify Verify Linux network/PID namespace isolation.
|
|
92
|
+
vibeguard aisvs [--json] AISVS-style internal control readiness mapping.
|
|
93
|
+
vibeguard skill-scan [dir] Scan skills/plugins/instruction files for malicious behavior.
|
|
94
|
+
vibeguard agent-risk [dir] Unified agent risk score + OWASP coverage (A-F).
|
|
95
|
+
vibeguard owasp-coverage [dir] OWASP Agentic AI + MCP Top 10 control coverage.
|
|
96
|
+
vibeguard agent-monitor [dir] Runtime agent activity; --watch to follow the audit log.
|
|
81
97
|
vibeguard agent-scan [dir] AI Agent Security Posture: one grade across MCP, data leakage, LLM-output sinks, prompt injection, agent capability.
|
|
82
98
|
vibeguard guard-action <action> Action firewall: block secret/PII exfiltration before it runs. Pass a shell command or JSON action. --trust host1,host2.
|
|
83
99
|
vibeguard compliance [dir] Map findings to SOC2/PCI/HIPAA/GDPR.
|
|
@@ -87,6 +103,8 @@ Advanced:
|
|
|
87
103
|
vibeguard trace [dir] Trace findings to AI prompts.
|
|
88
104
|
vibeguard repl [dir] Interactive REPL.
|
|
89
105
|
vibeguard auth-coverage [dir] Enumerate routes -> auth guards.
|
|
106
|
+
vibeguard attack-surface [dir] Entrypoints x auth x reachability: what is exposed now.
|
|
107
|
+
vibeguard bundle-scan [dir] Scan dist/build/.next artifacts for inlined secrets + source maps.
|
|
90
108
|
vibeguard diff [dir] Compare vs baseline.
|
|
91
109
|
vibeguard deep-scan [dir] Full audit: scan + CVE + auth + behavior.
|
|
92
110
|
vibeguard html [dir] Generate HTML security report.
|
|
@@ -122,9 +140,14 @@ Advanced:
|
|
|
122
140
|
vibeguard proxy-stop Stop the local proxy.
|
|
123
141
|
vibeguard proxy-status Show proxy status and blocked request audit log.
|
|
124
142
|
|
|
143
|
+
vibeguard tokens [dir] Measure agent-context tokens saved by --lean vs JSON.
|
|
144
|
+
|
|
125
145
|
Options:
|
|
126
146
|
--json JSON output.
|
|
127
147
|
--sarif SARIF 2.1.0 (GitHub code scanning).
|
|
148
|
+
--lean Token-lean output for AI agents (55-90% fewer tokens than JSON).
|
|
149
|
+
--budget <n> Token ceiling for --lean; keeps highest-risk findings, reports the rest.
|
|
150
|
+
--delta With --lean: only findings new since the last scan.
|
|
128
151
|
--fix-prompt Print only the fix prompt block.
|
|
129
152
|
--apply (fix) Apply safe auto-fixes.
|
|
130
153
|
--all Show all findings (ignore baseline, show low-confidence).
|
|
@@ -141,6 +164,7 @@ Options:
|
|
|
141
164
|
--no-summary Suppress summary line.
|
|
142
165
|
--show-suppressed Include inline-suppressed findings.
|
|
143
166
|
--yes Skip consent prompts (shell hook, auto).
|
|
167
|
+
--trust-plugins Explicitly allow target-project plugins (DANGEROUS; review first).
|
|
144
168
|
--patch Output as unified diff.
|
|
145
169
|
-o, --output <file> HTML report output path.
|
|
146
170
|
-h, --help Show this help.
|
|
@@ -151,6 +175,24 @@ misconfig) and helps you fix them. It does NOT prove an app is safe.
|
|
|
151
175
|
}
|
|
152
176
|
|
|
153
177
|
function outputResult(result, flags) {
|
|
178
|
+
// --lean: the dialect written for an AI agent's context window rather than a
|
|
179
|
+
// human terminal. Snapshot persistence lives in src/tokenlean.js so the CLI
|
|
180
|
+
// and the MCP server share one notion of "already reported".
|
|
181
|
+
if (flags.lean) {
|
|
182
|
+
const tokenlean = require('../src/tokenlean');
|
|
183
|
+
const budget = Number(flags.budget || process.env.VIBEGUARD_TOKEN_BUDGET || 0) || 0;
|
|
184
|
+
const root = result.root || process.cwd();
|
|
185
|
+
if (flags.delta) {
|
|
186
|
+
const d = tokenlean.deltaReport(result, tokenlean.readSnapshot(root), { budget });
|
|
187
|
+
tokenlean.writeSnapshot(root, d.snapshot);
|
|
188
|
+
process.stdout.write(d.text + '\n');
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const lean = tokenlean.renderLean(result, { budget });
|
|
192
|
+
tokenlean.writeSnapshot(root, tokenlean.snapshotOf(result));
|
|
193
|
+
process.stdout.write(lean.text + '\n');
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
154
196
|
if (flags.json) {
|
|
155
197
|
process.stdout.write(renderJson(result) + '\n');
|
|
156
198
|
return;
|
|
@@ -198,14 +240,56 @@ function detectFramework(dir) {
|
|
|
198
240
|
return null;
|
|
199
241
|
}
|
|
200
242
|
|
|
201
|
-
|
|
243
|
+
/*
|
|
244
|
+
* `vibeguard tokens` — how much agent context the lean dialect saves here.
|
|
245
|
+
*
|
|
246
|
+
* Published as a command rather than a marketing claim so anyone can reproduce
|
|
247
|
+
* the number on their own repository.
|
|
248
|
+
*/
|
|
249
|
+
function cmdTokens(dir, flags) {
|
|
250
|
+
const tokenlean = require('../src/tokenlean');
|
|
251
|
+
const result = scan(dir, { deps: flags.deps !== false && !flags['no-deps'] });
|
|
252
|
+
const budget = Number(flags.budget || 0) || 0;
|
|
253
|
+
const s = tokenlean.leanStats(result, { budget });
|
|
254
|
+
if (flags.json) {
|
|
255
|
+
process.stdout.write(
|
|
256
|
+
JSON.stringify(
|
|
257
|
+
{
|
|
258
|
+
findings: s.findings,
|
|
259
|
+
clusters: s.clusters,
|
|
260
|
+
scannedFiles: result.scannedFiles,
|
|
261
|
+
jsonTokens: s.jsonTokens,
|
|
262
|
+
leanTokens: s.leanTokens,
|
|
263
|
+
saved: s.saved,
|
|
264
|
+
savedPct: s.savedPct,
|
|
265
|
+
},
|
|
266
|
+
null,
|
|
267
|
+
2
|
|
268
|
+
) + '\n'
|
|
269
|
+
);
|
|
270
|
+
return 0;
|
|
271
|
+
}
|
|
272
|
+
const pad = (n) => String(n).padStart(8);
|
|
273
|
+
process.stdout.write(
|
|
274
|
+
`\n${C.bold}${C.cyan}VibeGuard${C.reset} ${C.dim}token report${C.reset}\n` +
|
|
275
|
+
`${C.dim}${result.root}${C.reset}\n\n` +
|
|
276
|
+
` findings ${pad(s.findings)} in ${s.clusters} rule cluster(s), ${result.scannedFiles} files\n` +
|
|
277
|
+
` pretty JSON ${pad(s.jsonTokens)} tokens ${C.dim}(what other scanners hand an agent)${C.reset}\n` +
|
|
278
|
+
` token-lean ${pad(s.leanTokens)} tokens ${C.dim}(--lean)${C.reset}\n` +
|
|
279
|
+
` ${C.green}${C.bold}saved ${pad(s.saved)} tokens (${s.savedPct}%) per scan call${C.reset}\n\n` +
|
|
280
|
+
`${C.dim}Counts are estimates from an offline model (no tokenizer dependency), ~±10%.${C.reset}\n`
|
|
281
|
+
);
|
|
282
|
+
return 0;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async function cmdScan(dir, flags) {
|
|
202
286
|
// Auto-detect framework/stack and apply preset if not explicitly set.
|
|
203
287
|
if (!flags.preset && !flags['no-preset']) {
|
|
204
288
|
const detected = detectFramework(dir);
|
|
205
289
|
if (detected) {
|
|
206
290
|
const { applyPreset } = require('../src/presets');
|
|
207
291
|
const applied = applyPreset(detected);
|
|
208
|
-
if (applied && !flags.json && !flags.sarif) {
|
|
292
|
+
if (applied && !flags.json && !flags.sarif && !flags.lean) {
|
|
209
293
|
process.stderr.write(`${C.dim}detected: ${detected} — applied preset${C.reset}\n`);
|
|
210
294
|
}
|
|
211
295
|
}
|
|
@@ -219,9 +303,12 @@ function cmdScan(dir, flags) {
|
|
|
219
303
|
changed: !!flags.changed,
|
|
220
304
|
staged: !!flags.staged,
|
|
221
305
|
noSuppress: !!flags['no-suppress'],
|
|
306
|
+
liveOnly: !!flags.live,
|
|
307
|
+
reachabilityGrade: !!flags['reachability-grade'],
|
|
308
|
+
trustPlugins: flags['trust-plugins'] === true,
|
|
222
309
|
});
|
|
223
310
|
|
|
224
|
-
if (flags.staged && result.staged && !flags.json && !flags.sarif) {
|
|
311
|
+
if (flags.staged && result.staged && !flags.json && !flags.sarif && !flags.lean) {
|
|
225
312
|
process.stderr.write(
|
|
226
313
|
`${C.dim}staged: scanned ${result.staged.scanned} staged file(s) of ${result.staged.total} ` +
|
|
227
314
|
`(cross-file analysis skipped — run a full scan for that)${C.reset}\n`
|
|
@@ -230,7 +317,7 @@ function cmdScan(dir, flags) {
|
|
|
230
317
|
|
|
231
318
|
// Incremental mode note: report how much work was skipped, and be explicit
|
|
232
319
|
// that cross-file analysis is not run (per-file only).
|
|
233
|
-
if (flags.changed && result.incremental && !flags.json && !flags.sarif) {
|
|
320
|
+
if (flags.changed && result.incremental && !flags.json && !flags.sarif && !flags.lean) {
|
|
234
321
|
const inc = result.incremental;
|
|
235
322
|
process.stderr.write(
|
|
236
323
|
`${C.dim}incremental: scanned ${inc.scanned}/${inc.total} changed file(s), ${inc.cached} unchanged skipped ` +
|
|
@@ -239,7 +326,7 @@ function cmdScan(dir, flags) {
|
|
|
239
326
|
}
|
|
240
327
|
|
|
241
328
|
// Engine-mode + coverage transparency. Never let a degraded scan look clean.
|
|
242
|
-
if (!flags.json && !flags.sarif) {
|
|
329
|
+
if (!flags.json && !flags.sarif && !flags.lean) {
|
|
243
330
|
if (result.engine && result.engine.mode === 'regex-only') {
|
|
244
331
|
process.stderr.write(
|
|
245
332
|
`${C.yellow}⚠ engine: regex-only — acorn not installed, AST/taint precision disabled. ` +
|
|
@@ -290,7 +377,7 @@ function cmdScan(dir, flags) {
|
|
|
290
377
|
|
|
291
378
|
// Baseline auto-suppression: if a baseline file exists and the user didn't
|
|
292
379
|
// explicitly pass --new-only or --all, default to new-only and inform them.
|
|
293
|
-
if (!flags.baseline && !flags['new-only'] && !flags.all && !flags.json && !flags.sarif) {
|
|
380
|
+
if (!flags.baseline && !flags['new-only'] && !flags.all && !flags.json && !flags.sarif && !flags.lean) {
|
|
294
381
|
const { readBaseline } = require('../src/verify');
|
|
295
382
|
const base = readBaseline(dir);
|
|
296
383
|
if (base && Array.isArray(base.findings) && base.findings.length > 0) {
|
|
@@ -326,7 +413,7 @@ function cmdScan(dir, flags) {
|
|
|
326
413
|
}
|
|
327
414
|
}
|
|
328
415
|
|
|
329
|
-
if (flags.deep && result.externalInfo && !flags.json && !flags.sarif) {
|
|
416
|
+
if (flags.deep && result.externalInfo && !flags.json && !flags.sarif && !flags.lean) {
|
|
330
417
|
const ran = result.externalInfo.ran || {};
|
|
331
418
|
process.stderr.write(
|
|
332
419
|
`${C.dim}deep: semgrep=${ran.semgrep ? 'ran' : 'skipped'}, gitleaks=${ran.gitleaks ? 'ran' : 'skipped'}` +
|
|
@@ -336,12 +423,27 @@ function cmdScan(dir, flags) {
|
|
|
336
423
|
}
|
|
337
424
|
if (flags.baseline) {
|
|
338
425
|
const p = writeBaseline(dir, result);
|
|
339
|
-
if (!flags.json && !flags.sarif) {
|
|
426
|
+
if (!flags.json && !flags.sarif && !flags.lean) {
|
|
340
427
|
process.stderr.write(`${C.dim}baseline saved: ${p}${C.reset}\n`);
|
|
341
428
|
}
|
|
342
429
|
}
|
|
343
430
|
outputResult(result, flags);
|
|
344
431
|
|
|
432
|
+
// Grade A celebration — print a byte-verified open GIF. Awaited so the line
|
|
433
|
+
// lands before the process exits (the return below computes the exit code
|
|
434
|
+
// after this block). Best-effort: opt-out with --no-fun or VG_NO_FUN=1,
|
|
435
|
+
// auto-silenced in CI (--ci sets CI via GitHub/GitLab/etc.).
|
|
436
|
+
if (result.grade === 'A' && !flags.json && !flags.sarif && !flags.lean && !flags['no-fun'] &&
|
|
437
|
+
!process.env.VG_NO_FUN && !process.env.CI) {
|
|
438
|
+
try {
|
|
439
|
+
const { searchGifs } = require('../src/gif');
|
|
440
|
+
const g = await searchGifs('grade a');
|
|
441
|
+
if (g && g.url) {
|
|
442
|
+
process.stderr.write(`\n${C.magenta}🎉 Grade A — celebrate:${C.reset} ${C.cyan}${g.url}${C.reset}\n`);
|
|
443
|
+
}
|
|
444
|
+
} catch { /* offline or backend hiccup — never fail the scan */ }
|
|
445
|
+
}
|
|
446
|
+
|
|
345
447
|
if (flags.precommit) {
|
|
346
448
|
// Hook mode: block only on CRITICAL.
|
|
347
449
|
return result.counts.critical > 0 ? 2 : 0;
|
|
@@ -394,6 +496,27 @@ function cmdFix(dir, flags) {
|
|
|
394
496
|
`${C.dim}Snapshot: ${snapDir}${C.reset}\n` +
|
|
395
497
|
`Undo with: ${C.bold}vibeguard rollback ${dir}${C.reset}\n\n`
|
|
396
498
|
);
|
|
499
|
+
if (flags.verify) {
|
|
500
|
+
// Retest loop (Strix "fix verified" parity): re-scan and confirm each
|
|
501
|
+
// applied fix actually removed its finding.
|
|
502
|
+
const after = scan(dir);
|
|
503
|
+
const afterArr = Array.isArray(after) ? after : (after.findings || []);
|
|
504
|
+
const afterKeys = new Set(afterArr.map((f) => `${f.ruleId}:${f.file}`));
|
|
505
|
+
let verified = 0;
|
|
506
|
+
let unverified = 0;
|
|
507
|
+
for (const c of changes) {
|
|
508
|
+
const gone = !afterKeys.has(`${c.ruleId}:${c.file}`);
|
|
509
|
+
if (gone) verified++; else unverified++;
|
|
510
|
+
process.stdout.write(
|
|
511
|
+
` ${gone ? C.green + '✓ fix verified' : C.yellow + '⚠ NOT verified'}${C.reset} ` +
|
|
512
|
+
`${c.description} [${c.ruleId}] ${C.dim}${c.file}${C.reset}\n`
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
process.stdout.write(
|
|
516
|
+
`\n${C.bold}Verification: ${verified} fixed, ${unverified} still failing.${C.reset}\n` +
|
|
517
|
+
`${C.dim}(Re-scan after apply — findings re-checked by rule + file.)${C.reset}\n\n`
|
|
518
|
+
);
|
|
519
|
+
}
|
|
397
520
|
} else {
|
|
398
521
|
process.stdout.write(
|
|
399
522
|
`${C.yellow}Dry run — nothing written.${C.reset} Apply these with: ` +
|
|
@@ -821,6 +944,18 @@ async function main() {
|
|
|
821
944
|
const args = parseArgs(argv);
|
|
822
945
|
const flags = args.flags;
|
|
823
946
|
|
|
947
|
+
// --version / -V: report the package version without running a scan (the old
|
|
948
|
+
// behavior fell through to a default scan, which made `--version` slow and
|
|
949
|
+
// confusing in CI).
|
|
950
|
+
if (flags.version || argv.includes('--version') || argv.includes('-V') || args._[0] === 'version') {
|
|
951
|
+
try {
|
|
952
|
+
process.stdout.write(require('../package.json').version + '\n');
|
|
953
|
+
} catch {
|
|
954
|
+
process.stdout.write('unknown\n');
|
|
955
|
+
}
|
|
956
|
+
process.exit(0);
|
|
957
|
+
}
|
|
958
|
+
|
|
824
959
|
if (flags.help || flags.h || args._[0] === 'help') {
|
|
825
960
|
printHelp();
|
|
826
961
|
process.exit(0);
|
|
@@ -829,7 +964,7 @@ async function main() {
|
|
|
829
964
|
const cmd = args._[0] || 'scan';
|
|
830
965
|
const dir = args._[1] || '.';
|
|
831
966
|
|
|
832
|
-
const noDirCmds = new Set(['url', 'rules', 'explain', 'secure-prompt', 'redact', 'detect-pii', 'firewall', 'exfil-check', 'dep-firewall', 'sandbox', 'output-guard', 'vault', 'audit-trail', 'why', 'guard', 'guard-action', 'install-shell-hook', 'uninstall-shell-hook', 'auto-start', 'auto-stop', 'auto-status', 'auto', 'container-scan', 'proxy-start', 'proxy-stop', 'proxy-status']);
|
|
967
|
+
const noDirCmds = new Set(['url', 'rules', 'explain', 'secure-prompt', 'redact', 'detect-pii', 'firewall', 'exfil-check', 'dep-firewall', 'sandbox', 'output-guard', 'vault', 'audit-trail', 'why', 'guard', 'guard-action', 'install-shell-hook', 'uninstall-shell-hook', 'auto-start', 'auto-stop', 'auto-status', 'auto', 'container-scan', 'proxy-start', 'proxy-stop', 'proxy-status', 'sbom-diff', 'gif', 'git-scan', 'llm-proxy', 'pentest', 'pr-scan', 'mcp-firewall', 'policy', 'audit', 'aisvs']);
|
|
833
968
|
if (!noDirCmds.has(cmd) && !fs.existsSync(dir)) {
|
|
834
969
|
process.stderr.write(`error: directory not found: ${dir}\n`);
|
|
835
970
|
process.exit(2);
|
|
@@ -847,9 +982,12 @@ async function main() {
|
|
|
847
982
|
(async () => {
|
|
848
983
|
const result = scan(dir, { deps: flags.deps !== false && !flags['no-deps'], deep: !!flags.deep });
|
|
849
984
|
try {
|
|
985
|
+
if (!flags.json && !flags.sarif && !flags.lean) {
|
|
986
|
+
process.stderr.write(`${C.yellow}⚠ --verify-keys sends found keys to their provider APIs (e.g. Stripe, OpenAI) to check if they are live.${C.reset}\n`);
|
|
987
|
+
}
|
|
850
988
|
const { verifyKeys } = require('../src/verifykeys');
|
|
851
989
|
const live = await verifyKeys(dir, result.findings);
|
|
852
|
-
if (live > 0 && !flags.json && !flags.sarif) {
|
|
990
|
+
if (live > 0 && !flags.json && !flags.sarif && !flags.lean) {
|
|
853
991
|
process.stderr.write(`${C.red}${live} key(s) CONFIRMED LIVE.${C.reset}\n`);
|
|
854
992
|
}
|
|
855
993
|
} catch (err) {
|
|
@@ -877,6 +1015,22 @@ async function main() {
|
|
|
877
1015
|
return;
|
|
878
1016
|
}
|
|
879
1017
|
|
|
1018
|
+
// MCP firewall: proxy mode owns stdin/stdout and must not be followed by
|
|
1019
|
+
// process.exit(). One-shot modes (--selftest/--check/--status) return a code.
|
|
1020
|
+
if (cmd === 'mcp-firewall') {
|
|
1021
|
+
const { cmdMcpFirewall } = require('./cmd-mcp-firewall');
|
|
1022
|
+
const code = cmdMcpFirewall(args, flags);
|
|
1023
|
+
if (typeof code === 'number') process.exit(code);
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// Live agent monitoring: long-running tail.
|
|
1028
|
+
if (cmd === 'agent-monitor' && flags.watch) {
|
|
1029
|
+
const { cmdAgentMonitor } = require('./cmd-agent-monitor');
|
|
1030
|
+
cmdAgentMonitor(args, flags);
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
880
1034
|
// Async command: live URL scan.
|
|
881
1035
|
if (cmd === 'url') {
|
|
882
1036
|
cmdUrl(args._[1], flags)
|
|
@@ -890,7 +1044,8 @@ async function main() {
|
|
|
890
1044
|
|
|
891
1045
|
let code = 0;
|
|
892
1046
|
try {
|
|
893
|
-
if (cmd === 'scan') code = cmdScan(dir, flags);
|
|
1047
|
+
if (cmd === 'scan') code = await cmdScan(dir, flags); // vibeguard-ignore-line [taint.xss-reflected]
|
|
1048
|
+
else if (cmd === 'tokens') code = cmdTokens(dir, flags);
|
|
894
1049
|
else if (cmd === 'fix') code = cmdFix(dir, flags);
|
|
895
1050
|
else if (cmd === 'verify') code = cmdVerify(dir, flags);
|
|
896
1051
|
else if (cmd === 'install-hook') code = cmdInstallHook(dir);
|
|
@@ -899,6 +1054,10 @@ async function main() {
|
|
|
899
1054
|
else if (cmd === 'badge') code = cmdBadge(dir, flags);
|
|
900
1055
|
else if (cmd === 'init-ci') code = cmdInitCi(dir);
|
|
901
1056
|
else if (cmd === 'mcp-audit') code = cmdMcpAudit(dir, flags);
|
|
1057
|
+
else if (cmd === 'skill-scan') { const { cmdSkillScan } = require('./cmd-skill-scan'); code = cmdSkillScan(args, flags); }
|
|
1058
|
+
else if (cmd === 'agent-risk') { const { cmdAgentRisk } = require('./cmd-agent-risk'); code = cmdAgentRisk(args, flags); }
|
|
1059
|
+
else if (cmd === 'owasp-coverage') { const { cmdOwaspCoverage } = require('./cmd-agent-risk'); code = cmdOwaspCoverage(args, flags); }
|
|
1060
|
+
else if (cmd === 'agent-monitor') { const { cmdAgentMonitor } = require('./cmd-agent-monitor'); code = cmdAgentMonitor(args, flags); }
|
|
902
1061
|
else if (cmd === 'agent-scan') code = cmdAgentScan(dir, flags);
|
|
903
1062
|
else if (cmd === 'guard-action') code = cmdGuardAction(args._[1], flags);
|
|
904
1063
|
else if (cmd === 'install') code = cmdInstall(flags);
|
|
@@ -912,6 +1071,8 @@ async function main() {
|
|
|
912
1071
|
else if (cmd === 'trace') code = cmdTrace(dir, flags);
|
|
913
1072
|
else if (cmd === 'repl') code = await cmdRepl(dir, flags);
|
|
914
1073
|
else if (cmd === 'auth-coverage') code = cmdAuthCoverage(dir, flags);
|
|
1074
|
+
else if (cmd === 'attack-surface' || cmd === 'surface') code = cmdAttackSurface(dir, flags);
|
|
1075
|
+
else if (cmd === 'bundle-scan') code = cmdBundleScan(dir, flags);
|
|
915
1076
|
else if (cmd === 'diff') code = cmdDiff(dir, flags);
|
|
916
1077
|
else if (cmd === 'deep-scan') code = await cmdDeepScan(dir, flags);
|
|
917
1078
|
else if (cmd === 'html') code = cmdHtml(dir, flags);
|
|
@@ -952,15 +1113,25 @@ async function main() {
|
|
|
952
1113
|
else if (cmd === 'output-guard') code = cmdOutputGuard(args, flags);
|
|
953
1114
|
else if (cmd === 'env-lock') code = cmdEnvLock(dir, flags);
|
|
954
1115
|
else if (cmd === 'self-check') code = cmdSelfCheck(dir, flags);
|
|
1116
|
+
else if (cmd === 'policy' || cmd === 'audit' || cmd === 'aisvs' || (cmd === 'sandbox' && (args._[1] === 'backends' || args._[1] === 'verify'))) {
|
|
1117
|
+
const { cmdPlatform } = require('./cmd-platform');
|
|
1118
|
+
code = await cmdPlatform(args, flags);
|
|
1119
|
+
}
|
|
955
1120
|
else if (cmd === 'sandbox') code = cmdSandbox(args, flags);
|
|
956
1121
|
else if (cmd === 'behavior') code = cmdBehavior(dir, flags);
|
|
957
1122
|
else if (cmd === 'supply-firewall') code = cmdSupplyFirewall(dir, flags);
|
|
958
1123
|
else if (cmd === 'vault') code = cmdVault(args, flags);
|
|
959
1124
|
else if (cmd === 'audit-trail') code = cmdAuditTrail(args, flags);
|
|
960
|
-
else if (cmd === 'pre-deploy') code = cmdPreDeploy(dir, flags);
|
|
1125
|
+
else if (cmd === 'pre-deploy') code = await cmdPreDeploy(dir, flags);
|
|
961
1126
|
else if (cmd === 'redact') code = cmdRedact(args, flags);
|
|
962
1127
|
else if (cmd === 'detect-pii') code = cmdDetectPII(args, flags);
|
|
963
1128
|
else if (cmd === 'sbom') code = cmdSBOM(dir, flags);
|
|
1129
|
+
else if (cmd === 'sbom-diff') { const { cmdSbomDiff } = require('./cmd-sbom-diff'); code = cmdSbomDiff(args, flags); }
|
|
1130
|
+
else if (cmd === 'gif') { const { cmdGif } = require('./cmd-gif'); code = await cmdGif(args, flags); }
|
|
1131
|
+
else if (cmd === 'git-scan') { const { cmdGitScan } = require('./cmd-git-scan'); code = await cmdGitScan(args, flags); }
|
|
1132
|
+
else if (cmd === 'llm-proxy') { const { cmdLlmProxy } = require('./cmd-llm-proxy'); code = await cmdLlmProxy(args, flags); }
|
|
1133
|
+
else if (cmd === 'pentest') { const { cmdPentest } = require('./cmd-pentest'); code = await cmdPentest(args, flags); }
|
|
1134
|
+
else if (cmd === 'pr-scan') { const { cmdPrScan } = require('./cmd-pr-scan'); code = await cmdPrScan(args, flags); }
|
|
964
1135
|
else if (cmd === 'reachability') code = await cmdReachability(dir, flags);
|
|
965
1136
|
else if (cmd === 'container-scan') code = await cmdContainerScan(args, flags);
|
|
966
1137
|
else if (cmd === 'license') code = await cmdLicense(dir, flags);
|
|
@@ -1114,6 +1285,147 @@ function cmdAuthCoverage(dir, flags) {
|
|
|
1114
1285
|
return coverage.unprotectedRoutes.length > 0 ? 1 : 0;
|
|
1115
1286
|
}
|
|
1116
1287
|
|
|
1288
|
+
function cmdAttackSurface(dir, flags) {
|
|
1289
|
+
const { scan } = require('../src/scanner');
|
|
1290
|
+
const { summarizeSurface } = require('../src/surface');
|
|
1291
|
+
const result = scan(dir, {
|
|
1292
|
+
surface: true,
|
|
1293
|
+
baseline: !flags.all,
|
|
1294
|
+
liveOnly: !!flags.live,
|
|
1295
|
+
reachabilityGrade: !!flags['reachability-grade'],
|
|
1296
|
+
minConfidence: flags['min-confidence'] || (flags.all ? 'low' : 'medium'),
|
|
1297
|
+
deps: flags.deps !== false && !flags['no-deps'],
|
|
1298
|
+
});
|
|
1299
|
+
const surface = result.surface;
|
|
1300
|
+
if (!surface) {
|
|
1301
|
+
process.stderr.write('attack-surface: analysis failed (no surface produced)\n');
|
|
1302
|
+
return 2;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
if (flags.json) {
|
|
1306
|
+
process.stdout.write(
|
|
1307
|
+
JSON.stringify(
|
|
1308
|
+
{
|
|
1309
|
+
root: result.root,
|
|
1310
|
+
grade: result.grade,
|
|
1311
|
+
counts: result.counts,
|
|
1312
|
+
stats: surface.stats,
|
|
1313
|
+
authCoverage: surface.authCoverage,
|
|
1314
|
+
middleware: surface.middleware,
|
|
1315
|
+
chains: surface.chains,
|
|
1316
|
+
entrypoints: surface.entrypoints,
|
|
1317
|
+
exposed: surface.exposed,
|
|
1318
|
+
byRule: surface.byRule,
|
|
1319
|
+
recommendations: surface.recommendations,
|
|
1320
|
+
},
|
|
1321
|
+
null,
|
|
1322
|
+
2
|
|
1323
|
+
) + '\n'
|
|
1324
|
+
);
|
|
1325
|
+
return surface.stats.unguardedStateChanging > 0 ? 2 : surface.exposed.length > 0 ? 1 : 0;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
if (flags.lean) {
|
|
1329
|
+
const lines = [summarizeSurface(surface)];
|
|
1330
|
+
const seenRules = new Set();
|
|
1331
|
+
for (const e of surface.entrypoints.slice(0, 40)) {
|
|
1332
|
+
if (e.verdict === 'clean') continue;
|
|
1333
|
+
lines.push(
|
|
1334
|
+
`${e.verdict.toUpperCase()} ${e.method} ${e.path} auth=${e.auth} idor=${e.ownership} ` +
|
|
1335
|
+
`writes=${e.writes} file=${e.file}:${e.line} risks=${e.risks.slice(0, 5).map((r) => r.ruleId).join(',') || '-'}`
|
|
1336
|
+
);
|
|
1337
|
+
for (const r of e.risks) seenRules.add(r.ruleId);
|
|
1338
|
+
}
|
|
1339
|
+
if (seenRules.size > 0) lines.push(`rules: ${[...seenRules].join(', ')}`);
|
|
1340
|
+
for (const c of surface.chains.slice(0, 6)) lines.push(`CHAIN ${c.precondition}: ${c.narrative}`);
|
|
1341
|
+
process.stdout.write(lines.join('\n') + '\n');
|
|
1342
|
+
return surface.stats.unguardedStateChanging > 0 ? 2 : surface.exposed.length > 0 ? 1 : 0;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
process.stdout.write(`\n${C.bold}VibeGuard attack surface${C.reset} ${dir}\n`);
|
|
1346
|
+
process.stdout.write(`${C.dim}${summarizeSurface(surface)}${C.reset}\n\n`);
|
|
1347
|
+
|
|
1348
|
+
const shown = surface.entrypoints.filter((e) => e.verdict !== 'clean').slice(0, 25);
|
|
1349
|
+
if (shown.length === 0) {
|
|
1350
|
+
process.stdout.write(`${C.green}No exposed entrypoints with findings.${C.reset}\n`);
|
|
1351
|
+
}
|
|
1352
|
+
for (const e of shown) {
|
|
1353
|
+
const color =
|
|
1354
|
+
e.verdict === 'critical' ? C.red : e.verdict === 'high' ? C.yellow : e.verdict === 'unguarded' ? C.yellow : C.dim;
|
|
1355
|
+
const flag = e.verdict === 'unguarded' ? 'UNGUARDED' : e.verdict.toUpperCase();
|
|
1356
|
+
process.stdout.write(
|
|
1357
|
+
`${color}${flag.padEnd(9)}${C.reset} ${String(e.method).padEnd(8)} ${e.path.padEnd(38)} ` +
|
|
1358
|
+
`${C.dim}[${e.framework}]${C.reset} ${e.file}:${e.line}\n`
|
|
1359
|
+
);
|
|
1360
|
+
const facts = [];
|
|
1361
|
+
facts.push(`auth: ${e.auth}`);
|
|
1362
|
+
if (e.ownership === 'missing') facts.push(`${C.red}IDOR: no ownership filter${C.reset}`);
|
|
1363
|
+
if (e.writes) facts.push('mutates state');
|
|
1364
|
+
if (e.sensitive && !e.rateLimited) facts.push('no rate limit');
|
|
1365
|
+
process.stdout.write(` ${C.dim}${facts.join(' · ')}${C.reset}\n`);
|
|
1366
|
+
for (const r of e.risks.slice(0, 4)) {
|
|
1367
|
+
process.stdout.write(
|
|
1368
|
+
` ${C.dim}-${C.reset} ${r.ruleId} ${C.dim}(${r.severity}, ${r.reach}, ${r.file}:${r.line})${C.reset}\n`
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
if (surface.chains.length > 0) {
|
|
1374
|
+
process.stdout.write(`\n${C.bold}Exploit chains${C.reset} ${C.dim}(reachable precondition → sink → impact)${C.reset}\n`);
|
|
1375
|
+
for (const c of surface.chains.slice(0, 8)) {
|
|
1376
|
+
const color = c.score >= 60 ? C.red : c.score >= 30 ? C.yellow : C.dim;
|
|
1377
|
+
process.stdout.write(` ${color}${c.precondition}${C.reset} ${c.narrative} ${C.dim}(${c.cwe || c.kind})${C.reset}\n`);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
if (surface.recommendations.length > 0) {
|
|
1382
|
+
process.stdout.write(`\n${C.bold}Fix first${C.reset}\n`);
|
|
1383
|
+
for (const rec of surface.recommendations.slice(0, 8)) {
|
|
1384
|
+
process.stdout.write(` ${rec.severity === 'critical' ? C.red : C.yellow}${rec.severity}${C.reset} ${rec.text}\n`);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
process.stdout.write(
|
|
1389
|
+
`\n${C.dim}Grade ${result.grade} · ${surface.stats.deadFindings} finding(s) outside every entrypoint's reach (fix last)${C.reset}\n`
|
|
1390
|
+
);
|
|
1391
|
+
return surface.stats.unguardedStateChanging > 0 ? 2 : surface.exposed.length > 0 ? 1 : 0;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
function cmdBundleScan(dir, flags) {
|
|
1395
|
+
const { scanBundles } = require('../src/bundles');
|
|
1396
|
+
const dirs = typeof flags.dir === 'string' ? flags.dir.split(',').map((s) => s.trim()).filter(Boolean) : undefined;
|
|
1397
|
+
const res = scanBundles(dir, { dirs });
|
|
1398
|
+
if (flags.json) {
|
|
1399
|
+
process.stdout.write(JSON.stringify(res, null, 2) + '\n');
|
|
1400
|
+
} else if (flags.lean) {
|
|
1401
|
+
const lines = [`bundle-scan: ${res.scannedFiles} artifacts in ${res.dirs.join(', ') || '(none)'} — ${res.findings.length} finding(s)`];
|
|
1402
|
+
for (const f of res.findings.slice(0, 30)) lines.push(`${f.severity} ${f.file}:${f.line} [${f.ruleId}] ${f.message.split('.')[0]}.`);
|
|
1403
|
+
for (const n of res.notes) lines.push(`note: ${n}`);
|
|
1404
|
+
process.stdout.write(lines.join('\n') + '\n');
|
|
1405
|
+
} else {
|
|
1406
|
+
process.stdout.write(`\n${C.bold}VibeGuard bundle scan${C.reset} ${dir}\n`);
|
|
1407
|
+
if (res.dirs.length === 0) {
|
|
1408
|
+
process.stdout.write(`${C.dim}no build output found (looked for dist/, build/, out/, .next/static)${C.reset}\n`);
|
|
1409
|
+
} else {
|
|
1410
|
+
process.stdout.write(
|
|
1411
|
+
`${C.dim}${res.scannedFiles} artifact(s) in ${res.dirs.join(', ')} — values here are PUBLIC to every visitor${C.reset}\n\n`
|
|
1412
|
+
);
|
|
1413
|
+
}
|
|
1414
|
+
for (const f of res.findings) {
|
|
1415
|
+
const color = f.severity === 'critical' ? C.red : f.severity === 'high' ? C.yellow : C.dim;
|
|
1416
|
+
process.stdout.write(`${color}${f.severity.toUpperCase().padEnd(8)}${C.reset} ${f.file}:${f.line} [${f.ruleId}]\n`);
|
|
1417
|
+
process.stdout.write(` ${f.message}\n`);
|
|
1418
|
+
process.stdout.write(` ${C.dim}fix: ${f.fix}${C.reset}\n`);
|
|
1419
|
+
}
|
|
1420
|
+
if (res.findings.length === 0 && res.dirs.length > 0) {
|
|
1421
|
+
process.stdout.write(`${C.green}No secrets or exposed source maps in the build output.${C.reset}\n`);
|
|
1422
|
+
}
|
|
1423
|
+
for (const n of res.notes) process.stdout.write(`${C.dim}note: ${n}${C.reset}\n`);
|
|
1424
|
+
process.stdout.write('\n');
|
|
1425
|
+
}
|
|
1426
|
+
return res.findings.some((f) => f.severity === 'critical') ? 2 : res.findings.length > 0 ? 1 : 0;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1117
1429
|
function cmdDiff(dir, flags) {
|
|
1118
1430
|
const { scan } = require('../src/scanner');
|
|
1119
1431
|
const { verify } = require('../src/verify');
|
|
@@ -1384,7 +1696,7 @@ function cmdDepFirewall(args, flags) {
|
|
|
1384
1696
|
process.stdout.write(` ${C2.red}✗ BLOCKED${C.reset}\n\n`);
|
|
1385
1697
|
for (const r of result.risks) {
|
|
1386
1698
|
const sc = r.severity === 'critical' ? C2.red : C2.yellow;
|
|
1387
|
-
process.stdout.write(` ${sc}[${r.severity}]${
|
|
1699
|
+
process.stdout.write(` ${sc}[${r.severity}]${C.reset} ${r.message}\n`);
|
|
1388
1700
|
}
|
|
1389
1701
|
}
|
|
1390
1702
|
return result.allowed ? 0 : 1;
|
|
@@ -1398,7 +1710,10 @@ function cmdInterceptTest(dir, args, flags) {
|
|
|
1398
1710
|
|
|
1399
1711
|
const tests = [
|
|
1400
1712
|
['Fetch with PII', () => interceptor.checkOutboundData('email: john@example.com, ssn: 123-45-6789')],
|
|
1401
|
-
|
|
1713
|
+
// Demo-only fake credential: intentionally non-matching shape so the scanner's own
|
|
1714
|
+
// entropy + secret rules don't flag this file, but the interceptor still sees a "key:" line.
|
|
1715
|
+
// vibeguard-ignore: demo test for exfil blocking
|
|
1716
|
+
['Fetch with secret', () => interceptor.checkOutboundData('key: demo_key_REDACTED_not_real')],
|
|
1402
1717
|
['Metadata service', () => interceptor.checkDomain('http://169.254.169.254/latest/meta-data')],
|
|
1403
1718
|
['.env file access', () => interceptor.checkFilePath('.env')],
|
|
1404
1719
|
['sudo rm -rf', () => interceptor.checkCommand('sudo rm -rf /')],
|
|
@@ -1410,7 +1725,7 @@ function cmdInterceptTest(dir, args, flags) {
|
|
|
1410
1725
|
|
|
1411
1726
|
// AI response sanitization
|
|
1412
1727
|
process.stdout.write(`\n${C2.bold}AI Response Sanitization${C.reset}\n`);
|
|
1413
|
-
const rc = interceptor.sanitizeAIResponse('Key: sk-proj-
|
|
1728
|
+
const rc = interceptor.sanitizeAIResponse('Key: ' + 'sk-proj' + '-demo-fake-not-real, email: admin@company.com');
|
|
1414
1729
|
process.stdout.write(` Blocked: ${rc.blockedCount} items\n`);
|
|
1415
1730
|
for (const b of rc.blocked) process.stdout.write(` ${C2.red}${b.type}${C.reset}: ${b.reason}\n`);
|
|
1416
1731
|
process.stdout.write(` ${C2.dim}Sanitized: ${rc.sanitized.slice(0, 80)}${C.reset}\n`);
|
|
@@ -1519,10 +1834,23 @@ function cmdSelfCheck(dir, flags) {
|
|
|
1519
1834
|
|
|
1520
1835
|
function cmdSandbox(args, flags) {
|
|
1521
1836
|
const code = (args._ || args || []).slice(1).join(' ');
|
|
1522
|
-
if (!code) { process.stderr.write('Usage: vibeguard sandbox <code
|
|
1523
|
-
const
|
|
1524
|
-
const
|
|
1525
|
-
|
|
1837
|
+
if (!code) { process.stderr.write('Usage: vibeguard sandbox <code> [--isolation vm|process|auto] [--timeout ms] [--memory mb]\n'); return 1; }
|
|
1838
|
+
const sandbox = require('../src/sandbox');
|
|
1839
|
+
const timeout = flags.timeout ? Number(flags.timeout) : undefined;
|
|
1840
|
+
const maxMemory = flags.memory ? Number(flags.memory) * 1024 * 1024 : undefined;
|
|
1841
|
+
const mode = String(flags.isolation || 'auto').toLowerCase();
|
|
1842
|
+
let result;
|
|
1843
|
+
if (mode === 'process') {
|
|
1844
|
+
result = sandbox.runInProcess(code, { timeout, maxMemory });
|
|
1845
|
+
} else if (mode === 'vm') {
|
|
1846
|
+
result = sandbox.runInSandbox(code, { timeout, maxMemory });
|
|
1847
|
+
} else if (sandbox.processIsolationSupported()) {
|
|
1848
|
+
result = sandbox.runInProcess(code, { timeout, maxMemory });
|
|
1849
|
+
} else {
|
|
1850
|
+
result = sandbox.runInSandbox(code, { timeout, maxMemory });
|
|
1851
|
+
}
|
|
1852
|
+
if (flags.json) process.stdout.write(JSON.stringify(result, null, 2) + '\n');
|
|
1853
|
+
else process.stdout.write(sandbox.renderSandboxReport(result) + '\n');
|
|
1526
1854
|
return result.success ? 0 : 1;
|
|
1527
1855
|
}
|
|
1528
1856
|
|
|
@@ -1591,12 +1919,12 @@ function cmdAuditTrail(args, flags) {
|
|
|
1591
1919
|
if (action === 'show' || action === 'status') {
|
|
1592
1920
|
process.stdout.write(audit.renderAuditReport() + '\n');
|
|
1593
1921
|
} else if (action === 'export') {
|
|
1594
|
-
const outPath =
|
|
1922
|
+
const outPath = allArgs[2] || flags.output || 'vibeguard-audit.json';
|
|
1595
1923
|
audit.exportLog(outPath);
|
|
1596
|
-
process.stdout.write(`${C2.green}Exported to ${outPath}${
|
|
1924
|
+
process.stdout.write(`${C2.green}Exported to ${outPath}${C.reset}\n`);
|
|
1597
1925
|
} else if (action === 'verify') {
|
|
1598
1926
|
const v = audit.verifyChain();
|
|
1599
|
-
process.stdout.write(v.valid ? `${C2.green}PASS Chain intact (${v.total} entries)${
|
|
1927
|
+
process.stdout.write(v.valid ? `${C2.green}PASS Chain intact (${v.total} entries)${C.reset}\n` : `${C2.red}FAIL Chain broken at: ${v.brokenAt.join(',')}${C.reset}\n`);
|
|
1600
1928
|
} else {
|
|
1601
1929
|
process.stderr.write('Usage: vibeguard audit-trail [show|export|verify]\n');
|
|
1602
1930
|
return 1;
|
|
@@ -1604,9 +1932,9 @@ function cmdAuditTrail(args, flags) {
|
|
|
1604
1932
|
return 0;
|
|
1605
1933
|
}
|
|
1606
1934
|
|
|
1607
|
-
function cmdPreDeploy(dir, flags) {
|
|
1935
|
+
async function cmdPreDeploy(dir, flags) {
|
|
1608
1936
|
const { runPreDeployGate, renderPreDeployReport } = require('../src/pre-deploy');
|
|
1609
|
-
const summary = runPreDeployGate(dir, { strict: flags.strict, json: flags.json });
|
|
1937
|
+
const summary = await runPreDeployGate(dir, { strict: flags.strict, json: flags.json, pentestUrl: flags['pentest-url'] !== undefined && flags['pentest-url'] !== true ? String(flags['pentest-url']) : undefined, pentestVerifySsrf: flags['pentest-verify-ssrf'] === true });
|
|
1610
1938
|
if (flags.json) {
|
|
1611
1939
|
process.stdout.write(JSON.stringify(summary, null, 2) + '\n');
|
|
1612
1940
|
} else {
|
|
@@ -2372,7 +2700,7 @@ function cmdAutoUnified(dir, args, flags) {
|
|
|
2372
2700
|
yes: !!flags.yes || !!flags.force,
|
|
2373
2701
|
};
|
|
2374
2702
|
|
|
2375
|
-
process.stdout.write(`\n${C.bold}${C.cyan}[VibeGuard] Activating
|
|
2703
|
+
process.stdout.write(`\n${C.bold}${C.cyan}[VibeGuard] Activating layered protection...${C.reset}\n\n`);
|
|
2376
2704
|
|
|
2377
2705
|
const r = auto.autoStart(rootDir, opts);
|
|
2378
2706
|
if (!r.ok) {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* bin/cmd-agent-monitor.js — one-shot or live view of agent runtime events.
|
|
5
|
+
*
|
|
6
|
+
* vibeguard agent-monitor [dir] [--json] [--audit file]
|
|
7
|
+
* vibeguard agent-monitor [dir] --watch [--interval 1000]
|
|
8
|
+
*
|
|
9
|
+
* In --watch mode this process stays alive and streams new audit entries.
|
|
10
|
+
* The CLI main() must not call process.exit() for this command.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const { analyzeMonitorLog, renderMonitor, watchAudit, formatEvent } = require('../src/agent-monitor');
|
|
15
|
+
|
|
16
|
+
function cmdAgentMonitor(args, flags) {
|
|
17
|
+
const root = path.resolve(flags.dir || args._[1] || '.');
|
|
18
|
+
const auditFile = path.resolve(root, flags.audit || '.vibeguard/audit/mcp-firewall.jsonl');
|
|
19
|
+
|
|
20
|
+
if (!flags.watch) {
|
|
21
|
+
const report = analyzeMonitorLog(auditFile);
|
|
22
|
+
if (flags.json) process.stdout.write(JSON.stringify(report, null, 2) + '\n');
|
|
23
|
+
else process.stdout.write(renderMonitor(report) + '\n');
|
|
24
|
+
return report.exists ? (report.blocked > 0 || !report.chainValid ? 1 : 0) : 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const initial = analyzeMonitorLog(auditFile);
|
|
28
|
+
if (!flags.json) {
|
|
29
|
+
process.stdout.write(renderMonitor(initial) + '\n');
|
|
30
|
+
process.stdout.write('\nwatching for new events (Ctrl+C to stop)\n\n');
|
|
31
|
+
}
|
|
32
|
+
const watcher = watchAudit(auditFile, {
|
|
33
|
+
interval: Number(flags.interval || 1000),
|
|
34
|
+
onEvent(entry) {
|
|
35
|
+
if (flags.json) process.stdout.write(JSON.stringify(entry) + '\n');
|
|
36
|
+
else process.stdout.write(formatEvent(entry) + '\n');
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const stop = () => { watcher.stop(); process.exit(0); };
|
|
40
|
+
process.on('SIGINT', stop);
|
|
41
|
+
process.on('SIGTERM', stop);
|
|
42
|
+
return null; // keep running
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = { cmdAgentMonitor };
|