@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
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/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";
|
package/dist/index.js
CHANGED
|
@@ -14,10 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.DEFAULT_SKILL_NAMES = exports.AGENT_SKILLS = void 0;
|
|
17
18
|
__exportStar(require("./agentPack/generateAgentPack"), exports);
|
|
18
19
|
__exportStar(require("./agentPack/policy"), exports);
|
|
20
|
+
var templates_1 = require("./agentPack/templates");
|
|
21
|
+
Object.defineProperty(exports, "AGENT_SKILLS", { enumerable: true, get: function () { return templates_1.AGENT_SKILLS; } });
|
|
22
|
+
Object.defineProperty(exports, "DEFAULT_SKILL_NAMES", { enumerable: true, get: function () { return templates_1.DEFAULT_SKILL_NAMES; } });
|
|
19
23
|
__exportStar(require("./core/config"), exports);
|
|
20
24
|
__exportStar(require("./core/engine"), exports);
|
|
21
25
|
__exportStar(require("./core/finding"), exports);
|
|
26
|
+
__exportStar(require("./core/privacyReview"), exports);
|
|
22
27
|
__exportStar(require("./core/projectDetector"), exports);
|
|
23
28
|
__exportStar(require("./mcp/server"), exports);
|
|
@@ -30,7 +30,7 @@ export declare const categorySchema: {
|
|
|
30
30
|
readonly type: "array";
|
|
31
31
|
readonly items: {
|
|
32
32
|
readonly type: "string";
|
|
33
|
-
readonly enum: readonly ["security", "correctness", "dead_code", "leftovers", "maintainability", "dependencies", "tests", "efficiency", "refactor_readiness"];
|
|
33
|
+
readonly enum: readonly ["security", "correctness", "dead_code", "leftovers", "maintainability", "dependencies", "tests", "privacy", "efficiency", "refactor_readiness"];
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
export declare function parseCategories(value: unknown): FindingCategory[] | undefined;
|
package/dist/reporters/html.js
CHANGED
|
@@ -52,17 +52,19 @@ function renderHtmlReport(scan) {
|
|
|
52
52
|
<div class="score">Health: ${scan.score.overall}/100 ${scan.score.overall >= 85 ? "✅" : "⚠️"}</div>
|
|
53
53
|
|
|
54
54
|
<div class="summary">
|
|
55
|
-
<span class="pill">Blockers: ${scan.blockers.length}</span>
|
|
56
|
-
<span class="pill">Fix next: ${scan.fixNext.length}</span>
|
|
57
|
-
<span class="pill">
|
|
55
|
+
<span class="pill">Blockers: ${scan.blockers.length}</span>
|
|
56
|
+
<span class="pill">Fix next: ${scan.fixNext.length}</span>
|
|
57
|
+
<span class="pill">Privacy Review: ${scan.privacyFindings.length}</span>
|
|
58
|
+
<span class="pill">Leftovers: ${scan.leftovers.length}</span>
|
|
58
59
|
<span class="pill">Dead chains: ${scan.deadCodeCandidates.length}</span>
|
|
59
60
|
<span class="pill">Refactor: ${scan.refactorCandidates.length}</span>
|
|
60
61
|
</div>
|
|
61
62
|
|
|
62
63
|
<div class="section">
|
|
63
|
-
${renderFindingList(scan.blockers, "BLOCKERS")}
|
|
64
|
-
${renderFindingList(scan.fixNext, "FIX NEXT")}
|
|
65
|
-
${renderFindingList(scan.
|
|
64
|
+
${renderFindingList(scan.blockers, "BLOCKERS")}
|
|
65
|
+
${renderFindingList(scan.fixNext, "FIX NEXT")}
|
|
66
|
+
${renderFindingList(scan.privacyFindings.slice(0, 10), "PRIVACY REVIEW FINDINGS")}
|
|
67
|
+
${renderFindingList(scan.leftovers, "LEFTOVERS")}
|
|
66
68
|
${renderFindingList(scan.deadCodeCandidates, "DEAD CHAINS")}
|
|
67
69
|
${renderFindingList(scan.refactorCandidates, "REFACTOR CANDIDATES")}
|
|
68
70
|
</div>
|
package/dist/reporters/json.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.renderJsonReport = renderJsonReport;
|
|
7
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
8
4
|
function renderJsonReport(scan) {
|
|
9
5
|
return JSON.stringify({
|
|
10
6
|
score: scan.score.overall,
|
|
11
7
|
categoryScores: scan.score.categories,
|
|
12
8
|
findings: scan.findings,
|
|
13
9
|
topFindings: scan.topFindings,
|
|
10
|
+
privacyFindings: scan.privacyFindings,
|
|
11
|
+
privacyReview: scan.privacyReview,
|
|
14
12
|
toolStatuses: scan.toolStatuses,
|
|
15
13
|
skippedTools: scan.skippedTools,
|
|
16
14
|
agentPlan: scan.agentPlan
|
|
17
|
-
}, null, 2)
|
|
15
|
+
}, null, 2) + "\n";
|
|
18
16
|
}
|
|
@@ -7,6 +7,7 @@ function renderMarkdownReport(scan) {
|
|
|
7
7
|
lines.push("## Summary");
|
|
8
8
|
lines.push(`- Blockers: ${scan.blockers.length}`);
|
|
9
9
|
lines.push(`- Fix next: ${scan.fixNext.length}`);
|
|
10
|
+
lines.push(`- Privacy Review findings: ${scan.privacyFindings.length}`);
|
|
10
11
|
lines.push(`- Leftovers: ${scan.leftovers.length}`);
|
|
11
12
|
lines.push(`- Dead code candidates: ${scan.deadCodeCandidates.length}`);
|
|
12
13
|
lines.push(`- Refactor candidates: ${scan.refactorCandidates.length}`);
|
|
@@ -19,6 +20,12 @@ function renderMarkdownReport(scan) {
|
|
|
19
20
|
}
|
|
20
21
|
lines.push("", "## Fix next");
|
|
21
22
|
scan.fixNext.forEach((finding) => lines.push(`- ${finding.title}${finding.file ? ` — \`${finding.file}\`` : ""}`));
|
|
23
|
+
if (scan.privacyFindings.length > 0) {
|
|
24
|
+
lines.push("", "## Privacy Review findings");
|
|
25
|
+
scan.privacyFindings
|
|
26
|
+
.slice(0, 10)
|
|
27
|
+
.forEach((finding) => lines.push(`- ${finding.title}${finding.file ? ` — \`${finding.file}${finding.startLine ? `:${finding.startLine}` : ""}\`` : ""}: ${finding.evidence?.maskedValue ?? finding.evidence?.entityType ?? finding.message}`));
|
|
28
|
+
}
|
|
22
29
|
if (scan.deadCodeCandidates.length > 0) {
|
|
23
30
|
lines.push("", "## Dead chains and dead code");
|
|
24
31
|
scan.deadCodeCandidates.slice(0, 5).forEach((finding) => lines.push(`- ${finding.title}${finding.file ? ` — \`${finding.file}\`` : ""}: ${finding.message}`));
|
package/dist/reporters/sarif.js
CHANGED
|
@@ -17,6 +17,12 @@ function renderSarif(scan) {
|
|
|
17
17
|
message: {
|
|
18
18
|
text: finding.message
|
|
19
19
|
},
|
|
20
|
+
properties: {
|
|
21
|
+
category: finding.category,
|
|
22
|
+
confidence: finding.confidence,
|
|
23
|
+
entityType: finding.evidence?.entityType,
|
|
24
|
+
sensitivity: finding.evidence?.sensitivity
|
|
25
|
+
},
|
|
20
26
|
locations: finding.file
|
|
21
27
|
? [
|
|
22
28
|
{
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.renderTerminalReport = renderTerminalReport;
|
|
7
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
8
4
|
const engine_1 = require("../core/engine");
|
|
9
5
|
function renderTerminalReport(scan) {
|
|
10
|
-
return `${(0, engine_1.buildSummaryLines)(scan).join(
|
|
6
|
+
return `${(0, engine_1.buildSummaryLines)(scan).join("\n")}\n\n`;
|
|
11
7
|
}
|