@neuralaxis/vibedoctor 0.1.1 → 0.1.3

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.
Files changed (75) hide show
  1. package/README.md +219 -290
  2. package/dist/adapters/biome.d.ts +1 -1
  3. package/dist/adapters/biome.js +7 -4
  4. package/dist/adapters/coveragePy.js +3 -0
  5. package/dist/adapters/customDeadChain.d.ts +2 -1
  6. package/dist/adapters/customDeadChain.js +100 -8
  7. package/dist/adapters/customLeftovers.js +33 -10
  8. package/dist/adapters/deptry.js +21 -2
  9. package/dist/adapters/index.d.ts +3 -0
  10. package/dist/adapters/index.js +7 -1
  11. package/dist/adapters/jscpd.d.ts +1 -0
  12. package/dist/adapters/jscpd.js +10 -1
  13. package/dist/adapters/knip.js +29 -4
  14. package/dist/adapters/lizard.d.ts +1 -1
  15. package/dist/adapters/lizard.js +51 -2
  16. package/dist/adapters/osvScanner.js +14 -2
  17. package/dist/adapters/presidio.d.ts +2 -0
  18. package/dist/adapters/presidio.js +158 -0
  19. package/dist/adapters/privacyDetector.d.ts +10 -0
  20. package/dist/adapters/privacyDetector.js +600 -0
  21. package/dist/adapters/ruff.d.ts +1 -1
  22. package/dist/adapters/ruff.js +4 -1
  23. package/dist/adapters/semgrep.d.ts +1 -1
  24. package/dist/adapters/semgrep.js +17 -3
  25. package/dist/adapters/shared.d.ts +1 -0
  26. package/dist/adapters/shared.js +22 -0
  27. package/dist/adapters/telemetryDetector.d.ts +2 -0
  28. package/dist/adapters/telemetryDetector.js +118 -0
  29. package/dist/adapters/tsc.js +43 -18
  30. package/dist/adapters/vulture.d.ts +1 -1
  31. package/dist/adapters/vulture.js +25 -6
  32. package/dist/agentPack/generateAgentPack.d.ts +7 -0
  33. package/dist/agentPack/generateAgentPack.js +89 -1
  34. package/dist/agentPack/templates/index.js +21 -15
  35. package/dist/agentPack/templates/skills.js +57 -4
  36. package/dist/cli/commands/agent.d.ts +5 -0
  37. package/dist/cli/commands/agent.js +10 -0
  38. package/dist/cli/commands/agentPlan.js +9 -1
  39. package/dist/cli/commands/init.js +50 -17
  40. package/dist/cli/commands/privacyReview.d.ts +9 -0
  41. package/dist/cli/commands/privacyReview.js +304 -0
  42. package/dist/cli/commands/scan.d.ts +1 -1
  43. package/dist/cli/commands/scan.js +31 -1
  44. package/dist/cli/commands/setup.js +16 -1
  45. package/dist/cli/commands/tool.d.ts +4 -0
  46. package/dist/cli/commands/tool.js +11 -0
  47. package/dist/cli/index.js +36 -0
  48. package/dist/core/config.d.ts +29 -0
  49. package/dist/core/config.js +142 -5
  50. package/dist/core/engine.d.ts +35 -1
  51. package/dist/core/engine.js +204 -36
  52. package/dist/core/finding.d.ts +16 -2
  53. package/dist/core/finding.js +5 -0
  54. package/dist/core/paths.js +5 -0
  55. package/dist/core/privacyReview.d.ts +51 -0
  56. package/dist/core/privacyReview.js +94 -0
  57. package/dist/core/projectDetector.d.ts +1 -1
  58. package/dist/core/projectDetector.js +34 -12
  59. package/dist/core/scanPlanner.js +4 -0
  60. package/dist/core/scoring.js +6 -0
  61. package/dist/core/toolRunner.d.ts +1 -0
  62. package/dist/core/toolRunner.js +73 -11
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.js +5 -0
  65. package/dist/mcp/tools/shared.d.ts +1 -1
  66. package/dist/mcp/tools/shared.js +8 -1
  67. package/dist/reporters/agent.js +8 -0
  68. package/dist/reporters/html.js +12 -8
  69. package/dist/reporters/json.js +5 -5
  70. package/dist/reporters/markdown.js +15 -1
  71. package/dist/reporters/sarif.js +6 -0
  72. package/dist/reporters/terminal.js +1 -5
  73. package/dist/rules/severityMap.d.ts +1 -0
  74. package/dist/rules/severityMap.js +1 -0
  75. package/package.json +6 -2
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.presidioAdapter = void 0;
4
+ const privacyDetector_1 = require("./privacyDetector");
5
+ const paths_1 = require("../core/paths");
6
+ const toolRunner_1 = require("../core/toolRunner");
7
+ const CONFIDENCE_RANK = {
8
+ low: 0,
9
+ medium: 1,
10
+ high: 2
11
+ };
12
+ const PRESIDIO_EXTENSIONS = /\.(ts|tsx|js|jsx|py|json|jsonl|ya?ml|toml|md|txt|log|csv|tsv|sql|graphql|gql)$/i;
13
+ const PRESIDIO_SCRIPT = String.raw `
14
+ import json
15
+ import os
16
+ import pathlib
17
+ import sys
18
+
19
+ try:
20
+ from presidio_analyzer import AnalyzerEngine
21
+ except Exception as exc:
22
+ sys.stderr.write(f"presidio_analyzer is not installed: {exc}\n")
23
+ sys.exit(2)
24
+
25
+ root = pathlib.Path(sys.argv[1])
26
+ files = json.loads(os.environ.get("VIBEDOCTOR_PRESIDIO_FILES", "[]"))
27
+ max_file_bytes = int(os.environ.get("VIBEDOCTOR_PRESIDIO_MAX_FILE_BYTES", "1048576"))
28
+ analyzer = AnalyzerEngine()
29
+ out = []
30
+
31
+ for rel in files:
32
+ candidate = root / rel
33
+ try:
34
+ if candidate.stat().st_size > max_file_bytes:
35
+ continue
36
+ text = candidate.read_text(encoding="utf-8", errors="ignore")
37
+ except Exception:
38
+ continue
39
+
40
+ for item in analyzer.analyze(text=text, language="en"):
41
+ value = text[item.start:item.end]
42
+ out.append({
43
+ "file": rel,
44
+ "line": text.count("\n", 0, item.start) + 1,
45
+ "entityType": item.entity_type.lower(),
46
+ "score": float(item.score),
47
+ "value": value,
48
+ })
49
+
50
+ print(json.dumps(out))
51
+ `;
52
+ function passesConfidenceThreshold(score, minimum) {
53
+ return CONFIDENCE_RANK[(0, privacyDetector_1.confidenceFromScore)(score)] >= CONFIDENCE_RANK[minimum];
54
+ }
55
+ function normalizeStatus(status) {
56
+ if (status.status === "error" && /presidio_analyzer is not installed|No module named ['"]presidio_analyzer/i.test(status.stderr)) {
57
+ return {
58
+ ...status,
59
+ status: "skipped",
60
+ installHint: "Install Presidio in the project environment: python -m pip install presidio-analyzer"
61
+ };
62
+ }
63
+ return status;
64
+ }
65
+ function sensitivityForPresidio(entityType) {
66
+ if (/credit_card|iban|crypto|passport|aadhaar|pan|bank/.test(entityType)) {
67
+ return "regulated_identifier";
68
+ }
69
+ if (/medical|patient|health|location/.test(entityType)) {
70
+ return "high";
71
+ }
72
+ if (/phone|ip|date_time|id/.test(entityType)) {
73
+ return "moderate";
74
+ }
75
+ return "low";
76
+ }
77
+ function toFinding(item, ctx) {
78
+ const entityType = item.entityType.toLowerCase();
79
+ const sensitivity = sensitivityForPresidio(entityType);
80
+ const confidence = (0, privacyDetector_1.confidenceFromScore)(item.score);
81
+ const maskedValue = (0, privacyDetector_1.maskPiiValue)(item.value, entityType, ctx.config.checks.privacy.maskExamples);
82
+ return {
83
+ id: `privacy-presidio:${item.file}:${item.line ?? 0}:${entityType}:${maskedValue}`,
84
+ source: "presidio",
85
+ category: "privacy",
86
+ severity: sensitivity === "low" ? "low" : "medium",
87
+ confidence,
88
+ title: `PII detected: ${entityType}`,
89
+ message: `${entityType} detected by Presidio with ${confidence} confidence.`,
90
+ file: item.file,
91
+ startLine: item.line,
92
+ isNew: true,
93
+ isAutofixable: false,
94
+ safeToAutofix: false,
95
+ agentInstruction: "Review this Presidio privacy finding before treating it as confirmed PII.",
96
+ tags: ["privacy", entityType, sensitivity],
97
+ evidence: {
98
+ detector: "presidio",
99
+ entityType,
100
+ sensitivity,
101
+ maskedValue,
102
+ fieldPath: item.line ? `${item.file}:${item.line}` : item.file,
103
+ matchedPattern: entityType,
104
+ detectionPath: "presidio",
105
+ confidenceScore: Number(item.score.toFixed(2)),
106
+ coverageConfidence: 0.75,
107
+ reviewState: item.score >= 0.85 ? "confirmed" : "needs_human_review",
108
+ reasons: ["Presidio analyzer returned this entity span"]
109
+ },
110
+ scoreImpact: 0
111
+ };
112
+ }
113
+ exports.presidioAdapter = {
114
+ id: "presidio",
115
+ category: "privacy",
116
+ async detect(_project, config) {
117
+ return config.checks.privacy.enabled && config.checks.privacy.presidio.enabled;
118
+ },
119
+ async runStandalone(ctx) {
120
+ const files = (0, paths_1.filterPaths)(ctx.project.projectFiles, ctx.config.paths.include, ctx.config.paths.exclude)
121
+ .filter((file) => PRESIDIO_EXTENSIONS.test(file))
122
+ .slice(0, 500);
123
+ const status = normalizeStatus(await (0, toolRunner_1.runCommand)({
124
+ cmd: "python",
125
+ args: ["-c", PRESIDIO_SCRIPT, ctx.root],
126
+ cwd: ctx.root,
127
+ timeoutMs: 120_000,
128
+ env: {
129
+ VIBEDOCTOR_PRESIDIO_FILES: JSON.stringify(files),
130
+ VIBEDOCTOR_PRESIDIO_MAX_FILE_BYTES: String(ctx.config.checks.privacy.maxFileBytes)
131
+ }
132
+ }, "Install Presidio in the project environment: python -m pip install presidio-analyzer"));
133
+ if (status.status !== "ok") {
134
+ return { findings: [], status };
135
+ }
136
+ let raw = [];
137
+ try {
138
+ raw = JSON.parse(status.stdout.trim() || "[]");
139
+ }
140
+ catch {
141
+ return {
142
+ findings: [],
143
+ status: {
144
+ ...status,
145
+ status: "error",
146
+ stderr: "Presidio output was not valid JSON."
147
+ }
148
+ };
149
+ }
150
+ return {
151
+ findings: raw
152
+ .filter((item) => passesConfidenceThreshold(item.score, ctx.config.checks.privacy.minConfidenceToReport))
153
+ .map((item) => toFinding(item, ctx)),
154
+ status
155
+ };
156
+ },
157
+ installHint: "Optional privacy scanner. Enable checks.privacy.presidio.enabled and install presidio-analyzer."
158
+ };
@@ -0,0 +1,10 @@
1
+ import { type Confidence, type Finding } from "../core/finding";
2
+ import type { ToolAdapter, ToolAdapterContext } from "./shared";
3
+ export type PrivacySensitivity = "low" | "moderate" | "high" | "regulated_identifier" | "combination_risk";
4
+ export declare function confidenceFromScore(score: number): Confidence;
5
+ export declare function passesLuhn(value: string): boolean;
6
+ export declare function isValidAadhaar(value: string): boolean;
7
+ export declare function maskPiiValue(value: string, entityType: string, maskExamples?: boolean): string;
8
+ export declare function detectPiiFindings(ctx: ToolAdapterContext): Promise<Finding[]>;
9
+ export declare const privacyDetectorAdapter: ToolAdapter;
10
+ export declare function normalizeExternalFile(file: string | undefined, root: string): string | undefined;