@neuralaxis/vibedoctor 0.1.0 → 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 -280
- 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 +49 -9
- package/dist/cli/index.js +63 -7
- 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/core/toolRunner.js +25 -4
- 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 +3 -2
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[];
|
package/dist/core/engine.js
CHANGED
|
@@ -9,8 +9,10 @@ exports.createBaseline = createBaseline;
|
|
|
9
9
|
exports.safeFix = safeFix;
|
|
10
10
|
const adapters_1 = require("../adapters");
|
|
11
11
|
const customLeftovers_1 = require("../adapters/customLeftovers");
|
|
12
|
+
const privacyDetector_1 = require("../adapters/privacyDetector");
|
|
12
13
|
const customRefactor_1 = require("../adapters/customRefactor");
|
|
13
14
|
const customDeadChain_1 = require("../adapters/customDeadChain");
|
|
15
|
+
const presidio_1 = require("../adapters/presidio");
|
|
14
16
|
const policy_1 = require("../agentPack/policy");
|
|
15
17
|
const baseline_1 = require("./baseline");
|
|
16
18
|
const config_1 = require("./config");
|
|
@@ -20,6 +22,7 @@ const scanPlanner_1 = require("./scanPlanner");
|
|
|
20
22
|
const scoring_1 = require("./scoring");
|
|
21
23
|
const toolRunner_1 = require("./toolRunner");
|
|
22
24
|
const severityMap_1 = require("../rules/severityMap");
|
|
25
|
+
const privacyReview_1 = require("./privacyReview");
|
|
23
26
|
const ALL_ADAPTERS = [
|
|
24
27
|
adapters_1.gitleaksAdapter,
|
|
25
28
|
adapters_1.osvScannerAdapter,
|
|
@@ -37,6 +40,9 @@ const ALL_ADAPTERS = [
|
|
|
37
40
|
adapters_1.coveragePyAdapter,
|
|
38
41
|
adapters_1.vitestAdapter,
|
|
39
42
|
adapters_1.jestAdapter,
|
|
43
|
+
privacyDetector_1.privacyDetectorAdapter,
|
|
44
|
+
presidio_1.presidioAdapter,
|
|
45
|
+
adapters_1.telemetryDetectorAdapter,
|
|
40
46
|
customLeftovers_1.customLeftoversAdapter,
|
|
41
47
|
customRefactor_1.customRefactorAdapter
|
|
42
48
|
];
|
|
@@ -45,11 +51,12 @@ const categoryPriority = {
|
|
|
45
51
|
tests: 1,
|
|
46
52
|
correctness: 2,
|
|
47
53
|
dependencies: 3,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
privacy: 4,
|
|
55
|
+
dead_code: 5,
|
|
56
|
+
leftovers: 6,
|
|
57
|
+
refactor_readiness: 7,
|
|
58
|
+
maintainability: 8,
|
|
59
|
+
efficiency: 9
|
|
53
60
|
};
|
|
54
61
|
function sortFindings(findings) {
|
|
55
62
|
return [...findings].sort((left, right) => {
|
|
@@ -82,7 +89,8 @@ function sortFindings(findings) {
|
|
|
82
89
|
function summarizeFindings(findings) {
|
|
83
90
|
const ordered = sortFindings(findings);
|
|
84
91
|
const blockers = ordered.filter((finding) => severityMap_1.severityRank[finding.severity] >= severityMap_1.severityRank.high);
|
|
85
|
-
const fixNext = ordered.filter((finding) => finding.category !== "leftovers").slice(0, 3);
|
|
92
|
+
const fixNext = ordered.filter((finding) => finding.category !== "leftovers" && finding.category !== "privacy").slice(0, 3);
|
|
93
|
+
const privacyFindings = ordered.filter((finding) => finding.category === "privacy");
|
|
86
94
|
const leftovers = ordered.filter((finding) => finding.category === "leftovers");
|
|
87
95
|
const deadCodeCandidates = ordered.filter((finding) => finding.category === "dead_code");
|
|
88
96
|
const refactorCandidates = ordered.filter((finding) => finding.category === "refactor_readiness");
|
|
@@ -91,6 +99,7 @@ function summarizeFindings(findings) {
|
|
|
91
99
|
ordered,
|
|
92
100
|
blockers,
|
|
93
101
|
fixNext,
|
|
102
|
+
privacyFindings,
|
|
94
103
|
leftovers,
|
|
95
104
|
deadCodeCandidates,
|
|
96
105
|
refactorCandidates,
|
|
@@ -203,6 +212,8 @@ function buildScanOutput(options) {
|
|
|
203
212
|
topFindings: summary.topFindings,
|
|
204
213
|
blockers: summary.blockers,
|
|
205
214
|
fixNext: summary.fixNext,
|
|
215
|
+
privacyFindings: summary.privacyFindings,
|
|
216
|
+
privacyReview: options.privacyReview,
|
|
206
217
|
leftovers: summary.leftovers,
|
|
207
218
|
deadCodeCandidates: summary.deadCodeCandidates,
|
|
208
219
|
refactorCandidates: summary.refactorCandidates,
|
|
@@ -313,7 +324,7 @@ async function runScan(root, mode = "default") {
|
|
|
313
324
|
}
|
|
314
325
|
let deadChainFindings = [];
|
|
315
326
|
if (config.checks.deadCode.enabled) {
|
|
316
|
-
const rawDead = await (0, customDeadChain_1.detectDeadChains)(project, findings);
|
|
327
|
+
const rawDead = await (0, customDeadChain_1.detectDeadChains)(project, findings, config);
|
|
317
328
|
const minConf = config.checks.deadCode.minConfidenceToReport;
|
|
318
329
|
const rank = { low: 0, medium: 1, high: 2 };
|
|
319
330
|
const minRank = rank[minConf];
|
|
@@ -324,6 +335,8 @@ async function runScan(root, mode = "default") {
|
|
|
324
335
|
const baseline = await (0, baseline_1.loadBaseline)(root, config.baseline.file);
|
|
325
336
|
allFindings = (0, finding_1.applyBaseline)(allFindings, new Set(baseline.findings.map((entry) => entry.fingerprint)));
|
|
326
337
|
}
|
|
338
|
+
const privacyReview = await (0, privacyReview_1.loadPrivacyReview)(root, config.output.privacyReview);
|
|
339
|
+
allFindings = (0, privacyReview_1.mergePrivacyReviewIntoFindings)(allFindings, privacyReview);
|
|
327
340
|
allFindings = sortFindings(allFindings);
|
|
328
341
|
const score = (0, scoring_1.buildScore)(allFindings);
|
|
329
342
|
return buildScanOutput({
|
|
@@ -335,7 +348,8 @@ async function runScan(root, mode = "default") {
|
|
|
335
348
|
skippedTools,
|
|
336
349
|
testCommands: project.testCommands,
|
|
337
350
|
policy,
|
|
338
|
-
configPath
|
|
351
|
+
configPath,
|
|
352
|
+
privacyReview: privacyReview?.summary
|
|
339
353
|
});
|
|
340
354
|
}
|
|
341
355
|
function filterScanByCategories(scan, categories, options = {}) {
|
|
@@ -351,13 +365,15 @@ function filterScanByCategories(scan, categories, options = {}) {
|
|
|
351
365
|
testCommands: scan.testCommands,
|
|
352
366
|
policy: options.policy,
|
|
353
367
|
target: options.target ?? scan.agentPlan.target,
|
|
354
|
-
configPath: scan.configPath
|
|
368
|
+
configPath: scan.configPath,
|
|
369
|
+
privacyReview: scan.privacyReview
|
|
355
370
|
});
|
|
356
371
|
}
|
|
357
372
|
function buildSummaryLines(scan) {
|
|
358
373
|
const lines = [`Health: ${scan.score.overall}/100 ${scan.score.overall >= 85 ? "✅" : "⚠️"}`, ""];
|
|
359
374
|
lines.push(`Blockers: ${scan.blockers.length}`);
|
|
360
375
|
lines.push(`Fix next: ${scan.fixNext.length}`);
|
|
376
|
+
lines.push(`Privacy Review findings: ${scan.privacyFindings.length}`);
|
|
361
377
|
lines.push(`Leftovers: ${scan.leftovers.length}`);
|
|
362
378
|
lines.push(`Dead code candidates: ${scan.deadCodeCandidates.length}`);
|
|
363
379
|
lines.push(`Refactor candidates: ${scan.refactorCandidates.length}`);
|
|
@@ -369,6 +385,12 @@ function buildSummaryLines(scan) {
|
|
|
369
385
|
lines.push("", "FIX NEXT");
|
|
370
386
|
scan.fixNext.forEach((finding, index) => lines.push(`${index + 1}. ${finding.title}${finding.file ? ` (${finding.file})` : ""}`));
|
|
371
387
|
}
|
|
388
|
+
if (scan.privacyFindings.length > 0) {
|
|
389
|
+
lines.push("", "PRIVACY REVIEW FINDINGS");
|
|
390
|
+
scan.privacyFindings
|
|
391
|
+
.slice(0, 5)
|
|
392
|
+
.forEach((finding, index) => lines.push(`${index + 1}. ${finding.title}${finding.file ? ` (${finding.file}${finding.startLine ? `:${finding.startLine}` : ""})` : ""}`));
|
|
393
|
+
}
|
|
372
394
|
if (scan.leftovers.length > 0) {
|
|
373
395
|
lines.push("", "LEFTOVERS");
|
|
374
396
|
scan.leftovers.forEach((finding, index) => lines.push(`${index + 1}. ${finding.title}${finding.file ? ` (${finding.file})` : ""}`));
|
package/dist/core/finding.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const FINDING_SOURCES: readonly ["ruff", "biome", "tsc", "pyright", "semgrep", "gitleaks", "osv-scanner", "knip", "vulture", "deptry", "jscpd", "lizard", "radon", "coverage.py", "vitest", "jest", "custom-leftovers", "custom-refactor", "custom-dead-chain"];
|
|
2
|
-
export declare const FINDING_CATEGORIES: readonly ["security", "correctness", "dead_code", "leftovers", "maintainability", "dependencies", "tests", "efficiency", "refactor_readiness"];
|
|
1
|
+
export declare const FINDING_SOURCES: readonly ["ruff", "biome", "tsc", "pyright", "semgrep", "gitleaks", "osv-scanner", "knip", "vulture", "deptry", "jscpd", "lizard", "radon", "coverage.py", "vitest", "jest", "privacy-detector", "presidio", "privacy-ai-review", "telemetry-detector", "custom-leftovers", "custom-refactor", "custom-dead-chain"];
|
|
2
|
+
export declare const FINDING_CATEGORIES: readonly ["security", "correctness", "dead_code", "leftovers", "maintainability", "dependencies", "tests", "privacy", "efficiency", "refactor_readiness"];
|
|
3
3
|
export type FindingSource = (typeof FINDING_SOURCES)[number];
|
|
4
4
|
export type FindingCategory = (typeof FINDING_CATEGORIES)[number];
|
|
5
5
|
export type Severity = "info" | "low" | "medium" | "high" | "critical";
|
|
@@ -25,6 +25,20 @@ export type Finding = {
|
|
|
25
25
|
snippet?: string;
|
|
26
26
|
toolRawId?: string;
|
|
27
27
|
matchedPattern?: string;
|
|
28
|
+
detector?: string;
|
|
29
|
+
entityType?: string;
|
|
30
|
+
sensitivity?: string;
|
|
31
|
+
maskedValue?: string;
|
|
32
|
+
fieldPath?: string;
|
|
33
|
+
detectionPath?: string;
|
|
34
|
+
confidenceScore?: number;
|
|
35
|
+
coverageConfidence?: number;
|
|
36
|
+
reviewState?: "confirmed" | "likely" | "false_positive" | "needs_human_review";
|
|
37
|
+
reviewedAt?: string;
|
|
38
|
+
reviewedBy?: string;
|
|
39
|
+
rationale?: string;
|
|
40
|
+
recommendedAction?: string;
|
|
41
|
+
reasons?: string[];
|
|
28
42
|
};
|
|
29
43
|
scoreImpact: number;
|
|
30
44
|
};
|
package/dist/core/finding.js
CHANGED
|
@@ -30,6 +30,10 @@ exports.FINDING_SOURCES = [
|
|
|
30
30
|
"coverage.py",
|
|
31
31
|
"vitest",
|
|
32
32
|
"jest",
|
|
33
|
+
"privacy-detector",
|
|
34
|
+
"presidio",
|
|
35
|
+
"privacy-ai-review",
|
|
36
|
+
"telemetry-detector",
|
|
33
37
|
"custom-leftovers",
|
|
34
38
|
"custom-refactor",
|
|
35
39
|
"custom-dead-chain"
|
|
@@ -42,6 +46,7 @@ exports.FINDING_CATEGORIES = [
|
|
|
42
46
|
"maintainability",
|
|
43
47
|
"dependencies",
|
|
44
48
|
"tests",
|
|
49
|
+
"privacy",
|
|
45
50
|
"efficiency",
|
|
46
51
|
"refactor_readiness"
|
|
47
52
|
];
|
package/dist/core/paths.js
CHANGED
|
@@ -23,7 +23,12 @@ exports.DEFAULT_EXCLUDES = [
|
|
|
23
23
|
"**/.venv/**",
|
|
24
24
|
"coverage/**",
|
|
25
25
|
".next/**",
|
|
26
|
+
"**/.next/**",
|
|
26
27
|
"vendor/**",
|
|
28
|
+
".agents/**",
|
|
29
|
+
"**/.agents/**",
|
|
30
|
+
".vibedoctor/**",
|
|
31
|
+
"**/.vibedoctor/**",
|
|
27
32
|
".git/**",
|
|
28
33
|
"**/__pycache__/**",
|
|
29
34
|
"**/*.egg-info/**"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Finding } from "./finding";
|
|
2
|
+
export type PrivacyReviewState = "confirmed" | "likely" | "false_positive" | "needs_human_review";
|
|
3
|
+
export type PrivacyReviewStatus = "ok" | "needs_human_review" | "ai_error";
|
|
4
|
+
export type PrivacyReviewFinding = {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
file?: string;
|
|
8
|
+
startLine?: number;
|
|
9
|
+
entityType?: string;
|
|
10
|
+
sensitivity?: string;
|
|
11
|
+
reviewState: PrivacyReviewState;
|
|
12
|
+
reviewedAt: string;
|
|
13
|
+
reviewedBy: string;
|
|
14
|
+
rationale: string;
|
|
15
|
+
recommendedAction: string;
|
|
16
|
+
};
|
|
17
|
+
export type PrivacyReviewSummary = {
|
|
18
|
+
total: number;
|
|
19
|
+
confirmed: number;
|
|
20
|
+
likely: number;
|
|
21
|
+
falsePositive: number;
|
|
22
|
+
needsHumanReview: number;
|
|
23
|
+
regulatedIdentifiers: number;
|
|
24
|
+
sensitiveAttributes: number;
|
|
25
|
+
combinationRisk: number;
|
|
26
|
+
generatedAt?: string;
|
|
27
|
+
reviewedBy?: string;
|
|
28
|
+
model?: string;
|
|
29
|
+
status?: PrivacyReviewStatus;
|
|
30
|
+
};
|
|
31
|
+
export type PrivacyReviewArtifact = {
|
|
32
|
+
version: 1;
|
|
33
|
+
generatedAt: string;
|
|
34
|
+
reviewedBy: string;
|
|
35
|
+
model?: string;
|
|
36
|
+
status: PrivacyReviewStatus;
|
|
37
|
+
summary: PrivacyReviewSummary;
|
|
38
|
+
findings: PrivacyReviewFinding[];
|
|
39
|
+
};
|
|
40
|
+
export declare const DEFAULT_PRIVACY_REVIEW_FILE = ".vibedoctor/privacy-review.json";
|
|
41
|
+
export declare function summarizePrivacyReview(findings: PrivacyReviewFinding[], metadata: Pick<PrivacyReviewArtifact, "generatedAt" | "reviewedBy" | "model" | "status">): PrivacyReviewSummary;
|
|
42
|
+
export declare function buildPrivacyReviewArtifact(options: {
|
|
43
|
+
generatedAt: string;
|
|
44
|
+
reviewedBy: string;
|
|
45
|
+
model?: string;
|
|
46
|
+
status: PrivacyReviewStatus;
|
|
47
|
+
findings: PrivacyReviewFinding[];
|
|
48
|
+
}): PrivacyReviewArtifact;
|
|
49
|
+
export declare function loadPrivacyReview(root: string, reviewFile?: string): Promise<PrivacyReviewArtifact | undefined>;
|
|
50
|
+
export declare function writePrivacyReview(root: string, artifact: PrivacyReviewArtifact, reviewFile?: string): Promise<string>;
|
|
51
|
+
export declare function mergePrivacyReviewIntoFindings(findings: Finding[], artifact: PrivacyReviewArtifact | undefined): Finding[];
|
|
@@ -0,0 +1,94 @@
|
|
|
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.DEFAULT_PRIVACY_REVIEW_FILE = void 0;
|
|
7
|
+
exports.summarizePrivacyReview = summarizePrivacyReview;
|
|
8
|
+
exports.buildPrivacyReviewArtifact = buildPrivacyReviewArtifact;
|
|
9
|
+
exports.loadPrivacyReview = loadPrivacyReview;
|
|
10
|
+
exports.writePrivacyReview = writePrivacyReview;
|
|
11
|
+
exports.mergePrivacyReviewIntoFindings = mergePrivacyReviewIntoFindings;
|
|
12
|
+
const node_fs_1 = require("node:fs");
|
|
13
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
+
const paths_1 = require("./paths");
|
|
15
|
+
exports.DEFAULT_PRIVACY_REVIEW_FILE = ".vibedoctor/privacy-review.json";
|
|
16
|
+
function toAbsolutePath(root, reviewFile) {
|
|
17
|
+
return node_path_1.default.isAbsolute(reviewFile) ? reviewFile : node_path_1.default.join(root, reviewFile);
|
|
18
|
+
}
|
|
19
|
+
function summarizePrivacyReview(findings, metadata) {
|
|
20
|
+
return {
|
|
21
|
+
total: findings.length,
|
|
22
|
+
confirmed: findings.filter((finding) => finding.reviewState === "confirmed").length,
|
|
23
|
+
likely: findings.filter((finding) => finding.reviewState === "likely").length,
|
|
24
|
+
falsePositive: findings.filter((finding) => finding.reviewState === "false_positive").length,
|
|
25
|
+
needsHumanReview: findings.filter((finding) => finding.reviewState === "needs_human_review").length,
|
|
26
|
+
regulatedIdentifiers: findings.filter((finding) => finding.sensitivity === "regulated_identifier").length,
|
|
27
|
+
sensitiveAttributes: findings.filter((finding) => finding.sensitivity === "high").length,
|
|
28
|
+
combinationRisk: findings.filter((finding) => finding.sensitivity === "combination_risk").length,
|
|
29
|
+
generatedAt: metadata.generatedAt,
|
|
30
|
+
reviewedBy: metadata.reviewedBy,
|
|
31
|
+
model: metadata.model,
|
|
32
|
+
status: metadata.status
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function buildPrivacyReviewArtifact(options) {
|
|
36
|
+
return {
|
|
37
|
+
version: 1,
|
|
38
|
+
generatedAt: options.generatedAt,
|
|
39
|
+
reviewedBy: options.reviewedBy,
|
|
40
|
+
model: options.model,
|
|
41
|
+
status: options.status,
|
|
42
|
+
findings: options.findings,
|
|
43
|
+
summary: summarizePrivacyReview(options.findings, options)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async function loadPrivacyReview(root, reviewFile = exports.DEFAULT_PRIVACY_REVIEW_FILE) {
|
|
47
|
+
const reviewPath = toAbsolutePath(root, reviewFile);
|
|
48
|
+
if (!(await (0, paths_1.pathExists)(reviewPath))) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const parsed = JSON.parse(await node_fs_1.promises.readFile(reviewPath, "utf8"));
|
|
52
|
+
if (parsed.version !== 1 || !Array.isArray(parsed.findings)) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const generatedAt = parsed.generatedAt ?? "";
|
|
56
|
+
const reviewedBy = parsed.reviewedBy ?? "unknown";
|
|
57
|
+
const status = parsed.status ?? "needs_human_review";
|
|
58
|
+
return buildPrivacyReviewArtifact({
|
|
59
|
+
generatedAt,
|
|
60
|
+
reviewedBy,
|
|
61
|
+
model: parsed.model,
|
|
62
|
+
status,
|
|
63
|
+
findings: parsed.findings.filter((finding) => typeof finding.id === "string")
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
async function writePrivacyReview(root, artifact, reviewFile = exports.DEFAULT_PRIVACY_REVIEW_FILE) {
|
|
67
|
+
const reviewPath = toAbsolutePath(root, reviewFile);
|
|
68
|
+
await (0, paths_1.ensureDir)(node_path_1.default.dirname(reviewPath));
|
|
69
|
+
await node_fs_1.promises.writeFile(reviewPath, `${JSON.stringify(artifact, null, 2)}\n`, "utf8");
|
|
70
|
+
return reviewPath;
|
|
71
|
+
}
|
|
72
|
+
function mergePrivacyReviewIntoFindings(findings, artifact) {
|
|
73
|
+
if (!artifact) {
|
|
74
|
+
return findings;
|
|
75
|
+
}
|
|
76
|
+
const byId = new Map(artifact.findings.map((finding) => [finding.id, finding]));
|
|
77
|
+
return findings.map((finding) => {
|
|
78
|
+
const review = byId.get(finding.id);
|
|
79
|
+
if (!review) {
|
|
80
|
+
return finding;
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
...finding,
|
|
84
|
+
evidence: {
|
|
85
|
+
...finding.evidence,
|
|
86
|
+
reviewState: review.reviewState,
|
|
87
|
+
reviewedAt: review.reviewedAt,
|
|
88
|
+
reviewedBy: review.reviewedBy,
|
|
89
|
+
rationale: review.rationale,
|
|
90
|
+
recommendedAction: review.recommendedAction
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
}
|
|
@@ -105,6 +105,11 @@ async function readPackageMetadata(root, packageManager) {
|
|
|
105
105
|
}
|
|
106
106
|
return { testCommands, frameworkHints };
|
|
107
107
|
}
|
|
108
|
+
function isFrameworkEntryFile(file) {
|
|
109
|
+
return (/^(?:src\/)?app\/(?:.+\/)?(?:page|layout|route|loading|error|global-error|not-found|default|template)\.(ts|tsx|js|jsx)$/.test(file) ||
|
|
110
|
+
/^(?:src\/)?pages\/(?:.+)\.(ts|tsx|js|jsx)$/.test(file) ||
|
|
111
|
+
/^(?:src\/)?(?:middleware|instrumentation)\.(ts|js)$/.test(file));
|
|
112
|
+
}
|
|
108
113
|
async function detectProject(root) {
|
|
109
114
|
const projectFiles = await (0, paths_1.listProjectFiles)(root);
|
|
110
115
|
const fileSet = new Set(projectFiles);
|
|
@@ -142,7 +147,7 @@ async function detectProject(root) {
|
|
|
142
147
|
packageMetadata.testCommands.push(pythonTestCommand(packageManagers));
|
|
143
148
|
}
|
|
144
149
|
const toolPairs = await Promise.all(KNOWN_TOOLS.map(async (tool) => [tool, await commandExists(tool, root)]));
|
|
145
|
-
const entryFiles = projectFiles.filter((file) => /(^|\/)(main|index|app|server|cli)\.(ts|tsx|js|jsx|py)$/.test(file) || file === "package.json");
|
|
150
|
+
const entryFiles = projectFiles.filter((file) => /(^|\/)(main|index|app|server|cli)\.(ts|tsx|js|jsx|py)$/.test(file) || isFrameworkEntryFile(file) || file === "package.json");
|
|
146
151
|
return {
|
|
147
152
|
root,
|
|
148
153
|
languages: Array.from(languages).sort(),
|
package/dist/core/scanPlanner.js
CHANGED
|
@@ -10,6 +10,7 @@ async function createScanPlan(project, config, adapters, mode) {
|
|
|
10
10
|
"pyright",
|
|
11
11
|
"gitleaks",
|
|
12
12
|
"osv-scanner",
|
|
13
|
+
"privacy-detector",
|
|
13
14
|
"custom-leftovers"
|
|
14
15
|
]);
|
|
15
16
|
for (const adapter of adapters) {
|
|
@@ -31,6 +32,9 @@ async function createScanPlan(project, config, adapters, mode) {
|
|
|
31
32
|
if (adapter.category === "dependencies" && !config.checks.dependencies.enabled) {
|
|
32
33
|
continue;
|
|
33
34
|
}
|
|
35
|
+
if (adapter.category === "privacy" && !config.checks.privacy.enabled) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
34
38
|
if (mode === "quick" && !quickAdapterIds.has(adapter.id)) {
|
|
35
39
|
continue;
|
|
36
40
|
}
|
package/dist/core/scoring.js
CHANGED
|
@@ -11,6 +11,7 @@ const defaultCategoryScore = {
|
|
|
11
11
|
maintainability: 100,
|
|
12
12
|
dependencies: 100,
|
|
13
13
|
tests: 100,
|
|
14
|
+
privacy: 100,
|
|
14
15
|
efficiency: 100,
|
|
15
16
|
refactor_readiness: 100
|
|
16
17
|
};
|
|
@@ -22,10 +23,14 @@ const defaultPenalties = {
|
|
|
22
23
|
maintainability: 0,
|
|
23
24
|
dependencies: 0,
|
|
24
25
|
tests: 0,
|
|
26
|
+
privacy: 0,
|
|
25
27
|
efficiency: 0,
|
|
26
28
|
refactor_readiness: 0
|
|
27
29
|
};
|
|
28
30
|
function scoreFinding(finding) {
|
|
31
|
+
if (finding.category === "privacy" && finding.evidence?.reviewState === "false_positive") {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
29
34
|
const issueMultiplier = finding.isNew ? 1.5 : 0.3;
|
|
30
35
|
const confidence = severityMap_1.confidenceMultiplier[finding.confidence];
|
|
31
36
|
const autofix = finding.safeToAutofix ? 0.5 : 1;
|
|
@@ -48,6 +53,7 @@ function buildScore(findings) {
|
|
|
48
53
|
categories.correctness * severityMap_1.categoryWeights.correctness +
|
|
49
54
|
categories.tests * severityMap_1.categoryWeights.tests +
|
|
50
55
|
categories.dependencies * severityMap_1.categoryWeights.dependencies +
|
|
56
|
+
categories.privacy * severityMap_1.categoryWeights.privacy +
|
|
51
57
|
categories.maintainability * severityMap_1.categoryWeights.maintainability +
|
|
52
58
|
categories.dead_code * severityMap_1.categoryWeights.dead_code +
|
|
53
59
|
categories.leftovers * severityMap_1.categoryWeights.leftovers +
|
package/dist/core/toolRunner.js
CHANGED
|
@@ -67,11 +67,29 @@ async function runCommand(spec, installHint) {
|
|
|
67
67
|
child.stderr.on("data", (chunk) => {
|
|
68
68
|
stderr += chunk.toString();
|
|
69
69
|
});
|
|
70
|
+
function cleanup() {
|
|
71
|
+
try {
|
|
72
|
+
if (timeoutHandle) {
|
|
73
|
+
clearTimeout(timeoutHandle);
|
|
74
|
+
timeoutHandle = undefined;
|
|
75
|
+
}
|
|
76
|
+
child.stdout?.removeAllListeners("data");
|
|
77
|
+
child.stderr?.removeAllListeners("data");
|
|
78
|
+
child.removeAllListeners();
|
|
79
|
+
// Release stdio handles so they don't keep the event loop referenced on some platforms
|
|
80
|
+
child.stdout?.destroy();
|
|
81
|
+
child.stderr?.destroy();
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// best effort
|
|
85
|
+
}
|
|
86
|
+
}
|
|
70
87
|
child.on("error", (error) => {
|
|
71
88
|
if (settled) {
|
|
72
89
|
return;
|
|
73
90
|
}
|
|
74
91
|
settled = true;
|
|
92
|
+
cleanup();
|
|
75
93
|
resolve({
|
|
76
94
|
command: [spec.cmd, ...spec.args].join(" "),
|
|
77
95
|
stdout,
|
|
@@ -87,9 +105,7 @@ async function runCommand(spec, installHint) {
|
|
|
87
105
|
return;
|
|
88
106
|
}
|
|
89
107
|
settled = true;
|
|
90
|
-
|
|
91
|
-
clearTimeout(timeoutHandle);
|
|
92
|
-
}
|
|
108
|
+
cleanup();
|
|
93
109
|
resolve({
|
|
94
110
|
command: [spec.cmd, ...spec.args].join(" "),
|
|
95
111
|
stdout,
|
|
@@ -110,7 +126,12 @@ async function runCommand(spec, installHint) {
|
|
|
110
126
|
return;
|
|
111
127
|
}
|
|
112
128
|
settled = true;
|
|
113
|
-
|
|
129
|
+
const killSignal = process.platform === "win32" ? undefined : "SIGTERM";
|
|
130
|
+
try {
|
|
131
|
+
child.kill(killSignal);
|
|
132
|
+
}
|
|
133
|
+
catch { }
|
|
134
|
+
cleanup();
|
|
114
135
|
resolve({
|
|
115
136
|
command: [spec.cmd, ...spec.args].join(" "),
|
|
116
137
|
stdout,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from "./agentPack/generateAgentPack";
|
|
2
2
|
export * from "./agentPack/policy";
|
|
3
|
+
export { AGENT_SKILLS, DEFAULT_SKILL_NAMES, type SkillTemplate } from "./agentPack/templates";
|
|
3
4
|
export * from "./core/config";
|
|
4
5
|
export * from "./core/engine";
|
|
5
6
|
export * from "./core/finding";
|
|
7
|
+
export * from "./core/privacyReview";
|
|
6
8
|
export * from "./core/projectDetector";
|
|
7
9
|
export * from "./mcp/server";
|