@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.
Files changed (112) hide show
  1. package/README.md +298 -115
  2. package/dist/adapters/biome.js +135 -21
  3. package/dist/adapters/dpdp.d.ts +6 -0
  4. package/dist/adapters/dpdp.js +34 -0
  5. package/dist/adapters/index.d.ts +1 -0
  6. package/dist/adapters/index.js +3 -1
  7. package/dist/adapters/osvScanner.js +136 -17
  8. package/dist/adapters/presidio.js +6 -2
  9. package/dist/adapters/privacyDetector.d.ts +24 -1
  10. package/dist/adapters/privacyDetector.js +86 -2
  11. package/dist/adapters/shared.d.ts +6 -0
  12. package/dist/agentPack/templates/skills.js +159 -53
  13. package/dist/cli/commands/dpdp.d.ts +35 -0
  14. package/dist/cli/commands/dpdp.js +103 -0
  15. package/dist/cli/commands/init.js +105 -50
  16. package/dist/cli/commands/privacyReview.js +3 -4
  17. package/dist/cli/commands/scan.js +4 -1
  18. package/dist/cli/commands/setup.d.ts +13 -17
  19. package/dist/cli/commands/setup.js +138 -200
  20. package/dist/cli/index.js +84 -0
  21. package/dist/core/capability.d.ts +92 -0
  22. package/dist/core/capability.js +122 -0
  23. package/dist/core/config.d.ts +57 -0
  24. package/dist/core/config.js +194 -7
  25. package/dist/core/credentialHeuristics.d.ts +28 -0
  26. package/dist/core/credentialHeuristics.js +179 -0
  27. package/dist/core/engine.d.ts +21 -0
  28. package/dist/core/engine.js +484 -84
  29. package/dist/core/executable.d.ts +18 -0
  30. package/dist/core/executable.js +137 -0
  31. package/dist/core/fileRole.d.ts +24 -0
  32. package/dist/core/fileRole.js +125 -0
  33. package/dist/core/finding.d.ts +125 -1
  34. package/dist/core/finding.js +63 -5
  35. package/dist/core/findingNormalizer.d.ts +33 -0
  36. package/dist/core/findingNormalizer.js +171 -0
  37. package/dist/core/projectDetector.d.ts +13 -0
  38. package/dist/core/projectDetector.js +100 -15
  39. package/dist/core/relevance.d.ts +87 -0
  40. package/dist/core/relevance.js +367 -0
  41. package/dist/core/scanPlanner.d.ts +12 -0
  42. package/dist/core/scanPlanner.js +61 -29
  43. package/dist/core/semverLite.d.ts +27 -0
  44. package/dist/core/semverLite.js +163 -0
  45. package/dist/core/suppressions.d.ts +96 -0
  46. package/dist/core/suppressions.js +302 -0
  47. package/dist/core/toolRegistry.d.ts +58 -0
  48. package/dist/core/toolRegistry.js +247 -0
  49. package/dist/core/toolRunner.d.ts +23 -2
  50. package/dist/core/toolRunner.js +61 -93
  51. package/dist/core/toolVerification.d.ts +87 -0
  52. package/dist/core/toolVerification.js +370 -0
  53. package/dist/dpdp/artifacts.d.ts +11 -0
  54. package/dist/dpdp/artifacts.js +120 -0
  55. package/dist/dpdp/catalogue.d.ts +14 -0
  56. package/dist/dpdp/catalogue.js +661 -0
  57. package/dist/dpdp/collectors/confidence.d.ts +9 -0
  58. package/dist/dpdp/collectors/confidence.js +25 -0
  59. package/dist/dpdp/collectors/dependencies.d.ts +7 -0
  60. package/dist/dpdp/collectors/dependencies.js +63 -0
  61. package/dist/dpdp/collectors/index.d.ts +24 -0
  62. package/dist/dpdp/collectors/index.js +71 -0
  63. package/dist/dpdp/collectors/lifecycle.d.ts +2 -0
  64. package/dist/dpdp/collectors/lifecycle.js +202 -0
  65. package/dist/dpdp/collectors/optionalScanners.d.ts +14 -0
  66. package/dist/dpdp/collectors/optionalScanners.js +437 -0
  67. package/dist/dpdp/collectors/privacyBridge.d.ts +13 -0
  68. package/dist/dpdp/collectors/privacyBridge.js +152 -0
  69. package/dist/dpdp/collectors/safeguards.d.ts +5 -0
  70. package/dist/dpdp/collectors/safeguards.js +186 -0
  71. package/dist/dpdp/collectors/schema.d.ts +6 -0
  72. package/dist/dpdp/collectors/schema.js +122 -0
  73. package/dist/dpdp/collectors/shared.d.ts +10 -0
  74. package/dist/dpdp/collectors/shared.js +43 -0
  75. package/dist/dpdp/context.d.ts +28 -0
  76. package/dist/dpdp/context.js +195 -0
  77. package/dist/dpdp/dataMap.d.ts +7 -0
  78. package/dist/dpdp/dataMap.js +339 -0
  79. package/dist/dpdp/evaluators.d.ts +20 -0
  80. package/dist/dpdp/evaluators.js +522 -0
  81. package/dist/dpdp/evidence.d.ts +11 -0
  82. package/dist/dpdp/evidence.js +123 -0
  83. package/dist/dpdp/findings.d.ts +44 -0
  84. package/dist/dpdp/findings.js +286 -0
  85. package/dist/dpdp/gates.d.ts +14 -0
  86. package/dist/dpdp/gates.js +47 -0
  87. package/dist/dpdp/index.d.ts +16 -0
  88. package/dist/dpdp/index.js +32 -0
  89. package/dist/dpdp/legalSources.d.ts +10 -0
  90. package/dist/dpdp/legalSources.js +104 -0
  91. package/dist/dpdp/paths.d.ts +25 -0
  92. package/dist/dpdp/paths.js +85 -0
  93. package/dist/dpdp/report.d.ts +6 -0
  94. package/dist/dpdp/report.js +222 -0
  95. package/dist/dpdp/reviewQueue.d.ts +3 -0
  96. package/dist/dpdp/reviewQueue.js +88 -0
  97. package/dist/dpdp/scan.d.ts +26 -0
  98. package/dist/dpdp/scan.js +310 -0
  99. package/dist/dpdp/scoring.d.ts +41 -0
  100. package/dist/dpdp/scoring.js +237 -0
  101. package/dist/dpdp/types.d.ts +312 -0
  102. package/dist/dpdp/types.js +86 -0
  103. package/dist/index.d.ts +1 -0
  104. package/dist/index.js +1 -0
  105. package/dist/mcp/tools/dpdp.d.ts +11 -0
  106. package/dist/mcp/tools/dpdp.js +151 -0
  107. package/dist/mcp/tools/index.js +3 -1
  108. package/dist/reporters/html.js +57 -13
  109. package/dist/reporters/json.js +12 -1
  110. package/dist/reporters/markdown.js +46 -4
  111. package/dist/reporters/sarif.js +54 -5
  112. package/package.json +4 -1
@@ -0,0 +1,44 @@
1
+ import type { DataFlowStep, EvidenceGrade, Finding, FindingRemediation } from "../core/finding";
2
+ import type { ControlResult, DpdpCapabilityStatus, EvidenceItem, VerificationClass } from "./types";
3
+ /**
4
+ * Build a stable, masked snippet for fingerprinting.
5
+ * When present, fingerprintFinding omits startLine so line-only moves do not thrash baselines.
6
+ */
7
+ export declare function stableDpdpFindingSnippet(result: ControlResult, primary: EvidenceItem | undefined): string;
8
+ /**
9
+ * Maps how a control was checked onto how strongly its evidence supports the
10
+ * claim.
11
+ *
12
+ * A DPDP finding could previously carry critical severity whether it came from
13
+ * following a data path or from a variable name that looked like an identifier.
14
+ * A readiness figure built on that mixture reads as stronger than the evidence
15
+ * behind it, which is worse than a lower, honest one.
16
+ */
17
+ export declare function evidenceGradeForControl(verificationClass: VerificationClass, primary: EvidenceItem | undefined): EvidenceGrade;
18
+ /**
19
+ * Whether a control that observed nothing means the control is missing, or only
20
+ * that static analysis could not settle the question.
21
+ *
22
+ * These need different responses — one is a gap to fix, the other a gap in
23
+ * coverage — and presenting them identically is what let a readiness score imply
24
+ * more than the scan established.
25
+ */
26
+ export declare function absenceClaimForControl(result: ControlResult, capabilities: DpdpCapabilityStatus[]): Finding["absenceClaim"];
27
+ /**
28
+ * Assembles the data path behind a control from its own evidence items, ordered
29
+ * source to sink. Each step carries its own grade, so a traced storage write and
30
+ * an inferred processor hop are not presented as equally established.
31
+ */
32
+ export declare function buildDataFlow(result: ControlResult, evidenceById: Map<string, EvidenceItem>): DataFlowStep[] | undefined;
33
+ /**
34
+ * Works out what kind of change a remediation actually is, so the finding
35
+ * reaches whoever can act on it rather than defaulting to an engineer.
36
+ */
37
+ export declare function remediationForControl(result: ControlResult): FindingRemediation | undefined;
38
+ export declare function controlResultsToFindings(results: ControlResult[], evidenceById: Map<string, EvidenceItem>, capabilities?: DpdpCapabilityStatus[]): Finding[];
39
+ /**
40
+ * Sync control `isNew` from baselined findings.
41
+ * Controls without a finding (not VIOLATED/PARTIAL/ERROR) keep isNew=false after baseline is applied
42
+ * so they do not look like "new issues" in matrices.
43
+ */
44
+ export declare function syncControlIsNewFromFindings(controls: ControlResult[], findings: Finding[], baselineEnabled: boolean): ControlResult[];
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stableDpdpFindingSnippet = stableDpdpFindingSnippet;
4
+ exports.evidenceGradeForControl = evidenceGradeForControl;
5
+ exports.absenceClaimForControl = absenceClaimForControl;
6
+ exports.buildDataFlow = buildDataFlow;
7
+ exports.remediationForControl = remediationForControl;
8
+ exports.controlResultsToFindings = controlResultsToFindings;
9
+ exports.syncControlIsNewFromFindings = syncControlIsNewFromFindings;
10
+ const STATUS_TO_INCLUDE = new Set(["VIOLATED", "PARTIAL", "ERROR"]);
11
+ /**
12
+ * Build a stable, masked snippet for fingerprinting.
13
+ * When present, fingerprintFinding omits startLine so line-only moves do not thrash baselines.
14
+ */
15
+ function stableDpdpFindingSnippet(result, primary) {
16
+ return [
17
+ result.controlId,
18
+ result.status,
19
+ primary?.file ?? "repo",
20
+ primary?.field ?? primary?.symbol ?? "",
21
+ // Prefer classified summary over free-form explanation drift where possible
22
+ primary?.summary ?? result.explanation
23
+ ]
24
+ .join("|")
25
+ .slice(0, 400);
26
+ }
27
+ /**
28
+ * Maps how a control was checked onto how strongly its evidence supports the
29
+ * claim.
30
+ *
31
+ * A DPDP finding could previously carry critical severity whether it came from
32
+ * following a data path or from a variable name that looked like an identifier.
33
+ * A readiness figure built on that mixture reads as stronger than the evidence
34
+ * behind it, which is worse than a lower, honest one.
35
+ */
36
+ function evidenceGradeForControl(verificationClass, primary) {
37
+ if (verificationClass === "DETERMINISTIC") {
38
+ return primary?.certainty === "confirmed" ? "verified" : "observed";
39
+ }
40
+ if (verificationClass === "TECHNICAL_SIGNAL") {
41
+ // A signal anchored to a real file and line was observed; one inferred from
42
+ // shape alone is a heuristic, however plausible.
43
+ if (primary?.certainty === "confirmed" && primary.file) {
44
+ return "observed";
45
+ }
46
+ return "heuristic";
47
+ }
48
+ if (verificationClass === "DECLARED_EVIDENCE") {
49
+ return "unproven";
50
+ }
51
+ return "unproven";
52
+ }
53
+ /**
54
+ * Whether a control that observed nothing means the control is missing, or only
55
+ * that static analysis could not settle the question.
56
+ *
57
+ * These need different responses — one is a gap to fix, the other a gap in
58
+ * coverage — and presenting them identically is what let a readiness score imply
59
+ * more than the scan established.
60
+ */
61
+ function absenceClaimForControl(result, capabilities) {
62
+ if (!result.applicable || result.status === "NOT_APPLICABLE") {
63
+ return "not_applicable";
64
+ }
65
+ // A scanner that did not run cannot have failed to find something.
66
+ const unavailable = capabilities.filter((capability) => capability.status !== "available");
67
+ if (unavailable.length > 0 && result.verificationClass === "TECHNICAL_SIGNAL") {
68
+ return "not_statically_provable";
69
+ }
70
+ if (result.verificationClass === "HUMAN_REVIEW" || result.verificationClass === "DECLARED_EVIDENCE") {
71
+ return "not_statically_provable";
72
+ }
73
+ return result.status === "VIOLATED" ? "control_absent" : "not_statically_provable";
74
+ }
75
+ /**
76
+ * Classifies an evidence item's place in a data path. The mapping is by evidence
77
+ * kind rather than by guesswork, so a step only appears when something concrete
78
+ * was recorded at that stage.
79
+ */
80
+ function flowKindFor(item) {
81
+ const kind = item.kind;
82
+ if (/collect|input|form|field|schema|request|param/i.test(kind)) {
83
+ return "source";
84
+ }
85
+ if (/storage|store|cookie|database|table|column|persist|cache/i.test(kind)) {
86
+ return "store";
87
+ }
88
+ if (/transfer|processor|third_party|vendor|llm|model|ai|api_call/i.test(kind)) {
89
+ return "processor";
90
+ }
91
+ if (/log|export|sink|telemetry|analytics|email|report/i.test(kind)) {
92
+ return "sink";
93
+ }
94
+ if (/transform|mask|redact|hash|encrypt/i.test(kind)) {
95
+ return "transform";
96
+ }
97
+ return undefined;
98
+ }
99
+ const FLOW_ORDER = {
100
+ source: 0,
101
+ transform: 1,
102
+ store: 2,
103
+ processor: 3,
104
+ sink: 4
105
+ };
106
+ /**
107
+ * Assembles the data path behind a control from its own evidence items, ordered
108
+ * source to sink. Each step carries its own grade, so a traced storage write and
109
+ * an inferred processor hop are not presented as equally established.
110
+ */
111
+ function buildDataFlow(result, evidenceById) {
112
+ const steps = [];
113
+ for (const id of result.evidenceIds) {
114
+ const item = evidenceById.get(id);
115
+ if (!item) {
116
+ continue;
117
+ }
118
+ const kind = flowKindFor(item);
119
+ if (!kind) {
120
+ continue;
121
+ }
122
+ steps.push({
123
+ kind,
124
+ label: item.field ?? item.symbol ?? item.summary.slice(0, 80),
125
+ file: item.file,
126
+ startLine: item.line,
127
+ evidenceGrade: item.certainty === "confirmed" && item.file ? "observed" : item.certainty === "declared" ? "unproven" : "heuristic",
128
+ detail: item.summary
129
+ });
130
+ }
131
+ if (steps.length < 2) {
132
+ // A single step is not a path; the finding's own location already says where
133
+ // it is, and calling one point a "flow" would overstate the evidence.
134
+ return undefined;
135
+ }
136
+ return steps.sort((left, right) => FLOW_ORDER[left.kind] - FLOW_ORDER[right.kind]);
137
+ }
138
+ /**
139
+ * Works out what kind of change a remediation actually is, so the finding
140
+ * reaches whoever can act on it rather than defaulting to an engineer.
141
+ */
142
+ function remediationForControl(result) {
143
+ if (!result.remediation) {
144
+ return undefined;
145
+ }
146
+ // Domains whose controls are satisfied by a documented decision or process
147
+ // rather than by code. Routing these to an engineer produces a task nobody can
148
+ // close.
149
+ const policyDomains = new Set([
150
+ "grievance_handling",
151
+ "nomination",
152
+ "significant_data_fiduciary",
153
+ "exemptions_and_applicability",
154
+ "breach_preparedness",
155
+ "notice"
156
+ ]);
157
+ const kind = result.verificationClass === "HUMAN_REVIEW" || result.verificationClass === "DECLARED_EVIDENCE"
158
+ ? "human_review"
159
+ : policyDomains.has(result.domain)
160
+ ? "policy"
161
+ : /config|setting|environment|flag|header|policy file/i.test(result.remediation)
162
+ ? "config"
163
+ : "code";
164
+ return {
165
+ kind,
166
+ component: result.controlId,
167
+ steps: [result.remediation, ...(result.humanReviewQuestion ? [`Confirm with an owner: ${result.humanReviewQuestion}`] : [])],
168
+ requiredEvidence: result.verificationClass === "DETERMINISTIC"
169
+ ? "A rerun of `vibedoctor dpdp scan` showing this control verified."
170
+ : result.verificationClass === "TECHNICAL_SIGNAL"
171
+ ? "Code changes plus a rerun, or a declared-evidence entry recording the decision."
172
+ : `A signed-off entry in the declared-evidence file (${result.controlId}).`,
173
+ requiresHumanDecision: kind === "human_review" || kind === "policy"
174
+ };
175
+ }
176
+ function controlResultsToFindings(results, evidenceById, capabilities = []) {
177
+ const findings = [];
178
+ for (const result of results) {
179
+ if (!STATUS_TO_INCLUDE.has(result.status)) {
180
+ continue;
181
+ }
182
+ const primary = result.evidenceIds.map((id) => evidenceById.get(id)).find(Boolean);
183
+ const severity = result.status === "VIOLATED"
184
+ ? result.severity
185
+ : result.status === "ERROR"
186
+ ? "medium"
187
+ : result.severity === "critical"
188
+ ? "high"
189
+ : result.severity;
190
+ const snippet = primary?.snippet ?? stableDpdpFindingSnippet(result, primary);
191
+ const evidenceGrade = evidenceGradeForControl(result.verificationClass, primary);
192
+ const absenceClaim = absenceClaimForControl(result, capabilities);
193
+ const dataFlow = buildDataFlow(result, evidenceById);
194
+ // State the strength of the claim in the message itself. A reader scanning a
195
+ // list should not have to open the JSON to learn that a "critical" item rests
196
+ // on a naming heuristic.
197
+ const gradeNote = evidenceGrade === "verified"
198
+ ? "Verified from code."
199
+ : evidenceGrade === "observed"
200
+ ? "Observed at a specific location; its meaning is inferred."
201
+ : evidenceGrade === "heuristic"
202
+ ? "Heuristic signal: inferred from names or shape, not from a traced code path."
203
+ : "Not established from code; needs human confirmation.";
204
+ const absenceNote = absenceClaim === "not_statically_provable"
205
+ ? " This scan could not prove the control is absent, only that it was not observed."
206
+ : "";
207
+ findings.push({
208
+ id: `dpdp:${result.controlId}:${result.status}:${primary?.file ?? "repo"}:${primary?.line ?? 0}`,
209
+ source: "dpdp",
210
+ category: "privacy",
211
+ severity,
212
+ confidence: result.confidence,
213
+ title: `DPDP ${result.status}: ${result.title}`,
214
+ message: `${result.explanation} ${gradeNote}${absenceNote}`,
215
+ file: primary?.file,
216
+ startLine: primary?.line,
217
+ isNew: result.isNew,
218
+ isAutofixable: false,
219
+ safeToAutofix: false,
220
+ agentInstruction: result.remediation,
221
+ evidenceGrade,
222
+ absenceClaim,
223
+ dataFlow,
224
+ remediation: remediationForControl(result),
225
+ tags: [
226
+ "dpdp",
227
+ result.controlId,
228
+ result.domain,
229
+ result.status.toLowerCase(),
230
+ result.verificationClass.toLowerCase(),
231
+ `evidence:${evidenceGrade}`
232
+ ],
233
+ evidence: {
234
+ detector: "dpdp",
235
+ // Always set snippet so fingerprints prefer content hash over line number
236
+ snippet,
237
+ fieldPath: primary?.field,
238
+ matchedPattern: result.controlId,
239
+ detectionPath: result.verificationClass,
240
+ reasons: [
241
+ result.explanation,
242
+ gradeNote,
243
+ ...(absenceClaim === "not_statically_provable"
244
+ ? ["Absence of the control was not proven; it was not observed."]
245
+ : []),
246
+ ...(result.limitations ?? [])
247
+ ],
248
+ recommendedAction: result.remediation,
249
+ rationale: result.humanReviewQuestion,
250
+ entityType: primary?.dataCategory,
251
+ sensitivity: result.severity === "critical" || result.severity === "high"
252
+ ? result.severity === "critical"
253
+ ? "regulated_identifier"
254
+ : "high"
255
+ : "moderate"
256
+ },
257
+ scoreImpact: 0
258
+ });
259
+ }
260
+ return findings;
261
+ }
262
+ /**
263
+ * Sync control `isNew` from baselined findings.
264
+ * Controls without a finding (not VIOLATED/PARTIAL/ERROR) keep isNew=false after baseline is applied
265
+ * so they do not look like "new issues" in matrices.
266
+ */
267
+ function syncControlIsNewFromFindings(controls, findings, baselineEnabled) {
268
+ if (!baselineEnabled) {
269
+ return controls;
270
+ }
271
+ const findingByControl = new Map();
272
+ for (const finding of findings) {
273
+ const controlId = finding.tags.find((tag) => tag.startsWith("DPDP-"));
274
+ if (controlId) {
275
+ findingByControl.set(controlId, finding);
276
+ }
277
+ }
278
+ return controls.map((result) => {
279
+ const finding = findingByControl.get(result.controlId);
280
+ if (finding) {
281
+ return { ...result, isNew: finding.isNew };
282
+ }
283
+ // No open finding for this control → not a new open issue
284
+ return { ...result, isNew: false };
285
+ });
286
+ }
@@ -0,0 +1,14 @@
1
+ import type { VibeDoctorConfig } from "../core/config";
2
+ import type { Finding, Severity } from "../core/finding";
3
+ import type { ControlResult, ControlStatus, VerificationClass } from "./types";
4
+ export type DpdpGateCandidate = {
5
+ controlId: string;
6
+ status: ControlStatus;
7
+ severity: Severity;
8
+ verificationClass: VerificationClass;
9
+ isNew: boolean;
10
+ };
11
+ export declare function controlToGateCandidate(control: ControlResult): DpdpGateCandidate;
12
+ export declare function findingToGateCandidate(finding: Finding): DpdpGateCandidate | undefined;
13
+ /** Shared CI policy for dedicated and normal DPDP scan entry points. */
14
+ export declare function evaluateDpdpFailureGate(candidates: DpdpGateCandidate[], config: VibeDoctorConfig): boolean;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.controlToGateCandidate = controlToGateCandidate;
4
+ exports.findingToGateCandidate = findingToGateCandidate;
5
+ exports.evaluateDpdpFailureGate = evaluateDpdpFailureGate;
6
+ function controlToGateCandidate(control) {
7
+ return {
8
+ controlId: control.controlId,
9
+ status: control.status,
10
+ severity: control.severity,
11
+ verificationClass: control.verificationClass,
12
+ isNew: control.isNew
13
+ };
14
+ }
15
+ function findingToGateCandidate(finding) {
16
+ if (finding.source !== "dpdp") {
17
+ return undefined;
18
+ }
19
+ const controlId = finding.tags.find((tag) => tag.startsWith("DPDP-"));
20
+ const statusTag = finding.tags.find((tag) => ["violated", "partial", "error"].includes(tag));
21
+ const verificationTag = finding.tags.find((tag) => ["deterministic", "technical_signal", "declared_evidence", "human_review"].includes(tag));
22
+ if (!controlId || !statusTag || !verificationTag) {
23
+ return undefined;
24
+ }
25
+ return {
26
+ controlId,
27
+ status: statusTag.toUpperCase(),
28
+ severity: finding.severity,
29
+ verificationClass: verificationTag.toUpperCase(),
30
+ isNew: finding.isNew
31
+ };
32
+ }
33
+ /** Shared CI policy for dedicated and normal DPDP scan entry points. */
34
+ function evaluateDpdpFailureGate(candidates, config) {
35
+ const dpdp = config.checks.dpdp;
36
+ if (!dpdp.enabled) {
37
+ return false;
38
+ }
39
+ const eligible = candidates.filter((candidate) => (dpdp.failOnlyOnNew ? candidate.isNew : true));
40
+ if (eligible.some((candidate) => candidate.status === "VIOLATED" && dpdp.failOnViolatedControls.includes(candidate.controlId))) {
41
+ return true;
42
+ }
43
+ const severities = new Set(dpdp.failOnSeverity);
44
+ return eligible.some((candidate) => (candidate.status === "VIOLATED" || candidate.status === "PARTIAL") &&
45
+ candidate.verificationClass === "DETERMINISTIC" &&
46
+ severities.has(candidate.severity));
47
+ }
@@ -0,0 +1,16 @@
1
+ export * from "./types";
2
+ export * from "./legalSources";
3
+ export * from "./catalogue";
4
+ export * from "./context";
5
+ export * from "./evidence";
6
+ export * from "./paths";
7
+ export * from "./collectors";
8
+ export * from "./evaluators";
9
+ export * from "./scoring";
10
+ export * from "./dataMap";
11
+ export * from "./findings";
12
+ export * from "./gates";
13
+ export * from "./reviewQueue";
14
+ export * from "./artifacts";
15
+ export * from "./report";
16
+ export * from "./scan";
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./legalSources"), exports);
19
+ __exportStar(require("./catalogue"), exports);
20
+ __exportStar(require("./context"), exports);
21
+ __exportStar(require("./evidence"), exports);
22
+ __exportStar(require("./paths"), exports);
23
+ __exportStar(require("./collectors"), exports);
24
+ __exportStar(require("./evaluators"), exports);
25
+ __exportStar(require("./scoring"), exports);
26
+ __exportStar(require("./dataMap"), exports);
27
+ __exportStar(require("./findings"), exports);
28
+ __exportStar(require("./gates"), exports);
29
+ __exportStar(require("./reviewQueue"), exports);
30
+ __exportStar(require("./artifacts"), exports);
31
+ __exportStar(require("./report"), exports);
32
+ __exportStar(require("./scan"), exports);
@@ -0,0 +1,10 @@
1
+ import type { LegalSourceRef } from "./types";
2
+ /**
3
+ * Versioned offline legal-source baseline for reproducible DPDP technical scans.
4
+ * Agent reviews must verify current official sources at review time; this manifest
5
+ * is not proof of current law and is not legal advice.
6
+ */
7
+ export declare const LEGAL_SOURCE_MANIFEST_VERSION = "2025.2-final-corrigendum";
8
+ export declare const LEGAL_SOURCES: LegalSourceRef[];
9
+ export declare function getLegalSource(id: string): LegalSourceRef | undefined;
10
+ export declare function formatLegalCitations(sourceIds: string[], sections: string[]): string[];
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LEGAL_SOURCES = exports.LEGAL_SOURCE_MANIFEST_VERSION = void 0;
4
+ exports.getLegalSource = getLegalSource;
5
+ exports.formatLegalCitations = formatLegalCitations;
6
+ /**
7
+ * Versioned offline legal-source baseline for reproducible DPDP technical scans.
8
+ * Agent reviews must verify current official sources at review time; this manifest
9
+ * is not proof of current law and is not legal advice.
10
+ */
11
+ exports.LEGAL_SOURCE_MANIFEST_VERSION = "2025.2-final-corrigendum";
12
+ exports.LEGAL_SOURCES = [
13
+ {
14
+ id: "DPDP-ACT-2023",
15
+ title: "Digital Personal Data Protection Act, 2023",
16
+ version: "2023",
17
+ citation: "Act No. 22 of 2023 (India)",
18
+ notificationId: "Act No. 22 of 2023",
19
+ publishedAt: "2023-08-11",
20
+ sourceStatus: "enacted",
21
+ sections: [
22
+ "Section 2 (definitions)",
23
+ "Section 3 (application)",
24
+ "Section 4 (grounds for processing)",
25
+ "Section 5 (notice)",
26
+ "Section 6 (consent)",
27
+ "Section 7 (certain legitimate uses)",
28
+ "Section 8 (general obligations of Data Fiduciary)",
29
+ "Section 9 (processing of personal data of children)",
30
+ "Section 10 (Additional obligations of Significant Data Fiduciary)",
31
+ "Section 11 (Right to access information about personal data)",
32
+ "Section 12 (Right to correction and erasure)",
33
+ "Section 13 (Right of grievance redressal)",
34
+ "Section 14 (Right to nominate)",
35
+ "Section 16 (Transfer of personal data outside India)",
36
+ "Section 17 (exemptions)"
37
+ ],
38
+ url: "https://www.meity.gov.in/static/uploads/2024/06/2bf1f0e9f04e6fb4f8fef35e82c42aa5.pdf"
39
+ },
40
+ {
41
+ id: "DPDP-RULES-2025",
42
+ title: "Digital Personal Data Protection Rules, 2025",
43
+ version: "2025-final",
44
+ citation: "G.S.R. 846(E), dated 13 November 2025",
45
+ notificationId: "G.S.R. 846(E)",
46
+ publishedAt: "2025-11-14",
47
+ sourceStatus: "notified",
48
+ effectiveSchedule: [
49
+ "Rules 1, 2 and 17-21: on Gazette publication",
50
+ "Rule 4: one year after Gazette publication",
51
+ "Rules 3, 5-16, 22 and 23: eighteen months after Gazette publication"
52
+ ],
53
+ sections: [
54
+ "Notice requirements",
55
+ "Consent manager related provisions",
56
+ "Security safeguards",
57
+ "Retention and erasure timelines",
58
+ "Breach intimation",
59
+ "Significant Data Fiduciary obligations",
60
+ "Children's data processing",
61
+ "Cross-border transfer conditions"
62
+ ],
63
+ url: "https://www.meity.gov.in/static/uploads/2025/11/53450e6e5dc0bfa85ebd78686cadad39.pdf"
64
+ },
65
+ {
66
+ id: "DPDP-CORRIGENDUM",
67
+ title: "DPDP corrigendum / rectification notifications",
68
+ version: "2025-12",
69
+ citation: "G.S.R. 892(E), corrigendum to G.S.R. 846(E)",
70
+ notificationId: "G.S.R. 892(E)",
71
+ publishedAt: "2025-12-12",
72
+ sourceStatus: "corrigendum",
73
+ sections: ["Corrections to the final Digital Personal Data Protection Rules, 2025"],
74
+ url: "https://www.meity.gov.in/documents/act-and-policies/digital-personal-data-protection-rules-2025-gDOxUjMtQWa"
75
+ },
76
+ {
77
+ id: "DPDP-ENFORCEMENT-NOTIFICATION",
78
+ title: "DPDP enforcement / commencement notification",
79
+ version: "2025-11",
80
+ citation: "G.S.R. 843(E), dated 13 November 2025",
81
+ notificationId: "G.S.R. 843(E)",
82
+ publishedAt: "2025-11-14",
83
+ sourceStatus: "notified",
84
+ effectiveSchedule: [
85
+ "Specified institutional provisions: on Gazette publication",
86
+ "Section 6(9) and section 27(1)(d): one year after Gazette publication",
87
+ "Core processing, rights and obligation provisions: eighteen months after Gazette publication"
88
+ ],
89
+ sections: ["Phased commencement of the Digital Personal Data Protection Act, 2023"],
90
+ url: "https://www.meity.gov.in/static/uploads/2025/11/c56ceae6c383460ca69577428d36828b.pdf"
91
+ }
92
+ ];
93
+ function getLegalSource(id) {
94
+ return exports.LEGAL_SOURCES.find((source) => source.id === id);
95
+ }
96
+ function formatLegalCitations(sourceIds, sections) {
97
+ return [
98
+ ...sourceIds.map((id) => {
99
+ const source = getLegalSource(id);
100
+ return source ? `${source.title} (${source.version})` : id;
101
+ }),
102
+ ...sections
103
+ ];
104
+ }
@@ -0,0 +1,25 @@
1
+ import type { ToolAdapterContext } from "../adapters/shared";
2
+ import type { DpdpCapabilityStatus } from "./types";
3
+ export type DpdpScanScope = "full" | "changed" | "changed-fallback-full";
4
+ export type DpdpCandidateResolution = {
5
+ /** Files to scan after include/exclude + text filters. */
6
+ files: string[];
7
+ /** How the candidate set was chosen. */
8
+ scope: DpdpScanScope;
9
+ /** Raw base set size before include/exclude (project or changed). */
10
+ baseFileCount: number;
11
+ /** Git changed file count from project context. */
12
+ changedFileCount: number;
13
+ /** Capability status for reports (changed scope / fallback). */
14
+ capability?: DpdpCapabilityStatus;
15
+ };
16
+ export declare function isDpdpTextCandidate(file: string): boolean;
17
+ export declare function normalizeDpdpPath(file: string): string;
18
+ /**
19
+ * Resolve which repository files DPDP collectors should read.
20
+ *
21
+ * Changed mode scopes collection to `project.changedFiles` when non-empty.
22
+ * Empty changed set falls back to full project scope (never empty matrix).
23
+ * Control matrix evaluation always remains full-catalogue; only evidence collection is scoped.
24
+ */
25
+ export declare function resolveDpdpCandidateFiles(ctx: ToolAdapterContext): DpdpCandidateResolution;
@@ -0,0 +1,85 @@
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.isDpdpTextCandidate = isDpdpTextCandidate;
7
+ exports.normalizeDpdpPath = normalizeDpdpPath;
8
+ exports.resolveDpdpCandidateFiles = resolveDpdpCandidateFiles;
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const paths_1 = require("../core/paths");
11
+ const TEXT_EXTENSIONS = new Set([
12
+ ".ts",
13
+ ".tsx",
14
+ ".js",
15
+ ".jsx",
16
+ ".py",
17
+ ".json",
18
+ ".yml",
19
+ ".yaml",
20
+ ".toml",
21
+ ".env",
22
+ ".sql",
23
+ ".prisma",
24
+ ".graphql",
25
+ ".gql",
26
+ ".md",
27
+ ".txt",
28
+ ".log",
29
+ ".csv"
30
+ ]);
31
+ function isDpdpTextCandidate(file) {
32
+ const extension = node_path_1.default.extname(file).toLowerCase();
33
+ return TEXT_EXTENSIONS.has(extension) || /(^|\/)(\.env|Dockerfile|openapi)/i.test((0, paths_1.normalizeToPosix)(file));
34
+ }
35
+ function normalizeDpdpPath(file) {
36
+ return (0, paths_1.normalizeToPosix)(file.trim());
37
+ }
38
+ /**
39
+ * Resolve which repository files DPDP collectors should read.
40
+ *
41
+ * Changed mode scopes collection to `project.changedFiles` when non-empty.
42
+ * Empty changed set falls back to full project scope (never empty matrix).
43
+ * Control matrix evaluation always remains full-catalogue; only evidence collection is scoped.
44
+ */
45
+ function resolveDpdpCandidateFiles(ctx) {
46
+ const dpdpCfg = ctx.config.checks.dpdp;
47
+ const include = dpdpCfg.include.length > 0 ? dpdpCfg.include : ctx.config.paths.include;
48
+ const exclude = [...ctx.config.paths.exclude, ...dpdpCfg.exclude];
49
+ const projectFiles = ctx.project.projectFiles.map(normalizeDpdpPath);
50
+ const changedFiles = (ctx.project.changedFiles ?? []).map(normalizeDpdpPath).filter(Boolean);
51
+ const isChangedMode = ctx.scanMode === "changed";
52
+ let base = projectFiles;
53
+ let scope = "full";
54
+ let capability;
55
+ if (isChangedMode) {
56
+ if (changedFiles.length > 0) {
57
+ // Prefer intersection with known project files when available; keep git paths that may be new.
58
+ const projectSet = new Set(projectFiles);
59
+ const intersected = changedFiles.filter((file) => projectSet.has(file));
60
+ base = intersected.length > 0 ? intersected : changedFiles;
61
+ scope = "changed";
62
+ capability = {
63
+ id: "changed-scope",
64
+ status: "available",
65
+ message: `Scoped DPDP collection to ${base.length} changed file(s)`
66
+ };
67
+ }
68
+ else {
69
+ scope = "changed-fallback-full";
70
+ capability = {
71
+ id: "changed-scope",
72
+ status: "skipped",
73
+ message: "No git changed files detected; ran full repository scope for DPDP collection"
74
+ };
75
+ }
76
+ }
77
+ const files = (0, paths_1.filterPaths)(base, include, exclude).filter(isDpdpTextCandidate).map(normalizeDpdpPath);
78
+ return {
79
+ files,
80
+ scope,
81
+ baseFileCount: base.length,
82
+ changedFileCount: changedFiles.length,
83
+ capability
84
+ };
85
+ }