@neuralaxis/vibedoctor 0.1.1 → 0.1.2
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 +203 -290
- package/dist/adapters/customDeadChain.d.ts +2 -1
- package/dist/adapters/customDeadChain.js +100 -8
- package/dist/adapters/customLeftovers.js +33 -10
- package/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.js +7 -1
- package/dist/adapters/jscpd.d.ts +1 -0
- package/dist/adapters/jscpd.js +10 -1
- package/dist/adapters/presidio.d.ts +2 -0
- package/dist/adapters/presidio.js +158 -0
- package/dist/adapters/privacyDetector.d.ts +10 -0
- package/dist/adapters/privacyDetector.js +600 -0
- package/dist/adapters/telemetryDetector.d.ts +2 -0
- package/dist/adapters/telemetryDetector.js +118 -0
- package/dist/agentPack/generateAgentPack.d.ts +7 -0
- package/dist/agentPack/generateAgentPack.js +89 -1
- package/dist/agentPack/templates/index.js +14 -11
- package/dist/agentPack/templates/skills.js +47 -0
- package/dist/cli/commands/agent.d.ts +5 -0
- package/dist/cli/commands/agent.js +10 -0
- package/dist/cli/commands/init.js +38 -13
- package/dist/cli/commands/privacyReview.d.ts +9 -0
- package/dist/cli/commands/privacyReview.js +304 -0
- package/dist/cli/commands/scan.js +27 -1
- package/dist/cli/commands/setup.js +13 -0
- package/dist/cli/index.js +24 -0
- package/dist/core/config.d.ts +23 -0
- package/dist/core/config.js +114 -5
- package/dist/core/engine.d.ts +3 -0
- package/dist/core/engine.js +31 -9
- package/dist/core/finding.d.ts +16 -2
- package/dist/core/finding.js +5 -0
- package/dist/core/paths.js +5 -0
- package/dist/core/privacyReview.d.ts +51 -0
- package/dist/core/privacyReview.js +94 -0
- package/dist/core/projectDetector.js +6 -1
- package/dist/core/scanPlanner.js +4 -0
- package/dist/core/scoring.js +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/mcp/tools/shared.d.ts +1 -1
- package/dist/reporters/html.js +8 -6
- package/dist/reporters/json.js +3 -5
- package/dist/reporters/markdown.js +7 -0
- package/dist/reporters/sarif.js +6 -0
- package/dist/reporters/terminal.js +1 -5
- package/dist/rules/severityMap.d.ts +1 -0
- package/dist/rules/severityMap.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runPrivacyReviewCommand = runPrivacyReviewCommand;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const shared_1 = require("./shared");
|
|
10
|
+
const engine_1 = require("../../core/engine");
|
|
11
|
+
const paths_1 = require("../../core/paths");
|
|
12
|
+
const privacyReview_1 = require("../../core/privacyReview");
|
|
13
|
+
const VALID_REVIEW_STATES = new Set(["confirmed", "likely", "false_positive", "needs_human_review"]);
|
|
14
|
+
async function loadOrRefreshScan(root, refresh) {
|
|
15
|
+
const { config } = await (0, shared_1.getConfig)(root);
|
|
16
|
+
const reportPath = node_path_1.default.join(root, config.output.json);
|
|
17
|
+
if (!refresh && (await (0, paths_1.pathExists)(reportPath))) {
|
|
18
|
+
const parsed = JSON.parse(await node_fs_1.promises.readFile(reportPath, "utf8"));
|
|
19
|
+
if (Array.isArray(parsed.findings)) {
|
|
20
|
+
const privacyFindings = parsed.privacyFindings ?? parsed.findings.filter((finding) => finding.category === "privacy");
|
|
21
|
+
return {
|
|
22
|
+
...parsed,
|
|
23
|
+
privacyFindings
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const scan = await (0, engine_1.runScan)(root, "full");
|
|
28
|
+
await (0, shared_1.ensureOutputArtifacts)(root, config, scan);
|
|
29
|
+
return scan;
|
|
30
|
+
}
|
|
31
|
+
function needsAiReview(finding) {
|
|
32
|
+
if (finding.category !== "privacy") {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (["confirmed", "likely", "false_positive"].includes(finding.evidence?.reviewState ?? "")) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return finding.evidence?.reviewState === "needs_human_review" || finding.confidence !== "high";
|
|
39
|
+
}
|
|
40
|
+
async function readRawSnippet(root, finding) {
|
|
41
|
+
if (!finding.file || !finding.startLine) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const absolutePath = node_path_1.default.join(root, finding.file);
|
|
45
|
+
const content = await node_fs_1.promises.readFile(absolutePath, "utf8").catch(() => undefined);
|
|
46
|
+
if (!content) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
return content.split(/\r?\n/)[finding.startLine - 1]?.trim();
|
|
50
|
+
}
|
|
51
|
+
async function buildReviewFindings(root, findings, includeRawValues) {
|
|
52
|
+
const payload = [];
|
|
53
|
+
for (const finding of findings.filter(needsAiReview).slice(0, 50)) {
|
|
54
|
+
payload.push({
|
|
55
|
+
id: finding.id,
|
|
56
|
+
title: finding.title,
|
|
57
|
+
file: finding.file,
|
|
58
|
+
startLine: finding.startLine,
|
|
59
|
+
confidence: finding.confidence,
|
|
60
|
+
entityType: finding.evidence?.entityType,
|
|
61
|
+
sensitivity: finding.evidence?.sensitivity,
|
|
62
|
+
maskedValue: finding.evidence?.maskedValue,
|
|
63
|
+
snippet: finding.evidence?.snippet,
|
|
64
|
+
rawSnippet: includeRawValues ? await readRawSnippet(root, finding) : undefined,
|
|
65
|
+
reasons: finding.evidence?.reasons
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return payload;
|
|
69
|
+
}
|
|
70
|
+
function buildPrompt(findings, includeRawValues) {
|
|
71
|
+
return [
|
|
72
|
+
"Review these VibeDoctor Privacy Review findings.",
|
|
73
|
+
"Classify each finding as one of: confirmed, likely, false_positive, needs_human_review.",
|
|
74
|
+
"Return strict JSON with this shape: {\"findings\":[{\"id\":\"...\",\"classification\":\"...\",\"rationale\":\"...\",\"recommended_action\":\"...\"}]}",
|
|
75
|
+
includeRawValues
|
|
76
|
+
? "Raw source snippets may be included because repository config explicitly allowed raw value review."
|
|
77
|
+
: "Only masked snippets are included. Do not ask for raw values unless needed for human review.",
|
|
78
|
+
JSON.stringify({ findings }, null, 2)
|
|
79
|
+
].join("\n\n");
|
|
80
|
+
}
|
|
81
|
+
async function callAiReview(baseUrl, apiKey, model, findings, includeRawValues) {
|
|
82
|
+
const response = await fetch(`${baseUrl.replace(/\/$/, "")}/chat/completions`, {
|
|
83
|
+
method: "POST",
|
|
84
|
+
headers: {
|
|
85
|
+
Authorization: `Bearer ${apiKey}`,
|
|
86
|
+
"Content-Type": "application/json"
|
|
87
|
+
},
|
|
88
|
+
body: JSON.stringify({
|
|
89
|
+
model,
|
|
90
|
+
temperature: 0,
|
|
91
|
+
messages: [
|
|
92
|
+
{
|
|
93
|
+
role: "system",
|
|
94
|
+
content: "You review privacy scanner findings. Be conservative, concise, and return only valid JSON."
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
role: "user",
|
|
98
|
+
content: buildPrompt(findings, includeRawValues)
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
throw new Error(`AI review request failed: ${response.status} ${response.statusText}`);
|
|
105
|
+
}
|
|
106
|
+
const json = (await response.json());
|
|
107
|
+
const content = json.choices?.[0]?.message?.content;
|
|
108
|
+
if (!content) {
|
|
109
|
+
throw new Error("AI review response did not include message content.");
|
|
110
|
+
}
|
|
111
|
+
return content;
|
|
112
|
+
}
|
|
113
|
+
function parseAiJson(content) {
|
|
114
|
+
const trimmed = content.trim();
|
|
115
|
+
const fenced = trimmed.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i)?.[1];
|
|
116
|
+
return JSON.parse(fenced ?? trimmed);
|
|
117
|
+
}
|
|
118
|
+
function normalizeAiState(value) {
|
|
119
|
+
if (typeof value !== "string") {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
const normalized = value.trim().toLowerCase().replaceAll("-", "_");
|
|
123
|
+
return VALID_REVIEW_STATES.has(normalized) ? normalized : undefined;
|
|
124
|
+
}
|
|
125
|
+
function findingFallbackState(finding) {
|
|
126
|
+
if (finding.confidence === "high") {
|
|
127
|
+
return "confirmed";
|
|
128
|
+
}
|
|
129
|
+
return "needs_human_review";
|
|
130
|
+
}
|
|
131
|
+
function defaultRecommendedAction(state, finding) {
|
|
132
|
+
if (state === "false_positive") {
|
|
133
|
+
return "Keep as reviewed false positive unless the source data changes.";
|
|
134
|
+
}
|
|
135
|
+
if (state === "needs_human_review") {
|
|
136
|
+
return "Review with a human before treating this as confirmed personal data.";
|
|
137
|
+
}
|
|
138
|
+
if (finding.evidence?.sensitivity === "regulated_identifier" || finding.evidence?.sensitivity === "high") {
|
|
139
|
+
return "Remove, anonymize, or move this data into a controlled fixture or secret store.";
|
|
140
|
+
}
|
|
141
|
+
return "Verify whether this personal data belongs in the repository and mask it where possible.";
|
|
142
|
+
}
|
|
143
|
+
function buildFallbackDecision(finding, reviewedAt, reviewedBy, rationale) {
|
|
144
|
+
const reviewState = findingFallbackState(finding);
|
|
145
|
+
return {
|
|
146
|
+
id: finding.id,
|
|
147
|
+
title: finding.title,
|
|
148
|
+
file: finding.file,
|
|
149
|
+
startLine: finding.startLine,
|
|
150
|
+
entityType: finding.evidence?.entityType,
|
|
151
|
+
sensitivity: finding.evidence?.sensitivity,
|
|
152
|
+
reviewState,
|
|
153
|
+
reviewedAt,
|
|
154
|
+
reviewedBy,
|
|
155
|
+
rationale: rationale ??
|
|
156
|
+
(reviewState === "confirmed"
|
|
157
|
+
? "High-confidence deterministic Privacy Review finding."
|
|
158
|
+
: "Finding needs human review because deterministic evidence was not high-confidence."),
|
|
159
|
+
recommendedAction: defaultRecommendedAction(reviewState, finding)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function buildAiDecisions(findings, reviewCandidates, content, reviewedAt, reviewedBy) {
|
|
163
|
+
const parsed = parseAiJson(content);
|
|
164
|
+
if (!Array.isArray(parsed.findings)) {
|
|
165
|
+
throw new Error("AI review JSON did not contain a findings array.");
|
|
166
|
+
}
|
|
167
|
+
const candidateIds = new Set(reviewCandidates.map((finding) => finding.id));
|
|
168
|
+
const byId = new Map();
|
|
169
|
+
for (const item of parsed.findings) {
|
|
170
|
+
if (typeof item.id === "string" && candidateIds.has(item.id)) {
|
|
171
|
+
byId.set(item.id, item);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return findings.map((finding) => {
|
|
175
|
+
const ai = byId.get(finding.id);
|
|
176
|
+
if (!ai) {
|
|
177
|
+
return buildFallbackDecision(finding, reviewedAt, reviewedBy);
|
|
178
|
+
}
|
|
179
|
+
const reviewState = normalizeAiState(ai.classification ?? ai.reviewState);
|
|
180
|
+
if (!reviewState) {
|
|
181
|
+
return buildFallbackDecision(finding, reviewedAt, reviewedBy, "AI review returned an unsupported classification.");
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
id: finding.id,
|
|
185
|
+
title: finding.title,
|
|
186
|
+
file: finding.file,
|
|
187
|
+
startLine: finding.startLine,
|
|
188
|
+
entityType: finding.evidence?.entityType,
|
|
189
|
+
sensitivity: finding.evidence?.sensitivity,
|
|
190
|
+
reviewState,
|
|
191
|
+
reviewedAt,
|
|
192
|
+
reviewedBy,
|
|
193
|
+
rationale: typeof ai.rationale === "string" && ai.rationale.trim() ? ai.rationale.trim() : "AI review did not provide a rationale.",
|
|
194
|
+
recommendedAction: typeof (ai.recommendedAction ?? ai.recommended_action) === "string" && String(ai.recommendedAction ?? ai.recommended_action).trim()
|
|
195
|
+
? String(ai.recommendedAction ?? ai.recommended_action).trim()
|
|
196
|
+
: defaultRecommendedAction(reviewState, finding)
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function buildErroredDecisions(findings, reviewedAt, reviewedBy, message) {
|
|
201
|
+
return findings.map((finding) => finding.confidence === "high"
|
|
202
|
+
? buildFallbackDecision(finding, reviewedAt, reviewedBy)
|
|
203
|
+
: buildFallbackDecision(finding, reviewedAt, reviewedBy, message));
|
|
204
|
+
}
|
|
205
|
+
function renderFindingLine(finding) {
|
|
206
|
+
const location = finding.file ? ` (${finding.file}${finding.startLine ? `:${finding.startLine}` : ""})` : "";
|
|
207
|
+
return `- ${finding.title}${location}: ${finding.rationale} Action: ${finding.recommendedAction}`;
|
|
208
|
+
}
|
|
209
|
+
function renderGroup(title, findings) {
|
|
210
|
+
if (findings.length === 0) {
|
|
211
|
+
return [`## ${title}`, "", "- None", ""];
|
|
212
|
+
}
|
|
213
|
+
return [`## ${title}`, "", ...findings.map(renderFindingLine), ""];
|
|
214
|
+
}
|
|
215
|
+
function renderMarkdown(payload) {
|
|
216
|
+
const findings = payload.findings;
|
|
217
|
+
const falsePositives = findings.filter((finding) => finding.reviewState === "false_positive");
|
|
218
|
+
const unresolved = findings.filter((finding) => finding.reviewState === "needs_human_review");
|
|
219
|
+
const confirmedRegulated = findings.filter((finding) => finding.reviewState === "confirmed" && finding.sensitivity === "regulated_identifier");
|
|
220
|
+
const sensitiveAttributes = findings.filter((finding) => finding.sensitivity === "high" && finding.reviewState !== "false_positive");
|
|
221
|
+
const combinationRisk = findings.filter((finding) => finding.sensitivity === "combination_risk" && finding.reviewState !== "false_positive");
|
|
222
|
+
const lines = [
|
|
223
|
+
"# VibeDoctor Privacy Review",
|
|
224
|
+
"",
|
|
225
|
+
`Status: ${payload.status}`,
|
|
226
|
+
`Review file: ${payload.reviewPath}`,
|
|
227
|
+
`Reviewed findings: ${payload.summary.total}`,
|
|
228
|
+
`Needs human review: ${payload.summary.needsHumanReview}`,
|
|
229
|
+
`False positives: ${payload.summary.falsePositive}`,
|
|
230
|
+
""
|
|
231
|
+
];
|
|
232
|
+
if (payload.model) {
|
|
233
|
+
lines.push(`Model: ${payload.model}`, "");
|
|
234
|
+
}
|
|
235
|
+
if (payload.message) {
|
|
236
|
+
lines.push(payload.message, "");
|
|
237
|
+
}
|
|
238
|
+
lines.push(...renderGroup("Confirmed Regulated Identifiers", confirmedRegulated), ...renderGroup("Sensitive Attributes", sensitiveAttributes), ...renderGroup("Combination-Risk Fields", combinationRisk), ...renderGroup("Likely False Positives", falsePositives), ...renderGroup("Unresolved Review Items", unresolved));
|
|
239
|
+
return `${lines.join("\n").trimEnd()}\n`;
|
|
240
|
+
}
|
|
241
|
+
async function runPrivacyReviewCommand(root, options = {}) {
|
|
242
|
+
const { config } = await (0, shared_1.getConfig)(root);
|
|
243
|
+
const scan = await loadOrRefreshScan(root, options.refresh === true);
|
|
244
|
+
const aiConfig = config.checks.privacy.ai;
|
|
245
|
+
const reviewedAt = new Date().toISOString();
|
|
246
|
+
const reviewCandidates = await buildReviewFindings(root, scan.privacyFindings ?? [], aiConfig.includeRawValues);
|
|
247
|
+
const allPrivacyFindings = scan.privacyFindings ?? [];
|
|
248
|
+
let status = reviewCandidates.length > 0 ? "needs_human_review" : "ok";
|
|
249
|
+
let reviewedBy = "privacy-detector";
|
|
250
|
+
let model;
|
|
251
|
+
let message;
|
|
252
|
+
let decisions = allPrivacyFindings.map((finding) => buildFallbackDecision(finding, reviewedAt, reviewedBy));
|
|
253
|
+
let exitCode = 0;
|
|
254
|
+
if (reviewCandidates.length > 0 && aiConfig.enabled) {
|
|
255
|
+
const apiKey = process.env[aiConfig.apiKeyEnv];
|
|
256
|
+
model = process.env[aiConfig.modelEnv];
|
|
257
|
+
const baseUrl = process.env[aiConfig.baseUrlEnv] ?? "https://api.openai.com/v1";
|
|
258
|
+
if (!apiKey || !model) {
|
|
259
|
+
status = "ai_error";
|
|
260
|
+
exitCode = 1;
|
|
261
|
+
message = `Missing AI review configuration. Set ${aiConfig.apiKeyEnv} and ${aiConfig.modelEnv}.`;
|
|
262
|
+
decisions = buildErroredDecisions(allPrivacyFindings, reviewedAt, reviewedBy, message);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
reviewedBy = `privacy-ai-review:${model}`;
|
|
266
|
+
try {
|
|
267
|
+
const content = await callAiReview(baseUrl, apiKey, model, reviewCandidates, aiConfig.includeRawValues);
|
|
268
|
+
decisions = buildAiDecisions(allPrivacyFindings, reviewCandidates, content, reviewedAt, reviewedBy);
|
|
269
|
+
status = decisions.some((finding) => finding.reviewState === "needs_human_review") ? "needs_human_review" : "ok";
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
status = "ai_error";
|
|
273
|
+
exitCode = 1;
|
|
274
|
+
message = error instanceof Error ? error.message : String(error);
|
|
275
|
+
decisions = buildErroredDecisions(allPrivacyFindings, reviewedAt, reviewedBy, message);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
else if (reviewCandidates.length > 0) {
|
|
280
|
+
message = "AI review is disabled. Medium- and low-confidence findings were left as needs_human_review.";
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
message = "No medium- or low-confidence Privacy Review findings need AI review.";
|
|
284
|
+
}
|
|
285
|
+
const artifact = (0, privacyReview_1.buildPrivacyReviewArtifact)({
|
|
286
|
+
generatedAt: reviewedAt,
|
|
287
|
+
reviewedBy,
|
|
288
|
+
model,
|
|
289
|
+
status,
|
|
290
|
+
findings: decisions
|
|
291
|
+
});
|
|
292
|
+
const reviewPath = await (0, privacyReview_1.writePrivacyReview)(root, artifact, config.output.privacyReview);
|
|
293
|
+
const mergedScan = await (0, engine_1.runScan)(root, "full");
|
|
294
|
+
await (0, shared_1.ensureOutputArtifacts)(root, config, mergedScan);
|
|
295
|
+
const payload = {
|
|
296
|
+
...artifact,
|
|
297
|
+
reviewPath,
|
|
298
|
+
message
|
|
299
|
+
};
|
|
300
|
+
return {
|
|
301
|
+
output: options.format === "markdown" ? renderMarkdown(payload) : `${JSON.stringify(payload, null, 2)}\n`,
|
|
302
|
+
exitCode
|
|
303
|
+
};
|
|
304
|
+
}
|
|
@@ -16,6 +16,12 @@ function shouldCountForFailure(isNew, config) {
|
|
|
16
16
|
function isHighSeverity(finding) {
|
|
17
17
|
return finding.severity === "high" || finding.severity === "critical";
|
|
18
18
|
}
|
|
19
|
+
function isHighConfidence(finding) {
|
|
20
|
+
return finding.confidence === "high";
|
|
21
|
+
}
|
|
22
|
+
function isReviewedFalsePositive(finding) {
|
|
23
|
+
return finding.evidence?.reviewState === "false_positive";
|
|
24
|
+
}
|
|
19
25
|
function determineExitCode(scan, config) {
|
|
20
26
|
if (scan.score.overall < config.score.minimum) {
|
|
21
27
|
return 1;
|
|
@@ -36,7 +42,27 @@ function determineExitCode(scan, config) {
|
|
|
36
42
|
const testFailure = config.checks.correctness.enabled &&
|
|
37
43
|
config.checks.correctness.failOnTestFailures &&
|
|
38
44
|
failingFindings.some((finding) => finding.category === "tests" && isHighSeverity(finding));
|
|
39
|
-
|
|
45
|
+
const regulatedIdentifierFailure = config.checks.privacy.enabled &&
|
|
46
|
+
config.checks.privacy.failOnRegulatedIdentifiers &&
|
|
47
|
+
failingFindings.some((finding) => finding.category === "privacy" &&
|
|
48
|
+
isHighConfidence(finding) &&
|
|
49
|
+
!isReviewedFalsePositive(finding) &&
|
|
50
|
+
finding.evidence?.sensitivity === "regulated_identifier");
|
|
51
|
+
const sensitiveAttributeFailure = config.checks.privacy.enabled &&
|
|
52
|
+
config.checks.privacy.failOnSensitiveAttributes &&
|
|
53
|
+
failingFindings.some((finding) => finding.category === "privacy" &&
|
|
54
|
+
isHighConfidence(finding) &&
|
|
55
|
+
!isReviewedFalsePositive(finding) &&
|
|
56
|
+
finding.evidence?.sensitivity === "high");
|
|
57
|
+
return secretFailure ||
|
|
58
|
+
dependencyFailure ||
|
|
59
|
+
missingDependencyFailure ||
|
|
60
|
+
typeFailure ||
|
|
61
|
+
testFailure ||
|
|
62
|
+
regulatedIdentifierFailure ||
|
|
63
|
+
sensitiveAttributeFailure
|
|
64
|
+
? 1
|
|
65
|
+
: 0;
|
|
40
66
|
}
|
|
41
67
|
async function runScanCommand(root, options) {
|
|
42
68
|
const mode = options.changed ? "changed" : options.quick ? "quick" : options.full ? "full" : "default";
|
|
@@ -29,6 +29,12 @@ const essentialTools = [
|
|
|
29
29
|
priority: "essential",
|
|
30
30
|
reason: "Finds large or complex files that need tests before refactor work."
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
id: "privacy-detector",
|
|
34
|
+
ecosystem: "built-in",
|
|
35
|
+
priority: "essential",
|
|
36
|
+
reason: "Finds personal-data and Privacy Review signals without sending data to an external service."
|
|
37
|
+
},
|
|
32
38
|
{
|
|
33
39
|
id: "tsc",
|
|
34
40
|
packageName: "typescript",
|
|
@@ -153,6 +159,13 @@ const recommendedTools = [
|
|
|
153
159
|
priority: "recommended",
|
|
154
160
|
reason: "Additional security and correctness rules.",
|
|
155
161
|
installHint: "Install Semgrep with: pipx install semgrep, uv tool install semgrep, or your OS package manager."
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: "presidio",
|
|
165
|
+
ecosystem: "manual",
|
|
166
|
+
priority: "recommended",
|
|
167
|
+
reason: "Optional external scanner for Privacy Review when checks.privacy.presidio.enabled is true.",
|
|
168
|
+
installHint: "Install in the project Python environment with: python -m pip install presidio-analyzer"
|
|
156
169
|
}
|
|
157
170
|
];
|
|
158
171
|
function hasActiveLanguage(project, language) {
|
package/dist/cli/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const explain_1 = require("./commands/explain");
|
|
|
14
14
|
const fix_1 = require("./commands/fix");
|
|
15
15
|
const init_1 = require("./commands/init");
|
|
16
16
|
const server_1 = require("../mcp/server");
|
|
17
|
+
const privacyReview_1 = require("./commands/privacyReview");
|
|
17
18
|
const report_1 = require("./commands/report");
|
|
18
19
|
const scan_1 = require("./commands/scan");
|
|
19
20
|
const setup_1 = require("./commands/setup");
|
|
@@ -121,6 +122,16 @@ async function main() {
|
|
|
121
122
|
process.stdout.write(await (0, agent_1.runAgentSyncCommand)(process.cwd(), options));
|
|
122
123
|
process.exit(0);
|
|
123
124
|
});
|
|
125
|
+
agent
|
|
126
|
+
.command("plugin")
|
|
127
|
+
.description("Generate installable Codex and Claude plugin bundle files")
|
|
128
|
+
.option("--target <target>", "Single target alias for --targets")
|
|
129
|
+
.option("--targets <targets>", "codex,claude|all", "all")
|
|
130
|
+
.option("--force", "Overwrite generated plugin files")
|
|
131
|
+
.action(async (options) => {
|
|
132
|
+
process.stdout.write(await (0, agent_1.runAgentPluginCommand)(process.cwd(), options));
|
|
133
|
+
process.exit(0);
|
|
134
|
+
});
|
|
124
135
|
agent
|
|
125
136
|
.command("doctor")
|
|
126
137
|
.description("Check whether the agent-pack setup is healthy")
|
|
@@ -165,6 +176,19 @@ async function main() {
|
|
|
165
176
|
process.stdout.write(result.output);
|
|
166
177
|
process.exit(result.exitCode);
|
|
167
178
|
});
|
|
179
|
+
program
|
|
180
|
+
.command("privacy-review")
|
|
181
|
+
.description("Create a structured Privacy Review artifact for Privacy Review findings")
|
|
182
|
+
.option("--refresh", "Refresh the full scan before reviewing")
|
|
183
|
+
.option("--format <format>", "json|markdown", "json")
|
|
184
|
+
.action(async (options) => {
|
|
185
|
+
const result = await (0, privacyReview_1.runPrivacyReviewCommand)(process.cwd(), {
|
|
186
|
+
refresh: options.refresh,
|
|
187
|
+
format: options.format === "markdown" ? "markdown" : "json"
|
|
188
|
+
});
|
|
189
|
+
process.stdout.write(result.output);
|
|
190
|
+
process.exit(result.exitCode);
|
|
191
|
+
});
|
|
168
192
|
program
|
|
169
193
|
.command("mcp")
|
|
170
194
|
.description("Start the VibeDoctor MCP server over stdio")
|
package/dist/core/config.d.ts
CHANGED
|
@@ -56,12 +56,35 @@ export type VibeDoctorConfig = {
|
|
|
56
56
|
failOnMissingDependencies: boolean;
|
|
57
57
|
failOnNewDirectVulnerabilities: boolean;
|
|
58
58
|
};
|
|
59
|
+
privacy: {
|
|
60
|
+
enabled: boolean;
|
|
61
|
+
minConfidenceToReport: "low" | "medium" | "high";
|
|
62
|
+
maskExamples: boolean;
|
|
63
|
+
maxFileBytes: number;
|
|
64
|
+
failOnRegulatedIdentifiers: boolean;
|
|
65
|
+
failOnSensitiveAttributes: boolean;
|
|
66
|
+
detectTelemetryOptOut: boolean;
|
|
67
|
+
detectUnsanitizedLogs: boolean;
|
|
68
|
+
detectApiOverfetching: boolean;
|
|
69
|
+
detectMissingRetention: boolean;
|
|
70
|
+
ai: {
|
|
71
|
+
enabled: boolean;
|
|
72
|
+
apiKeyEnv: string;
|
|
73
|
+
baseUrlEnv: string;
|
|
74
|
+
modelEnv: string;
|
|
75
|
+
includeRawValues: boolean;
|
|
76
|
+
};
|
|
77
|
+
presidio: {
|
|
78
|
+
enabled: boolean;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
59
81
|
};
|
|
60
82
|
output: {
|
|
61
83
|
terminal: boolean;
|
|
62
84
|
json: string;
|
|
63
85
|
html: string;
|
|
64
86
|
agent: string;
|
|
87
|
+
privacyReview: string;
|
|
65
88
|
};
|
|
66
89
|
};
|
|
67
90
|
export declare const defaultConfig: VibeDoctorConfig;
|
package/dist/core/config.js
CHANGED
|
@@ -18,8 +18,27 @@ exports.defaultConfig = {
|
|
|
18
18
|
languages: []
|
|
19
19
|
},
|
|
20
20
|
paths: {
|
|
21
|
-
include: [
|
|
22
|
-
|
|
21
|
+
include: [
|
|
22
|
+
"src/**",
|
|
23
|
+
"app/**",
|
|
24
|
+
"packages/**",
|
|
25
|
+
"services/**",
|
|
26
|
+
"tests/**",
|
|
27
|
+
"*.{js,jsx,ts,tsx,py}",
|
|
28
|
+
"**/*.{js,jsx,ts,tsx,py}",
|
|
29
|
+
"*.prisma",
|
|
30
|
+
"**/*.prisma"
|
|
31
|
+
],
|
|
32
|
+
exclude: [
|
|
33
|
+
...paths_1.DEFAULT_EXCLUDES,
|
|
34
|
+
"test/**",
|
|
35
|
+
"tests/**",
|
|
36
|
+
"**/test/**",
|
|
37
|
+
"**/tests/**",
|
|
38
|
+
"**/*.test.*",
|
|
39
|
+
"**/*.spec.*",
|
|
40
|
+
"**/__tests__/**"
|
|
41
|
+
]
|
|
23
42
|
},
|
|
24
43
|
baseline: {
|
|
25
44
|
enabled: true,
|
|
@@ -67,13 +86,36 @@ exports.defaultConfig = {
|
|
|
67
86
|
enabled: true,
|
|
68
87
|
failOnMissingDependencies: true,
|
|
69
88
|
failOnNewDirectVulnerabilities: true
|
|
89
|
+
},
|
|
90
|
+
privacy: {
|
|
91
|
+
enabled: true,
|
|
92
|
+
minConfidenceToReport: "medium",
|
|
93
|
+
maskExamples: true,
|
|
94
|
+
maxFileBytes: 1_048_576,
|
|
95
|
+
failOnRegulatedIdentifiers: false,
|
|
96
|
+
failOnSensitiveAttributes: false,
|
|
97
|
+
detectTelemetryOptOut: true,
|
|
98
|
+
detectUnsanitizedLogs: true,
|
|
99
|
+
detectApiOverfetching: true,
|
|
100
|
+
detectMissingRetention: true,
|
|
101
|
+
ai: {
|
|
102
|
+
enabled: false,
|
|
103
|
+
apiKeyEnv: "VIBEDOCTOR_AI_API_KEY",
|
|
104
|
+
baseUrlEnv: "VIBEDOCTOR_AI_BASE_URL",
|
|
105
|
+
modelEnv: "VIBEDOCTOR_AI_MODEL",
|
|
106
|
+
includeRawValues: false
|
|
107
|
+
},
|
|
108
|
+
presidio: {
|
|
109
|
+
enabled: false
|
|
110
|
+
}
|
|
70
111
|
}
|
|
71
112
|
},
|
|
72
113
|
output: {
|
|
73
114
|
terminal: true,
|
|
74
115
|
json: ".vibedoctor/report.json",
|
|
75
116
|
html: ".vibedoctor/report.html",
|
|
76
|
-
agent: ".vibedoctor/agent-plan.md"
|
|
117
|
+
agent: ".vibedoctor/agent-plan.md",
|
|
118
|
+
privacyReview: ".vibedoctor/privacy-review.json"
|
|
77
119
|
}
|
|
78
120
|
};
|
|
79
121
|
const CONFIG_FILES = ["vibedoctor.yml", "vibedoctor.yaml", "vibedoctor.json"];
|
|
@@ -107,9 +149,10 @@ async function findConfigFile(root) {
|
|
|
107
149
|
return undefined;
|
|
108
150
|
}
|
|
109
151
|
function normalizeRawConfig(raw) {
|
|
110
|
-
const { baseline: _baseline, checks: _checks, ...rest } = raw;
|
|
152
|
+
const { baseline: _baseline, checks: _checks, output: _output, ...rest } = raw;
|
|
111
153
|
const rawChecks = raw.checks;
|
|
112
154
|
const rawBaseline = raw.baseline;
|
|
155
|
+
const rawOutput = raw.output;
|
|
113
156
|
const rawDeadCode = (rawChecks?.deadCode ?? rawChecks?.dead_code);
|
|
114
157
|
const rawLeftovers = rawChecks?.leftovers;
|
|
115
158
|
const rawRefactor = (rawChecks?.refactorReadiness ?? rawChecks?.refactor_readiness);
|
|
@@ -117,8 +160,24 @@ function normalizeRawConfig(raw) {
|
|
|
117
160
|
const rawCorrectness = rawChecks?.correctness;
|
|
118
161
|
const rawTests = rawChecks?.tests;
|
|
119
162
|
const rawDependencies = rawChecks?.dependencies;
|
|
163
|
+
const rawPrivacy = rawChecks?.privacy;
|
|
164
|
+
const rawPrivacyAi = (rawPrivacy?.ai ?? {});
|
|
165
|
+
const rawPresidio = (rawPrivacy?.presidio ?? {});
|
|
120
166
|
return {
|
|
121
167
|
...rest,
|
|
168
|
+
...(rawOutput
|
|
169
|
+
? {
|
|
170
|
+
output: {
|
|
171
|
+
terminal: rawOutput.terminal ?? exports.defaultConfig.output.terminal,
|
|
172
|
+
json: rawOutput.json ?? exports.defaultConfig.output.json,
|
|
173
|
+
html: rawOutput.html ?? exports.defaultConfig.output.html,
|
|
174
|
+
agent: rawOutput.agent ?? exports.defaultConfig.output.agent,
|
|
175
|
+
privacyReview: rawOutput.privacyReview ??
|
|
176
|
+
rawOutput.privacy_review ??
|
|
177
|
+
exports.defaultConfig.output.privacyReview
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
: {}),
|
|
122
181
|
...(rawBaseline
|
|
123
182
|
? {
|
|
124
183
|
baseline: {
|
|
@@ -218,7 +277,57 @@ function normalizeRawConfig(raw) {
|
|
|
218
277
|
rawDependencies.fail_on_new_direct_vulnerabilities ??
|
|
219
278
|
exports.defaultConfig.checks.dependencies.failOnNewDirectVulnerabilities
|
|
220
279
|
}
|
|
221
|
-
: exports.defaultConfig.checks.dependencies
|
|
280
|
+
: exports.defaultConfig.checks.dependencies,
|
|
281
|
+
privacy: rawPrivacy
|
|
282
|
+
? {
|
|
283
|
+
enabled: rawPrivacy.enabled ?? exports.defaultConfig.checks.privacy.enabled,
|
|
284
|
+
minConfidenceToReport: rawPrivacy.minConfidenceToReport ??
|
|
285
|
+
rawPrivacy.min_confidence_to_report ??
|
|
286
|
+
exports.defaultConfig.checks.privacy.minConfidenceToReport,
|
|
287
|
+
maskExamples: rawPrivacy.maskExamples ??
|
|
288
|
+
rawPrivacy.mask_examples ??
|
|
289
|
+
exports.defaultConfig.checks.privacy.maskExamples,
|
|
290
|
+
maxFileBytes: rawPrivacy.maxFileBytes ??
|
|
291
|
+
rawPrivacy.max_file_bytes ??
|
|
292
|
+
exports.defaultConfig.checks.privacy.maxFileBytes,
|
|
293
|
+
failOnRegulatedIdentifiers: rawPrivacy.failOnRegulatedIdentifiers ??
|
|
294
|
+
rawPrivacy.fail_on_regulated_identifiers ??
|
|
295
|
+
exports.defaultConfig.checks.privacy.failOnRegulatedIdentifiers,
|
|
296
|
+
failOnSensitiveAttributes: rawPrivacy.failOnSensitiveAttributes ??
|
|
297
|
+
rawPrivacy.fail_on_sensitive_attributes ??
|
|
298
|
+
exports.defaultConfig.checks.privacy.failOnSensitiveAttributes,
|
|
299
|
+
detectTelemetryOptOut: rawPrivacy.detectTelemetryOptOut ??
|
|
300
|
+
rawPrivacy.detect_telemetry_opt_out ??
|
|
301
|
+
exports.defaultConfig.checks.privacy.detectTelemetryOptOut,
|
|
302
|
+
detectUnsanitizedLogs: rawPrivacy.detectUnsanitizedLogs ??
|
|
303
|
+
rawPrivacy.detect_unsanitized_logs ??
|
|
304
|
+
exports.defaultConfig.checks.privacy.detectUnsanitizedLogs,
|
|
305
|
+
detectApiOverfetching: rawPrivacy.detectApiOverfetching ??
|
|
306
|
+
rawPrivacy.detect_api_overfetching ??
|
|
307
|
+
exports.defaultConfig.checks.privacy.detectApiOverfetching,
|
|
308
|
+
detectMissingRetention: rawPrivacy.detectMissingRetention ??
|
|
309
|
+
rawPrivacy.detect_missing_retention ??
|
|
310
|
+
exports.defaultConfig.checks.privacy.detectMissingRetention,
|
|
311
|
+
ai: {
|
|
312
|
+
enabled: rawPrivacyAi.enabled ?? exports.defaultConfig.checks.privacy.ai.enabled,
|
|
313
|
+
apiKeyEnv: rawPrivacyAi.apiKeyEnv ??
|
|
314
|
+
rawPrivacyAi.api_key_env ??
|
|
315
|
+
exports.defaultConfig.checks.privacy.ai.apiKeyEnv,
|
|
316
|
+
baseUrlEnv: rawPrivacyAi.baseUrlEnv ??
|
|
317
|
+
rawPrivacyAi.base_url_env ??
|
|
318
|
+
exports.defaultConfig.checks.privacy.ai.baseUrlEnv,
|
|
319
|
+
modelEnv: rawPrivacyAi.modelEnv ??
|
|
320
|
+
rawPrivacyAi.model_env ??
|
|
321
|
+
exports.defaultConfig.checks.privacy.ai.modelEnv,
|
|
322
|
+
includeRawValues: rawPrivacyAi.includeRawValues ??
|
|
323
|
+
rawPrivacyAi.include_raw_values ??
|
|
324
|
+
exports.defaultConfig.checks.privacy.ai.includeRawValues
|
|
325
|
+
},
|
|
326
|
+
presidio: {
|
|
327
|
+
enabled: rawPresidio.enabled ?? exports.defaultConfig.checks.privacy.presidio.enabled
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
: exports.defaultConfig.checks.privacy
|
|
222
331
|
}
|
|
223
332
|
}
|
|
224
333
|
: {})
|
package/dist/core/engine.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type Finding, type FindingCategory } from "./finding";
|
|
|
3
3
|
import { type ScanMode } from "./scanPlanner";
|
|
4
4
|
import { type ScoreBreakdown } from "./scoring";
|
|
5
5
|
import { type ToolResult } from "./toolRunner";
|
|
6
|
+
import { type PrivacyReviewSummary } from "./privacyReview";
|
|
6
7
|
export type AgentPlanTarget = "generic" | "codex" | "copilot" | "claude" | "cursor";
|
|
7
8
|
export type AgentPlanTask = {
|
|
8
9
|
id: string;
|
|
@@ -43,6 +44,8 @@ export type ScanOutput = {
|
|
|
43
44
|
topFindings: Finding[];
|
|
44
45
|
blockers: Finding[];
|
|
45
46
|
fixNext: Finding[];
|
|
47
|
+
privacyFindings: Finding[];
|
|
48
|
+
privacyReview?: PrivacyReviewSummary;
|
|
46
49
|
leftovers: Finding[];
|
|
47
50
|
deadCodeCandidates: Finding[];
|
|
48
51
|
refactorCandidates: Finding[];
|