@neuralaxis/vibedoctor 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +213 -116
  2. package/dist/adapters/dpdp.d.ts +6 -0
  3. package/dist/adapters/dpdp.js +34 -0
  4. package/dist/adapters/index.d.ts +1 -0
  5. package/dist/adapters/index.js +3 -1
  6. package/dist/adapters/presidio.js +3 -1
  7. package/dist/adapters/privacyDetector.d.ts +24 -1
  8. package/dist/adapters/privacyDetector.js +86 -2
  9. package/dist/adapters/shared.d.ts +6 -0
  10. package/dist/agentPack/templates/skills.js +159 -53
  11. package/dist/cli/commands/dpdp.d.ts +35 -0
  12. package/dist/cli/commands/dpdp.js +103 -0
  13. package/dist/cli/commands/scan.js +4 -1
  14. package/dist/cli/commands/setup.js +1 -1
  15. package/dist/cli/index.js +84 -0
  16. package/dist/core/config.d.ts +21 -0
  17. package/dist/core/config.js +89 -4
  18. package/dist/core/engine.js +22 -3
  19. package/dist/core/finding.d.ts +1 -1
  20. package/dist/core/finding.js +1 -0
  21. package/dist/core/scanPlanner.js +10 -2
  22. package/dist/dpdp/artifacts.d.ts +11 -0
  23. package/dist/dpdp/artifacts.js +120 -0
  24. package/dist/dpdp/catalogue.d.ts +14 -0
  25. package/dist/dpdp/catalogue.js +661 -0
  26. package/dist/dpdp/collectors/confidence.d.ts +9 -0
  27. package/dist/dpdp/collectors/confidence.js +25 -0
  28. package/dist/dpdp/collectors/dependencies.d.ts +7 -0
  29. package/dist/dpdp/collectors/dependencies.js +63 -0
  30. package/dist/dpdp/collectors/index.d.ts +24 -0
  31. package/dist/dpdp/collectors/index.js +71 -0
  32. package/dist/dpdp/collectors/lifecycle.d.ts +2 -0
  33. package/dist/dpdp/collectors/lifecycle.js +202 -0
  34. package/dist/dpdp/collectors/optionalScanners.d.ts +14 -0
  35. package/dist/dpdp/collectors/optionalScanners.js +347 -0
  36. package/dist/dpdp/collectors/privacyBridge.d.ts +13 -0
  37. package/dist/dpdp/collectors/privacyBridge.js +152 -0
  38. package/dist/dpdp/collectors/safeguards.d.ts +5 -0
  39. package/dist/dpdp/collectors/safeguards.js +186 -0
  40. package/dist/dpdp/collectors/schema.d.ts +6 -0
  41. package/dist/dpdp/collectors/schema.js +122 -0
  42. package/dist/dpdp/collectors/shared.d.ts +10 -0
  43. package/dist/dpdp/collectors/shared.js +43 -0
  44. package/dist/dpdp/context.d.ts +28 -0
  45. package/dist/dpdp/context.js +195 -0
  46. package/dist/dpdp/dataMap.d.ts +7 -0
  47. package/dist/dpdp/dataMap.js +339 -0
  48. package/dist/dpdp/evaluators.d.ts +20 -0
  49. package/dist/dpdp/evaluators.js +522 -0
  50. package/dist/dpdp/evidence.d.ts +11 -0
  51. package/dist/dpdp/evidence.js +123 -0
  52. package/dist/dpdp/findings.d.ts +14 -0
  53. package/dist/dpdp/findings.js +99 -0
  54. package/dist/dpdp/gates.d.ts +14 -0
  55. package/dist/dpdp/gates.js +47 -0
  56. package/dist/dpdp/index.d.ts +16 -0
  57. package/dist/dpdp/index.js +32 -0
  58. package/dist/dpdp/legalSources.d.ts +10 -0
  59. package/dist/dpdp/legalSources.js +104 -0
  60. package/dist/dpdp/paths.d.ts +25 -0
  61. package/dist/dpdp/paths.js +85 -0
  62. package/dist/dpdp/report.d.ts +6 -0
  63. package/dist/dpdp/report.js +222 -0
  64. package/dist/dpdp/reviewQueue.d.ts +3 -0
  65. package/dist/dpdp/reviewQueue.js +88 -0
  66. package/dist/dpdp/scan.d.ts +26 -0
  67. package/dist/dpdp/scan.js +310 -0
  68. package/dist/dpdp/scoring.d.ts +31 -0
  69. package/dist/dpdp/scoring.js +211 -0
  70. package/dist/dpdp/types.d.ts +294 -0
  71. package/dist/dpdp/types.js +86 -0
  72. package/dist/index.d.ts +1 -0
  73. package/dist/index.js +1 -0
  74. package/dist/mcp/tools/dpdp.d.ts +11 -0
  75. package/dist/mcp/tools/dpdp.js +151 -0
  76. package/dist/mcp/tools/index.js +3 -1
  77. package/dist/reporters/json.js +6 -1
  78. package/package.json +4 -1
@@ -0,0 +1,339 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildDataMapGraph = buildDataMapGraph;
4
+ exports.buildPersonalDataMap = buildPersonalDataMap;
5
+ const evidence_1 = require("./evidence");
6
+ const DISCLAIMER = "Personal-data processing map for DPDP technical readiness. Values are masked/classified. Not a legal processing record of processing activities (RoPA) substitute.";
7
+ function safeLabel(value) {
8
+ return (0, evidence_1.redactLikelyPii)(value).slice(0, 160);
9
+ }
10
+ function edgeId(from, to, relation) {
11
+ return `edge:${relation}:${from}->${to}`;
12
+ }
13
+ /**
14
+ * Build a lightweight evidence graph from map aggregates + evidence ledger.
15
+ * Labels are classified/masked only — never raw PII.
16
+ */
17
+ function buildDataMapGraph(categories, collectionPoints, stores, externalRecipients, lifecycleSignals, safeguardGaps, relatedControls, evidence) {
18
+ const nodes = new Map();
19
+ const edges = new Map();
20
+ const addNode = (node) => {
21
+ if (!nodes.has(node.id)) {
22
+ nodes.set(node.id, {
23
+ ...node,
24
+ label: safeLabel(node.label)
25
+ });
26
+ }
27
+ };
28
+ const addEdge = (from, to, relation) => {
29
+ if (!nodes.has(from) || !nodes.has(to)) {
30
+ return;
31
+ }
32
+ const id = edgeId(from, to, relation);
33
+ if (!edges.has(id)) {
34
+ edges.set(id, { id, from, to, relation });
35
+ }
36
+ };
37
+ for (const category of categories) {
38
+ addNode({
39
+ id: `category:${category.category}`,
40
+ kind: "category",
41
+ label: category.category,
42
+ category: category.category,
43
+ evidenceIds: category.evidenceIds
44
+ });
45
+ }
46
+ for (const point of collectionPoints) {
47
+ addNode({
48
+ id: `collection:${point.id}`,
49
+ kind: "collection",
50
+ label: point.summary,
51
+ file: point.file,
52
+ line: point.line,
53
+ evidenceIds: point.evidenceIds
54
+ });
55
+ }
56
+ for (const store of stores) {
57
+ addNode({
58
+ id: `store:${store.id}`,
59
+ kind: "store",
60
+ label: store.summary,
61
+ file: store.file,
62
+ evidenceIds: store.evidenceIds
63
+ });
64
+ }
65
+ for (const recipient of externalRecipients) {
66
+ addNode({
67
+ id: `external:${recipient.id}`,
68
+ kind: "external",
69
+ label: `${recipient.name} (${recipient.kind})`,
70
+ file: recipient.file,
71
+ evidenceIds: recipient.evidenceIds
72
+ });
73
+ }
74
+ for (const lifecycle of lifecycleSignals) {
75
+ addNode({
76
+ id: `lifecycle:${lifecycle.id}`,
77
+ kind: "lifecycle",
78
+ label: lifecycle.summary,
79
+ file: lifecycle.file,
80
+ line: lifecycle.line,
81
+ evidenceIds: lifecycle.evidenceIds
82
+ });
83
+ }
84
+ for (const gap of safeguardGaps) {
85
+ addNode({
86
+ id: `gap:${gap.id}`,
87
+ kind: "safeguard_gap",
88
+ label: gap.summary,
89
+ file: gap.file,
90
+ line: gap.line,
91
+ evidenceIds: gap.evidenceIds
92
+ });
93
+ }
94
+ for (const controlId of relatedControls) {
95
+ addNode({
96
+ id: `control:${controlId}`,
97
+ kind: "control",
98
+ label: controlId
99
+ });
100
+ }
101
+ // Field / category evidence nodes and relations
102
+ for (const item of evidence) {
103
+ if (item.kind === "declared_assertion" || item.kind === "skip_or_capability") {
104
+ continue;
105
+ }
106
+ if (item.field || item.kind === "field_or_column") {
107
+ const fieldId = `field:${item.id}`;
108
+ addNode({
109
+ id: fieldId,
110
+ kind: "field",
111
+ label: item.field ? safeLabel(item.field) : safeLabel(item.summary),
112
+ category: item.dataCategory,
113
+ file: item.file,
114
+ line: item.line,
115
+ evidenceIds: [item.id]
116
+ });
117
+ if (item.dataCategory) {
118
+ addEdge(fieldId, `category:${item.dataCategory}`, "instance_of");
119
+ }
120
+ if (item.file) {
121
+ // Link field to co-located store/collection by file
122
+ for (const store of stores) {
123
+ if (store.file === item.file) {
124
+ addEdge(fieldId, `store:${store.id}`, "stored_in");
125
+ }
126
+ }
127
+ for (const point of collectionPoints) {
128
+ if (point.file === item.file) {
129
+ addEdge(fieldId, `collection:${point.id}`, "collected_at");
130
+ }
131
+ }
132
+ }
133
+ for (const controlId of item.relatedControls) {
134
+ addEdge(fieldId, `control:${controlId}`, "related_control");
135
+ }
136
+ }
137
+ else if (item.dataCategory) {
138
+ for (const controlId of item.relatedControls) {
139
+ addEdge(`category:${item.dataCategory}`, `control:${controlId}`, "related_control");
140
+ }
141
+ }
142
+ }
143
+ // Co-location and flow edges by shared file
144
+ for (const point of collectionPoints) {
145
+ if (!point.file) {
146
+ continue;
147
+ }
148
+ for (const store of stores) {
149
+ if (store.file === point.file) {
150
+ addEdge(`collection:${point.id}`, `store:${store.id}`, "stored_in");
151
+ }
152
+ }
153
+ for (const recipient of externalRecipients) {
154
+ if (recipient.file === point.file) {
155
+ addEdge(`collection:${point.id}`, `external:${recipient.id}`, "sent_to");
156
+ }
157
+ }
158
+ for (const category of categories) {
159
+ // Category ↔ collection when any category evidence shares the file
160
+ const sharesFile = evidence.some((item) => item.dataCategory === category.category && item.file === point.file);
161
+ if (sharesFile) {
162
+ addEdge(`category:${category.category}`, `collection:${point.id}`, "collected_at");
163
+ }
164
+ }
165
+ }
166
+ for (const store of stores) {
167
+ if (!store.file) {
168
+ continue;
169
+ }
170
+ for (const recipient of externalRecipients) {
171
+ if (recipient.file === store.file) {
172
+ addEdge(`store:${store.id}`, `external:${recipient.id}`, "sent_to");
173
+ }
174
+ }
175
+ for (const category of categories) {
176
+ const sharesFile = evidence.some((item) => item.dataCategory === category.category && item.file === store.file);
177
+ if (sharesFile) {
178
+ addEdge(`category:${category.category}`, `store:${store.id}`, "stored_in");
179
+ }
180
+ }
181
+ for (const lifecycle of lifecycleSignals) {
182
+ if (lifecycle.file === store.file) {
183
+ addEdge(`lifecycle:${lifecycle.id}`, `store:${store.id}`, "lifecycle_of");
184
+ }
185
+ }
186
+ }
187
+ for (const gap of safeguardGaps) {
188
+ if (!gap.file) {
189
+ continue;
190
+ }
191
+ for (const store of stores) {
192
+ if (store.file === gap.file) {
193
+ addEdge(`gap:${gap.id}`, `store:${store.id}`, "protected_by");
194
+ }
195
+ }
196
+ for (const point of collectionPoints) {
197
+ if (point.file === gap.file) {
198
+ addEdge(`gap:${gap.id}`, `collection:${point.id}`, "protected_by");
199
+ }
200
+ }
201
+ for (const recipient of externalRecipients) {
202
+ if (recipient.file === gap.file) {
203
+ addEdge(`gap:${gap.id}`, `external:${recipient.id}`, "protected_by");
204
+ }
205
+ }
206
+ }
207
+ // Co-locate external + category when same file
208
+ for (const recipient of externalRecipients) {
209
+ if (!recipient.file) {
210
+ continue;
211
+ }
212
+ for (const category of categories) {
213
+ const sharesFile = evidence.some((item) => item.dataCategory === category.category && item.file === recipient.file);
214
+ if (sharesFile) {
215
+ addEdge(`category:${category.category}`, `external:${recipient.id}`, "sent_to");
216
+ }
217
+ }
218
+ }
219
+ return {
220
+ nodes: Array.from(nodes.values()).sort((left, right) => left.id.localeCompare(right.id)),
221
+ edges: Array.from(edges.values()).sort((left, right) => left.id.localeCompare(right.id))
222
+ };
223
+ }
224
+ function buildPersonalDataMap(signals, evidence, controls, generatedAt) {
225
+ const categoryMap = new Map();
226
+ for (const item of evidence) {
227
+ if (!item.dataCategory) {
228
+ continue;
229
+ }
230
+ const list = categoryMap.get(item.dataCategory) ?? [];
231
+ list.push(item.id);
232
+ categoryMap.set(item.dataCategory, list);
233
+ }
234
+ const collectionPoints = signals
235
+ .filter((signal) => signal.kind === "collection" || signal.tags.includes("collection-point"))
236
+ .map((signal) => ({
237
+ id: signal.id,
238
+ kind: "collection",
239
+ file: signal.file,
240
+ line: signal.line,
241
+ summary: safeLabel(signal.summary),
242
+ evidenceIds: [signal.id]
243
+ }));
244
+ const stores = signals
245
+ .filter((signal) => signal.kind === "storage" || signal.tags.includes("pii-store") || signal.kind === "retention")
246
+ .map((signal) => ({
247
+ id: signal.id,
248
+ kind: signal.tags.includes("retention-present") ? "retention" : "storage",
249
+ file: signal.file,
250
+ summary: safeLabel(signal.summary),
251
+ evidenceIds: [signal.id]
252
+ }));
253
+ const externalRecipients = signals
254
+ .filter((signal) => signal.kind === "external")
255
+ .map((signal) => {
256
+ const nameTag = signal.tags.find((tag) => !["external-processor", "lockfile-processor", "cross-border"].includes(tag));
257
+ return {
258
+ id: signal.id,
259
+ name: nameTag ?? "external-service",
260
+ kind: signal.tags.find((tag) => [
261
+ "analytics",
262
+ "error_tracking",
263
+ "telemetry",
264
+ "messaging",
265
+ "payments",
266
+ "identity",
267
+ "advertising",
268
+ "llm",
269
+ "cloud",
270
+ "vector_db",
271
+ "mcp"
272
+ ].includes(tag)) ?? "external",
273
+ file: signal.file,
274
+ summary: safeLabel(signal.summary),
275
+ evidenceIds: [signal.id]
276
+ };
277
+ });
278
+ const lifecycleSignals = signals
279
+ .filter((signal) => ["consent", "deletion", "rights", "retention"].includes(signal.kind) ||
280
+ signal.tags.some((tag) => [
281
+ "consent-capture",
282
+ "consent-withdrawal",
283
+ "erasure-path",
284
+ "access-export",
285
+ "correction-path",
286
+ "grievance",
287
+ "retention-present"
288
+ ].includes(tag)))
289
+ .map((signal) => ({
290
+ id: signal.id,
291
+ kind: signal.kind,
292
+ file: signal.file,
293
+ line: signal.line,
294
+ summary: safeLabel(signal.summary),
295
+ evidenceIds: [signal.id]
296
+ }));
297
+ const safeguardGaps = signals
298
+ .filter((signal) => signal.kind === "safeguard_gap")
299
+ .map((signal) => ({
300
+ id: signal.id,
301
+ kind: "safeguard_gap",
302
+ file: signal.file,
303
+ line: signal.line,
304
+ summary: safeLabel(signal.summary),
305
+ evidenceIds: [signal.id]
306
+ }));
307
+ const categories = Array.from(categoryMap.entries())
308
+ .map(([category, evidenceIds]) => ({
309
+ category,
310
+ count: evidenceIds.length,
311
+ evidenceIds: Array.from(new Set(evidenceIds))
312
+ }))
313
+ .sort((left, right) => left.category.localeCompare(right.category));
314
+ const relatedControls = Array.from(new Set(controls.filter((item) => item.applicable).map((item) => item.controlId))).sort();
315
+ const graph = buildDataMapGraph(categories, dedupeById(collectionPoints), dedupeById(stores), dedupeById(externalRecipients), dedupeById(lifecycleSignals), dedupeById(safeguardGaps), relatedControls, evidence);
316
+ return {
317
+ version: 1,
318
+ generatedAt,
319
+ disclaimer: DISCLAIMER,
320
+ categories,
321
+ collectionPoints: dedupeById(collectionPoints),
322
+ stores: dedupeById(stores),
323
+ externalRecipients: dedupeById(externalRecipients),
324
+ lifecycleSignals: dedupeById(lifecycleSignals),
325
+ safeguardGaps: dedupeById(safeguardGaps),
326
+ relatedControls,
327
+ graph
328
+ };
329
+ }
330
+ function dedupeById(items) {
331
+ const seen = new Set();
332
+ return items.filter((item) => {
333
+ if (seen.has(item.id)) {
334
+ return false;
335
+ }
336
+ seen.add(item.id);
337
+ return true;
338
+ });
339
+ }
@@ -0,0 +1,20 @@
1
+ import type { ControlResult, DeclaredAssertion, DpdpContext, EvidenceItem, TechnicalSignalBag, VerificationClass } from "./types";
2
+ export type EvaluationContext = {
3
+ signals: TechnicalSignalBag[];
4
+ evidence: EvidenceItem[];
5
+ context: DpdpContext;
6
+ declared: DeclaredAssertion[];
7
+ capabilities: Array<{
8
+ id: string;
9
+ status: "available" | "skipped" | "error";
10
+ message?: string;
11
+ }>;
12
+ };
13
+ /**
14
+ * Only value-literal (or seed/fixture path) detections count as hardcoded production PII.
15
+ * Field-name / schema metadata alone must not flip this control to VIOLATED.
16
+ */
17
+ export declare function isHardcodedLiteralSignal(signal: TechnicalSignalBag): boolean;
18
+ export declare function evaluateAllControls(ctx: EvaluationContext): ControlResult[];
19
+ export declare function attachDeclaredEvidenceIds(results: ControlResult[], declared: DeclaredAssertion[]): ControlResult[];
20
+ export declare function controlVerificationClass(controlId: string): VerificationClass | undefined;