@neuralaxis/vibedoctor 0.1.2 → 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 +215 -102
- package/dist/adapters/biome.d.ts +1 -1
- package/dist/adapters/biome.js +7 -4
- package/dist/adapters/coveragePy.js +3 -0
- package/dist/adapters/deptry.js +21 -2
- 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/knip.js +29 -4
- package/dist/adapters/lizard.d.ts +1 -1
- package/dist/adapters/lizard.js +51 -2
- package/dist/adapters/osvScanner.js +14 -2
- package/dist/adapters/presidio.js +3 -1
- package/dist/adapters/privacyDetector.d.ts +24 -1
- package/dist/adapters/privacyDetector.js +91 -7
- package/dist/adapters/ruff.d.ts +1 -1
- package/dist/adapters/ruff.js +4 -1
- package/dist/adapters/semgrep.d.ts +1 -1
- package/dist/adapters/semgrep.js +17 -3
- package/dist/adapters/shared.d.ts +7 -0
- package/dist/adapters/shared.js +22 -0
- package/dist/adapters/tsc.js +43 -18
- package/dist/adapters/vulture.d.ts +1 -1
- package/dist/adapters/vulture.js +25 -6
- package/dist/agentPack/templates/index.js +7 -4
- package/dist/agentPack/templates/skills.js +156 -44
- package/dist/cli/commands/agentPlan.js +9 -1
- package/dist/cli/commands/dpdp.d.ts +35 -0
- package/dist/cli/commands/dpdp.js +103 -0
- package/dist/cli/commands/init.js +12 -4
- package/dist/cli/commands/scan.d.ts +1 -1
- package/dist/cli/commands/scan.js +8 -1
- package/dist/cli/commands/setup.js +4 -2
- package/dist/cli/commands/tool.d.ts +4 -0
- package/dist/cli/commands/tool.js +11 -0
- package/dist/cli/index.js +96 -0
- package/dist/core/config.d.ts +27 -0
- package/dist/core/config.js +118 -5
- package/dist/core/engine.d.ts +32 -1
- package/dist/core/engine.js +195 -30
- package/dist/core/finding.d.ts +1 -1
- package/dist/core/finding.js +1 -0
- package/dist/core/projectDetector.d.ts +1 -1
- package/dist/core/projectDetector.js +29 -12
- package/dist/core/scanPlanner.js +10 -2
- package/dist/core/toolRunner.d.ts +1 -0
- package/dist/core/toolRunner.js +73 -11
- 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/mcp/tools/shared.js +8 -1
- package/dist/reporters/agent.js +8 -0
- package/dist/reporters/html.js +4 -2
- package/dist/reporters/json.js +8 -1
- package/dist/reporters/markdown.js +8 -1
- package/package.json +9 -2
|
@@ -110,12 +110,12 @@ function isFrameworkEntryFile(file) {
|
|
|
110
110
|
/^(?:src\/)?pages\/(?:.+)\.(ts|tsx|js|jsx)$/.test(file) ||
|
|
111
111
|
/^(?:src\/)?(?:middleware|instrumentation)\.(ts|js)$/.test(file));
|
|
112
112
|
}
|
|
113
|
-
async function detectProject(root) {
|
|
113
|
+
async function detectProject(root, excludePatterns) {
|
|
114
114
|
const projectFiles = await (0, paths_1.listProjectFiles)(root);
|
|
115
|
-
const
|
|
115
|
+
const detectionFiles = excludePatterns ? (0, paths_1.filterPaths)(projectFiles, ["**/*"], excludePatterns) : projectFiles;
|
|
116
116
|
const languages = new Set();
|
|
117
117
|
const frameworkHints = new Set();
|
|
118
|
-
for (const file of
|
|
118
|
+
for (const file of detectionFiles) {
|
|
119
119
|
if (file.endsWith(".py")) {
|
|
120
120
|
languages.add("python");
|
|
121
121
|
}
|
|
@@ -133,29 +133,46 @@ async function detectProject(root) {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
const packageManagers = new Set();
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
const hasPackageJson = detectionFiles.some((f) => f === "package.json" || f.endsWith("/package.json"));
|
|
137
|
+
const hasPythonManifest = detectionFiles.some((f) => f === "requirements.txt" || f.endsWith("/requirements.txt") || f === "pyproject.toml" || f.endsWith("/pyproject.toml"));
|
|
138
|
+
if (hasPackageJson) {
|
|
139
|
+
packageManagers.add(detectionFiles.some((f) => f === "pnpm-lock.yaml" || f.endsWith("/pnpm-lock.yaml"))
|
|
140
|
+
? "pnpm"
|
|
141
|
+
: detectionFiles.some((f) => f === "yarn.lock" || f.endsWith("/yarn.lock"))
|
|
142
|
+
? "yarn"
|
|
143
|
+
: detectionFiles.some((f) => f === "bun.lockb" || f.endsWith("/bun.lockb"))
|
|
144
|
+
? "bun"
|
|
145
|
+
: "npm");
|
|
146
|
+
}
|
|
147
|
+
if (hasPythonManifest) {
|
|
148
|
+
packageManagers.add(detectionFiles.some((f) => f === "uv.lock" || f.endsWith("/uv.lock"))
|
|
149
|
+
? "uv"
|
|
150
|
+
: detectionFiles.some((f) => f === "poetry.lock" || f.endsWith("/poetry.lock"))
|
|
151
|
+
? "poetry"
|
|
152
|
+
: detectionFiles.some((f) => f === "pdm.lock" || f.endsWith("/pdm.lock"))
|
|
153
|
+
? "pdm"
|
|
154
|
+
: "pip");
|
|
141
155
|
}
|
|
142
156
|
const packageMetadata = await readPackageMetadata(root, ["npm", "pnpm", "yarn", "bun"].find((manager) => packageManagers.has(manager)));
|
|
143
157
|
for (const hint of packageMetadata.frameworkHints) {
|
|
144
158
|
frameworkHints.add(hint);
|
|
145
159
|
}
|
|
146
|
-
if (
|
|
160
|
+
if (detectionFiles.some((f) => f === "pytest.ini" || f.endsWith("/pytest.ini")) ||
|
|
161
|
+
detectionFiles.some((file) => /(^|\/)tests?\//.test(file) && file.endsWith(".py"))) {
|
|
147
162
|
packageMetadata.testCommands.push(pythonTestCommand(packageManagers));
|
|
148
163
|
}
|
|
149
164
|
const toolPairs = await Promise.all(KNOWN_TOOLS.map(async (tool) => [tool, await commandExists(tool, root)]));
|
|
150
|
-
const entryFiles =
|
|
165
|
+
const entryFiles = detectionFiles.filter((file) => /(^|\/)(main|index|app|server|cli)\.(ts|tsx|js|jsx|py)$/.test(file) || isFrameworkEntryFile(file) || file.endsWith("package.json"));
|
|
151
166
|
return {
|
|
152
167
|
root,
|
|
153
168
|
languages: Array.from(languages).sort(),
|
|
154
169
|
packageManagers: Array.from(packageManagers).sort(),
|
|
155
170
|
hasGit: await (0, git_1.isGitRepo)(root),
|
|
156
171
|
changedFiles: await (0, git_1.getChangedFiles)(root),
|
|
157
|
-
configFiles: KNOWN_CONFIG_FILES.filter((fileName) =>
|
|
158
|
-
|
|
172
|
+
configFiles: KNOWN_CONFIG_FILES.filter((fileName) => detectionFiles.some((f) => f === fileName || f.endsWith(`/${fileName}`))),
|
|
173
|
+
// Consumers pass these values directly to tools such as osv-scanner, so
|
|
174
|
+
// retain the repository-relative path rather than just the basename.
|
|
175
|
+
lockfiles: detectionFiles.filter((file) => KNOWN_LOCKFILES.some((fileName) => file === fileName || file.endsWith(`/${fileName}`))),
|
|
159
176
|
testCommands: Array.from(new Set(packageMetadata.testCommands)),
|
|
160
177
|
toolsAvailable: Object.fromEntries(toolPairs),
|
|
161
178
|
frameworkHints: Array.from(frameworkHints).sort(),
|
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;
|
|
@@ -16,6 +16,7 @@ export type ToolResult = {
|
|
|
16
16
|
};
|
|
17
17
|
export declare function getLocalToolSearchPaths(cwd: string | undefined): string[];
|
|
18
18
|
export declare function buildCommandEnv(cwd: string | undefined, overrides: NodeJS.ProcessEnv | undefined): NodeJS.ProcessEnv;
|
|
19
|
+
export declare function commandExistsOnWindowsPath(command: string, cwd?: string): boolean;
|
|
19
20
|
export declare function runCommand(spec: CommandSpec, installHint?: string): Promise<ToolResult>;
|
|
20
21
|
export declare function runCommands(commands: Array<{
|
|
21
22
|
id: string;
|
package/dist/core/toolRunner.js
CHANGED
|
@@ -5,10 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getLocalToolSearchPaths = getLocalToolSearchPaths;
|
|
7
7
|
exports.buildCommandEnv = buildCommandEnv;
|
|
8
|
+
exports.commandExistsOnWindowsPath = commandExistsOnWindowsPath;
|
|
8
9
|
exports.runCommand = runCommand;
|
|
9
10
|
exports.runCommands = runCommands;
|
|
10
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const node_fs_1 = require("node:fs");
|
|
11
13
|
const node_child_process_1 = require("node:child_process");
|
|
14
|
+
const node_child_process_2 = require("node:child_process");
|
|
12
15
|
const LOCAL_TOOL_PATHS = [
|
|
13
16
|
["node_modules", ".bin"],
|
|
14
17
|
[".venv", "Scripts"],
|
|
@@ -38,23 +41,78 @@ function getLocalToolSearchPaths(cwd) {
|
|
|
38
41
|
const paths = ancestorDirs(cwd).flatMap((dir) => LOCAL_TOOL_PATHS.map((segments) => node_path_1.default.join(dir, ...segments)));
|
|
39
42
|
return Array.from(new Set(paths));
|
|
40
43
|
}
|
|
44
|
+
function getUserToolSearchPaths(env) {
|
|
45
|
+
const paths = [];
|
|
46
|
+
if (process.platform === "win32" && env.APPDATA) {
|
|
47
|
+
const pythonRoot = node_path_1.default.join(env.APPDATA, "Python");
|
|
48
|
+
try {
|
|
49
|
+
for (const entry of (0, node_fs_1.readdirSync)(pythonRoot, { withFileTypes: true })) {
|
|
50
|
+
if (entry.isDirectory() && /^Python\d+$/i.test(entry.name)) {
|
|
51
|
+
paths.push(node_path_1.default.join(pythonRoot, entry.name, "Scripts"));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Python user packages have not been installed for this account.
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (env.HOME) {
|
|
60
|
+
paths.push(node_path_1.default.join(env.HOME, ".local", "bin"));
|
|
61
|
+
}
|
|
62
|
+
return paths;
|
|
63
|
+
}
|
|
41
64
|
function buildCommandEnv(cwd, overrides) {
|
|
42
65
|
const env = { ...process.env, ...overrides };
|
|
43
66
|
const pathKey = getPathKey(env);
|
|
44
67
|
const existingPath = env[pathKey];
|
|
45
|
-
env[pathKey] = [...getLocalToolSearchPaths(cwd), existingPath].filter(Boolean).join(node_path_1.default.delimiter);
|
|
68
|
+
env[pathKey] = [...getLocalToolSearchPaths(cwd), ...getUserToolSearchPaths(env), existingPath].filter(Boolean).join(node_path_1.default.delimiter);
|
|
46
69
|
return env;
|
|
47
70
|
}
|
|
71
|
+
function findWindowsCommandOnPath(command, env) {
|
|
72
|
+
const pathValue = env[getPathKey(env)] ?? "";
|
|
73
|
+
const extensions = (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD")
|
|
74
|
+
.split(";")
|
|
75
|
+
.map((extension) => extension.toLowerCase());
|
|
76
|
+
for (const directory of pathValue.split(node_path_1.default.delimiter).filter(Boolean)) {
|
|
77
|
+
for (const extension of extensions) {
|
|
78
|
+
const candidate = node_path_1.default.join(directory, `${command}${extension}`);
|
|
79
|
+
if ((0, node_fs_1.existsSync)(candidate)) {
|
|
80
|
+
return candidate;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
function commandExistsOnWindowsPath(command, cwd) {
|
|
87
|
+
return findWindowsCommandOnPath(command, buildCommandEnv(cwd, undefined)) !== undefined;
|
|
88
|
+
}
|
|
89
|
+
function resolveWindowsCommand(command, env) {
|
|
90
|
+
if (process.platform !== "win32" || node_path_1.default.isAbsolute(command) || node_path_1.default.extname(command)) {
|
|
91
|
+
return { command, useShell: false };
|
|
92
|
+
}
|
|
93
|
+
const candidate = findWindowsCommandOnPath(command, env);
|
|
94
|
+
if (candidate) {
|
|
95
|
+
if (/\.(?:cmd|bat)$/i.test(candidate)) {
|
|
96
|
+
// cmd.exe scripts must run through the shell; quote the resolved path so
|
|
97
|
+
// directories with spaces (e.g. "Program Files") do not break parsing.
|
|
98
|
+
return { command: candidate.includes(" ") ? `"${candidate}"` : candidate, useShell: true };
|
|
99
|
+
}
|
|
100
|
+
return { command: candidate, useShell: false };
|
|
101
|
+
}
|
|
102
|
+
// Not found via PATH/PATHEXT probing. Fall back to the shell so commands that
|
|
103
|
+
// are only reachable through cmd.exe mechanisms (App Execution Aliases,
|
|
104
|
+
// App Paths registry entries) still launch, matching the previous behavior.
|
|
105
|
+
return { command, useShell: true };
|
|
106
|
+
}
|
|
48
107
|
async function runCommand(spec, installHint) {
|
|
49
108
|
const startedAt = Date.now();
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
node_path_1.default.extname(spec.cmd).length === 0;
|
|
109
|
+
const env = buildCommandEnv(spec.cwd, spec.env);
|
|
110
|
+
const resolved = resolveWindowsCommand(spec.cmd, env);
|
|
53
111
|
return new Promise((resolve) => {
|
|
54
|
-
const child = (0, node_child_process_1.spawn)(
|
|
112
|
+
const child = (0, node_child_process_1.spawn)(resolved.command, spec.args, {
|
|
55
113
|
cwd: spec.cwd,
|
|
56
|
-
env
|
|
57
|
-
shell: useShell,
|
|
114
|
+
env,
|
|
115
|
+
shell: resolved.useShell,
|
|
58
116
|
windowsHide: true
|
|
59
117
|
});
|
|
60
118
|
let stdout = "";
|
|
@@ -126,11 +184,15 @@ async function runCommand(spec, installHint) {
|
|
|
126
184
|
return;
|
|
127
185
|
}
|
|
128
186
|
settled = true;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
187
|
+
if (process.platform === "win32" && child.pid) {
|
|
188
|
+
(0, node_child_process_2.execFile)("taskkill", ["/pid", String(child.pid), "/T", "/F"], { windowsHide: true }, () => undefined);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
try {
|
|
192
|
+
child.kill("SIGTERM");
|
|
193
|
+
}
|
|
194
|
+
catch { }
|
|
132
195
|
}
|
|
133
|
-
catch { }
|
|
134
196
|
cleanup();
|
|
135
197
|
resolve({
|
|
136
198
|
command: [spec.cmd, ...spec.args].join(" "),
|
|
@@ -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
|
+
};
|