@yagyeshvyas/vibeguard 0.1.0
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/README.md +600 -0
- package/bin/cli.js +1640 -0
- package/ci/vibeguard.yml +41 -0
- package/ci-templates/Jenkinsfile +26 -0
- package/ci-templates/azure-pipelines.yml +29 -0
- package/ci-templates/circleci.yml +24 -0
- package/ci-templates/gitlab.yml +19 -0
- package/hooks/pre-commit +31 -0
- package/package.json +94 -0
- package/src/ai-guard.js +205 -0
- package/src/ast.js +319 -0
- package/src/audit-trail.js +154 -0
- package/src/autofix.js +524 -0
- package/src/badge.js +42 -0
- package/src/behavior.js +205 -0
- package/src/compliance.js +151 -0
- package/src/crosstaint.js +324 -0
- package/src/cve-intel.js +136 -0
- package/src/dashboard.js +279 -0
- package/src/deps.js +159 -0
- package/src/doctor.js +111 -0
- package/src/engine.js +234 -0
- package/src/external.js +160 -0
- package/src/firewall.js +517 -0
- package/src/history.js +87 -0
- package/src/hook.js +151 -0
- package/src/install.js +248 -0
- package/src/interceptor.js +476 -0
- package/src/mcp-server.js +1804 -0
- package/src/net-audit.js +208 -0
- package/src/pii.js +212 -0
- package/src/plugin.js +80 -0
- package/src/policy-gen.js +288 -0
- package/src/pre-deploy.js +282 -0
- package/src/presets.js +113 -0
- package/src/privacy-audit.js +273 -0
- package/src/repl.js +150 -0
- package/src/report.js +312 -0
- package/src/rules-pack.js +2753 -0
- package/src/rules.js +1446 -0
- package/src/sandbox.js +139 -0
- package/src/scanner.js +651 -0
- package/src/secure-prompt.js +140 -0
- package/src/slopsquat.js +144 -0
- package/src/supply-firewall.js +243 -0
- package/src/suppress.js +89 -0
- package/src/taint.js +168 -0
- package/src/trace.js +220 -0
- package/src/urlscan.js +142 -0
- package/src/vault.js +145 -0
- package/src/verify.js +98 -0
- package/src/verifykeys.js +87 -0
package/ci/vibeguard.yml
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: VibeGuard
|
|
2
|
+
|
|
3
|
+
# Runs VibeGuard on every push and pull request. Fails the job when a CRITICAL
|
|
4
|
+
# issue is found, and uploads a SARIF report to GitHub code scanning so findings
|
|
5
|
+
# show up inline on the PR.
|
|
6
|
+
#
|
|
7
|
+
# Scope reminder: VibeGuard catches high-frequency, well-defined issues (secrets,
|
|
8
|
+
# injection, misconfig). It is not a full security review.
|
|
9
|
+
|
|
10
|
+
on:
|
|
11
|
+
push:
|
|
12
|
+
branches: [main, master]
|
|
13
|
+
pull_request:
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
security-events: write # required to upload SARIF
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
vibeguard:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: 20
|
|
28
|
+
|
|
29
|
+
# Produce a SARIF report for GitHub code scanning (does not fail the job).
|
|
30
|
+
- name: VibeGuard scan (SARIF)
|
|
31
|
+
run: npx -y vibeguard scan . --sarif --no-deps > vibeguard.sarif || true
|
|
32
|
+
|
|
33
|
+
- name: Upload SARIF
|
|
34
|
+
if: always()
|
|
35
|
+
uses: github/codeql-action/upload-sarif@v3
|
|
36
|
+
with:
|
|
37
|
+
sarif_file: vibeguard.sarif
|
|
38
|
+
|
|
39
|
+
# Gate the build: fail only on CRITICAL findings.
|
|
40
|
+
- name: VibeGuard gate (block on CRITICAL)
|
|
41
|
+
run: npx -y vibeguard scan . --precommit
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// VibeGuard Jenkins CI template
|
|
2
|
+
// Generated by 'vibeguard init-ci --jenkins' — add this to your Jenkinsfile
|
|
3
|
+
|
|
4
|
+
pipeline {
|
|
5
|
+
agent {
|
|
6
|
+
docker { image 'node:22' }
|
|
7
|
+
}
|
|
8
|
+
stages {
|
|
9
|
+
stage('Install') {
|
|
10
|
+
steps {
|
|
11
|
+
sh 'npm ci'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
stage('VibeGuard Security Scan') {
|
|
15
|
+
steps {
|
|
16
|
+
sh 'npx -y vibeguard scan . --sarif > vibeguard-report.sarif || true'
|
|
17
|
+
sh 'npx -y vibeguard scan . --fail-on high'
|
|
18
|
+
}
|
|
19
|
+
post {
|
|
20
|
+
always {
|
|
21
|
+
archiveArtifacts artifacts: 'vibeguard-report.sarif', allowEmptyArchive: true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# VibeGuard Azure DevOps Pipeline template
|
|
2
|
+
# Generated by 'vibeguard init-ci --azure' — add this to azure-pipelines.yml
|
|
3
|
+
|
|
4
|
+
trigger:
|
|
5
|
+
branches:
|
|
6
|
+
include:
|
|
7
|
+
- main
|
|
8
|
+
- feature/*
|
|
9
|
+
|
|
10
|
+
pool:
|
|
11
|
+
vmImage: 'ubuntu-latest'
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- task: NodeTool@0
|
|
15
|
+
inputs:
|
|
16
|
+
versionSpec: '22.x'
|
|
17
|
+
displayName: 'Install Node.js'
|
|
18
|
+
|
|
19
|
+
- script: |
|
|
20
|
+
npm ci
|
|
21
|
+
npx -y vibeguard scan . --sarif > $(Build.ArtifactStagingDirectory)/vibeguard-report.sarif || true
|
|
22
|
+
npx -y vibeguard scan . --fail-on high
|
|
23
|
+
displayName: 'VibeGuard Security Scan'
|
|
24
|
+
|
|
25
|
+
- task: PublishBuildArtifacts@1
|
|
26
|
+
inputs:
|
|
27
|
+
PathtoPublish: '$(Build.ArtifactStagingDirectory)/vibeguard-report.sarif'
|
|
28
|
+
ArtifactName: 'VibeGuardReport'
|
|
29
|
+
condition: always()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# VibeGuard CircleCI template
|
|
2
|
+
# Generated by 'vibeguard init-ci --circleci' — add this to .circleci/config.yml
|
|
3
|
+
|
|
4
|
+
version: 2.1
|
|
5
|
+
jobs:
|
|
6
|
+
vibeguard:
|
|
7
|
+
docker:
|
|
8
|
+
- image: cimg/node:22.0
|
|
9
|
+
steps:
|
|
10
|
+
- checkout
|
|
11
|
+
- run: npm ci
|
|
12
|
+
- run:
|
|
13
|
+
name: VibeGuard Security Scan
|
|
14
|
+
command: |
|
|
15
|
+
npx -y vibeguard scan . --sarif > vibeguard-report.sarif || true
|
|
16
|
+
npx -y vibeguard scan . --fail-on high
|
|
17
|
+
- store_artifacts:
|
|
18
|
+
path: vibeguard-report.sarif
|
|
19
|
+
|
|
20
|
+
workflows:
|
|
21
|
+
version: 2
|
|
22
|
+
security:
|
|
23
|
+
jobs:
|
|
24
|
+
- vibeguard
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# VibeGuard GitLab CI template
|
|
2
|
+
# Generated by 'vibeguard init-ci --gitlab' — add this to .gitlab-ci.yml
|
|
3
|
+
|
|
4
|
+
vibeguard:
|
|
5
|
+
stage: test
|
|
6
|
+
image: node:22
|
|
7
|
+
script:
|
|
8
|
+
- npm ci
|
|
9
|
+
- npx -y vibeguard scan . --sarif > vibeguard-report.sarif
|
|
10
|
+
- npx -y vibeguard scan . --fail-on high
|
|
11
|
+
artifacts:
|
|
12
|
+
reports:
|
|
13
|
+
codequality: vibeguard-report.sarif
|
|
14
|
+
paths:
|
|
15
|
+
- vibeguard-report.sarif
|
|
16
|
+
expire_in: 30 days
|
|
17
|
+
rules:
|
|
18
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
19
|
+
- if: $CI_COMMIT_BRANCH == "main"
|
package/hooks/pre-commit
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
#
|
|
3
|
+
# VibeGuard pre-commit hook.
|
|
4
|
+
# Blocks the commit ONLY when a CRITICAL issue is found (secrets, exposed .env,
|
|
5
|
+
# private keys). High/medium/low issues are reported but do not block, so the
|
|
6
|
+
# hook stays out of your way for lower-severity noise.
|
|
7
|
+
#
|
|
8
|
+
# Install: vibeguard install-hook (from your repo root)
|
|
9
|
+
# Bypass: git commit --no-verify (use sparingly, and know why)
|
|
10
|
+
|
|
11
|
+
# Resolve the runner: prefer a locally installed vibeguard, else npx.
|
|
12
|
+
if command -v vibeguard >/dev/null 2>&1; then
|
|
13
|
+
RUN="vibeguard"
|
|
14
|
+
elif [ -f "node_modules/.bin/vibeguard" ]; then
|
|
15
|
+
RUN="node_modules/.bin/vibeguard"
|
|
16
|
+
else
|
|
17
|
+
RUN="npx --no-install vibeguard"
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# --precommit makes the CLI exit non-zero ONLY on CRITICAL findings.
|
|
21
|
+
$RUN scan . --precommit
|
|
22
|
+
STATUS=$?
|
|
23
|
+
|
|
24
|
+
if [ "$STATUS" -eq 2 ]; then
|
|
25
|
+
echo ""
|
|
26
|
+
echo "VibeGuard: commit blocked — CRITICAL security issue(s) found above."
|
|
27
|
+
echo "Fix them, or bypass intentionally with: git commit --no-verify"
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
exit 0
|
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yagyeshvyas/vibeguard",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Free security & privacy scanner for AI-coded apps. 699 rules, 76 MCP tools, 13-layer defense, AI firewall, zero-trust sandbox, jailbreak protection. Runs locally, zero telemetry, $0 cost.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"author": "Yagyesh Vyas <https://www.linkedin.com/in/yagyeshvyas/>",
|
|
8
|
+
"homepage": "https://github.com/yagyeshVyas/VibeGuard",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/yagyeshVyas/VibeGuard.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/yagyeshVyas/VibeGuard/issues"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"vibeguard": "bin/cli.js",
|
|
18
|
+
"vibeguard-mcp": "src/mcp-server.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"bin",
|
|
22
|
+
"src",
|
|
23
|
+
"hooks",
|
|
24
|
+
"ci",
|
|
25
|
+
"ci-templates",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"test": "node test/run.js",
|
|
30
|
+
"scan": "node bin/cli.js scan",
|
|
31
|
+
"lint": "eslint src/ bin/ --ignore-pattern node_modules",
|
|
32
|
+
"coverage": "c8 node test/run.js",
|
|
33
|
+
"prepublishOnly": "node test/run.js"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"security",
|
|
37
|
+
"sast",
|
|
38
|
+
"scanner",
|
|
39
|
+
"secrets",
|
|
40
|
+
"sarif",
|
|
41
|
+
"mcp",
|
|
42
|
+
"claude",
|
|
43
|
+
"cursor",
|
|
44
|
+
"windsurf",
|
|
45
|
+
"codex",
|
|
46
|
+
"vibe-coding",
|
|
47
|
+
"vibecoding",
|
|
48
|
+
"ai-security",
|
|
49
|
+
"prompt-injection",
|
|
50
|
+
"jailbreak",
|
|
51
|
+
"privacy",
|
|
52
|
+
"pii",
|
|
53
|
+
"firewall",
|
|
54
|
+
"sandbox",
|
|
55
|
+
"zero-trust",
|
|
56
|
+
"supply-chain",
|
|
57
|
+
"compliance",
|
|
58
|
+
"gdpr",
|
|
59
|
+
"soc2",
|
|
60
|
+
"hipaa",
|
|
61
|
+
"pre-commit",
|
|
62
|
+
"linter",
|
|
63
|
+
"static-analysis",
|
|
64
|
+
"vulnerability",
|
|
65
|
+
"xss",
|
|
66
|
+
"sql-injection",
|
|
67
|
+
"supabase",
|
|
68
|
+
"firebase",
|
|
69
|
+
"react",
|
|
70
|
+
"nextjs",
|
|
71
|
+
"typescript",
|
|
72
|
+
"python",
|
|
73
|
+
"go",
|
|
74
|
+
"rust"
|
|
75
|
+
],
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=18"
|
|
78
|
+
},
|
|
79
|
+
"publishConfig": {
|
|
80
|
+
"access": "public"
|
|
81
|
+
},
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
84
|
+
},
|
|
85
|
+
"optionalDependencies": {
|
|
86
|
+
"acorn": "^8.17.0",
|
|
87
|
+
"acorn-typescript": "^1.4.13",
|
|
88
|
+
"acorn-walk": "^8.3.5"
|
|
89
|
+
},
|
|
90
|
+
"devDependencies": {
|
|
91
|
+
"c8": "^10.1.3",
|
|
92
|
+
"eslint": "^9.39.5"
|
|
93
|
+
}
|
|
94
|
+
}
|
package/src/ai-guard.js
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* VibeGuard AI Data Guard.
|
|
5
|
+
*
|
|
6
|
+
* Detects when user data (PII, secrets, personal information) is sent to
|
|
7
|
+
* AI/LLM APIs without being redacted or anonymized first.
|
|
8
|
+
*
|
|
9
|
+
* This is the #1 privacy concern with AI agents: they send user data to
|
|
10
|
+
* external AI providers (OpenAI, Anthropic, Google) as part of prompts.
|
|
11
|
+
* VibeGuard catches this and warns before the data leaves your machine.
|
|
12
|
+
*
|
|
13
|
+
* 100% local. Zero network. Zero dependencies.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const { detectPII } = require('./pii');
|
|
19
|
+
|
|
20
|
+
const AI_API_PATTERNS = [
|
|
21
|
+
{ re: /openai\.(?:chat\.completions|completions|embeddings|images|audio)/i, provider: 'OpenAI' },
|
|
22
|
+
{ re: /https?:\/\/api\.openai\.com\/v1\//i, provider: 'OpenAI' },
|
|
23
|
+
{ re: /anthropic\.(?:messages|completions)/i, provider: 'Anthropic' },
|
|
24
|
+
{ re: /https?:\/\/api\.anthropic\.com\/v1\//i, provider: 'Anthropic' },
|
|
25
|
+
{ re: /(?:google\.generativeai|genai|gemini)\.(?:generateContent|generate)/i, provider: 'Google Gemini' },
|
|
26
|
+
{ re: /https?:\/\/generativelanguage\.googleapis\.com/i, provider: 'Google Gemini' },
|
|
27
|
+
{ re: /https?:\/\/api\.cohere\.com/i, provider: 'Cohere' },
|
|
28
|
+
{ re: /https?:\/\/api\.mistral\.ai/i, provider: 'Mistral' },
|
|
29
|
+
{ re: /https?:\/\/api\.together\.xyz/i, provider: 'Together AI' },
|
|
30
|
+
{ re: /https?:\/\/api\.groq\.com/i, provider: 'Groq' },
|
|
31
|
+
{ re: /https?:\/\/api\.perplexity\.ai/i, provider: 'Perplexity' },
|
|
32
|
+
{ re: /https?:\/\/api\.x\.ai/i, provider: 'xAI (Grok)' },
|
|
33
|
+
{ re: /https?:\/\/api\.deepseek\.com/i, provider: 'DeepSeek' },
|
|
34
|
+
{ re: /https?:\/\/api\.replicate\.com/i, provider: 'Replicate' },
|
|
35
|
+
{ re: /fetch\s*\(\s*['"]https?:\/\/api\.(?:openai|anthropic|googleapis|cohere|mistral|together|groq|perplexity|x\.ai|deepseek|replicate)\./i, provider: 'AI API (fetch)' },
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
const USER_DATA_RE = /\b(?:req\.body|req\.query|req\.params|request\.body|request\.query|request\.data|userInput|userText|userMessage|userInput)\b/i;
|
|
39
|
+
const PII_IN_PROMPT_RE = /\b(?:email|phone|ssn|address|password|credit.?card|cvv|dob|name|ip.?address)\b/i;
|
|
40
|
+
const REDACTION_RE = /redact|anonym|mask|scrub|sanitize|detectPII|redactText/i;
|
|
41
|
+
|
|
42
|
+
function auditAIData(dir, files) {
|
|
43
|
+
const findings = [];
|
|
44
|
+
|
|
45
|
+
for (const file of files) {
|
|
46
|
+
let content;
|
|
47
|
+
try { content = fs.readFileSync(file, 'utf8'); } catch { continue; }
|
|
48
|
+
const rel = path.relative(dir, file).split(path.sep).join('/');
|
|
49
|
+
const lines = content.split(/\r?\n/);
|
|
50
|
+
|
|
51
|
+
for (let i = 0; i < lines.length; i++) {
|
|
52
|
+
const line = lines[i];
|
|
53
|
+
|
|
54
|
+
// Check for AI API calls
|
|
55
|
+
for (const pattern of AI_API_PATTERNS) {
|
|
56
|
+
if (!pattern.re.test(line)) continue;
|
|
57
|
+
|
|
58
|
+
// Check nearby lines for user data and PII (within 5 lines)
|
|
59
|
+
const start = Math.max(0, i - 5);
|
|
60
|
+
const end = Math.min(lines.length, i + 6);
|
|
61
|
+
const context = lines.slice(start, end).join('\n');
|
|
62
|
+
|
|
63
|
+
const isUserDataPassed = USER_DATA_RE.test(line) || USER_DATA_RE.test(context);
|
|
64
|
+
const hasPII = PII_IN_PROMPT_RE.test(context);
|
|
65
|
+
const hasRedaction = REDACTION_RE.test(context);
|
|
66
|
+
|
|
67
|
+
if (isUserDataPassed || hasPII) {
|
|
68
|
+
findings.push({
|
|
69
|
+
file: rel,
|
|
70
|
+
line: i + 1,
|
|
71
|
+
provider: pattern.provider,
|
|
72
|
+
severity: hasRedaction ? 'low' : 'high',
|
|
73
|
+
message: hasRedaction
|
|
74
|
+
? `Data sent to ${pattern.provider} — redaction detected nearby (verify it covers all PII)`
|
|
75
|
+
: `User data sent to ${pattern.provider} without redaction — PII may leak to AI provider`,
|
|
76
|
+
fix: hasRedaction
|
|
77
|
+
? 'Verify redaction covers all PII types (email, phone, SSN, credit cards).'
|
|
78
|
+
: 'Redact PII before sending to AI: const { redactText } = require("vibeguard/pii"); const safe = redactText(userInput);',
|
|
79
|
+
hasRedaction,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
break; // Only match one pattern per line
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Also check for raw PII in prompt strings going to AI APIs
|
|
88
|
+
for (const file of files) {
|
|
89
|
+
let content;
|
|
90
|
+
try { content = fs.readFileSync(file, 'utf8'); } catch { continue; }
|
|
91
|
+
const rel = path.relative(dir, file).split(path.sep).join('/');
|
|
92
|
+
const lines = content.split(/\r?\n/);
|
|
93
|
+
|
|
94
|
+
for (let i = 0; i < lines.length; i++) {
|
|
95
|
+
const line = lines[i];
|
|
96
|
+
|
|
97
|
+
// Check for prompt/message strings with PII
|
|
98
|
+
if (/(?:prompt|message|content|input)\s*[:=]\s*[`'"]/.test(line)) {
|
|
99
|
+
const detected = detectPII(line, { types: ['email', 'ssn', 'credit-card', 'phone'] });
|
|
100
|
+
if (detected.length > 0) {
|
|
101
|
+
const context = lines.slice(Math.max(0, i - 3), Math.min(lines.length, i + 4)).join('\n');
|
|
102
|
+
if (/openai|anthropic|gemini|ai\.|llm|model|completion|chat/i.test(context)) {
|
|
103
|
+
findings.push({
|
|
104
|
+
file: rel,
|
|
105
|
+
line: i + 1,
|
|
106
|
+
provider: 'AI (inferred from context)',
|
|
107
|
+
severity: 'critical',
|
|
108
|
+
message: `PII (${detected.map(d => d.type).join(', ')}) detected in prompt/message string going to AI API`,
|
|
109
|
+
fix: 'Redact PII before building the prompt: const { redactText } = require("vibeguard/pii"); prompt = redactText(prompt);',
|
|
110
|
+
hasRedaction: false,
|
|
111
|
+
piiTypes: detected.map(d => d.type),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Deduplicate by file+line
|
|
120
|
+
const seen = new Set();
|
|
121
|
+
const unique = findings.filter(f => {
|
|
122
|
+
const key = `${f.file}:${f.line}`;
|
|
123
|
+
if (seen.has(key)) return false;
|
|
124
|
+
seen.add(key);
|
|
125
|
+
return true;
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
findings: unique,
|
|
130
|
+
summary: {
|
|
131
|
+
totalRisks: unique.length,
|
|
132
|
+
highRisk: unique.filter(f => f.severity === 'high' || f.severity === 'critical').length,
|
|
133
|
+
criticalRisk: unique.filter(f => f.severity === 'critical').length,
|
|
134
|
+
providers: [...new Set(unique.map(f => f.provider))],
|
|
135
|
+
redacted: unique.filter(f => f.hasRedaction).length,
|
|
136
|
+
unredacted: unique.filter(f => !f.hasRedaction).length,
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function renderAIGuardReport(result) {
|
|
142
|
+
const C = {
|
|
143
|
+
red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m',
|
|
144
|
+
cyan: '\x1b[36m', dim: '\x1b[2m', bold: '\x1b[1m', reset: '\x1b[0m',
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const lines = [];
|
|
148
|
+
lines.push(`${C.bold}VibeGuard AI Data Guard${C.reset}`);
|
|
149
|
+
lines.push(`${C.dim}${'─'.repeat(60)}${C.reset}`);
|
|
150
|
+
lines.push('');
|
|
151
|
+
|
|
152
|
+
lines.push(`${C.bold}Summary${C.reset}`);
|
|
153
|
+
lines.push(` Total risks: ${result.summary.totalRisks}`);
|
|
154
|
+
lines.push(` Critical: ${C.red}${result.summary.criticalRisk}${C.reset}`);
|
|
155
|
+
lines.push(` High: ${C.yellow}${result.summary.highRisk - result.summary.criticalRisk}${C.reset}`);
|
|
156
|
+
lines.push(` Redacted (ok): ${C.green}${result.summary.redacted}${C.reset}`);
|
|
157
|
+
lines.push(` Unredacted (risk): ${C.red}${result.summary.unredacted}${C.reset}`);
|
|
158
|
+
if (result.summary.providers.length > 0) {
|
|
159
|
+
lines.push(` AI providers: ${result.summary.providers.join(', ')}`);
|
|
160
|
+
}
|
|
161
|
+
lines.push('');
|
|
162
|
+
|
|
163
|
+
if (result.findings.length === 0) {
|
|
164
|
+
lines.push(` ${C.green}No user data sent to AI APIs without redaction${C.reset}`);
|
|
165
|
+
lines.push('');
|
|
166
|
+
return lines.join('\n');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const critical = result.findings.filter(f => f.severity === 'critical');
|
|
170
|
+
const high = result.findings.filter(f => f.severity === 'high');
|
|
171
|
+
const low = result.findings.filter(f => f.severity === 'low');
|
|
172
|
+
|
|
173
|
+
if (critical.length > 0) {
|
|
174
|
+
lines.push(`${C.red}${C.bold}Critical — PII in AI prompts${C.reset}`);
|
|
175
|
+
for (const f of critical) {
|
|
176
|
+
lines.push(` ${C.red}[CRITICAL]${C.reset} ${f.provider} — ${f.file}:${f.line}`);
|
|
177
|
+
lines.push(` ${f.message}`);
|
|
178
|
+
lines.push(` ${C.green}fix:${C.reset} ${f.fix}`);
|
|
179
|
+
lines.push('');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (high.length > 0) {
|
|
184
|
+
lines.push(`${C.yellow}${C.bold}High — User data to AI without redaction${C.reset}`);
|
|
185
|
+
for (const f of high) {
|
|
186
|
+
lines.push(` ${C.yellow}[HIGH]${C.reset} ${f.provider} — ${f.file}:${f.line}`);
|
|
187
|
+
lines.push(` ${f.message}`);
|
|
188
|
+
lines.push(` ${C.green}fix:${C.reset} ${f.fix}`);
|
|
189
|
+
lines.push('');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (low.length > 0) {
|
|
194
|
+
lines.push(`${C.dim}Redacted (verify coverage)${C.reset}`);
|
|
195
|
+
for (const f of low.slice(0, 5)) {
|
|
196
|
+
lines.push(` ${C.dim}[LOW]${C.reset} ${f.provider} — ${f.file}:${f.line}`);
|
|
197
|
+
lines.push(` ${f.message}`);
|
|
198
|
+
lines.push('');
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return lines.join('\n');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
module.exports = { auditAIData, renderAIGuardReport, AI_API_PATTERNS };
|