@vibecheckai/cli 3.5.0 → 3.5.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/bin/registry.js +174 -449
- package/bin/runners/cli-utils.js +33 -2
- package/bin/runners/context/generators/cursor.js +2 -49
- package/bin/runners/context/generators/mcp.js +13 -15
- package/bin/runners/context/proof-context.js +1 -248
- package/bin/runners/lib/analysis-core.js +180 -198
- package/bin/runners/lib/analyzers.js +241 -2212
- package/bin/runners/lib/cli-output.js +210 -242
- package/bin/runners/lib/detectors-v2.js +785 -547
- package/bin/runners/lib/entitlements-v2.js +431 -161
- package/bin/runners/lib/error-handler.js +9 -16
- package/bin/runners/lib/global-flags.js +0 -37
- package/bin/runners/lib/html-proof-report.js +700 -350
- package/bin/runners/lib/missions/plan.js +6 -46
- package/bin/runners/lib/missions/templates.js +0 -232
- package/bin/runners/lib/route-truth.js +322 -1167
- package/bin/runners/lib/scan-output.js +467 -493
- package/bin/runners/lib/ship-output.js +27 -280
- package/bin/runners/lib/terminal-ui.js +700 -310
- package/bin/runners/lib/truth.js +321 -1004
- package/bin/runners/lib/unified-output.js +158 -162
- package/bin/runners/lib/upsell.js +204 -104
- package/bin/runners/runAIAgent.js +10 -5
- package/bin/runners/runAllowlist.js +324 -0
- package/bin/runners/runAuth.js +94 -344
- package/bin/runners/runCheckpoint.js +45 -43
- package/bin/runners/runContext.js +24 -139
- package/bin/runners/runDoctor.js +101 -136
- package/bin/runners/runEvidencePack.js +219 -0
- package/bin/runners/runFix.js +71 -82
- package/bin/runners/runGuard.js +119 -606
- package/bin/runners/runInit.js +60 -22
- package/bin/runners/runInstall.js +281 -0
- package/bin/runners/runLabs.js +341 -0
- package/bin/runners/runMcp.js +62 -139
- package/bin/runners/runPolish.js +83 -282
- package/bin/runners/runPromptFirewall.js +12 -5
- package/bin/runners/runProve.js +58 -33
- package/bin/runners/runReality.js +58 -81
- package/bin/runners/runReport.js +7 -34
- package/bin/runners/runRuntime.js +8 -5
- package/bin/runners/runScan.js +844 -219
- package/bin/runners/runShip.js +59 -721
- package/bin/runners/runValidate.js +11 -24
- package/bin/runners/runWatch.js +76 -131
- package/bin/vibecheck.js +69 -295
- package/mcp-server/ARCHITECTURE.md +339 -0
- package/mcp-server/__tests__/cache.test.ts +313 -0
- package/mcp-server/__tests__/executor.test.ts +239 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.cache/webpack/cache.pack +1 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.next/server/chunk.js +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.turbo/cache.json +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/.venv/lib/env.py +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/dist/bundle.js +3 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/package.json +5 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/src/app.ts +5 -0
- package/mcp-server/__tests__/fixtures/exclusion-test/venv/lib/config.py +4 -0
- package/mcp-server/__tests__/ids.test.ts +345 -0
- package/mcp-server/__tests__/integration/tools.test.ts +410 -0
- package/mcp-server/__tests__/registry.test.ts +365 -0
- package/mcp-server/__tests__/sandbox.test.ts +323 -0
- package/mcp-server/__tests__/schemas.test.ts +372 -0
- package/mcp-server/benchmarks/run-benchmarks.ts +304 -0
- package/mcp-server/examples/doctor.request.json +14 -0
- package/mcp-server/examples/doctor.response.json +53 -0
- package/mcp-server/examples/error.response.json +15 -0
- package/mcp-server/examples/scan.request.json +14 -0
- package/mcp-server/examples/scan.response.json +108 -0
- package/mcp-server/handlers/tool-handler.ts +671 -0
- package/mcp-server/index-v1.js +698 -0
- package/mcp-server/index-v3.ts +293 -0
- package/mcp-server/index.js +1080 -1757
- package/mcp-server/index.old.js +4137 -0
- package/mcp-server/lib/cache.ts +341 -0
- package/mcp-server/lib/errors.ts +346 -0
- package/mcp-server/lib/executor.ts +792 -0
- package/mcp-server/lib/ids.ts +238 -0
- package/mcp-server/lib/logger.ts +368 -0
- package/mcp-server/lib/metrics.ts +365 -0
- package/mcp-server/lib/sandbox.ts +337 -0
- package/mcp-server/lib/validator.ts +229 -0
- package/mcp-server/package-lock.json +165 -0
- package/mcp-server/package.json +32 -7
- package/mcp-server/premium-tools.js +2 -2
- package/mcp-server/registry/tools.json +476 -0
- package/mcp-server/schemas/error-envelope.schema.json +125 -0
- package/mcp-server/schemas/finding.schema.json +167 -0
- package/mcp-server/schemas/report-artifact.schema.json +88 -0
- package/mcp-server/schemas/run-request.schema.json +75 -0
- package/mcp-server/schemas/verdict.schema.json +168 -0
- package/mcp-server/tier-auth.d.ts +71 -0
- package/mcp-server/tier-auth.js +371 -183
- package/mcp-server/truth-context.js +90 -131
- package/mcp-server/truth-firewall-tools.js +1000 -1611
- package/mcp-server/tsconfig.json +34 -0
- package/mcp-server/vibecheck-tools.js +2 -2
- package/mcp-server/vitest.config.ts +16 -0
- package/package.json +3 -4
- package/bin/runners/lib/agent-firewall/ai/false-positive-analyzer.js +0 -474
- package/bin/runners/lib/agent-firewall/change-packet/builder.js +0 -488
- package/bin/runners/lib/agent-firewall/change-packet/schema.json +0 -228
- package/bin/runners/lib/agent-firewall/change-packet/store.js +0 -200
- package/bin/runners/lib/agent-firewall/claims/claim-types.js +0 -21
- package/bin/runners/lib/agent-firewall/claims/extractor.js +0 -303
- package/bin/runners/lib/agent-firewall/claims/patterns.js +0 -24
- package/bin/runners/lib/agent-firewall/critic/index.js +0 -151
- package/bin/runners/lib/agent-firewall/critic/judge.js +0 -432
- package/bin/runners/lib/agent-firewall/critic/prompts.js +0 -305
- package/bin/runners/lib/agent-firewall/evidence/auth-evidence.js +0 -88
- package/bin/runners/lib/agent-firewall/evidence/contract-evidence.js +0 -75
- package/bin/runners/lib/agent-firewall/evidence/env-evidence.js +0 -127
- package/bin/runners/lib/agent-firewall/evidence/resolver.js +0 -102
- package/bin/runners/lib/agent-firewall/evidence/route-evidence.js +0 -213
- package/bin/runners/lib/agent-firewall/evidence/side-effect-evidence.js +0 -145
- package/bin/runners/lib/agent-firewall/fs-hook/daemon.js +0 -19
- package/bin/runners/lib/agent-firewall/fs-hook/installer.js +0 -87
- package/bin/runners/lib/agent-firewall/fs-hook/watcher.js +0 -184
- package/bin/runners/lib/agent-firewall/git-hook/pre-commit.js +0 -163
- package/bin/runners/lib/agent-firewall/ide-extension/cursor.js +0 -107
- package/bin/runners/lib/agent-firewall/ide-extension/vscode.js +0 -68
- package/bin/runners/lib/agent-firewall/ide-extension/windsurf.js +0 -66
- package/bin/runners/lib/agent-firewall/interceptor/base.js +0 -304
- package/bin/runners/lib/agent-firewall/interceptor/cursor.js +0 -35
- package/bin/runners/lib/agent-firewall/interceptor/vscode.js +0 -35
- package/bin/runners/lib/agent-firewall/interceptor/windsurf.js +0 -34
- package/bin/runners/lib/agent-firewall/lawbook/distributor.js +0 -465
- package/bin/runners/lib/agent-firewall/lawbook/evaluator.js +0 -604
- package/bin/runners/lib/agent-firewall/lawbook/index.js +0 -304
- package/bin/runners/lib/agent-firewall/lawbook/registry.js +0 -514
- package/bin/runners/lib/agent-firewall/lawbook/schema.js +0 -420
- package/bin/runners/lib/agent-firewall/learning/learning-engine.js +0 -849
- package/bin/runners/lib/agent-firewall/logger.js +0 -141
- package/bin/runners/lib/agent-firewall/policy/default-policy.json +0 -90
- package/bin/runners/lib/agent-firewall/policy/engine.js +0 -103
- package/bin/runners/lib/agent-firewall/policy/loader.js +0 -451
- package/bin/runners/lib/agent-firewall/policy/rules/auth-drift.js +0 -50
- package/bin/runners/lib/agent-firewall/policy/rules/contract-drift.js +0 -50
- package/bin/runners/lib/agent-firewall/policy/rules/fake-success.js +0 -86
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-env.js +0 -162
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-route.js +0 -189
- package/bin/runners/lib/agent-firewall/policy/rules/scope.js +0 -93
- package/bin/runners/lib/agent-firewall/policy/rules/unsafe-side-effect.js +0 -57
- package/bin/runners/lib/agent-firewall/policy/schema.json +0 -183
- package/bin/runners/lib/agent-firewall/policy/verdict.js +0 -54
- package/bin/runners/lib/agent-firewall/proposal/extractor.js +0 -394
- package/bin/runners/lib/agent-firewall/proposal/index.js +0 -212
- package/bin/runners/lib/agent-firewall/proposal/schema.js +0 -251
- package/bin/runners/lib/agent-firewall/proposal/validator.js +0 -386
- package/bin/runners/lib/agent-firewall/reality/index.js +0 -332
- package/bin/runners/lib/agent-firewall/reality/state.js +0 -625
- package/bin/runners/lib/agent-firewall/reality/watcher.js +0 -322
- package/bin/runners/lib/agent-firewall/risk/index.js +0 -173
- package/bin/runners/lib/agent-firewall/risk/scorer.js +0 -328
- package/bin/runners/lib/agent-firewall/risk/thresholds.js +0 -321
- package/bin/runners/lib/agent-firewall/risk/vectors.js +0 -421
- package/bin/runners/lib/agent-firewall/simulator/diff-simulator.js +0 -472
- package/bin/runners/lib/agent-firewall/simulator/import-resolver.js +0 -346
- package/bin/runners/lib/agent-firewall/simulator/index.js +0 -181
- package/bin/runners/lib/agent-firewall/simulator/route-validator.js +0 -380
- package/bin/runners/lib/agent-firewall/time-machine/incident-correlator.js +0 -661
- package/bin/runners/lib/agent-firewall/time-machine/index.js +0 -267
- package/bin/runners/lib/agent-firewall/time-machine/replay-engine.js +0 -436
- package/bin/runners/lib/agent-firewall/time-machine/state-reconstructor.js +0 -490
- package/bin/runners/lib/agent-firewall/time-machine/timeline-builder.js +0 -530
- package/bin/runners/lib/agent-firewall/truthpack/index.js +0 -67
- package/bin/runners/lib/agent-firewall/truthpack/loader.js +0 -137
- package/bin/runners/lib/agent-firewall/unblock/planner.js +0 -337
- package/bin/runners/lib/agent-firewall/utils/ignore-checker.js +0 -118
- package/bin/runners/lib/api-client.js +0 -269
- package/bin/runners/lib/audit-logger.js +0 -532
- package/bin/runners/lib/authority/authorities/architecture.js +0 -364
- package/bin/runners/lib/authority/authorities/compliance.js +0 -341
- package/bin/runners/lib/authority/authorities/human.js +0 -343
- package/bin/runners/lib/authority/authorities/quality.js +0 -420
- package/bin/runners/lib/authority/authorities/security.js +0 -228
- package/bin/runners/lib/authority/index.js +0 -293
- package/bin/runners/lib/authority-badge.js +0 -425
- package/bin/runners/lib/bundle/bundle-intelligence.js +0 -846
- package/bin/runners/lib/cli-charts.js +0 -368
- package/bin/runners/lib/cli-config-display.js +0 -405
- package/bin/runners/lib/cli-demo.js +0 -275
- package/bin/runners/lib/cli-errors.js +0 -438
- package/bin/runners/lib/cli-help-formatter.js +0 -439
- package/bin/runners/lib/cli-interactive-menu.js +0 -509
- package/bin/runners/lib/cli-prompts.js +0 -441
- package/bin/runners/lib/cli-scan-cards.js +0 -362
- package/bin/runners/lib/compliance-reporter.js +0 -710
- package/bin/runners/lib/conductor/index.js +0 -671
- package/bin/runners/lib/easy/README.md +0 -123
- package/bin/runners/lib/easy/index.js +0 -140
- package/bin/runners/lib/easy/interactive-wizard.js +0 -788
- package/bin/runners/lib/easy/one-click-firewall.js +0 -564
- package/bin/runners/lib/easy/zero-config-reality.js +0 -714
- package/bin/runners/lib/engines/accessibility-engine.js +0 -390
- package/bin/runners/lib/engines/api-consistency-engine.js +0 -467
- package/bin/runners/lib/engines/ast-cache.js +0 -99
- package/bin/runners/lib/engines/async-patterns-engine.js +0 -444
- package/bin/runners/lib/engines/bundle-size-engine.js +0 -433
- package/bin/runners/lib/engines/code-quality-engine.js +0 -255
- package/bin/runners/lib/engines/confidence-scoring.js +0 -276
- package/bin/runners/lib/engines/console-logs-engine.js +0 -115
- package/bin/runners/lib/engines/context-detection.js +0 -264
- package/bin/runners/lib/engines/cross-file-analysis-engine.js +0 -533
- package/bin/runners/lib/engines/database-patterns-engine.js +0 -429
- package/bin/runners/lib/engines/dead-code-engine.js +0 -198
- package/bin/runners/lib/engines/deprecated-api-engine.js +0 -226
- package/bin/runners/lib/engines/duplicate-code-engine.js +0 -354
- package/bin/runners/lib/engines/empty-catch-engine.js +0 -260
- package/bin/runners/lib/engines/env-variables-engine.js +0 -458
- package/bin/runners/lib/engines/error-handling-engine.js +0 -437
- package/bin/runners/lib/engines/false-positive-prevention.js +0 -630
- package/bin/runners/lib/engines/file-filter.js +0 -131
- package/bin/runners/lib/engines/framework-adapters/index.js +0 -607
- package/bin/runners/lib/engines/framework-detection.js +0 -508
- package/bin/runners/lib/engines/hardcoded-secrets-engine.js +0 -251
- package/bin/runners/lib/engines/import-order-engine.js +0 -429
- package/bin/runners/lib/engines/mock-data-engine.js +0 -315
- package/bin/runners/lib/engines/naming-conventions-engine.js +0 -544
- package/bin/runners/lib/engines/noise-reduction-engine.js +0 -452
- package/bin/runners/lib/engines/orchestrator.js +0 -334
- package/bin/runners/lib/engines/parallel-processor.js +0 -71
- package/bin/runners/lib/engines/performance-issues-engine.js +0 -405
- package/bin/runners/lib/engines/react-patterns-engine.js +0 -457
- package/bin/runners/lib/engines/security-vulnerabilities-engine.js +0 -571
- package/bin/runners/lib/engines/todo-fixme-engine.js +0 -115
- package/bin/runners/lib/engines/type-aware-engine.js +0 -376
- package/bin/runners/lib/engines/unsafe-regex-engine.js +0 -225
- package/bin/runners/lib/engines/vibecheck-engines/README.md +0 -53
- package/bin/runners/lib/engines/vibecheck-engines/index.js +0 -124
- package/bin/runners/lib/engines/vibecheck-engines/lib/ai-hallucination-engine.js +0 -806
- package/bin/runners/lib/engines/vibecheck-engines/lib/hardcoded-secrets-engine.js +0 -439
- package/bin/runners/lib/engines/vibecheck-engines/lib/smart-fix-engine.js +0 -577
- package/bin/runners/lib/engines/vibecheck-engines/lib/vibe-score-engine.js +0 -543
- package/bin/runners/lib/engines/vibecheck-engines/package.json +0 -13
- package/bin/runners/lib/engines/vibecheck-engines.js +0 -514
- package/bin/runners/lib/enhanced-features/index.js +0 -305
- package/bin/runners/lib/enhanced-output.js +0 -631
- package/bin/runners/lib/enterprise.js +0 -300
- package/bin/runners/lib/exit-codes.js +0 -275
- package/bin/runners/lib/fingerprint.js +0 -377
- package/bin/runners/lib/firewall/command-validator.js +0 -351
- package/bin/runners/lib/firewall/config.js +0 -341
- package/bin/runners/lib/firewall/content-validator.js +0 -519
- package/bin/runners/lib/firewall/index.js +0 -101
- package/bin/runners/lib/firewall/path-validator.js +0 -256
- package/bin/runners/lib/help-formatter.js +0 -413
- package/bin/runners/lib/intelligence/cross-repo-intelligence.js +0 -817
- package/bin/runners/lib/logger.js +0 -38
- package/bin/runners/lib/mcp-utils.js +0 -425
- package/bin/runners/lib/output/index.js +0 -1022
- package/bin/runners/lib/policy-engine.js +0 -652
- package/bin/runners/lib/polish/autofix/accessibility-fixes.js +0 -333
- package/bin/runners/lib/polish/autofix/async-handlers.js +0 -273
- package/bin/runners/lib/polish/autofix/dead-code.js +0 -280
- package/bin/runners/lib/polish/autofix/imports-optimizer.js +0 -344
- package/bin/runners/lib/polish/autofix/index.js +0 -200
- package/bin/runners/lib/polish/autofix/remove-consoles.js +0 -209
- package/bin/runners/lib/polish/autofix/strengthen-types.js +0 -245
- package/bin/runners/lib/polish/backend-checks.js +0 -148
- package/bin/runners/lib/polish/documentation-checks.js +0 -111
- package/bin/runners/lib/polish/frontend-checks.js +0 -168
- package/bin/runners/lib/polish/index.js +0 -71
- package/bin/runners/lib/polish/infrastructure-checks.js +0 -131
- package/bin/runners/lib/polish/library-detection.js +0 -175
- package/bin/runners/lib/polish/performance-checks.js +0 -100
- package/bin/runners/lib/polish/security-checks.js +0 -148
- package/bin/runners/lib/polish/utils.js +0 -203
- package/bin/runners/lib/prompt-builder.js +0 -540
- package/bin/runners/lib/proof-certificate.js +0 -634
- package/bin/runners/lib/reality/accessibility-audit.js +0 -946
- package/bin/runners/lib/reality/api-contract-validator.js +0 -1012
- package/bin/runners/lib/reality/chaos-engineering.js +0 -1084
- package/bin/runners/lib/reality/performance-tracker.js +0 -1077
- package/bin/runners/lib/reality/scenario-generator.js +0 -1404
- package/bin/runners/lib/reality/visual-regression.js +0 -852
- package/bin/runners/lib/reality-profiler.js +0 -717
- package/bin/runners/lib/replay/flight-recorder-viewer.js +0 -1160
- package/bin/runners/lib/review/ai-code-review.js +0 -832
- package/bin/runners/lib/rules/custom-rule-engine.js +0 -985
- package/bin/runners/lib/sbom-generator.js +0 -641
- package/bin/runners/lib/scan-output-enhanced.js +0 -512
- package/bin/runners/lib/security/owasp-scanner.js +0 -939
- package/bin/runners/lib/ship-output-enterprise.js +0 -239
- package/bin/runners/lib/unified-cli-output.js +0 -777
- package/bin/runners/lib/validators/contract-validator.js +0 -283
- package/bin/runners/lib/validators/dead-export-detector.js +0 -279
- package/bin/runners/lib/validators/dep-audit.js +0 -245
- package/bin/runners/lib/validators/env-validator.js +0 -319
- package/bin/runners/lib/validators/index.js +0 -120
- package/bin/runners/lib/validators/license-checker.js +0 -252
- package/bin/runners/lib/validators/route-validator.js +0 -290
- package/bin/runners/runAgent.d.ts +0 -5
- package/bin/runners/runAgent.js +0 -164
- package/bin/runners/runApprove.js +0 -1233
- package/bin/runners/runAuthority.js +0 -528
- package/bin/runners/runClassify.js +0 -862
- package/bin/runners/runConductor.js +0 -772
- package/bin/runners/runContainer.js +0 -366
- package/bin/runners/runContext.d.ts +0 -4
- package/bin/runners/runEasy.js +0 -410
- package/bin/runners/runFirewall.d.ts +0 -5
- package/bin/runners/runFirewall.js +0 -137
- package/bin/runners/runFirewallHook.d.ts +0 -5
- package/bin/runners/runFirewallHook.js +0 -59
- package/bin/runners/runIaC.js +0 -372
- package/bin/runners/runPolish.d.ts +0 -4
- package/bin/runners/runProof.zip +0 -0
- package/bin/runners/runTruth.d.ts +0 -5
- package/bin/runners/runTruth.js +0 -104
- package/bin/runners/runVibe.js +0 -791
- package/mcp-server/HARDENING_SUMMARY.md +0 -299
- package/mcp-server/agent-firewall-interceptor.js +0 -500
- package/mcp-server/authority-tools.js +0 -569
- package/mcp-server/conductor/conflict-resolver.js +0 -588
- package/mcp-server/conductor/execution-planner.js +0 -544
- package/mcp-server/conductor/index.js +0 -377
- package/mcp-server/conductor/lock-manager.js +0 -615
- package/mcp-server/conductor/request-queue.js +0 -550
- package/mcp-server/conductor/session-manager.js +0 -500
- package/mcp-server/conductor/tools.js +0 -510
- package/mcp-server/lib/api-client.cjs +0 -13
- package/mcp-server/lib/logger.cjs +0 -30
- package/mcp-server/logger.js +0 -173
- package/mcp-server/tools-v3.js +0 -1039
- package/mcp-server/tools.js +0 -495
- package/mcp-server/vibecheck-mcp-server-3.2.0.tgz +0 -0
package/bin/runners/runGuard.js
CHANGED
|
@@ -1,487 +1,73 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vibecheck guard -
|
|
2
|
+
* vibecheck guard - Unified trust boundary enforcement
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Monitors and blocks AI agent actions based on policy
|
|
6
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
4
|
+
* Combines: validate + claim-verifier + prompt-firewall
|
|
7
5
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* - Forbidden paths (secrets, .env, config files)
|
|
14
|
-
* - Scope violations (writing outside allowed directories)
|
|
15
|
-
* - Dangerous commands (rm -rf, curl | bash)
|
|
16
|
-
* - Hallucination patterns (fake APIs, placeholder data)
|
|
17
|
-
* - Policy violations (custom rules)
|
|
6
|
+
* Usage:
|
|
7
|
+
* vibecheck guard # Run all checks
|
|
8
|
+
* vibecheck guard --claims # Verify AI claims against truthpack
|
|
9
|
+
* vibecheck guard --prompts # Check for prompt injection
|
|
10
|
+
* vibecheck guard --hallucinations # Detect AI hallucination patterns
|
|
18
11
|
*/
|
|
19
12
|
|
|
20
13
|
const path = require("path");
|
|
21
14
|
const fs = require("fs");
|
|
22
|
-
const { parseGlobalFlags, shouldSuppressOutput, isJsonMode } = require("./lib/global-flags");
|
|
23
|
-
const { EXIT } = require("./lib/exit-codes");
|
|
24
|
-
const { tierHasFeature, getCurrentTier } = require("./lib/entitlements-v2");
|
|
25
|
-
const {
|
|
26
|
-
ansi,
|
|
27
|
-
sym,
|
|
28
|
-
renderMinimalHeader,
|
|
29
|
-
renderSectionHeader,
|
|
30
|
-
renderVerdict,
|
|
31
|
-
renderSuccess,
|
|
32
|
-
renderError,
|
|
33
|
-
renderWarning,
|
|
34
|
-
renderInfo,
|
|
35
|
-
renderFooter,
|
|
36
|
-
Spinner,
|
|
37
|
-
getTierFromKey,
|
|
38
|
-
} = require("./lib/unified-cli-output");
|
|
39
|
-
|
|
40
|
-
// Unified Output System
|
|
41
|
-
const { output } = require("./lib/output/index.js");
|
|
42
|
-
|
|
43
|
-
// Import firewall components
|
|
44
|
-
const {
|
|
45
|
-
loadFirewallConfig,
|
|
46
|
-
PathValidator,
|
|
47
|
-
CommandValidator,
|
|
48
|
-
ContentValidator,
|
|
49
|
-
createFirewall,
|
|
50
|
-
initFirewallConfig,
|
|
51
|
-
} = require("./lib/firewall");
|
|
52
|
-
|
|
53
|
-
// Import underlying implementations for legacy support
|
|
54
|
-
let runValidate, runPromptFirewall;
|
|
55
|
-
try {
|
|
56
|
-
runValidate = require("./runValidate").runValidate;
|
|
57
|
-
} catch {
|
|
58
|
-
runValidate = null;
|
|
59
|
-
}
|
|
60
|
-
try {
|
|
61
|
-
runPromptFirewall = require("./runPromptFirewall").runPromptFirewall;
|
|
62
|
-
} catch {
|
|
63
|
-
runPromptFirewall = null;
|
|
64
|
-
}
|
|
65
15
|
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
16
|
+
// Import underlying implementations
|
|
17
|
+
const { runValidate } = require("./runValidate");
|
|
18
|
+
const { runPromptFirewall } = require("./runPromptFirewall");
|
|
19
|
+
|
|
20
|
+
// ANSI colors
|
|
21
|
+
const c = {
|
|
22
|
+
reset: "\x1b[0m",
|
|
23
|
+
dim: "\x1b[2m",
|
|
24
|
+
bold: "\x1b[1m",
|
|
25
|
+
cyan: "\x1b[36m",
|
|
26
|
+
green: "\x1b[32m",
|
|
27
|
+
yellow: "\x1b[33m",
|
|
28
|
+
red: "\x1b[31m",
|
|
29
|
+
magenta: "\x1b[35m",
|
|
30
|
+
};
|
|
69
31
|
|
|
70
32
|
function printHelp() {
|
|
71
33
|
console.log(`
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
${ansi.cyan}--config <path>${ansi.reset} Path to firewall config (default: .vibecheck/firewall.json)
|
|
95
|
-
|
|
96
|
-
${ansi.bold}LEGACY CHECK MODES${ansi.reset}
|
|
97
|
-
${ansi.cyan}--claims${ansi.reset} Verify AI claims against truthpack
|
|
98
|
-
${ansi.cyan}--prompts${ansi.reset} Check code for prompt injection
|
|
99
|
-
${ansi.cyan}--hallucinations${ansi.reset} Detect AI hallucination patterns
|
|
100
|
-
${ansi.dim}(default: run all checks)${ansi.reset}
|
|
101
|
-
|
|
102
|
-
${ansi.bold}OTHER OPTIONS${ansi.reset}
|
|
103
|
-
${ansi.cyan}--init${ansi.reset} Initialize firewall configuration
|
|
104
|
-
${ansi.cyan}--strict${ansi.reset} Fail on warnings (default: fail on errors only)
|
|
105
|
-
${ansi.cyan}--json${ansi.reset} Output as JSON (CI integration)
|
|
106
|
-
${ansi.cyan}--quiet, -q${ansi.reset} Suppress non-essential output
|
|
107
|
-
${ansi.cyan}--help, -h${ansi.reset} Show this help
|
|
108
|
-
|
|
109
|
-
${ansi.bold}EXAMPLES${ansi.reset}
|
|
110
|
-
${ansi.dim}# Initialize firewall configuration${ansi.reset}
|
|
111
|
-
vibecheck guard --init
|
|
112
|
-
|
|
113
|
-
${ansi.dim}# Check if path is allowed (observe mode)${ansi.reset}
|
|
114
|
-
vibecheck guard --mode observe --action write --path .env
|
|
115
|
-
|
|
116
|
-
${ansi.dim}# Block write to sensitive file (enforce mode, PRO)${ansi.reset}
|
|
117
|
-
vibecheck guard --mode enforce --action write --path .env
|
|
118
|
-
|
|
119
|
-
${ansi.dim}# Validate command before execution${ansi.reset}
|
|
120
|
-
vibecheck guard --action execute --command "rm -rf /"
|
|
121
|
-
|
|
122
|
-
${ansi.dim}# Validate content for hallucinations${ansi.reset}
|
|
123
|
-
echo "fetch('https://example.com/api')" | vibecheck guard --action write --path api.js
|
|
124
|
-
|
|
125
|
-
${ansi.dim}# CI pipeline (strict, JSON output)${ansi.reset}
|
|
126
|
-
vibecheck guard --strict --json
|
|
127
|
-
|
|
128
|
-
${ansi.bold}EXIT CODES${ansi.reset}
|
|
129
|
-
0 Action allowed / checks passed
|
|
130
|
-
1 Warnings found (non-blocking)
|
|
131
|
-
2 Action blocked / errors found
|
|
132
|
-
3 Pro feature required
|
|
133
|
-
|
|
134
|
-
${ansi.bold}CONFIGURATION${ansi.reset}
|
|
135
|
-
Configure via ${ansi.cyan}.vibecheck/firewall.json${ansi.reset}:
|
|
136
|
-
{
|
|
137
|
-
"mode": "observe",
|
|
138
|
-
"paths": {
|
|
139
|
-
"forbidden": [".env", "secrets/**"],
|
|
140
|
-
"allowed": ["src/**", "lib/**"]
|
|
141
|
-
},
|
|
142
|
-
"commands": {
|
|
143
|
-
"blocked": ["rm -rf /", "curl | bash"]
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
${ansi.dim}────────────────────────────────────────────────────────────────────${ansi.reset}
|
|
148
|
-
${ansi.dim}Documentation: https://docs.vibecheckai.dev/cli/guard${ansi.reset}
|
|
34
|
+
${c.cyan}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${c.reset}
|
|
35
|
+
${c.bold}vibecheck guard${c.reset} - Trust boundary enforcement for AI outputs
|
|
36
|
+
${c.cyan}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${c.reset}
|
|
37
|
+
|
|
38
|
+
${c.green}USAGE${c.reset}
|
|
39
|
+
vibecheck guard [options]
|
|
40
|
+
|
|
41
|
+
${c.yellow}OPTIONS${c.reset}
|
|
42
|
+
--claims Verify AI claims against truthpack (route_exists, auth_enforced, etc.)
|
|
43
|
+
--prompts Check code for prompt injection vulnerabilities
|
|
44
|
+
--hallucinations Detect AI hallucination patterns in generated code
|
|
45
|
+
--file <path> Check specific file(s)
|
|
46
|
+
--json Output JSON for CI integration
|
|
47
|
+
--strict Fail on warnings (default: fail on errors only)
|
|
48
|
+
|
|
49
|
+
${c.magenta}EXAMPLES${c.reset}
|
|
50
|
+
vibecheck guard # Run all checks
|
|
51
|
+
vibecheck guard --claims --file api.ts # Verify claims in specific file
|
|
52
|
+
vibecheck guard --prompts # Prompt injection scan
|
|
53
|
+
vibecheck guard --json # CI-friendly output
|
|
54
|
+
|
|
55
|
+
${c.dim}This command unifies trust boundary checks for AI-generated code.${c.reset}
|
|
149
56
|
`);
|
|
150
57
|
}
|
|
151
58
|
|
|
152
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
153
|
-
// MAIN GUARD FUNCTION - New Firewall Mode
|
|
154
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Run the firewall validation
|
|
158
|
-
* @param {object} options - Validation options
|
|
159
|
-
* @returns {object} Validation result
|
|
160
|
-
*/
|
|
161
|
-
async function runFirewallCheck(options) {
|
|
162
|
-
const { mode = "observe", action, path: filePath, content, command, configPath } = options;
|
|
163
|
-
|
|
164
|
-
// Enforce mode requires PRO
|
|
165
|
-
if (mode === "enforce") {
|
|
166
|
-
const tier = await getCurrentTier();
|
|
167
|
-
if (!tierHasFeature(tier, "firewall.enforce")) {
|
|
168
|
-
return {
|
|
169
|
-
allowed: true,
|
|
170
|
-
reason: "free-tier-passthrough",
|
|
171
|
-
message: "Enforce mode requires VibeCheck Pro. Running in observe mode.",
|
|
172
|
-
tier,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// Load configuration
|
|
178
|
-
const config = loadFirewallConfig(configPath || ".vibecheck/firewall.json");
|
|
179
|
-
|
|
180
|
-
// Create validators
|
|
181
|
-
const pathValidator = new PathValidator(config);
|
|
182
|
-
const commandValidator = new CommandValidator(config);
|
|
183
|
-
const contentValidator = new ContentValidator(config);
|
|
184
|
-
|
|
185
|
-
const violations = [];
|
|
186
|
-
const warnings = [];
|
|
187
|
-
|
|
188
|
-
// Validate path
|
|
189
|
-
if (filePath && (action === "write" || action === "delete" || !action)) {
|
|
190
|
-
const pathResult = pathValidator.validate({ action: action || "write", path: filePath });
|
|
191
|
-
if (!pathResult.valid) {
|
|
192
|
-
violations.push({
|
|
193
|
-
type: "path",
|
|
194
|
-
...pathResult,
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// Validate command
|
|
200
|
-
if (command && (action === "execute" || !action)) {
|
|
201
|
-
const cmdResult = commandValidator.validate({ command });
|
|
202
|
-
if (!cmdResult.valid) {
|
|
203
|
-
violations.push({
|
|
204
|
-
type: "command",
|
|
205
|
-
...cmdResult,
|
|
206
|
-
});
|
|
207
|
-
} else if (cmdResult.requiresConfirmation) {
|
|
208
|
-
warnings.push({
|
|
209
|
-
type: "command",
|
|
210
|
-
...cmdResult,
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Validate content
|
|
216
|
-
if (content && (action === "write" || !action)) {
|
|
217
|
-
const contentResult = contentValidator.validate({ content, path: filePath });
|
|
218
|
-
if (!contentResult.valid) {
|
|
219
|
-
violations.push({
|
|
220
|
-
type: "content",
|
|
221
|
-
...contentResult,
|
|
222
|
-
});
|
|
223
|
-
} else if (contentResult.hasWarnings) {
|
|
224
|
-
warnings.push(...contentResult.warnings.map(w => ({
|
|
225
|
-
type: "content",
|
|
226
|
-
...w,
|
|
227
|
-
})));
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const hasViolations = violations.length > 0;
|
|
232
|
-
|
|
233
|
-
// Determine if action is allowed based on mode
|
|
234
|
-
let allowed;
|
|
235
|
-
if (mode === "enforce") {
|
|
236
|
-
allowed = !hasViolations;
|
|
237
|
-
} else {
|
|
238
|
-
// Observe mode: always allow, but log violations
|
|
239
|
-
allowed = true;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return {
|
|
243
|
-
allowed,
|
|
244
|
-
mode,
|
|
245
|
-
violations,
|
|
246
|
-
warnings,
|
|
247
|
-
violationCount: violations.length,
|
|
248
|
-
warningCount: warnings.length,
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
253
|
-
// MAIN ENTRY POINT
|
|
254
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
255
|
-
|
|
256
59
|
async function runGuard(args = []) {
|
|
257
|
-
const { flags: globalFlags } = parseGlobalFlags(args);
|
|
258
|
-
const quiet = shouldSuppressOutput(globalFlags);
|
|
259
|
-
const json = isJsonMode(globalFlags) || args.includes("--json");
|
|
260
|
-
const startTime = Date.now();
|
|
261
|
-
|
|
262
60
|
// Parse arguments
|
|
263
|
-
if (
|
|
61
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
264
62
|
printHelp();
|
|
265
|
-
return
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// Check for --init flag
|
|
269
|
-
if (args.includes("--init")) {
|
|
270
|
-
try {
|
|
271
|
-
const configPath = initFirewallConfig(process.cwd());
|
|
272
|
-
if (!quiet && !json) {
|
|
273
|
-
renderSuccess(`Firewall configuration created at ${configPath}`);
|
|
274
|
-
renderInfo("Edit .vibecheck/firewall.json to customize rules");
|
|
275
|
-
}
|
|
276
|
-
if (json) {
|
|
277
|
-
console.log(JSON.stringify({ success: true, configPath }));
|
|
278
|
-
}
|
|
279
|
-
return EXIT.SUCCESS;
|
|
280
|
-
} catch (error) {
|
|
281
|
-
if (json) {
|
|
282
|
-
console.log(JSON.stringify({ success: false, error: error.message }));
|
|
283
|
-
} else {
|
|
284
|
-
renderError(`Failed to initialize firewall: ${error.message}`);
|
|
285
|
-
}
|
|
286
|
-
return EXIT.INTERNAL_ERROR;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// Detect if using new firewall mode (--action, --path, --content, --command)
|
|
291
|
-
const hasAction = args.includes("--action");
|
|
292
|
-
const hasPath = args.includes("--path");
|
|
293
|
-
const hasContent = args.includes("--content");
|
|
294
|
-
const hasCommand = args.includes("--command");
|
|
295
|
-
const hasMode = args.includes("--mode");
|
|
296
|
-
|
|
297
|
-
const isFirewallMode = hasAction || hasPath || hasContent || hasCommand || hasMode;
|
|
298
|
-
|
|
299
|
-
if (isFirewallMode) {
|
|
300
|
-
// New firewall validation mode
|
|
301
|
-
return await runFirewallValidation(args, { quiet, json, startTime });
|
|
302
|
-
} else {
|
|
303
|
-
// Legacy guard mode (claims, prompts, hallucinations)
|
|
304
|
-
return await runLegacyGuard(args, { quiet, json, startTime, globalFlags });
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
309
|
-
// FIREWALL VALIDATION MODE
|
|
310
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
311
|
-
|
|
312
|
-
async function runFirewallValidation(args, { quiet, json, startTime }) {
|
|
313
|
-
// Parse firewall-specific options
|
|
314
|
-
const modeIndex = args.indexOf("--mode");
|
|
315
|
-
const mode = modeIndex !== -1 ? args[modeIndex + 1] : "observe";
|
|
316
|
-
|
|
317
|
-
const actionIndex = args.indexOf("--action");
|
|
318
|
-
const action = actionIndex !== -1 ? args[actionIndex + 1] : null;
|
|
319
|
-
|
|
320
|
-
const pathIndex = args.indexOf("--path");
|
|
321
|
-
const filePath = pathIndex !== -1 ? args[pathIndex + 1] : null;
|
|
322
|
-
|
|
323
|
-
const contentIndex = args.indexOf("--content");
|
|
324
|
-
let content = contentIndex !== -1 ? args[contentIndex + 1] : null;
|
|
325
|
-
|
|
326
|
-
const commandIndex = args.indexOf("--command");
|
|
327
|
-
const command = commandIndex !== -1 ? args[commandIndex + 1] : null;
|
|
328
|
-
|
|
329
|
-
const configIndex = args.indexOf("--config");
|
|
330
|
-
const configPath = configIndex !== -1 ? args[configIndex + 1] : null;
|
|
331
|
-
|
|
332
|
-
// Read content from stdin if not provided
|
|
333
|
-
if (!content && !process.stdin.isTTY) {
|
|
334
|
-
content = await readStdin();
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// Validate mode
|
|
338
|
-
if (mode && !["observe", "enforce"].includes(mode)) {
|
|
339
|
-
if (json) {
|
|
340
|
-
console.log(JSON.stringify({ success: false, error: `Invalid mode: ${mode}` }));
|
|
341
|
-
} else {
|
|
342
|
-
renderError(`Invalid mode: ${mode}. Must be 'observe' or 'enforce'`);
|
|
343
|
-
}
|
|
344
|
-
return EXIT.USER_ERROR;
|
|
63
|
+
return 0;
|
|
345
64
|
}
|
|
346
|
-
|
|
347
|
-
// Validate action
|
|
348
|
-
if (action && !["write", "delete", "execute"].includes(action)) {
|
|
349
|
-
if (json) {
|
|
350
|
-
console.log(JSON.stringify({ success: false, error: `Invalid action: ${action}` }));
|
|
351
|
-
} else {
|
|
352
|
-
renderError(`Invalid action: ${action}. Must be 'write', 'delete', or 'execute'`);
|
|
353
|
-
}
|
|
354
|
-
return EXIT.USER_ERROR;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
try {
|
|
358
|
-
if (!quiet && !json) {
|
|
359
|
-
renderMinimalHeader("guard", "starter");
|
|
360
|
-
renderSectionHeader(`Agent Firewall (${mode} mode)`, sym.shield);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// Run firewall check
|
|
364
|
-
const result = await runFirewallCheck({
|
|
365
|
-
mode,
|
|
366
|
-
action,
|
|
367
|
-
path: filePath,
|
|
368
|
-
content,
|
|
369
|
-
command,
|
|
370
|
-
configPath,
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
const duration = Date.now() - startTime;
|
|
374
|
-
|
|
375
|
-
// Output results
|
|
376
|
-
if (json) {
|
|
377
|
-
console.log(JSON.stringify({
|
|
378
|
-
...result,
|
|
379
|
-
duration,
|
|
380
|
-
success: result.allowed,
|
|
381
|
-
}, null, 2));
|
|
382
|
-
} else if (!quiet) {
|
|
383
|
-
// Display violations
|
|
384
|
-
for (const violation of result.violations) {
|
|
385
|
-
console.log();
|
|
386
|
-
renderError(`${sym.cross} ${violation.rule}: ${violation.message}`);
|
|
387
|
-
if (violation.details) {
|
|
388
|
-
console.log(` ${ansi.dim}Path: ${violation.details.path || violation.details.command || "N/A"}${ansi.reset}`);
|
|
389
|
-
if (violation.details.suggestion) {
|
|
390
|
-
console.log(` ${ansi.cyan}Suggestion: ${violation.details.suggestion}${ansi.reset}`);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
// Display warnings
|
|
396
|
-
for (const warning of result.warnings) {
|
|
397
|
-
console.log();
|
|
398
|
-
renderWarning(`${sym.warn} ${warning.rule || warning.type}: ${warning.message}`);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
console.log();
|
|
402
|
-
|
|
403
|
-
if (result.allowed) {
|
|
404
|
-
if (result.violations.length > 0 && mode === "observe") {
|
|
405
|
-
renderVerdict("WARN", {
|
|
406
|
-
warnings: result.violationCount,
|
|
407
|
-
duration,
|
|
408
|
-
message: `${result.violationCount} violation(s) logged (observe mode - not blocking)`,
|
|
409
|
-
});
|
|
410
|
-
} else {
|
|
411
|
-
renderVerdict("PASS", {
|
|
412
|
-
warnings: result.warningCount,
|
|
413
|
-
duration,
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
} else {
|
|
417
|
-
renderVerdict("BLOCK", {
|
|
418
|
-
critical: result.violationCount,
|
|
419
|
-
duration,
|
|
420
|
-
message: `Action blocked: ${result.violations[0]?.message}`,
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
renderFooter({
|
|
425
|
-
nextSteps: result.allowed ? [
|
|
426
|
-
{ cmd: "vibecheck scan", desc: "run full code analysis" },
|
|
427
|
-
] : [
|
|
428
|
-
{ cmd: "vibecheck guard --mode observe", desc: "run in observe mode" },
|
|
429
|
-
{ cmd: "Edit .vibecheck/firewall.json", desc: "customize firewall rules" },
|
|
430
|
-
],
|
|
431
|
-
docsUrl: "https://docs.vibecheckai.dev/cli/guard",
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
// Return appropriate exit code
|
|
436
|
-
if (!result.allowed) {
|
|
437
|
-
return EXIT.BLOCKING;
|
|
438
|
-
}
|
|
439
|
-
if (result.violationCount > 0 || result.warningCount > 0) {
|
|
440
|
-
return EXIT.WARNINGS;
|
|
441
|
-
}
|
|
442
|
-
return EXIT.SUCCESS;
|
|
443
|
-
|
|
444
|
-
} catch (error) {
|
|
445
|
-
if (json) {
|
|
446
|
-
console.log(JSON.stringify({ success: false, error: error.message }));
|
|
447
|
-
} else {
|
|
448
|
-
renderError(`Firewall check failed: ${error.message}`);
|
|
449
|
-
}
|
|
450
|
-
return EXIT.INTERNAL_ERROR;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
455
|
-
// LEGACY GUARD MODE (Claims, Prompts, Hallucinations)
|
|
456
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
457
65
|
|
|
458
|
-
async function runLegacyGuard(args, { quiet, json, startTime, globalFlags }) {
|
|
459
66
|
const runClaims = args.includes("--claims") || (!args.includes("--prompts") && !args.includes("--hallucinations"));
|
|
460
67
|
const runPrompts = args.includes("--prompts") || (!args.includes("--claims") && !args.includes("--hallucinations"));
|
|
461
68
|
const runHallucinations = args.includes("--hallucinations") || (!args.includes("--claims") && !args.includes("--prompts"));
|
|
69
|
+
const jsonOutput = args.includes("--json");
|
|
462
70
|
const strict = args.includes("--strict");
|
|
463
|
-
|
|
464
|
-
// Validate --file if provided
|
|
465
|
-
const fileIndex = args.indexOf("--file");
|
|
466
|
-
if (fileIndex !== -1) {
|
|
467
|
-
const filePath = args[fileIndex + 1];
|
|
468
|
-
if (!filePath || filePath.startsWith("--")) {
|
|
469
|
-
if (json) {
|
|
470
|
-
console.log(JSON.stringify({ success: false, error: "--file requires a path argument" }));
|
|
471
|
-
} else {
|
|
472
|
-
renderError("--file requires a path argument");
|
|
473
|
-
}
|
|
474
|
-
return EXIT.USER_ERROR;
|
|
475
|
-
}
|
|
476
|
-
if (!fs.existsSync(filePath)) {
|
|
477
|
-
if (json) {
|
|
478
|
-
console.log(JSON.stringify({ success: false, error: `File not found: ${filePath}` }));
|
|
479
|
-
} else {
|
|
480
|
-
renderError(`File not found: ${filePath}`);
|
|
481
|
-
}
|
|
482
|
-
return EXIT.NOT_FOUND;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
71
|
|
|
486
72
|
const results = {
|
|
487
73
|
claims: null,
|
|
@@ -492,164 +78,91 @@ async function runLegacyGuard(args, { quiet, json, startTime, globalFlags }) {
|
|
|
492
78
|
warnings: 0,
|
|
493
79
|
};
|
|
494
80
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
81
|
+
console.log(`
|
|
82
|
+
${c.cyan}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${c.reset}
|
|
83
|
+
${c.bold}🛡️ VIBECHECK GUARD${c.reset} - Trust Boundary Enforcement
|
|
84
|
+
${c.cyan}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${c.reset}
|
|
85
|
+
`);
|
|
500
86
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
const exitCode = await runValidate(validateArgs);
|
|
512
|
-
results.claims = { exitCode, status: exitCode === 0 ? "pass" : "fail" };
|
|
513
|
-
if (exitCode !== 0) {
|
|
514
|
-
results.errors++;
|
|
515
|
-
results.verdict = "FAIL";
|
|
516
|
-
spinner?.fail("Claim verification failed");
|
|
517
|
-
} else {
|
|
518
|
-
spinner?.succeed("Claims verified");
|
|
519
|
-
}
|
|
520
|
-
} catch (e) {
|
|
521
|
-
results.claims = { error: e.message };
|
|
522
|
-
spinner?.warn(`Claims check failed: ${e.message}`);
|
|
523
|
-
}
|
|
87
|
+
// Run claims verification (validates AI claims against truthpack)
|
|
88
|
+
if (runClaims) {
|
|
89
|
+
console.log(`${c.dim}▸ Verifying AI claims against truthpack...${c.reset}`);
|
|
90
|
+
try {
|
|
91
|
+
const validateArgs = args.filter(a => !["--claims", "--prompts", "--hallucinations"].includes(a));
|
|
92
|
+
const exitCode = await runValidate(validateArgs);
|
|
93
|
+
results.claims = { exitCode, status: exitCode === 0 ? "pass" : "fail" };
|
|
94
|
+
if (exitCode !== 0) {
|
|
95
|
+
results.errors++;
|
|
96
|
+
results.verdict = "FAIL";
|
|
524
97
|
}
|
|
98
|
+
console.log(exitCode === 0
|
|
99
|
+
? ` ${c.green}✓${c.reset} Claims verified`
|
|
100
|
+
: ` ${c.red}✗${c.reset} Claim verification failed`);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
results.claims = { error: e.message };
|
|
103
|
+
console.log(` ${c.yellow}⚠${c.reset} Claims check skipped: ${e.message}`);
|
|
525
104
|
}
|
|
105
|
+
}
|
|
526
106
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
const exitCode = await runPromptFirewall(firewallArgs);
|
|
538
|
-
results.prompts = { exitCode, status: exitCode === 0 ? "pass" : "fail" };
|
|
539
|
-
if (exitCode !== 0) {
|
|
540
|
-
results.warnings++;
|
|
541
|
-
if (strict) results.verdict = "FAIL";
|
|
542
|
-
spinner?.warn("Prompt injection risks detected");
|
|
543
|
-
} else {
|
|
544
|
-
spinner?.succeed("No prompt injection risks");
|
|
545
|
-
}
|
|
546
|
-
} catch (e) {
|
|
547
|
-
results.prompts = { error: e.message };
|
|
548
|
-
spinner?.warn(`Prompt check failed: ${e.message}`);
|
|
549
|
-
}
|
|
107
|
+
// Run prompt injection detection
|
|
108
|
+
if (runPrompts) {
|
|
109
|
+
console.log(`${c.dim}▸ Scanning for prompt injection vulnerabilities...${c.reset}`);
|
|
110
|
+
try {
|
|
111
|
+
const firewallArgs = args.filter(a => !["--claims", "--prompts", "--hallucinations"].includes(a));
|
|
112
|
+
const exitCode = await runPromptFirewall(firewallArgs);
|
|
113
|
+
results.prompts = { exitCode, status: exitCode === 0 ? "pass" : "fail" };
|
|
114
|
+
if (exitCode !== 0) {
|
|
115
|
+
results.warnings++;
|
|
116
|
+
if (strict) results.verdict = "FAIL";
|
|
550
117
|
}
|
|
118
|
+
console.log(exitCode === 0
|
|
119
|
+
? ` ${c.green}✓${c.reset} No prompt injection risks`
|
|
120
|
+
: ` ${c.yellow}⚠${c.reset} Prompt injection risks detected`);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
results.prompts = { error: e.message };
|
|
123
|
+
console.log(` ${c.yellow}⚠${c.reset} Prompt check skipped: ${e.message}`);
|
|
551
124
|
}
|
|
125
|
+
}
|
|
552
126
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
results.hallucinations = { exitCode, status: exitCode === 0 ? "pass" : "fail" };
|
|
565
|
-
if (exitCode !== 0) {
|
|
566
|
-
results.warnings++;
|
|
567
|
-
if (strict) results.verdict = "FAIL";
|
|
568
|
-
spinner?.warn("Potential hallucinations detected");
|
|
569
|
-
} else {
|
|
570
|
-
spinner?.succeed("No hallucination patterns");
|
|
571
|
-
}
|
|
572
|
-
} catch (e) {
|
|
573
|
-
results.hallucinations = { error: e.message };
|
|
574
|
-
spinner?.warn(`Hallucination check failed: ${e.message}`);
|
|
575
|
-
}
|
|
127
|
+
// Run hallucination detection
|
|
128
|
+
if (runHallucinations) {
|
|
129
|
+
console.log(`${c.dim}▸ Detecting hallucination patterns...${c.reset}`);
|
|
130
|
+
// Use validate with hallucination focus
|
|
131
|
+
try {
|
|
132
|
+
const validateArgs = ["--hallucinations", ...args.filter(a => !["--claims", "--prompts", "--hallucinations"].includes(a))];
|
|
133
|
+
const exitCode = await runValidate(validateArgs);
|
|
134
|
+
results.hallucinations = { exitCode, status: exitCode === 0 ? "pass" : "fail" };
|
|
135
|
+
if (exitCode !== 0) {
|
|
136
|
+
results.warnings++;
|
|
137
|
+
if (strict) results.verdict = "FAIL";
|
|
576
138
|
}
|
|
139
|
+
console.log(exitCode === 0
|
|
140
|
+
? ` ${c.green}✓${c.reset} No hallucination patterns`
|
|
141
|
+
: ` ${c.yellow}⚠${c.reset} Potential hallucinations detected`);
|
|
142
|
+
} catch (e) {
|
|
143
|
+
results.hallucinations = { error: e.message };
|
|
144
|
+
console.log(` ${c.yellow}⚠${c.reset} Hallucination check skipped: ${e.message}`);
|
|
577
145
|
}
|
|
146
|
+
}
|
|
578
147
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
renderFooter({
|
|
590
|
-
nextSteps: results.verdict === "PASS" ? [
|
|
591
|
-
{ cmd: "vibecheck scan", desc: "run full code analysis" },
|
|
592
|
-
{ cmd: "vibecheck ship", desc: "get ship verdict" },
|
|
593
|
-
] : [
|
|
594
|
-
{ cmd: "vibecheck fix --plan-only", desc: "view fix recommendations" },
|
|
595
|
-
],
|
|
596
|
-
docsUrl: "https://docs.vibecheckai.dev/cli/guard",
|
|
597
|
-
});
|
|
598
|
-
}
|
|
148
|
+
// Summary
|
|
149
|
+
console.log(`
|
|
150
|
+
${c.cyan}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${c.reset}`);
|
|
151
|
+
|
|
152
|
+
if (results.verdict === "PASS") {
|
|
153
|
+
console.log(` ${c.green}${c.bold}✓ GUARD PASS${c.reset} - All trust boundaries intact`);
|
|
154
|
+
} else {
|
|
155
|
+
console.log(` ${c.red}${c.bold}✗ GUARD FAIL${c.reset} - Trust boundary violations detected`);
|
|
156
|
+
}
|
|
599
157
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
}
|
|
158
|
+
console.log(`${c.cyan}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${c.reset}
|
|
159
|
+
`);
|
|
603
160
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
return EXIT.SUCCESS;
|
|
607
|
-
} else if (results.errors > 0) {
|
|
608
|
-
return EXIT.BLOCKING;
|
|
609
|
-
} else {
|
|
610
|
-
return EXIT.WARNINGS;
|
|
611
|
-
}
|
|
612
|
-
} catch (error) {
|
|
613
|
-
if (json) {
|
|
614
|
-
console.log(JSON.stringify({ success: false, error: error.message }));
|
|
615
|
-
} else {
|
|
616
|
-
renderError(`Guard check failed: ${error.message}`);
|
|
617
|
-
}
|
|
618
|
-
return EXIT.INTERNAL_ERROR;
|
|
161
|
+
if (jsonOutput) {
|
|
162
|
+
console.log(JSON.stringify(results, null, 2));
|
|
619
163
|
}
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
623
|
-
// UTILITY FUNCTIONS
|
|
624
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
625
164
|
|
|
626
|
-
|
|
627
|
-
* Read content from stdin
|
|
628
|
-
* @returns {Promise<string>} Stdin content
|
|
629
|
-
*/
|
|
630
|
-
function readStdin() {
|
|
631
|
-
return new Promise((resolve) => {
|
|
632
|
-
let data = "";
|
|
633
|
-
process.stdin.setEncoding("utf8");
|
|
634
|
-
process.stdin.on("readable", () => {
|
|
635
|
-
let chunk;
|
|
636
|
-
while ((chunk = process.stdin.read()) !== null) {
|
|
637
|
-
data += chunk;
|
|
638
|
-
}
|
|
639
|
-
});
|
|
640
|
-
process.stdin.on("end", () => {
|
|
641
|
-
resolve(data);
|
|
642
|
-
});
|
|
643
|
-
// Timeout after 100ms if no data
|
|
644
|
-
setTimeout(() => resolve(data), 100);
|
|
645
|
-
});
|
|
165
|
+
return results.verdict === "PASS" ? 0 : (results.errors > 0 ? 2 : 1);
|
|
646
166
|
}
|
|
647
167
|
|
|
648
|
-
|
|
649
|
-
// EXPORTS
|
|
650
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
651
|
-
|
|
652
|
-
module.exports = {
|
|
653
|
-
runGuard,
|
|
654
|
-
runFirewallCheck,
|
|
655
|
-
};
|
|
168
|
+
module.exports = { runGuard };
|