@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.
- package/README.md +213 -116
- package/dist/adapters/dpdp.d.ts +6 -0
- package/dist/adapters/dpdp.js +34 -0
- package/dist/adapters/index.d.ts +1 -0
- package/dist/adapters/index.js +3 -1
- package/dist/adapters/presidio.js +3 -1
- package/dist/adapters/privacyDetector.d.ts +24 -1
- package/dist/adapters/privacyDetector.js +86 -2
- package/dist/adapters/shared.d.ts +6 -0
- package/dist/agentPack/templates/skills.js +159 -53
- package/dist/cli/commands/dpdp.d.ts +35 -0
- package/dist/cli/commands/dpdp.js +103 -0
- package/dist/cli/commands/scan.js +4 -1
- package/dist/cli/commands/setup.js +1 -1
- package/dist/cli/index.js +84 -0
- package/dist/core/config.d.ts +21 -0
- package/dist/core/config.js +89 -4
- package/dist/core/engine.js +22 -3
- package/dist/core/finding.d.ts +1 -1
- package/dist/core/finding.js +1 -0
- package/dist/core/scanPlanner.js +10 -2
- package/dist/dpdp/artifacts.d.ts +11 -0
- package/dist/dpdp/artifacts.js +120 -0
- package/dist/dpdp/catalogue.d.ts +14 -0
- package/dist/dpdp/catalogue.js +661 -0
- package/dist/dpdp/collectors/confidence.d.ts +9 -0
- package/dist/dpdp/collectors/confidence.js +25 -0
- package/dist/dpdp/collectors/dependencies.d.ts +7 -0
- package/dist/dpdp/collectors/dependencies.js +63 -0
- package/dist/dpdp/collectors/index.d.ts +24 -0
- package/dist/dpdp/collectors/index.js +71 -0
- package/dist/dpdp/collectors/lifecycle.d.ts +2 -0
- package/dist/dpdp/collectors/lifecycle.js +202 -0
- package/dist/dpdp/collectors/optionalScanners.d.ts +14 -0
- package/dist/dpdp/collectors/optionalScanners.js +347 -0
- package/dist/dpdp/collectors/privacyBridge.d.ts +13 -0
- package/dist/dpdp/collectors/privacyBridge.js +152 -0
- package/dist/dpdp/collectors/safeguards.d.ts +5 -0
- package/dist/dpdp/collectors/safeguards.js +186 -0
- package/dist/dpdp/collectors/schema.d.ts +6 -0
- package/dist/dpdp/collectors/schema.js +122 -0
- package/dist/dpdp/collectors/shared.d.ts +10 -0
- package/dist/dpdp/collectors/shared.js +43 -0
- package/dist/dpdp/context.d.ts +28 -0
- package/dist/dpdp/context.js +195 -0
- package/dist/dpdp/dataMap.d.ts +7 -0
- package/dist/dpdp/dataMap.js +339 -0
- package/dist/dpdp/evaluators.d.ts +20 -0
- package/dist/dpdp/evaluators.js +522 -0
- package/dist/dpdp/evidence.d.ts +11 -0
- package/dist/dpdp/evidence.js +123 -0
- package/dist/dpdp/findings.d.ts +14 -0
- package/dist/dpdp/findings.js +99 -0
- package/dist/dpdp/gates.d.ts +14 -0
- package/dist/dpdp/gates.js +47 -0
- package/dist/dpdp/index.d.ts +16 -0
- package/dist/dpdp/index.js +32 -0
- package/dist/dpdp/legalSources.d.ts +10 -0
- package/dist/dpdp/legalSources.js +104 -0
- package/dist/dpdp/paths.d.ts +25 -0
- package/dist/dpdp/paths.js +85 -0
- package/dist/dpdp/report.d.ts +6 -0
- package/dist/dpdp/report.js +222 -0
- package/dist/dpdp/reviewQueue.d.ts +3 -0
- package/dist/dpdp/reviewQueue.js +88 -0
- package/dist/dpdp/scan.d.ts +26 -0
- package/dist/dpdp/scan.js +310 -0
- package/dist/dpdp/scoring.d.ts +31 -0
- package/dist/dpdp/scoring.js +211 -0
- package/dist/dpdp/types.d.ts +294 -0
- package/dist/dpdp/types.js +86 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mcp/tools/dpdp.d.ts +11 -0
- package/dist/mcp/tools/dpdp.js +151 -0
- package/dist/mcp/tools/index.js +3 -1
- package/dist/reporters/json.js +6 -1
- package/package.json +4 -1
package/dist/core/config.js
CHANGED
|
@@ -115,7 +115,30 @@ exports.defaultConfig = {
|
|
|
115
115
|
includeRawValues: false
|
|
116
116
|
},
|
|
117
117
|
presidio: {
|
|
118
|
-
|
|
118
|
+
// Opt-out: try Presidio on normal privacy scans; skip gracefully if not installed.
|
|
119
|
+
enabled: true
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
dpdp: {
|
|
123
|
+
enabled: true,
|
|
124
|
+
include: [],
|
|
125
|
+
exclude: [],
|
|
126
|
+
minConfidenceToReport: "medium",
|
|
127
|
+
maskExamples: true,
|
|
128
|
+
// Opt-out: DPDP tries these by default so agents get full coverage without extra flags.
|
|
129
|
+
usePresidio: true,
|
|
130
|
+
useSemgrep: true,
|
|
131
|
+
legalSourceVersion: "2025.2-final-corrigendum",
|
|
132
|
+
contextFile: ".vibedoctor/dpdp/context.yml",
|
|
133
|
+
evidenceFile: ".vibedoctor/dpdp/evidence.yml",
|
|
134
|
+
failOnSeverity: [],
|
|
135
|
+
failOnViolatedControls: [],
|
|
136
|
+
failOnlyOnNew: true,
|
|
137
|
+
organization: {
|
|
138
|
+
processesPersonalData: "unknown",
|
|
139
|
+
isSignificantDataFiduciary: "unknown",
|
|
140
|
+
processesChildrenData: "unknown",
|
|
141
|
+
hasCrossBorderTransfer: "unknown"
|
|
119
142
|
}
|
|
120
143
|
}
|
|
121
144
|
},
|
|
@@ -131,6 +154,15 @@ const CONFIG_FILES = ["vibedoctor.yml", "vibedoctor.yaml", "vibedoctor.json"];
|
|
|
131
154
|
function isRecord(value) {
|
|
132
155
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
133
156
|
}
|
|
157
|
+
function normalizeStringArray(value, fallback) {
|
|
158
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [...fallback];
|
|
159
|
+
}
|
|
160
|
+
function normalizeSeverityArray(value, fallback) {
|
|
161
|
+
const allowed = new Set(["info", "low", "medium", "high", "critical"]);
|
|
162
|
+
return Array.isArray(value)
|
|
163
|
+
? value.filter((item) => typeof item === "string" && allowed.has(item))
|
|
164
|
+
: [...fallback];
|
|
165
|
+
}
|
|
134
166
|
function deepMerge(base, override) {
|
|
135
167
|
if (override === undefined) {
|
|
136
168
|
return base;
|
|
@@ -173,6 +205,8 @@ function normalizeRawConfig(raw) {
|
|
|
173
205
|
const rawPrivacy = rawChecks?.privacy;
|
|
174
206
|
const rawPrivacyAi = (rawPrivacy?.ai ?? {});
|
|
175
207
|
const rawPresidio = (rawPrivacy?.presidio ?? {});
|
|
208
|
+
const rawDpdp = rawChecks?.dpdp;
|
|
209
|
+
const rawDpdpOrg = (rawDpdp?.organization ?? rawDpdp?.organisation ?? {});
|
|
176
210
|
return {
|
|
177
211
|
...rest,
|
|
178
212
|
...(rawRuntime
|
|
@@ -355,19 +389,70 @@ function normalizeRawConfig(raw) {
|
|
|
355
389
|
enabled: rawPresidio.enabled ?? exports.defaultConfig.checks.privacy.presidio.enabled
|
|
356
390
|
}
|
|
357
391
|
}
|
|
358
|
-
: exports.defaultConfig.checks.privacy
|
|
392
|
+
: exports.defaultConfig.checks.privacy,
|
|
393
|
+
dpdp: rawDpdp
|
|
394
|
+
? {
|
|
395
|
+
enabled: rawDpdp.enabled ?? exports.defaultConfig.checks.dpdp.enabled,
|
|
396
|
+
include: normalizeStringArray(rawDpdp.include, exports.defaultConfig.checks.dpdp.include),
|
|
397
|
+
exclude: normalizeStringArray(rawDpdp.exclude, exports.defaultConfig.checks.dpdp.exclude),
|
|
398
|
+
minConfidenceToReport: rawDpdp.minConfidenceToReport ??
|
|
399
|
+
rawDpdp.min_confidence_to_report ??
|
|
400
|
+
exports.defaultConfig.checks.dpdp.minConfidenceToReport,
|
|
401
|
+
maskExamples: rawDpdp.maskExamples ??
|
|
402
|
+
rawDpdp.mask_examples ??
|
|
403
|
+
exports.defaultConfig.checks.dpdp.maskExamples,
|
|
404
|
+
usePresidio: rawDpdp.usePresidio ??
|
|
405
|
+
rawDpdp.use_presidio ??
|
|
406
|
+
exports.defaultConfig.checks.dpdp.usePresidio,
|
|
407
|
+
useSemgrep: rawDpdp.useSemgrep ??
|
|
408
|
+
rawDpdp.use_semgrep ??
|
|
409
|
+
exports.defaultConfig.checks.dpdp.useSemgrep,
|
|
410
|
+
legalSourceVersion: rawDpdp.legalSourceVersion ??
|
|
411
|
+
rawDpdp.legal_source_version ??
|
|
412
|
+
exports.defaultConfig.checks.dpdp.legalSourceVersion,
|
|
413
|
+
contextFile: rawDpdp.contextFile ??
|
|
414
|
+
rawDpdp.context_file ??
|
|
415
|
+
exports.defaultConfig.checks.dpdp.contextFile,
|
|
416
|
+
evidenceFile: rawDpdp.evidenceFile ??
|
|
417
|
+
rawDpdp.evidence_file ??
|
|
418
|
+
exports.defaultConfig.checks.dpdp.evidenceFile,
|
|
419
|
+
failOnSeverity: normalizeSeverityArray(rawDpdp.failOnSeverity ?? rawDpdp.fail_on_severity, exports.defaultConfig.checks.dpdp.failOnSeverity),
|
|
420
|
+
failOnViolatedControls: normalizeStringArray(rawDpdp.failOnViolatedControls ?? rawDpdp.fail_on_violated_controls, exports.defaultConfig.checks.dpdp.failOnViolatedControls),
|
|
421
|
+
failOnlyOnNew: rawDpdp.failOnlyOnNew ??
|
|
422
|
+
rawDpdp.fail_only_on_new ??
|
|
423
|
+
exports.defaultConfig.checks.dpdp.failOnlyOnNew,
|
|
424
|
+
organization: {
|
|
425
|
+
processesPersonalData: normalizeTriState(rawDpdpOrg.processesPersonalData ?? rawDpdpOrg.processes_personal_data, exports.defaultConfig.checks.dpdp.organization.processesPersonalData),
|
|
426
|
+
isSignificantDataFiduciary: normalizeTriState(rawDpdpOrg.isSignificantDataFiduciary ?? rawDpdpOrg.is_significant_data_fiduciary, exports.defaultConfig.checks.dpdp.organization.isSignificantDataFiduciary),
|
|
427
|
+
processesChildrenData: normalizeTriState(rawDpdpOrg.processesChildrenData ?? rawDpdpOrg.processes_children_data, exports.defaultConfig.checks.dpdp.organization.processesChildrenData),
|
|
428
|
+
hasCrossBorderTransfer: normalizeTriState(rawDpdpOrg.hasCrossBorderTransfer ?? rawDpdpOrg.has_cross_border_transfer, exports.defaultConfig.checks.dpdp.organization.hasCrossBorderTransfer)
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
: exports.defaultConfig.checks.dpdp
|
|
359
432
|
}
|
|
360
433
|
}
|
|
361
434
|
: {})
|
|
362
435
|
};
|
|
363
436
|
}
|
|
437
|
+
function normalizeTriState(value, fallback) {
|
|
438
|
+
if (value === true || value === "true" || value === "yes") {
|
|
439
|
+
return "true";
|
|
440
|
+
}
|
|
441
|
+
if (value === false || value === "false" || value === "no") {
|
|
442
|
+
return "false";
|
|
443
|
+
}
|
|
444
|
+
if (value === "unknown" || value === undefined || value === null) {
|
|
445
|
+
return value === "unknown" ? "unknown" : fallback;
|
|
446
|
+
}
|
|
447
|
+
return fallback;
|
|
448
|
+
}
|
|
364
449
|
async function loadConfig(root) {
|
|
365
450
|
const configPath = await findConfigFile(root);
|
|
366
451
|
if (!configPath) {
|
|
367
|
-
return { config: exports.defaultConfig };
|
|
452
|
+
return { config: structuredClone(exports.defaultConfig) };
|
|
368
453
|
}
|
|
369
454
|
const content = await node_fs_1.promises.readFile(configPath, "utf8");
|
|
370
455
|
const parsed = configPath.endsWith(".json") ? JSON.parse(content) : yaml_1.default.parse(content);
|
|
371
|
-
const config = deepMerge(exports.defaultConfig, normalizeRawConfig(parsed));
|
|
456
|
+
const config = deepMerge(structuredClone(exports.defaultConfig), normalizeRawConfig(parsed));
|
|
372
457
|
return { config, configPath };
|
|
373
458
|
}
|
package/dist/core/engine.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.safeFix = safeFix;
|
|
|
11
11
|
const adapters_1 = require("../adapters");
|
|
12
12
|
const customLeftovers_1 = require("../adapters/customLeftovers");
|
|
13
13
|
const privacyDetector_1 = require("../adapters/privacyDetector");
|
|
14
|
+
const dpdp_1 = require("../adapters/dpdp");
|
|
14
15
|
const customRefactor_1 = require("../adapters/customRefactor");
|
|
15
16
|
const customDeadChain_1 = require("../adapters/customDeadChain");
|
|
16
17
|
const presidio_1 = require("../adapters/presidio");
|
|
@@ -42,6 +43,7 @@ const ALL_ADAPTERS = [
|
|
|
42
43
|
adapters_1.vitestAdapter,
|
|
43
44
|
adapters_1.jestAdapter,
|
|
44
45
|
privacyDetector_1.privacyDetectorAdapter,
|
|
46
|
+
dpdp_1.dpdpAdapter,
|
|
45
47
|
presidio_1.presidioAdapter,
|
|
46
48
|
adapters_1.telemetryDetectorAdapter,
|
|
47
49
|
customLeftovers_1.customLeftoversAdapter,
|
|
@@ -338,9 +340,15 @@ async function runScan(root, mode = "default") {
|
|
|
338
340
|
const plan = await (0, scanPlanner_1.createScanPlan)(project, config, [...ALL_ADAPTERS], mode);
|
|
339
341
|
const ctx = { root, project, config, scanMode: mode };
|
|
340
342
|
const selectedAdapters = ALL_ADAPTERS.filter((adapter) => plan.adapterIds.includes(adapter.id));
|
|
341
|
-
|
|
342
|
-
//
|
|
343
|
-
|
|
343
|
+
const independentAdapters = selectedAdapters.filter((adapter) => adapter.id !== "dpdp");
|
|
344
|
+
// Run independent adapters once. DPDP follows so it can reuse optional scanner
|
|
345
|
+
// findings/status instead of launching duplicate Semgrep and Presidio processes.
|
|
346
|
+
const adapterResults = await Promise.all(independentAdapters.map(async (adapter) => ({ adapter, result: await runAdapter(adapter, ctx) })));
|
|
347
|
+
if (selectedAdapters.some((adapter) => adapter.id === "dpdp")) {
|
|
348
|
+
const sharedToolResults = Object.fromEntries(adapterResults.map(({ adapter, result }) => [adapter.id, result]));
|
|
349
|
+
const dpdpCtx = { ...ctx, sharedToolResults };
|
|
350
|
+
adapterResults.push({ adapter: dpdp_1.dpdpAdapter, result: await runAdapter(dpdp_1.dpdpAdapter, dpdpCtx) });
|
|
351
|
+
}
|
|
344
352
|
const findings = [];
|
|
345
353
|
const toolStatuses = [];
|
|
346
354
|
const skippedTools = [];
|
|
@@ -515,6 +523,10 @@ function buildSummaryLines(scan) {
|
|
|
515
523
|
lines.push(`Blockers: ${scan.blockers.length}`);
|
|
516
524
|
lines.push(`Fix next: ${scan.fixNext.length}`);
|
|
517
525
|
lines.push(`Privacy Review findings: ${scan.privacyFindings.length}`);
|
|
526
|
+
const dpdpFindings = scan.privacyFindings.filter((finding) => finding.source === "dpdp");
|
|
527
|
+
if (dpdpFindings.length > 0) {
|
|
528
|
+
lines.push(`DPDP technical findings: ${dpdpFindings.length} (not legal compliance)`);
|
|
529
|
+
}
|
|
518
530
|
lines.push(`Leftovers: ${scan.leftovers.length}`);
|
|
519
531
|
lines.push(`Dead code candidates: ${scan.deadCodeCandidates.length}`);
|
|
520
532
|
lines.push(`Refactor candidates: ${scan.refactorCandidates.length}`);
|
|
@@ -532,6 +544,13 @@ function buildSummaryLines(scan) {
|
|
|
532
544
|
.slice(0, 5)
|
|
533
545
|
.forEach((finding, index) => lines.push(`${index + 1}. ${finding.title}${finding.file ? ` (${finding.file}${finding.startLine ? `:${finding.startLine}` : ""})` : ""}`));
|
|
534
546
|
}
|
|
547
|
+
if (dpdpFindings.length > 0) {
|
|
548
|
+
lines.push("", "DPDP TECHNICAL FINDINGS (not legal compliance)");
|
|
549
|
+
dpdpFindings
|
|
550
|
+
.slice(0, 5)
|
|
551
|
+
.forEach((finding, index) => lines.push(`${index + 1}. ${finding.title}${finding.file ? ` (${finding.file}${finding.startLine ? `:${finding.startLine}` : ""})` : ""}`));
|
|
552
|
+
lines.push("Artifacts: .vibedoctor/dpdp/ · Command: vibedoctor dpdp report --markdown");
|
|
553
|
+
}
|
|
535
554
|
if (scan.leftovers.length > 0) {
|
|
536
555
|
lines.push("", "LEFTOVERS");
|
|
537
556
|
scan.leftovers.forEach((finding, index) => lines.push(`${index + 1}. ${finding.title}${finding.file ? ` (${finding.file})` : ""}`));
|
package/dist/core/finding.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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"];
|
|
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", "dpdp", "custom-leftovers", "custom-refactor", "custom-dead-chain"];
|
|
2
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];
|
package/dist/core/finding.js
CHANGED
package/dist/core/scanPlanner.js
CHANGED
|
@@ -11,6 +11,7 @@ async function createScanPlan(project, config, adapters, mode) {
|
|
|
11
11
|
"gitleaks",
|
|
12
12
|
"osv-scanner",
|
|
13
13
|
"privacy-detector",
|
|
14
|
+
"dpdp",
|
|
14
15
|
"custom-leftovers"
|
|
15
16
|
]);
|
|
16
17
|
for (const adapter of adapters) {
|
|
@@ -32,8 +33,15 @@ async function createScanPlan(project, config, adapters, mode) {
|
|
|
32
33
|
if (adapter.category === "dependencies" && !config.checks.dependencies.enabled) {
|
|
33
34
|
continue;
|
|
34
35
|
}
|
|
35
|
-
if (adapter.category === "privacy"
|
|
36
|
-
|
|
36
|
+
if (adapter.category === "privacy") {
|
|
37
|
+
if (adapter.id === "dpdp") {
|
|
38
|
+
if (!config.checks.dpdp.enabled) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (!config.checks.privacy.enabled) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
37
45
|
}
|
|
38
46
|
if (mode === "quick" && !quickAdapterIds.has(adapter.id)) {
|
|
39
47
|
continue;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DpdpScanResult } from "./types";
|
|
2
|
+
export declare const DPDP_ARTIFACT_DIR = ".vibedoctor/dpdp";
|
|
3
|
+
export declare const DPDP_READINESS_REPORT = "readiness-report.json";
|
|
4
|
+
export declare function writeDpdpArtifacts(root: string, result: DpdpScanResult): Promise<string[]>;
|
|
5
|
+
export declare function serializeDpdpReport(result: DpdpScanResult): Record<string, unknown>;
|
|
6
|
+
export declare function readDpdpArtifact<T>(root: string, name: string): Promise<T | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Load a previously written DPDP scan result from artifacts without re-scanning.
|
|
9
|
+
* Requires readiness-report.json (and preferably evidence-ledger.json).
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadCachedDpdpScanResult(root: string): Promise<DpdpScanResult | undefined>;
|
|
@@ -0,0 +1,120 @@
|
|
|
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.DPDP_READINESS_REPORT = exports.DPDP_ARTIFACT_DIR = void 0;
|
|
7
|
+
exports.writeDpdpArtifacts = writeDpdpArtifacts;
|
|
8
|
+
exports.serializeDpdpReport = serializeDpdpReport;
|
|
9
|
+
exports.readDpdpArtifact = readDpdpArtifact;
|
|
10
|
+
exports.loadCachedDpdpScanResult = loadCachedDpdpScanResult;
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const paths_1 = require("../core/paths");
|
|
14
|
+
const reviewQueue_1 = require("./reviewQueue");
|
|
15
|
+
const report_1 = require("./report");
|
|
16
|
+
exports.DPDP_ARTIFACT_DIR = ".vibedoctor/dpdp";
|
|
17
|
+
exports.DPDP_READINESS_REPORT = "readiness-report.json";
|
|
18
|
+
async function writeDpdpArtifacts(root, result) {
|
|
19
|
+
const dir = node_path_1.default.join(root, exports.DPDP_ARTIFACT_DIR);
|
|
20
|
+
await (0, paths_1.ensureDir)(dir);
|
|
21
|
+
const files = [
|
|
22
|
+
{ name: "data-map.json", content: `${JSON.stringify(result.dataMap, null, 2)}\n` },
|
|
23
|
+
{ name: "control-matrix.json", content: `${JSON.stringify(result.controlMatrix, null, 2)}\n` },
|
|
24
|
+
{ name: "evidence-ledger.json", content: `${JSON.stringify(result.evidenceLedger, null, 2)}\n` },
|
|
25
|
+
{ name: "review-queue.md", content: (0, reviewQueue_1.renderReviewQueueMarkdown)(result.reviewQueue) },
|
|
26
|
+
{ name: "agent-handoff.md", content: (0, report_1.renderAgentHandoff)(result) },
|
|
27
|
+
{ name: "readiness-report.json", content: `${JSON.stringify(serializeDpdpReport(result), null, 2)}\n` },
|
|
28
|
+
{ name: "readiness-report.md", content: (0, report_1.renderDpdpMarkdownReport)(result) },
|
|
29
|
+
{ name: "readiness-report.html", content: (0, report_1.renderDpdpHtmlReport)(result) }
|
|
30
|
+
];
|
|
31
|
+
const written = [];
|
|
32
|
+
for (const file of files) {
|
|
33
|
+
const absolute = node_path_1.default.join(dir, file.name);
|
|
34
|
+
await node_fs_1.promises.writeFile(absolute, file.content, "utf8");
|
|
35
|
+
written.push(node_path_1.default.join(exports.DPDP_ARTIFACT_DIR, file.name).replaceAll("\\", "/"));
|
|
36
|
+
}
|
|
37
|
+
return written;
|
|
38
|
+
}
|
|
39
|
+
function serializeDpdpReport(result) {
|
|
40
|
+
return {
|
|
41
|
+
version: result.version,
|
|
42
|
+
generatedAt: result.generatedAt,
|
|
43
|
+
disclaimer: result.disclaimer,
|
|
44
|
+
mode: result.mode,
|
|
45
|
+
legalSourceVersion: result.legalSourceVersion,
|
|
46
|
+
scores: result.scores,
|
|
47
|
+
summary: result.scores.statusCounts,
|
|
48
|
+
dataMap: result.dataMap,
|
|
49
|
+
controlMatrix: result.controlMatrix,
|
|
50
|
+
reviewQueue: result.reviewQueue,
|
|
51
|
+
fixNext: result.fixNext,
|
|
52
|
+
capabilities: result.capabilities,
|
|
53
|
+
findings: result.findings,
|
|
54
|
+
context: result.context,
|
|
55
|
+
baselineApplied: result.baselineApplied
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async function readDpdpArtifact(root, name) {
|
|
59
|
+
const absolute = node_path_1.default.join(root, exports.DPDP_ARTIFACT_DIR, name);
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(await node_fs_1.promises.readFile(absolute, "utf8"));
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Load a previously written DPDP scan result from artifacts without re-scanning.
|
|
69
|
+
* Requires readiness-report.json (and preferably evidence-ledger.json).
|
|
70
|
+
*/
|
|
71
|
+
async function loadCachedDpdpScanResult(root) {
|
|
72
|
+
const report = await readDpdpArtifact(root, exports.DPDP_READINESS_REPORT);
|
|
73
|
+
if (!report?.scores || !report?.controlMatrix) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
const evidenceLedger = (await readDpdpArtifact(root, "evidence-ledger.json")) ??
|
|
77
|
+
{
|
|
78
|
+
version: 1,
|
|
79
|
+
generatedAt: String(report.generatedAt ?? ""),
|
|
80
|
+
disclaimer: String(report.disclaimer ?? ""),
|
|
81
|
+
evidence: [],
|
|
82
|
+
declared: []
|
|
83
|
+
};
|
|
84
|
+
const dataMapRaw = (await readDpdpArtifact(root, "data-map.json")) ??
|
|
85
|
+
report.dataMap;
|
|
86
|
+
if (!dataMapRaw) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
const dataMap = {
|
|
90
|
+
...dataMapRaw,
|
|
91
|
+
graph: dataMapRaw.graph ?? { nodes: [], edges: [] }
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
version: 1,
|
|
95
|
+
generatedAt: String(report.generatedAt ?? ""),
|
|
96
|
+
root,
|
|
97
|
+
mode: report.mode ?? "full",
|
|
98
|
+
disclaimer: String(report.disclaimer ?? ""),
|
|
99
|
+
scores: report.scores,
|
|
100
|
+
dataMap,
|
|
101
|
+
controlMatrix: report.controlMatrix,
|
|
102
|
+
evidenceLedger,
|
|
103
|
+
reviewQueue: report.reviewQueue ?? [],
|
|
104
|
+
fixNext: report.fixNext ??
|
|
105
|
+
[],
|
|
106
|
+
capabilities: report.capabilities ?? [],
|
|
107
|
+
findings: report.findings ?? [],
|
|
108
|
+
legalSourceVersion: String(report.legalSourceVersion ?? ""),
|
|
109
|
+
context: report.context ?? {
|
|
110
|
+
version: 1,
|
|
111
|
+
organization: {
|
|
112
|
+
processesPersonalData: "unknown",
|
|
113
|
+
isSignificantDataFiduciary: "unknown",
|
|
114
|
+
processesChildrenData: "unknown",
|
|
115
|
+
hasCrossBorderTransfer: "unknown"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
baselineApplied: Boolean(report.baselineApplied)
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ControlDefinition, VerificationClass } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Machine-readable DPDP obligation catalogue for technical readiness assessment.
|
|
4
|
+
* Every control has verification class, legal reference, and evaluator linkage where deterministic.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DPDP_CONTROLS: ControlDefinition[];
|
|
7
|
+
export declare function getControlById(id: string): ControlDefinition | undefined;
|
|
8
|
+
export declare function controlsByDomain(): Record<string, ControlDefinition[]>;
|
|
9
|
+
export declare function controlsForVerificationClass(vc: VerificationClass): ControlDefinition[];
|
|
10
|
+
export declare const DPDP_CATALOGUE_META: {
|
|
11
|
+
version: string;
|
|
12
|
+
controlCount: number;
|
|
13
|
+
disclaimer: string;
|
|
14
|
+
};
|