@neuralaxis/vibedoctor 0.1.3 → 0.2.1
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 +298 -115
- package/dist/adapters/biome.js +135 -21
- 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/osvScanner.js +136 -17
- package/dist/adapters/presidio.js +6 -2
- 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/init.js +105 -50
- package/dist/cli/commands/privacyReview.js +3 -4
- package/dist/cli/commands/scan.js +4 -1
- package/dist/cli/commands/setup.d.ts +13 -17
- package/dist/cli/commands/setup.js +138 -200
- package/dist/cli/index.js +84 -0
- package/dist/core/capability.d.ts +92 -0
- package/dist/core/capability.js +122 -0
- package/dist/core/config.d.ts +57 -0
- package/dist/core/config.js +194 -7
- package/dist/core/credentialHeuristics.d.ts +28 -0
- package/dist/core/credentialHeuristics.js +179 -0
- package/dist/core/engine.d.ts +21 -0
- package/dist/core/engine.js +484 -84
- package/dist/core/executable.d.ts +18 -0
- package/dist/core/executable.js +137 -0
- package/dist/core/fileRole.d.ts +24 -0
- package/dist/core/fileRole.js +125 -0
- package/dist/core/finding.d.ts +125 -1
- package/dist/core/finding.js +63 -5
- package/dist/core/findingNormalizer.d.ts +33 -0
- package/dist/core/findingNormalizer.js +171 -0
- package/dist/core/projectDetector.d.ts +13 -0
- package/dist/core/projectDetector.js +100 -15
- package/dist/core/relevance.d.ts +87 -0
- package/dist/core/relevance.js +367 -0
- package/dist/core/scanPlanner.d.ts +12 -0
- package/dist/core/scanPlanner.js +61 -29
- package/dist/core/semverLite.d.ts +27 -0
- package/dist/core/semverLite.js +163 -0
- package/dist/core/suppressions.d.ts +96 -0
- package/dist/core/suppressions.js +302 -0
- package/dist/core/toolRegistry.d.ts +58 -0
- package/dist/core/toolRegistry.js +247 -0
- package/dist/core/toolRunner.d.ts +23 -2
- package/dist/core/toolRunner.js +61 -93
- package/dist/core/toolVerification.d.ts +87 -0
- package/dist/core/toolVerification.js +370 -0
- 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 +437 -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 +44 -0
- package/dist/dpdp/findings.js +286 -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 +41 -0
- package/dist/dpdp/scoring.js +237 -0
- package/dist/dpdp/types.d.ts +312 -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/html.js +57 -13
- package/dist/reporters/json.js +12 -1
- package/dist/reporters/markdown.js +46 -4
- package/dist/reporters/sarif.js +54 -5
- package/package.json +4 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DpdpScanResult } from "./types";
|
|
2
|
+
export declare function renderDpdpTerminalReport(result: DpdpScanResult): string;
|
|
3
|
+
export declare function renderDpdpMarkdownReport(result: DpdpScanResult): string;
|
|
4
|
+
export declare function renderDpdpHtmlReport(result: DpdpScanResult): string;
|
|
5
|
+
export declare function renderAgentHandoff(result: DpdpScanResult): string;
|
|
6
|
+
export declare function renderDpdpJsonReport(result: DpdpScanResult): string;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderDpdpTerminalReport = renderDpdpTerminalReport;
|
|
4
|
+
exports.renderDpdpMarkdownReport = renderDpdpMarkdownReport;
|
|
5
|
+
exports.renderDpdpHtmlReport = renderDpdpHtmlReport;
|
|
6
|
+
exports.renderAgentHandoff = renderAgentHandoff;
|
|
7
|
+
exports.renderDpdpJsonReport = renderDpdpJsonReport;
|
|
8
|
+
function renderDpdpTerminalReport(result) {
|
|
9
|
+
const { scores, dataMap, fixNext, capabilities } = result;
|
|
10
|
+
const lines = [
|
|
11
|
+
"DPDP technical readiness (not legal compliance)",
|
|
12
|
+
`${scores.labels.technicalPosture}: ${scores.technicalPostureScore}/100`,
|
|
13
|
+
`${scores.labels.evidenceCompleteness}: ${scores.evidenceCompletenessPercent}%`,
|
|
14
|
+
"",
|
|
15
|
+
`Controls — verified: ${scores.statusCounts.verified}, violated: ${scores.statusCounts.violated}, partial: ${scores.statusCounts.partial}, unresolved: ${scores.statusCounts.unresolved}, skipped: ${scores.statusCounts.skipped}, human-review: ${scores.statusCounts.humanReview}`,
|
|
16
|
+
`Open risk — critical: ${scores.openRiskBySeverity.critical}, high: ${scores.openRiskBySeverity.high}, medium: ${scores.openRiskBySeverity.medium}, low: ${scores.openRiskBySeverity.low}`,
|
|
17
|
+
"",
|
|
18
|
+
`Personal-data categories: ${dataMap.categories.map((item) => item.category).join(", ") || "(none observed)"}`,
|
|
19
|
+
`Stores: ${dataMap.stores.length}`,
|
|
20
|
+
`External recipients: ${dataMap.externalRecipients.length}`,
|
|
21
|
+
`Data-map graph: ${dataMap.graph?.nodes.length ?? 0} nodes, ${dataMap.graph?.edges.length ?? 0} edges`,
|
|
22
|
+
`Verified technical risks (violations): ${scores.statusCounts.violated}`,
|
|
23
|
+
`Partial controls: ${scores.statusCounts.partial}`,
|
|
24
|
+
`Human-review items: ${result.reviewQueue.length}`,
|
|
25
|
+
`Skipped capabilities: ${capabilities.filter((item) => item.status === "skipped").map((item) => item.id).join(", ") || "(none)"}`,
|
|
26
|
+
""
|
|
27
|
+
];
|
|
28
|
+
if (fixNext.length > 0) {
|
|
29
|
+
lines.push("FIX NEXT");
|
|
30
|
+
fixNext.slice(0, 5).forEach((item, index) => {
|
|
31
|
+
lines.push(`${index + 1}. [${item.severity}] ${item.controlId} — ${item.title}`);
|
|
32
|
+
lines.push(` ${item.remediation}`);
|
|
33
|
+
});
|
|
34
|
+
lines.push("");
|
|
35
|
+
}
|
|
36
|
+
lines.push("Artifacts: .vibedoctor/dpdp/");
|
|
37
|
+
lines.push("Handoff: vibedoctor dpdp handoff");
|
|
38
|
+
lines.push("");
|
|
39
|
+
lines.push(result.disclaimer);
|
|
40
|
+
return `${lines.join("\n")}\n`;
|
|
41
|
+
}
|
|
42
|
+
function renderDpdpMarkdownReport(result) {
|
|
43
|
+
const lines = [
|
|
44
|
+
"# DPDP Technical Readiness Report",
|
|
45
|
+
"",
|
|
46
|
+
`> ${result.disclaimer}`,
|
|
47
|
+
"",
|
|
48
|
+
"## Scores (technical readiness — not legal compliance)",
|
|
49
|
+
"",
|
|
50
|
+
`| Metric | Value |`,
|
|
51
|
+
`| --- | --- |`,
|
|
52
|
+
`| ${result.scores.labels.technicalPosture} | ${result.scores.technicalPostureScore}/100 |`,
|
|
53
|
+
`| ${result.scores.labels.evidenceCompleteness} | ${result.scores.evidenceCompletenessPercent}% |`,
|
|
54
|
+
"",
|
|
55
|
+
"## Control status counts",
|
|
56
|
+
"",
|
|
57
|
+
`- Verified: ${result.scores.statusCounts.verified}`,
|
|
58
|
+
`- Violated: ${result.scores.statusCounts.violated}`,
|
|
59
|
+
`- Partial: ${result.scores.statusCounts.partial}`,
|
|
60
|
+
`- Unresolved: ${result.scores.statusCounts.unresolved}`,
|
|
61
|
+
`- Needs context: ${result.scores.statusCounts.needsContext}`,
|
|
62
|
+
`- Not observed: ${result.scores.statusCounts.notObserved}`,
|
|
63
|
+
`- Not applicable: ${result.scores.statusCounts.notApplicable}`,
|
|
64
|
+
`- Skipped: ${result.scores.statusCounts.skipped}`,
|
|
65
|
+
`- Human-review: ${result.scores.statusCounts.humanReview}`,
|
|
66
|
+
"",
|
|
67
|
+
"## Personal-data map summary",
|
|
68
|
+
"",
|
|
69
|
+
`- Categories: ${result.dataMap.categories.map((item) => `${item.category} (${item.count})`).join(", ") || "none"}`,
|
|
70
|
+
`- Stores: ${result.dataMap.stores.length}`,
|
|
71
|
+
`- External recipients: ${result.dataMap.externalRecipients.map((item) => item.name).join(", ") || "none"}`,
|
|
72
|
+
`- Graph: ${result.dataMap.graph?.nodes.length ?? 0} nodes, ${result.dataMap.graph?.edges.length ?? 0} edges`,
|
|
73
|
+
"",
|
|
74
|
+
"## Fix next",
|
|
75
|
+
""
|
|
76
|
+
];
|
|
77
|
+
if (result.fixNext.length === 0) {
|
|
78
|
+
lines.push("_No violated/partial technical controls prioritised._");
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
for (const item of result.fixNext) {
|
|
82
|
+
lines.push(`### ${item.controlId} — ${item.title}`);
|
|
83
|
+
lines.push("");
|
|
84
|
+
lines.push(`- Severity: ${item.severity}`);
|
|
85
|
+
lines.push(`- Remediation: ${item.remediation}`);
|
|
86
|
+
lines.push("");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
lines.push("## Review queue");
|
|
90
|
+
lines.push("");
|
|
91
|
+
for (const item of result.reviewQueue.slice(0, 20)) {
|
|
92
|
+
lines.push(`- **${item.controlId}** (${item.audience}): ${item.question}`);
|
|
93
|
+
}
|
|
94
|
+
lines.push("");
|
|
95
|
+
lines.push(`Legal source version: ${result.legalSourceVersion}`);
|
|
96
|
+
lines.push("");
|
|
97
|
+
return `${lines.join("\n")}\n`;
|
|
98
|
+
}
|
|
99
|
+
function renderDpdpHtmlReport(result) {
|
|
100
|
+
const escape = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
101
|
+
const fixRows = result.fixNext
|
|
102
|
+
.map((item) => `<tr><td>${escape(item.controlId)}</td><td>${escape(item.severity)}</td><td>${escape(item.title)}</td><td>${escape(item.remediation)}</td></tr>`)
|
|
103
|
+
.join("");
|
|
104
|
+
return `<!doctype html>
|
|
105
|
+
<html lang="en">
|
|
106
|
+
<head>
|
|
107
|
+
<meta charset="utf-8" />
|
|
108
|
+
<title>DPDP Technical Readiness</title>
|
|
109
|
+
<style>
|
|
110
|
+
body { font-family: ui-sans-serif, system-ui, sans-serif; margin: 2rem; color: #0f172a; background: #f8fafc; }
|
|
111
|
+
.card { background: white; border: 1px solid #e2e8f0; border-radius: 12px; padding: 1.25rem; margin-bottom: 1rem; }
|
|
112
|
+
h1 { margin-top: 0; }
|
|
113
|
+
.muted { color: #475569; }
|
|
114
|
+
.score { font-size: 2rem; font-weight: 700; }
|
|
115
|
+
table { width: 100%; border-collapse: collapse; }
|
|
116
|
+
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
|
|
117
|
+
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; background: #e2e8f0; font-size: 0.85rem; }
|
|
118
|
+
</style>
|
|
119
|
+
</head>
|
|
120
|
+
<body>
|
|
121
|
+
<div class="card">
|
|
122
|
+
<h1>DPDP Technical Readiness</h1>
|
|
123
|
+
<p class="muted">${escape(result.disclaimer)}</p>
|
|
124
|
+
<p><span class="score">${result.scores.technicalPostureScore}</span> / 100 technical posture</p>
|
|
125
|
+
<p>Evidence completeness: <strong>${result.scores.evidenceCompletenessPercent}%</strong></p>
|
|
126
|
+
<p>
|
|
127
|
+
<span class="badge">violated ${result.scores.statusCounts.violated}</span>
|
|
128
|
+
<span class="badge">partial ${result.scores.statusCounts.partial}</span>
|
|
129
|
+
<span class="badge">verified ${result.scores.statusCounts.verified}</span>
|
|
130
|
+
<span class="badge">human-review ${result.scores.statusCounts.humanReview}</span>
|
|
131
|
+
</p>
|
|
132
|
+
</div>
|
|
133
|
+
<div class="card">
|
|
134
|
+
<h2>Personal-data categories</h2>
|
|
135
|
+
<p>${escape(result.dataMap.categories.map((item) => item.category).join(", ") || "none observed")}</p>
|
|
136
|
+
<h2>External recipients</h2>
|
|
137
|
+
<p>${escape(result.dataMap.externalRecipients.map((item) => item.name).join(", ") || "none observed")}</p>
|
|
138
|
+
</div>
|
|
139
|
+
<div class="card">
|
|
140
|
+
<h2>Fix next</h2>
|
|
141
|
+
<table>
|
|
142
|
+
<thead><tr><th>Control</th><th>Severity</th><th>Title</th><th>Remediation</th></tr></thead>
|
|
143
|
+
<tbody>${fixRows || "<tr><td colspan=4>None</td></tr>"}</tbody>
|
|
144
|
+
</table>
|
|
145
|
+
</div>
|
|
146
|
+
<div class="card">
|
|
147
|
+
<p class="muted">Legal source version: ${escape(result.legalSourceVersion)} · Generated ${escape(result.generatedAt)}</p>
|
|
148
|
+
</div>
|
|
149
|
+
</body>
|
|
150
|
+
</html>
|
|
151
|
+
`;
|
|
152
|
+
}
|
|
153
|
+
function renderAgentHandoff(result) {
|
|
154
|
+
const lines = [
|
|
155
|
+
"# DPDP Agent Handoff",
|
|
156
|
+
"",
|
|
157
|
+
result.disclaimer,
|
|
158
|
+
"",
|
|
159
|
+
"## Deterministic artifacts (source of truth)",
|
|
160
|
+
"",
|
|
161
|
+
"- `.vibedoctor/dpdp/data-map.json`",
|
|
162
|
+
"- `.vibedoctor/dpdp/control-matrix.json`",
|
|
163
|
+
"- `.vibedoctor/dpdp/evidence-ledger.json`",
|
|
164
|
+
"- `.vibedoctor/dpdp/review-queue.md`",
|
|
165
|
+
"",
|
|
166
|
+
"## Scores",
|
|
167
|
+
"",
|
|
168
|
+
`- Technical posture (not legal compliance): ${result.scores.technicalPostureScore}/100`,
|
|
169
|
+
`- Evidence completeness: ${result.scores.evidenceCompletenessPercent}%`,
|
|
170
|
+
"",
|
|
171
|
+
"## Rules for the agent",
|
|
172
|
+
"",
|
|
173
|
+
"1. Consume deterministic artifacts; do not re-implement a compliance engine.",
|
|
174
|
+
"2. Do not mark DETERMINISTIC controls as passed without matching control-matrix status.",
|
|
175
|
+
"3. Do not invent evidence.",
|
|
176
|
+
"4. Do not claim legal certification.",
|
|
177
|
+
"5. Do not calculate a separate compliance percentage.",
|
|
178
|
+
"6. Prefer the minimum human questions from the review queue, grouped by audience.",
|
|
179
|
+
"7. After code changes, re-run `vibedoctor dpdp verify`.",
|
|
180
|
+
`8. Treat legal source version \`${result.legalSourceVersion}\` as an offline baseline. Before interpreting current law, use the DPDP readiness-review skill to verify the latest official primary sources.`,
|
|
181
|
+
"9. If current official sources cannot be verified, report `CURRENT_LEGAL_SOURCES_NOT_VERIFIED`; if they differ, report `LEGAL_SOURCE_DRIFT`. Never silently change deterministic statuses.",
|
|
182
|
+
"",
|
|
183
|
+
"## Fix next (code/config first)",
|
|
184
|
+
""
|
|
185
|
+
];
|
|
186
|
+
for (const item of result.fixNext.slice(0, 10)) {
|
|
187
|
+
lines.push(`- **${item.controlId}** [${item.severity}]: ${item.remediation}`);
|
|
188
|
+
}
|
|
189
|
+
lines.push("", "## Human review by audience", "");
|
|
190
|
+
const audiences = Array.from(new Set(result.reviewQueue.map((item) => item.audience)));
|
|
191
|
+
for (const audience of audiences) {
|
|
192
|
+
lines.push(`### ${audience}`);
|
|
193
|
+
for (const item of result.reviewQueue.filter((entry) => entry.audience === audience).slice(0, 8)) {
|
|
194
|
+
lines.push(`- ${item.controlId}: ${item.question}`);
|
|
195
|
+
}
|
|
196
|
+
lines.push("");
|
|
197
|
+
}
|
|
198
|
+
lines.push("## Suggested commands", "");
|
|
199
|
+
lines.push("```bash");
|
|
200
|
+
lines.push("vibedoctor dpdp scan --full");
|
|
201
|
+
lines.push("vibedoctor dpdp review-queue");
|
|
202
|
+
lines.push("vibedoctor dpdp verify");
|
|
203
|
+
lines.push("```");
|
|
204
|
+
lines.push("");
|
|
205
|
+
return `${lines.join("\n")}\n`;
|
|
206
|
+
}
|
|
207
|
+
function renderDpdpJsonReport(result) {
|
|
208
|
+
return `${JSON.stringify({
|
|
209
|
+
disclaimer: result.disclaimer,
|
|
210
|
+
scores: result.scores,
|
|
211
|
+
statusCounts: result.scores.statusCounts,
|
|
212
|
+
openRiskBySeverity: result.scores.openRiskBySeverity,
|
|
213
|
+
dataMap: result.dataMap,
|
|
214
|
+
controlMatrix: result.controlMatrix,
|
|
215
|
+
reviewQueue: result.reviewQueue,
|
|
216
|
+
fixNext: result.fixNext,
|
|
217
|
+
capabilities: result.capabilities,
|
|
218
|
+
findings: result.findings,
|
|
219
|
+
legalSourceVersion: result.legalSourceVersion,
|
|
220
|
+
generatedAt: result.generatedAt
|
|
221
|
+
}, null, 2)}\n`;
|
|
222
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildReviewQueue = buildReviewQueue;
|
|
4
|
+
exports.renderReviewQueueMarkdown = renderReviewQueueMarkdown;
|
|
5
|
+
function audienceFor(domain) {
|
|
6
|
+
switch (domain) {
|
|
7
|
+
case "security_safeguards":
|
|
8
|
+
case "breach_preparedness":
|
|
9
|
+
return "security";
|
|
10
|
+
case "notice":
|
|
11
|
+
case "consent":
|
|
12
|
+
case "withdrawal":
|
|
13
|
+
case "purpose_limitation":
|
|
14
|
+
case "childrens_data":
|
|
15
|
+
case "guardian_consent":
|
|
16
|
+
return "product";
|
|
17
|
+
case "processors_and_recipients":
|
|
18
|
+
case "cross_border_signals":
|
|
19
|
+
case "significant_data_fiduciary":
|
|
20
|
+
case "exemptions_and_applicability":
|
|
21
|
+
return "legal";
|
|
22
|
+
case "retention":
|
|
23
|
+
case "erasure":
|
|
24
|
+
case "grievance_handling":
|
|
25
|
+
case "nomination":
|
|
26
|
+
return "operations";
|
|
27
|
+
case "applicability_and_inventory":
|
|
28
|
+
case "data_minimisation":
|
|
29
|
+
case "accuracy":
|
|
30
|
+
case "data_principal_access":
|
|
31
|
+
case "correction":
|
|
32
|
+
return "developer";
|
|
33
|
+
default:
|
|
34
|
+
return "founder";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function buildReviewQueue(controls) {
|
|
38
|
+
return controls
|
|
39
|
+
.filter((control) => control.applicable &&
|
|
40
|
+
(control.status === "NEEDS_CONTEXT" ||
|
|
41
|
+
control.status === "PARTIAL" ||
|
|
42
|
+
control.verificationClass === "HUMAN_REVIEW" ||
|
|
43
|
+
control.verificationClass === "DECLARED_EVIDENCE"))
|
|
44
|
+
.map((control) => ({
|
|
45
|
+
controlId: control.controlId,
|
|
46
|
+
title: control.title,
|
|
47
|
+
domain: control.domain,
|
|
48
|
+
audience: audienceFor(control.domain),
|
|
49
|
+
question: control.humanReviewQuestion ?? control.explanation,
|
|
50
|
+
status: control.status,
|
|
51
|
+
severity: control.severity
|
|
52
|
+
}))
|
|
53
|
+
.sort((left, right) => left.audience.localeCompare(right.audience) || left.controlId.localeCompare(right.controlId));
|
|
54
|
+
}
|
|
55
|
+
function renderReviewQueueMarkdown(items) {
|
|
56
|
+
const lines = [
|
|
57
|
+
"# DPDP Review Queue",
|
|
58
|
+
"",
|
|
59
|
+
"This queue lists unresolved organisational, legal, and product questions.",
|
|
60
|
+
"It is part of a **DPDP technical readiness** assessment — not legal certification.",
|
|
61
|
+
"",
|
|
62
|
+
"Do not re-ask questions already answered by deterministic evidence in the control matrix.",
|
|
63
|
+
""
|
|
64
|
+
];
|
|
65
|
+
const byAudience = new Map();
|
|
66
|
+
for (const item of items) {
|
|
67
|
+
const list = byAudience.get(item.audience) ?? [];
|
|
68
|
+
list.push(item);
|
|
69
|
+
byAudience.set(item.audience, list);
|
|
70
|
+
}
|
|
71
|
+
for (const audience of ["developer", "security", "product", "legal", "operations", "founder"]) {
|
|
72
|
+
const group = byAudience.get(audience);
|
|
73
|
+
if (!group || group.length === 0) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
lines.push(`## ${audience.charAt(0).toUpperCase()}${audience.slice(1)}`);
|
|
77
|
+
lines.push("");
|
|
78
|
+
for (const item of group) {
|
|
79
|
+
lines.push(`- **${item.controlId}** (${item.status}, ${item.severity}): ${item.question}`);
|
|
80
|
+
}
|
|
81
|
+
lines.push("");
|
|
82
|
+
}
|
|
83
|
+
if (items.length === 0) {
|
|
84
|
+
lines.push("_No human-review items queued from the latest scan._");
|
|
85
|
+
lines.push("");
|
|
86
|
+
}
|
|
87
|
+
return `${lines.join("\n")}\n`;
|
|
88
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { fingerprintFinding } from "../core/finding";
|
|
2
|
+
import { type VibeDoctorConfig } from "../core/config";
|
|
3
|
+
import type { ToolAdapterContext } from "../adapters/shared";
|
|
4
|
+
import type { DpdpScanMode, DpdpScanResult } from "./types";
|
|
5
|
+
export type RunDpdpScanOptions = {
|
|
6
|
+
/** Reuse the engine's project/config and completed tool results during a normal scan. */
|
|
7
|
+
context?: ToolAdapterContext;
|
|
8
|
+
/** Quick scans deliberately skip slow external tools; direct DPDP scans default to enabled. */
|
|
9
|
+
optionalScannersEnabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function runDpdpScan(root: string, mode?: DpdpScanMode, options?: RunDpdpScanOptions): Promise<DpdpScanResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Load cached DPDP artifacts when present; otherwise run a scan.
|
|
14
|
+
* Prefer this for map/report/explain/handoff paths so repeated CLI/MCP calls avoid re-walking the tree.
|
|
15
|
+
*/
|
|
16
|
+
export declare function loadOrScanDpdp(root: string, mode?: DpdpScanMode, refresh?: boolean): Promise<DpdpScanResult>;
|
|
17
|
+
export declare function explainDpdpTarget(root: string, id: string, options?: {
|
|
18
|
+
refresh?: boolean;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
type: "control" | "finding" | "unknown";
|
|
21
|
+
payload: unknown;
|
|
22
|
+
fromCache?: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function determineDpdpExitCode(result: DpdpScanResult, config: VibeDoctorConfig): number;
|
|
25
|
+
export declare function initDpdpWorkspace(root: string): Promise<string[]>;
|
|
26
|
+
export { fingerprintFinding };
|
|
@@ -0,0 +1,310 @@
|
|
|
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.fingerprintFinding = void 0;
|
|
7
|
+
exports.runDpdpScan = runDpdpScan;
|
|
8
|
+
exports.loadOrScanDpdp = loadOrScanDpdp;
|
|
9
|
+
exports.explainDpdpTarget = explainDpdpTarget;
|
|
10
|
+
exports.determineDpdpExitCode = determineDpdpExitCode;
|
|
11
|
+
exports.initDpdpWorkspace = initDpdpWorkspace;
|
|
12
|
+
const node_fs_1 = require("node:fs");
|
|
13
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
+
const finding_1 = require("../core/finding");
|
|
15
|
+
Object.defineProperty(exports, "fingerprintFinding", { enumerable: true, get: function () { return finding_1.fingerprintFinding; } });
|
|
16
|
+
const baseline_1 = require("../core/baseline");
|
|
17
|
+
const config_1 = require("../core/config");
|
|
18
|
+
const projectDetector_1 = require("../core/projectDetector");
|
|
19
|
+
const legalSources_1 = require("./legalSources");
|
|
20
|
+
const collectors_1 = require("./collectors");
|
|
21
|
+
const context_1 = require("./context");
|
|
22
|
+
const evidence_1 = require("./evidence");
|
|
23
|
+
const evaluators_1 = require("./evaluators");
|
|
24
|
+
const dataMap_1 = require("./dataMap");
|
|
25
|
+
const findings_1 = require("./findings");
|
|
26
|
+
const scoring_1 = require("./scoring");
|
|
27
|
+
const reviewQueue_1 = require("./reviewQueue");
|
|
28
|
+
const artifacts_1 = require("./artifacts");
|
|
29
|
+
const gates_1 = require("./gates");
|
|
30
|
+
const DISCLAIMER = "VibeDoctor DPDP output is a technical readiness / engineering-risk assessment. It is not legal advice and not a DPDP compliance certification.";
|
|
31
|
+
async function runDpdpScan(root, mode = "full", options = {}) {
|
|
32
|
+
const loaded = options.context ? undefined : await (0, config_1.loadConfig)(root);
|
|
33
|
+
const config = options.context?.config ?? loaded.config;
|
|
34
|
+
const project = options.context?.project ?? (await (0, projectDetector_1.detectProject)(root, config.paths.exclude));
|
|
35
|
+
const ctx = options.context
|
|
36
|
+
? { ...options.context, root, project, config }
|
|
37
|
+
: {
|
|
38
|
+
root,
|
|
39
|
+
project,
|
|
40
|
+
config,
|
|
41
|
+
scanMode: mode === "changed" ? "changed" : mode === "full" ? "full" : "default"
|
|
42
|
+
};
|
|
43
|
+
const capabilities = [
|
|
44
|
+
{ id: "privacy-detector", status: "available", message: "Built-in deterministic privacy detector (always on with DPDP)" }
|
|
45
|
+
];
|
|
46
|
+
if (!config.checks.dpdp.enabled) {
|
|
47
|
+
return emptyDisabledResult(root, mode, config, [
|
|
48
|
+
...capabilities,
|
|
49
|
+
{
|
|
50
|
+
id: "presidio",
|
|
51
|
+
status: "skipped",
|
|
52
|
+
message: "DPDP disabled"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: "semgrep",
|
|
56
|
+
status: "skipped",
|
|
57
|
+
message: "DPDP disabled"
|
|
58
|
+
}
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
const context = await (0, context_1.resolveDpdpContext)(root, config);
|
|
62
|
+
const declared = await (0, context_1.loadDeclaredEvidence)(root, config.checks.dpdp.evidenceFile);
|
|
63
|
+
const { signals, filesScanned, scope, scopeCapability, optionalCapabilities } = await (0, collectors_1.collectDpdpSignals)(ctx, {
|
|
64
|
+
optionalScannersEnabled: options.optionalScannersEnabled ?? ctx.scanMode !== "quick"
|
|
65
|
+
});
|
|
66
|
+
// Presidio/Semgrep run by default (opt-out). Missing tools → skipped, never a pass.
|
|
67
|
+
capabilities.push(...optionalCapabilities);
|
|
68
|
+
if (scopeCapability) {
|
|
69
|
+
capabilities.push(scopeCapability);
|
|
70
|
+
}
|
|
71
|
+
else if (mode === "full" || mode === "default") {
|
|
72
|
+
capabilities.push({
|
|
73
|
+
id: "changed-scope",
|
|
74
|
+
status: "available",
|
|
75
|
+
message: `Full repository collection scope (${scope})`
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const evidence = signals.map((signal) => (0, evidence_1.sanitizeEvidenceForOutput)((0, evidence_1.evidenceFromSignal)(signal)));
|
|
79
|
+
for (const assertion of declared) {
|
|
80
|
+
evidence.push((0, evidence_1.sanitizeEvidenceForOutput)({
|
|
81
|
+
id: `declared:${assertion.id}`,
|
|
82
|
+
kind: "declared_assertion",
|
|
83
|
+
detectionMethod: "declared-evidence-file",
|
|
84
|
+
confidence: "low",
|
|
85
|
+
provenance: "declared",
|
|
86
|
+
relatedControls: assertion.relatedControls,
|
|
87
|
+
certainty: "declared",
|
|
88
|
+
summary: assertion.statement,
|
|
89
|
+
tags: ["declared", assertion.suppliedRole]
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
let controlResults = (0, evaluators_1.evaluateAllControls)({
|
|
93
|
+
signals,
|
|
94
|
+
evidence,
|
|
95
|
+
context,
|
|
96
|
+
declared,
|
|
97
|
+
capabilities
|
|
98
|
+
});
|
|
99
|
+
controlResults = (0, evaluators_1.attachDeclaredEvidenceIds)(controlResults, declared);
|
|
100
|
+
const generatedAt = new Date().toISOString();
|
|
101
|
+
const evidenceById = new Map(evidence.map((item) => [item.id, item]));
|
|
102
|
+
let findings = (0, findings_1.controlResultsToFindings)(controlResults, evidenceById, capabilities);
|
|
103
|
+
// Apply shared baseline fingerprints, then sync control isNew from findings.
|
|
104
|
+
if (config.baseline.enabled) {
|
|
105
|
+
const baseline = await (0, baseline_1.loadBaseline)(root, config.baseline.file);
|
|
106
|
+
findings = (0, finding_1.applyBaseline)(findings, new Set(baseline.findings.map((entry) => entry.fingerprint)));
|
|
107
|
+
}
|
|
108
|
+
controlResults = (0, findings_1.syncControlIsNewFromFindings)(controlResults, findings, config.baseline.enabled);
|
|
109
|
+
const scores = (0, scoring_1.buildDpdpScores)(controlResults, capabilities);
|
|
110
|
+
const dataMap = (0, dataMap_1.buildPersonalDataMap)(signals, evidence, controlResults, generatedAt);
|
|
111
|
+
const reviewQueue = (0, reviewQueue_1.buildReviewQueue)(controlResults);
|
|
112
|
+
const fixNext = controlResults
|
|
113
|
+
.filter((result) => result.status === "VIOLATED" || result.status === "PARTIAL")
|
|
114
|
+
.sort((left, right) => severityRank(right.severity) - severityRank(left.severity))
|
|
115
|
+
.slice(0, 10)
|
|
116
|
+
.map((result) => ({
|
|
117
|
+
controlId: result.controlId,
|
|
118
|
+
title: result.title,
|
|
119
|
+
severity: result.severity,
|
|
120
|
+
remediation: result.remediation ?? "Review control evidence and remediate.",
|
|
121
|
+
evidenceIds: result.evidenceIds
|
|
122
|
+
}));
|
|
123
|
+
const result = {
|
|
124
|
+
version: 1,
|
|
125
|
+
generatedAt,
|
|
126
|
+
root,
|
|
127
|
+
mode,
|
|
128
|
+
disclaimer: DISCLAIMER,
|
|
129
|
+
scores,
|
|
130
|
+
dataMap,
|
|
131
|
+
controlMatrix: {
|
|
132
|
+
version: 1,
|
|
133
|
+
generatedAt,
|
|
134
|
+
disclaimer: DISCLAIMER,
|
|
135
|
+
legalSourceVersion: config.checks.dpdp.legalSourceVersion || legalSources_1.LEGAL_SOURCE_MANIFEST_VERSION,
|
|
136
|
+
controls: controlResults,
|
|
137
|
+
summary: scores.statusCounts
|
|
138
|
+
},
|
|
139
|
+
evidenceLedger: {
|
|
140
|
+
version: 1,
|
|
141
|
+
generatedAt,
|
|
142
|
+
disclaimer: DISCLAIMER,
|
|
143
|
+
evidence,
|
|
144
|
+
declared
|
|
145
|
+
},
|
|
146
|
+
reviewQueue,
|
|
147
|
+
fixNext,
|
|
148
|
+
capabilities: [
|
|
149
|
+
...capabilities,
|
|
150
|
+
{
|
|
151
|
+
id: "files-scanned",
|
|
152
|
+
status: "available",
|
|
153
|
+
message: `Scanned ${filesScanned} text file(s) for DPDP technical signals`
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
findings,
|
|
157
|
+
legalSourceVersion: config.checks.dpdp.legalSourceVersion || legalSources_1.LEGAL_SOURCE_MANIFEST_VERSION,
|
|
158
|
+
context,
|
|
159
|
+
baselineApplied: config.baseline.enabled
|
|
160
|
+
};
|
|
161
|
+
await (0, artifacts_1.writeDpdpArtifacts)(root, result);
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
function severityRank(severity) {
|
|
165
|
+
return { info: 0, low: 1, medium: 2, high: 3, critical: 4 }[severity];
|
|
166
|
+
}
|
|
167
|
+
function emptyDisabledResult(root, mode, config, capabilities) {
|
|
168
|
+
const generatedAt = new Date().toISOString();
|
|
169
|
+
return {
|
|
170
|
+
version: 1,
|
|
171
|
+
generatedAt,
|
|
172
|
+
root,
|
|
173
|
+
mode,
|
|
174
|
+
disclaimer: DISCLAIMER,
|
|
175
|
+
scores: {
|
|
176
|
+
technicalPostureScore: 0,
|
|
177
|
+
evidenceCompletenessPercent: 0,
|
|
178
|
+
openRiskBySeverity: { critical: 0, high: 0, medium: 0, low: 0, info: 0 },
|
|
179
|
+
statusCounts: {
|
|
180
|
+
verified: 0,
|
|
181
|
+
violated: 0,
|
|
182
|
+
partial: 0,
|
|
183
|
+
notObserved: 0,
|
|
184
|
+
needsContext: 0,
|
|
185
|
+
notApplicable: 0,
|
|
186
|
+
skipped: 0,
|
|
187
|
+
error: 0,
|
|
188
|
+
humanReview: 0,
|
|
189
|
+
unresolved: 0
|
|
190
|
+
},
|
|
191
|
+
labels: {
|
|
192
|
+
technicalPosture: "DPDP technical posture (not legal compliance)",
|
|
193
|
+
evidenceCompleteness: "Evidence completeness (technical observability)",
|
|
194
|
+
openRisk: "Open technical risk counts by severity"
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
dataMap: {
|
|
198
|
+
version: 1,
|
|
199
|
+
generatedAt,
|
|
200
|
+
disclaimer: DISCLAIMER,
|
|
201
|
+
categories: [],
|
|
202
|
+
collectionPoints: [],
|
|
203
|
+
stores: [],
|
|
204
|
+
externalRecipients: [],
|
|
205
|
+
lifecycleSignals: [],
|
|
206
|
+
safeguardGaps: [],
|
|
207
|
+
relatedControls: [],
|
|
208
|
+
graph: { nodes: [], edges: [] }
|
|
209
|
+
},
|
|
210
|
+
controlMatrix: {
|
|
211
|
+
version: 1,
|
|
212
|
+
generatedAt,
|
|
213
|
+
disclaimer: DISCLAIMER,
|
|
214
|
+
legalSourceVersion: config.checks.dpdp.legalSourceVersion,
|
|
215
|
+
controls: [],
|
|
216
|
+
summary: {
|
|
217
|
+
verified: 0,
|
|
218
|
+
violated: 0,
|
|
219
|
+
partial: 0,
|
|
220
|
+
notObserved: 0,
|
|
221
|
+
needsContext: 0,
|
|
222
|
+
notApplicable: 0,
|
|
223
|
+
skipped: 0,
|
|
224
|
+
error: 0,
|
|
225
|
+
humanReview: 0,
|
|
226
|
+
unresolved: 0
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
evidenceLedger: { version: 1, generatedAt, disclaimer: DISCLAIMER, evidence: [], declared: [] },
|
|
230
|
+
reviewQueue: [],
|
|
231
|
+
fixNext: [],
|
|
232
|
+
capabilities: [...capabilities, { id: "dpdp", status: "skipped", message: "checks.dpdp.enabled is false" }],
|
|
233
|
+
findings: [],
|
|
234
|
+
legalSourceVersion: config.checks.dpdp.legalSourceVersion,
|
|
235
|
+
context: {
|
|
236
|
+
version: 1,
|
|
237
|
+
organization: { ...config.checks.dpdp.organization }
|
|
238
|
+
},
|
|
239
|
+
baselineApplied: false
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Load cached DPDP artifacts when present; otherwise run a scan.
|
|
244
|
+
* Prefer this for map/report/explain/handoff paths so repeated CLI/MCP calls avoid re-walking the tree.
|
|
245
|
+
*/
|
|
246
|
+
async function loadOrScanDpdp(root, mode = "full", refresh = false) {
|
|
247
|
+
if (!refresh) {
|
|
248
|
+
const cached = await (0, artifacts_1.loadCachedDpdpScanResult)(root);
|
|
249
|
+
if (cached) {
|
|
250
|
+
return cached;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return runDpdpScan(root, mode);
|
|
254
|
+
}
|
|
255
|
+
async function explainDpdpTarget(root, id, options = {}) {
|
|
256
|
+
const refresh = options.refresh === true;
|
|
257
|
+
const hadCache = !refresh && Boolean(await (0, artifacts_1.loadCachedDpdpScanResult)(root));
|
|
258
|
+
const result = await loadOrScanDpdp(root, "full", refresh);
|
|
259
|
+
const control = result.controlMatrix.controls.find((item) => item.controlId === id);
|
|
260
|
+
if (control) {
|
|
261
|
+
const relatedEvidence = result.evidenceLedger.evidence.filter((item) => control.evidenceIds.includes(item.id) || item.relatedControls.includes(control.controlId));
|
|
262
|
+
return {
|
|
263
|
+
type: "control",
|
|
264
|
+
fromCache: hadCache && !refresh,
|
|
265
|
+
payload: {
|
|
266
|
+
control,
|
|
267
|
+
relatedEvidence,
|
|
268
|
+
disclaimer: DISCLAIMER
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
const finding = result.findings.find((item) => item.id === id);
|
|
273
|
+
if (finding) {
|
|
274
|
+
return { type: "finding", fromCache: hadCache && !refresh, payload: { finding, disclaimer: DISCLAIMER } };
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
type: "unknown",
|
|
278
|
+
fromCache: hadCache && !refresh,
|
|
279
|
+
payload: { message: `No control or finding matched '${id}'`, disclaimer: DISCLAIMER }
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function determineDpdpExitCode(result, config) {
|
|
283
|
+
return (0, gates_1.evaluateDpdpFailureGate)(result.controlMatrix.controls.map(gates_1.controlToGateCandidate), config) ? 1 : 0;
|
|
284
|
+
}
|
|
285
|
+
async function initDpdpWorkspace(root) {
|
|
286
|
+
const { config } = await (0, config_1.loadConfig)(root);
|
|
287
|
+
const dir = node_path_1.default.join(root, ".vibedoctor", "dpdp");
|
|
288
|
+
await node_fs_1.promises.mkdir(dir, { recursive: true });
|
|
289
|
+
const written = [];
|
|
290
|
+
const contextPath = node_path_1.default.join(root, config.checks.dpdp.contextFile);
|
|
291
|
+
const evidencePath = node_path_1.default.join(root, config.checks.dpdp.evidenceFile);
|
|
292
|
+
await node_fs_1.promises.mkdir(node_path_1.default.dirname(contextPath), { recursive: true });
|
|
293
|
+
await node_fs_1.promises.mkdir(node_path_1.default.dirname(evidencePath), { recursive: true });
|
|
294
|
+
try {
|
|
295
|
+
await node_fs_1.promises.access(contextPath);
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
await node_fs_1.promises.writeFile(contextPath, (0, context_1.renderDefaultContextYaml)(), "utf8");
|
|
299
|
+
written.push(config.checks.dpdp.contextFile);
|
|
300
|
+
}
|
|
301
|
+
try {
|
|
302
|
+
await node_fs_1.promises.access(evidencePath);
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
await node_fs_1.promises.writeFile(evidencePath, (0, context_1.renderDefaultEvidenceYaml)(), "utf8");
|
|
306
|
+
written.push(config.checks.dpdp.evidenceFile);
|
|
307
|
+
}
|
|
308
|
+
written.push(".vibedoctor/dpdp/");
|
|
309
|
+
return written;
|
|
310
|
+
}
|