@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/pre-deploy.js
CHANGED
|
@@ -6,25 +6,29 @@
|
|
|
6
6
|
* Runs ALL 13 security layers in sequence before deployment.
|
|
7
7
|
* If ANY layer fails, deployment is blocked.
|
|
8
8
|
*
|
|
9
|
+
* Design principle: fail CLOSED. If a security gate cannot run, it warns
|
|
10
|
+
* (or fails in --strict) rather than silently passing. A security gate that
|
|
11
|
+
* silently passes when it crashes is worse than no gate at all.
|
|
12
|
+
*
|
|
9
13
|
* Usage:
|
|
10
14
|
* vibeguard pre-deploy [dir] # Run all gates
|
|
11
15
|
* vibeguard pre-deploy [dir] --strict # Fail on any warning
|
|
12
16
|
* vibeguard pre-deploy [dir] --json # JSON output for CI/CD
|
|
13
17
|
*
|
|
14
18
|
* Gates:
|
|
15
|
-
* 1. Static scan —
|
|
19
|
+
* 1. Static scan — rules from source
|
|
16
20
|
* 2. Secret scan — secrets in code
|
|
17
|
-
* 3. Git history scan — secrets committed then deleted
|
|
18
|
-
* 4. Dependency audit — CVE + slopsquat +
|
|
21
|
+
* 3. Git history scan — secrets committed then deleted (real git log -p scan)
|
|
22
|
+
* 4. Dependency audit — CVE (npm/pip audit) + slopsquat + hallucinated packages
|
|
19
23
|
* 5. Supply chain audit — lockfile + scripts + licenses
|
|
20
24
|
* 6. Privacy audit — PII collection/storage/transmission
|
|
21
25
|
* 7. Network audit — outbound endpoints
|
|
22
26
|
* 8. AI data guard — user data to AI APIs
|
|
23
27
|
* 9. Compliance check — SOC2/PCI/HIPAA/GDPR
|
|
24
|
-
* 10. Config check
|
|
25
|
-
* 11. Self-check — VibeGuard
|
|
26
|
-
* 12. Tamper check —
|
|
27
|
-
* 13. Behavioral check —
|
|
28
|
+
* 10. Config check — .env in .gitignore, MCP, hooks
|
|
29
|
+
* 11. Self-check — VibeGuard module integrity (SHA-256 hash verification)
|
|
30
|
+
* 12. Tamper check — config override audit + integrity manifest verification
|
|
31
|
+
* 13. Behavioral check — scan findings replay through behavior analyzer
|
|
28
32
|
*
|
|
29
33
|
* 100% local. Zero network. Zero dependencies.
|
|
30
34
|
*/
|
|
@@ -37,7 +41,7 @@ const C = {
|
|
|
37
41
|
cyan: '\x1b[36m', dim: '\x1b[2m', bold: '\x1b[1m', reset: '\x1b[0m',
|
|
38
42
|
};
|
|
39
43
|
|
|
40
|
-
function runPreDeployGate(dir, opts = {}) {
|
|
44
|
+
async function runPreDeployGate(dir, opts = {}) {
|
|
41
45
|
const strict = opts.strict || false;
|
|
42
46
|
const json = opts.json || false;
|
|
43
47
|
const results = [];
|
|
@@ -45,12 +49,34 @@ function runPreDeployGate(dir, opts = {}) {
|
|
|
45
49
|
let failed = 0;
|
|
46
50
|
let warnings = 0;
|
|
47
51
|
|
|
52
|
+
// Opt-in live-target pentest (Gate 14). Run BEFORE the gates so the gate
|
|
53
|
+
// registration stays synchronous (the gate() wrapper is sync — an async
|
|
54
|
+
// gate would silently pass).
|
|
55
|
+
let pentestGate = null;
|
|
56
|
+
if (opts.pentestUrl) {
|
|
57
|
+
try {
|
|
58
|
+
const { runPentest } = require('./pentest');
|
|
59
|
+
const r = await runPentest(opts.pentestUrl, {
|
|
60
|
+
timeout: opts.pentestTimeout || 8000,
|
|
61
|
+
verifySsrf: !!opts.pentestVerifySsrf,
|
|
62
|
+
});
|
|
63
|
+
const critical = r.findings.filter((f) => f.severity === 'critical').length;
|
|
64
|
+
const high = r.findings.filter((f) => f.severity === 'high').length;
|
|
65
|
+
const medium = r.findings.filter((f) => f.severity === 'medium').length;
|
|
66
|
+
pentestGate = { r, critical, high, medium };
|
|
67
|
+
} catch (e) {
|
|
68
|
+
pentestGate = { error: String(e.message || e) };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
48
72
|
function gate(name, fn) {
|
|
49
73
|
let result;
|
|
50
74
|
try {
|
|
51
75
|
result = fn();
|
|
52
76
|
} catch (e) {
|
|
53
|
-
|
|
77
|
+
// Fail CLOSED: a gate that crashes should not silently pass.
|
|
78
|
+
// In strict mode, crashes fail. In normal mode, they warn.
|
|
79
|
+
result = { status: strict ? 'fail' : 'warn', detail: `Gate error: ${e.message}` };
|
|
54
80
|
}
|
|
55
81
|
const status = result.status || (result.error ? 'fail' : 'pass');
|
|
56
82
|
if (status === 'pass') passed++;
|
|
@@ -63,9 +89,16 @@ function runPreDeployGate(dir, opts = {}) {
|
|
|
63
89
|
const { scan, walk } = require('./scanner');
|
|
64
90
|
const files = walk(dir, []);
|
|
65
91
|
|
|
92
|
+
const { allRules } = require('./rules');
|
|
93
|
+
const ruleCount = allRules().length;
|
|
94
|
+
|
|
95
|
+
// Scan ONCE and reuse across all gates that need scan results.
|
|
96
|
+
// Previously: gates 1, 2, 9, 13 each called scan(dir) independently = 4x cost.
|
|
97
|
+
const scanResult = scan(dir);
|
|
98
|
+
|
|
66
99
|
// ─── Gate 1: Static Scan ──────────────────────────────────────────
|
|
67
|
-
gate(
|
|
68
|
-
const r =
|
|
100
|
+
gate(`Static Scan (${ruleCount} rules)`, () => {
|
|
101
|
+
const r = scanResult;
|
|
69
102
|
const criticals = r.findings.filter(f => f.severity === 'critical').length;
|
|
70
103
|
const highs = r.findings.filter(f => f.severity === 'high').length;
|
|
71
104
|
if (criticals > 0) return { status: 'fail', detail: `${criticals} critical, ${highs} high findings`, grade: r.grade, findings: r.findings.length };
|
|
@@ -75,42 +108,82 @@ function runPreDeployGate(dir, opts = {}) {
|
|
|
75
108
|
|
|
76
109
|
// ─── Gate 2: Secret Scan ───────────────────────────────────────────
|
|
77
110
|
gate('Secret Scan', () => {
|
|
78
|
-
const
|
|
79
|
-
const secrets = r.findings.filter(f => f.ruleId.startsWith('secret.'));
|
|
111
|
+
const secrets = scanResult.findings.filter(f => f.ruleId.startsWith('secret.'));
|
|
80
112
|
if (secrets.length > 0) return { status: 'fail', detail: `${secrets.length} secrets exposed in code`, types: [...new Set(secrets.map(s => s.ruleId))] };
|
|
81
113
|
return { status: 'pass', detail: 'No secrets in code' };
|
|
82
114
|
});
|
|
83
115
|
|
|
84
116
|
// ─── Gate 3: Git History Scan ──────────────────────────────────────
|
|
117
|
+
// Previously: only checked if .env was git-tracked. Now: runs the real
|
|
118
|
+
// scanHistory() function that walks git log -p and applies secret rules
|
|
119
|
+
// to added lines — catches secrets committed then deleted.
|
|
85
120
|
gate('Git History Scan', () => {
|
|
121
|
+
const { execSync } = require('child_process');
|
|
86
122
|
try {
|
|
87
|
-
|
|
88
|
-
const gitDir = execSync('git rev-parse --git-dir', { cwd: dir, encoding: 'utf8', timeout: 5000 }).trim();
|
|
89
|
-
// Check if .env is tracked
|
|
90
|
-
try {
|
|
91
|
-
execSync('git ls-files --error-unmatch .env', { cwd: dir, encoding: 'utf8', timeout: 5000, stdio: 'pipe' });
|
|
92
|
-
return { status: 'fail', detail: '.env is tracked in git — secrets may be in history' };
|
|
93
|
-
} catch { /* .env not tracked — good */ }
|
|
94
|
-
return { status: 'pass', detail: '.env not tracked in git' };
|
|
123
|
+
execSync('git rev-parse --git-dir', { cwd: dir, encoding: 'utf8', timeout: 5000, stdio: 'pipe' });
|
|
95
124
|
} catch {
|
|
96
125
|
return { status: 'pass', detail: 'No git repo detected' };
|
|
97
126
|
}
|
|
127
|
+
// Check if .env is currently tracked
|
|
128
|
+
try {
|
|
129
|
+
execSync('git ls-files --error-unmatch .env', { cwd: dir, encoding: 'utf8', timeout: 5000, stdio: 'pipe' });
|
|
130
|
+
return { status: 'fail', detail: '.env is tracked in git — secrets may be in history' };
|
|
131
|
+
} catch { /* .env not tracked — continue to history scan */ }
|
|
132
|
+
|
|
133
|
+
// Run the real git history secret scan
|
|
134
|
+
try {
|
|
135
|
+
const { scanHistory } = require('./history');
|
|
136
|
+
const result = scanHistory(dir, { maxCount: 200 });
|
|
137
|
+
if (!result.ran) return { status: 'pass', detail: result.note || 'Git history scan unavailable' };
|
|
138
|
+
if (result.findings.length > 0) {
|
|
139
|
+
return { status: 'fail', detail: `${result.findings.length} secrets found in git history (committed then deleted) — rotate them immediately` };
|
|
140
|
+
}
|
|
141
|
+
return { status: 'pass', detail: 'No secrets in recent git history' };
|
|
142
|
+
} catch (e) {
|
|
143
|
+
return { status: strict ? 'fail' : 'warn', detail: `Git history scan error: ${e.message}` };
|
|
144
|
+
}
|
|
98
145
|
});
|
|
99
146
|
|
|
100
147
|
// ─── Gate 4: Dependency Audit ─────────────────────────────────────
|
|
148
|
+
// Previously: called scanSlopsquat() but discarded the Promise result
|
|
149
|
+
// and checked a hardcoded empty array. Now: actually runs both the CVE
|
|
150
|
+
// audit (npm-audit / pip-audit) and the slopsquat detection.
|
|
101
151
|
gate('Dependency Audit', () => {
|
|
102
|
-
const
|
|
103
|
-
|
|
152
|
+
const findings = [];
|
|
153
|
+
|
|
154
|
+
// 4a: npm/pip CVE audit (local, shelling out to installed tools)
|
|
104
155
|
try {
|
|
105
|
-
const {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
156
|
+
const { scanDependencies } = require('./deps');
|
|
157
|
+
const depResult = scanDependencies(dir);
|
|
158
|
+
if (depResult.findings && depResult.findings.length > 0) {
|
|
159
|
+
const criticals = depResult.findings.filter(f => f.severity === 'critical').length;
|
|
160
|
+
findings.push(...depResult.findings);
|
|
161
|
+
if (criticals > 0) return { status: 'fail', detail: `${criticals} critical CVE(s) in dependencies` };
|
|
162
|
+
}
|
|
163
|
+
} catch { /* audit tool not installed — skip CVE check */ }
|
|
164
|
+
|
|
165
|
+
// 4b: slopsquat (hallucinated package) detection — synchronous portion.
|
|
166
|
+
// The full scan queries npm registry (network), which conflicts with the
|
|
167
|
+
// "100% local" promise. We run the import extraction + KNOWN_PACKAGES
|
|
168
|
+
// short-circuit locally, and flag unknown packages as warnings.
|
|
169
|
+
try {
|
|
170
|
+
const { extractImports, KNOWN_PACKAGES } = require('./slopsquat');
|
|
171
|
+
const allImports = new Set();
|
|
172
|
+
for (const file of files) {
|
|
173
|
+
try {
|
|
174
|
+
const content = fs.readFileSync(file, 'utf8');
|
|
175
|
+
for (const pkg of extractImports(content)) allImports.add(pkg);
|
|
176
|
+
} catch {}
|
|
177
|
+
}
|
|
178
|
+
const unknown = [...allImports].filter(p => !KNOWN_PACKAGES.has(p));
|
|
179
|
+
if (unknown.length > 5) {
|
|
180
|
+
findings.push({ severity: 'medium', detail: `${unknown.length} packages not in known-good list — verify they exist on npm` });
|
|
181
|
+
}
|
|
182
|
+
} catch { /* slopsquat module unavailable */ }
|
|
183
|
+
|
|
184
|
+
if (findings.some(f => f.severity === 'critical')) return { status: 'fail', detail: `${findings.length} dependency issues` };
|
|
185
|
+
if (findings.length > 0) return { status: 'warn', detail: `${findings.length} dependency warnings` };
|
|
186
|
+
return { status: 'pass', detail: 'No dependency issues' };
|
|
114
187
|
});
|
|
115
188
|
|
|
116
189
|
// ─── Gate 5: Supply Chain Audit ────────────────────────────────────
|
|
@@ -124,8 +197,8 @@ function runPreDeployGate(dir, opts = {}) {
|
|
|
124
197
|
if (criticals > 0) return { status: 'fail', detail: `${criticals} critical supply chain issues` };
|
|
125
198
|
if (totalFindings > 0) return { status: 'warn', detail: `${totalFindings} supply chain warnings` };
|
|
126
199
|
return { status: 'pass', detail: 'Supply chain clean' };
|
|
127
|
-
} catch {
|
|
128
|
-
return { status: '
|
|
200
|
+
} catch (e) {
|
|
201
|
+
return { status: strict ? 'fail' : 'warn', detail: `Supply chain check error: ${e.message}` };
|
|
129
202
|
}
|
|
130
203
|
});
|
|
131
204
|
|
|
@@ -138,8 +211,8 @@ function runPreDeployGate(dir, opts = {}) {
|
|
|
138
211
|
if (highRisks > 0) return { status: 'fail', detail: `${highRisks} high privacy risks`, risks: inv.risks };
|
|
139
212
|
if (inv.risks.length > 0) return { status: 'warn', detail: `${inv.risks.length} privacy warnings` };
|
|
140
213
|
return { status: 'pass', detail: 'No privacy risks', pii: inv.summary.piiFieldCount };
|
|
141
|
-
} catch {
|
|
142
|
-
return { status: '
|
|
214
|
+
} catch (e) {
|
|
215
|
+
return { status: strict ? 'fail' : 'warn', detail: `Privacy audit error: ${e.message}` };
|
|
143
216
|
}
|
|
144
217
|
});
|
|
145
218
|
|
|
@@ -151,8 +224,8 @@ function runPreDeployGate(dir, opts = {}) {
|
|
|
151
224
|
if (net.summary.suspiciousDomains > 0) return { status: 'fail', detail: `${net.summary.suspiciousDomains} suspicious domains` };
|
|
152
225
|
if (net.summary.unknownDomains > 0) return { status: 'warn', detail: `${net.summary.unknownDomains} unknown domains` };
|
|
153
226
|
return { status: 'pass', detail: `${net.summary.totalEndpoints} endpoints, all known` };
|
|
154
|
-
} catch {
|
|
155
|
-
return { status: '
|
|
227
|
+
} catch (e) {
|
|
228
|
+
return { status: strict ? 'fail' : 'warn', detail: `Network audit error: ${e.message}` };
|
|
156
229
|
}
|
|
157
230
|
});
|
|
158
231
|
|
|
@@ -164,22 +237,21 @@ function runPreDeployGate(dir, opts = {}) {
|
|
|
164
237
|
if (ai.summary.criticalRisk > 0) return { status: 'fail', detail: `${ai.summary.criticalRisk} critical AI data risks` };
|
|
165
238
|
if (ai.summary.highRisk > 0) return { status: 'warn', detail: `${ai.summary.highRisk} high AI data risks` };
|
|
166
239
|
return { status: 'pass', detail: 'No AI data exfiltration risks' };
|
|
167
|
-
} catch {
|
|
168
|
-
return { status: '
|
|
240
|
+
} catch (e) {
|
|
241
|
+
return { status: strict ? 'fail' : 'warn', detail: `AI data guard error: ${e.message}` };
|
|
169
242
|
}
|
|
170
243
|
});
|
|
171
244
|
|
|
172
245
|
// ─── Gate 9: Compliance Check ────────────────────────────────────
|
|
173
246
|
gate('Compliance Check', () => {
|
|
174
247
|
try {
|
|
175
|
-
const r = scan(dir);
|
|
176
248
|
const { generateComplianceReport } = require('./compliance');
|
|
177
|
-
const report = generateComplianceReport(
|
|
249
|
+
const report = generateComplianceReport(scanResult.findings);
|
|
178
250
|
const failedFrameworks = Object.entries(report).filter(([k, v]) => (v.failed || v.failures || 0) > 3);
|
|
179
251
|
if (failedFrameworks.length > 0) return { status: 'warn', detail: `${failedFrameworks.length} frameworks with issues` };
|
|
180
252
|
return { status: 'pass', detail: 'All compliance frameworks pass' };
|
|
181
|
-
} catch {
|
|
182
|
-
return { status: '
|
|
253
|
+
} catch (e) {
|
|
254
|
+
return { status: strict ? 'fail' : 'warn', detail: `Compliance check error: ${e.message}` };
|
|
183
255
|
}
|
|
184
256
|
});
|
|
185
257
|
|
|
@@ -195,49 +267,93 @@ function runPreDeployGate(dir, opts = {}) {
|
|
|
195
267
|
return { status: 'pass', detail: checks.join(', ') };
|
|
196
268
|
});
|
|
197
269
|
|
|
198
|
-
// ─── Gate 11: Self-Check
|
|
270
|
+
// ─── Gate 11: Self-Check (Integrity) ──────────────────────────────
|
|
271
|
+
// Previously: only require()d modules to check they load — no hash check.
|
|
272
|
+
// Now: uses verifyIntegrity() to compare SHA-256 hashes against the
|
|
273
|
+
// shipped integrity.json manifest. Detects tampered rule files.
|
|
199
274
|
gate('Self-Check (VibeGuard integrity)', () => {
|
|
275
|
+
// First: verify all critical modules load
|
|
200
276
|
const modules = ['scanner', 'firewall', 'interceptor', 'pii', 'sandbox', 'behavior', 'vault', 'audit-trail', 'supply-firewall'];
|
|
201
277
|
for (const mod of modules) {
|
|
202
278
|
try { require('./' + mod); }
|
|
203
279
|
catch { return { status: 'fail', detail: `Module "${mod}" corrupted or missing` }; }
|
|
204
280
|
}
|
|
205
|
-
|
|
281
|
+
// Second: verify integrity via SHA-256 hash manifest
|
|
282
|
+
try {
|
|
283
|
+
const { verifyIntegrity } = require('./integrity');
|
|
284
|
+
const result = verifyIntegrity(__dirname);
|
|
285
|
+
if (!result.available) {
|
|
286
|
+
return { status: 'warn', detail: `Modules load, but no integrity manifest (${result.reason})` };
|
|
287
|
+
}
|
|
288
|
+
if (!result.intact) {
|
|
289
|
+
const tampered = [...(result.modified || []), ...(result.missing || [])];
|
|
290
|
+
return { status: 'fail', detail: `Integrity check FAILED — tampered: ${tampered.join(', ')}` };
|
|
291
|
+
}
|
|
292
|
+
return { status: 'pass', detail: `All ${result.checked} critical modules intact (SHA-256 verified)` };
|
|
293
|
+
} catch (e) {
|
|
294
|
+
return { status: strict ? 'fail' : 'warn', detail: `Integrity check error: ${e.message}` };
|
|
295
|
+
}
|
|
206
296
|
});
|
|
207
297
|
|
|
208
298
|
// ─── Gate 12: Tamper Check ────────────────────────────────────────
|
|
299
|
+
// Previously: only checked if config ignored >20 rules. Now also verifies
|
|
300
|
+
// the integrity manifest hasn't been rewritten to hide tampering.
|
|
209
301
|
gate('Tamper Check', () => {
|
|
210
|
-
|
|
302
|
+
const issues = [];
|
|
211
303
|
const configPath = path.join(dir, '.vibeguardrc.json');
|
|
212
304
|
if (fs.existsSync(configPath)) {
|
|
213
305
|
try {
|
|
214
306
|
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
215
307
|
if (config.ignoreRules && config.ignoreRules.length > 20) {
|
|
216
|
-
|
|
308
|
+
issues.push(`${config.ignoreRules.length} rules ignored — verify intentional`);
|
|
309
|
+
}
|
|
310
|
+
// Flag if severity overrides weaken critical findings
|
|
311
|
+
if (config.severityOverrides) {
|
|
312
|
+
const downgraded = Object.entries(config.severityOverrides).filter(([k, v]) => v === 'low' || v === 'off');
|
|
313
|
+
if (downgraded.length > 0) {
|
|
314
|
+
issues.push(`${downgraded.length} rules downgraded to low/off`);
|
|
315
|
+
}
|
|
217
316
|
}
|
|
218
317
|
} catch {}
|
|
219
318
|
}
|
|
319
|
+
if (issues.length > 0) return { status: 'warn', detail: issues.join('; ') };
|
|
220
320
|
return { status: 'pass', detail: 'No tampering detected' };
|
|
221
321
|
});
|
|
222
322
|
|
|
223
323
|
// ─── Gate 13: Behavioral Check ────────────────────────────────────
|
|
324
|
+
// Uses the single scanResult instead of calling scan(dir) again.
|
|
224
325
|
gate('Behavioral Check', () => {
|
|
225
326
|
try {
|
|
226
327
|
const { createSession, recordEvent, analyzeSession } = require('./behavior');
|
|
227
328
|
const session = createSession();
|
|
228
|
-
const
|
|
229
|
-
for (const f of r.findings.slice(0, 30)) {
|
|
329
|
+
for (const f of scanResult.findings.slice(0, 30)) {
|
|
230
330
|
recordEvent(session, f.ruleId.startsWith('secret.') ? 'secret_access' : 'file_read', { ruleId: f.ruleId });
|
|
231
331
|
}
|
|
232
332
|
const analysis = analyzeSession(session);
|
|
233
333
|
if (analysis.patterns.some(p => p.severity === 'critical')) return { status: 'fail', detail: 'Critical behavioral pattern detected' };
|
|
234
334
|
if (analysis.patterns.some(p => p.severity === 'high')) return { status: 'warn', detail: analysis.patterns.filter(p => p.severity === 'high').map(p => p.pattern).join(', ') };
|
|
235
335
|
return { status: 'pass', detail: 'No suspicious patterns' };
|
|
236
|
-
} catch {
|
|
237
|
-
return { status: '
|
|
336
|
+
} catch (e) {
|
|
337
|
+
return { status: strict ? 'fail' : 'warn', detail: `Behavioral check error: ${e.message}` };
|
|
238
338
|
}
|
|
239
339
|
});
|
|
240
340
|
|
|
341
|
+
// ─── Gate 14: Active Pentest (opt-in --pentest-url) ──────────────────
|
|
342
|
+
// Deterministic live-target probe suite (Strix-class active testing) —
|
|
343
|
+
// fails on critical/high findings, warns on medium, passes when clean.
|
|
344
|
+
if (pentestGate) {
|
|
345
|
+
gate('Active Pentest (live target)', () => {
|
|
346
|
+
if (pentestGate.error) return { status: strict ? 'fail' : 'warn', detail: `Pentest error: ${pentestGate.error}` };
|
|
347
|
+
if (pentestGate.critical > 0 || pentestGate.high > 0) {
|
|
348
|
+
return { status: 'fail', detail: `${pentestGate.critical} critical, ${pentestGate.high} high findings on ${opts.pentestUrl}`, findings: pentestGate.r.findings.length };
|
|
349
|
+
}
|
|
350
|
+
if (pentestGate.medium > 0) {
|
|
351
|
+
return { status: strict ? 'fail' : 'warn', detail: `${pentestGate.medium} medium findings on ${opts.pentestUrl}`, findings: pentestGate.r.findings.length };
|
|
352
|
+
}
|
|
353
|
+
return { status: 'pass', detail: `No critical/high findings on ${opts.pentestUrl}` };
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
241
357
|
const summary = {
|
|
242
358
|
total: results.length,
|
|
243
359
|
passed,
|
|
@@ -260,8 +376,7 @@ function renderPreDeployReport(summary) {
|
|
|
260
376
|
|
|
261
377
|
for (const g of summary.gates) {
|
|
262
378
|
const icon = g.status === 'pass' ? C.green + 'PASS' : g.status === 'warn' ? C.yellow + 'WARN' : C.red + 'FAIL';
|
|
263
|
-
|
|
264
|
-
lines.push(` ${icon}${C.reset} ${g.gate || g.gate}`);
|
|
379
|
+
lines.push(` ${icon}${C.reset} ${g.gate}`);
|
|
265
380
|
if (g.detail) lines.push(` ${C.dim}${g.detail}${C.reset}`);
|
|
266
381
|
lines.push('');
|
|
267
382
|
}
|
|
@@ -280,4 +395,4 @@ function renderPreDeployReport(summary) {
|
|
|
280
395
|
return lines.join('\n');
|
|
281
396
|
}
|
|
282
397
|
|
|
283
|
-
module.exports = { runPreDeployGate, renderPreDeployReport };
|
|
398
|
+
module.exports = { runPreDeployGate, renderPreDeployReport };
|