@neuralaxis/vibedoctor 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +213 -116
  2. package/dist/adapters/dpdp.d.ts +6 -0
  3. package/dist/adapters/dpdp.js +34 -0
  4. package/dist/adapters/index.d.ts +1 -0
  5. package/dist/adapters/index.js +3 -1
  6. package/dist/adapters/presidio.js +3 -1
  7. package/dist/adapters/privacyDetector.d.ts +24 -1
  8. package/dist/adapters/privacyDetector.js +86 -2
  9. package/dist/adapters/shared.d.ts +6 -0
  10. package/dist/agentPack/templates/skills.js +159 -53
  11. package/dist/cli/commands/dpdp.d.ts +35 -0
  12. package/dist/cli/commands/dpdp.js +103 -0
  13. package/dist/cli/commands/scan.js +4 -1
  14. package/dist/cli/commands/setup.js +1 -1
  15. package/dist/cli/index.js +84 -0
  16. package/dist/core/config.d.ts +21 -0
  17. package/dist/core/config.js +89 -4
  18. package/dist/core/engine.js +22 -3
  19. package/dist/core/finding.d.ts +1 -1
  20. package/dist/core/finding.js +1 -0
  21. package/dist/core/scanPlanner.js +10 -2
  22. package/dist/dpdp/artifacts.d.ts +11 -0
  23. package/dist/dpdp/artifacts.js +120 -0
  24. package/dist/dpdp/catalogue.d.ts +14 -0
  25. package/dist/dpdp/catalogue.js +661 -0
  26. package/dist/dpdp/collectors/confidence.d.ts +9 -0
  27. package/dist/dpdp/collectors/confidence.js +25 -0
  28. package/dist/dpdp/collectors/dependencies.d.ts +7 -0
  29. package/dist/dpdp/collectors/dependencies.js +63 -0
  30. package/dist/dpdp/collectors/index.d.ts +24 -0
  31. package/dist/dpdp/collectors/index.js +71 -0
  32. package/dist/dpdp/collectors/lifecycle.d.ts +2 -0
  33. package/dist/dpdp/collectors/lifecycle.js +202 -0
  34. package/dist/dpdp/collectors/optionalScanners.d.ts +14 -0
  35. package/dist/dpdp/collectors/optionalScanners.js +347 -0
  36. package/dist/dpdp/collectors/privacyBridge.d.ts +13 -0
  37. package/dist/dpdp/collectors/privacyBridge.js +152 -0
  38. package/dist/dpdp/collectors/safeguards.d.ts +5 -0
  39. package/dist/dpdp/collectors/safeguards.js +186 -0
  40. package/dist/dpdp/collectors/schema.d.ts +6 -0
  41. package/dist/dpdp/collectors/schema.js +122 -0
  42. package/dist/dpdp/collectors/shared.d.ts +10 -0
  43. package/dist/dpdp/collectors/shared.js +43 -0
  44. package/dist/dpdp/context.d.ts +28 -0
  45. package/dist/dpdp/context.js +195 -0
  46. package/dist/dpdp/dataMap.d.ts +7 -0
  47. package/dist/dpdp/dataMap.js +339 -0
  48. package/dist/dpdp/evaluators.d.ts +20 -0
  49. package/dist/dpdp/evaluators.js +522 -0
  50. package/dist/dpdp/evidence.d.ts +11 -0
  51. package/dist/dpdp/evidence.js +123 -0
  52. package/dist/dpdp/findings.d.ts +14 -0
  53. package/dist/dpdp/findings.js +99 -0
  54. package/dist/dpdp/gates.d.ts +14 -0
  55. package/dist/dpdp/gates.js +47 -0
  56. package/dist/dpdp/index.d.ts +16 -0
  57. package/dist/dpdp/index.js +32 -0
  58. package/dist/dpdp/legalSources.d.ts +10 -0
  59. package/dist/dpdp/legalSources.js +104 -0
  60. package/dist/dpdp/paths.d.ts +25 -0
  61. package/dist/dpdp/paths.js +85 -0
  62. package/dist/dpdp/report.d.ts +6 -0
  63. package/dist/dpdp/report.js +222 -0
  64. package/dist/dpdp/reviewQueue.d.ts +3 -0
  65. package/dist/dpdp/reviewQueue.js +88 -0
  66. package/dist/dpdp/scan.d.ts +26 -0
  67. package/dist/dpdp/scan.js +310 -0
  68. package/dist/dpdp/scoring.d.ts +31 -0
  69. package/dist/dpdp/scoring.js +211 -0
  70. package/dist/dpdp/types.d.ts +294 -0
  71. package/dist/dpdp/types.js +86 -0
  72. package/dist/index.d.ts +1 -0
  73. package/dist/index.js +1 -0
  74. package/dist/mcp/tools/dpdp.d.ts +11 -0
  75. package/dist/mcp/tools/dpdp.js +151 -0
  76. package/dist/mcp/tools/index.js +3 -1
  77. package/dist/reporters/json.js +6 -1
  78. package/package.json +4 -1
@@ -0,0 +1,347 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectOptionalScannerSignals = collectOptionalScannerSignals;
4
+ const presidio_1 = require("../../adapters/presidio");
5
+ const semgrep_1 = require("../../adapters/semgrep");
6
+ const toolRunner_1 = require("../../core/toolRunner");
7
+ const confidence_1 = require("./confidence");
8
+ const privacyBridge_1 = require("./privacyBridge");
9
+ const shared_1 = require("./shared");
10
+ const evidence_1 = require("../evidence");
11
+ const ENTITY_TO_CATEGORY = {
12
+ aadhaar: "aadhaar",
13
+ pan: "pan",
14
+ passport: "passport",
15
+ email: "email",
16
+ phone: "phone",
17
+ phone_number: "phone",
18
+ date_of_birth: "date_of_birth",
19
+ date_time: "date_of_birth",
20
+ address: "postal_address",
21
+ location: "location",
22
+ ip_address: "ip_device_id",
23
+ ip: "ip_device_id",
24
+ device_id: "ip_device_id",
25
+ credit_card: "financial_payment",
26
+ payment_card: "financial_payment",
27
+ iban: "financial_payment",
28
+ bank_account: "financial_payment",
29
+ medical_license: "health_disability",
30
+ person: "name",
31
+ nrp: "other_personal",
32
+ us_ssn: "other_personal",
33
+ url: "other_personal"
34
+ };
35
+ function sanitizeSnippet(snippet) {
36
+ return snippet ? (0, evidence_1.redactLikelyPii)(snippet) : undefined;
37
+ }
38
+ function mapPrivacyLikeFindingToSignals(finding, signals, minConfidence, provenance) {
39
+ if (!(0, confidence_1.confidenceMeetsThreshold)(finding.confidence, minConfidence)) {
40
+ return;
41
+ }
42
+ const entity = finding.evidence?.entityType ?? finding.tags.find((tag) => tag !== "privacy") ?? "other_personal";
43
+ const category = ENTITY_TO_CATEGORY[entity.toLowerCase()] ?? "other_personal";
44
+ const snippet = sanitizeSnippet(finding.evidence?.snippet ?? finding.evidence?.maskedValue);
45
+ const detectionMethod = finding.evidence?.matchedPattern ?? provenance;
46
+ const detectionPath = finding.evidence?.detectionPath ?? provenance;
47
+ const tags = [
48
+ provenance,
49
+ entity.toLowerCase(),
50
+ ...(finding.tags ?? []),
51
+ ...(0, privacyBridge_1.classifyPrivacyFindingTags)(finding.file, detectionMethod, detectionPath)
52
+ ];
53
+ (0, shared_1.pushSignal)(signals, {
54
+ kind: finding.evidence?.fieldPath ? "field" : "category",
55
+ file: finding.file,
56
+ line: finding.startLine,
57
+ category,
58
+ field: finding.evidence?.fieldPath,
59
+ summary: `${finding.title} (${entity})`,
60
+ snippet,
61
+ confidence: finding.confidence,
62
+ confidenceScore: finding.evidence?.confidenceScore,
63
+ tags,
64
+ detectionMethod: `${provenance}:${detectionMethod}`,
65
+ provenance,
66
+ certainty: finding.confidence === "high" ? "confirmed" : "inferred",
67
+ relatedControls: ["DPDP-APP-001", "DPDP-SEC-007"]
68
+ });
69
+ const blob = `${finding.title} ${finding.message} ${finding.tags.join(" ")}`.toLowerCase();
70
+ if (/log|logger|unsanitized/.test(blob)) {
71
+ (0, shared_1.pushSignal)(signals, {
72
+ kind: "safeguard_gap",
73
+ file: finding.file,
74
+ line: finding.startLine,
75
+ category,
76
+ summary: "Potential PII in logging path (optional scanner)",
77
+ snippet,
78
+ confidence: finding.confidence,
79
+ tags: ["pii-in-logs", provenance],
80
+ detectionMethod: `${provenance}-log`,
81
+ provenance,
82
+ relatedControls: ["DPDP-SEC-001"]
83
+ });
84
+ }
85
+ if (/secret|password|credential|hardcoded|api[_-]?key/.test(blob)) {
86
+ (0, shared_1.pushSignal)(signals, {
87
+ kind: "safeguard_gap",
88
+ file: finding.file,
89
+ line: finding.startLine,
90
+ category,
91
+ summary: "Potential credential or sensitive secret signal (optional scanner)",
92
+ snippet,
93
+ confidence: finding.confidence,
94
+ tags: ["hardcoded-secret", provenance],
95
+ detectionMethod: `${provenance}-secret`,
96
+ provenance,
97
+ relatedControls: ["DPDP-SEC-007", "DPDP-SEC-010"]
98
+ });
99
+ }
100
+ }
101
+ function isPrivacyRelevantSemgrep(finding) {
102
+ const blob = `${finding.id} ${finding.title} ${finding.message} ${(finding.tags ?? []).join(" ")}`.toLowerCase();
103
+ return /pii|privacy|secret|password|credential|token|personal|gdpr|log|auth|jwt|cookie|ssn|aadhaar|pan|email|phone|encrypt|mask|redact/.test(blob);
104
+ }
105
+ function inCandidateScope(finding, candidates) {
106
+ if (!finding.file) {
107
+ return false;
108
+ }
109
+ return candidates.has(finding.file.replaceAll("\\", "/"));
110
+ }
111
+ function scopedScannerContext(ctx, candidates) {
112
+ return {
113
+ ...ctx,
114
+ project: { ...ctx.project, projectFiles: candidates },
115
+ config: {
116
+ ...ctx.config,
117
+ paths: {
118
+ ...ctx.config.paths,
119
+ // Candidates have already passed global + DPDP include/exclude resolution.
120
+ include: candidates,
121
+ exclude: []
122
+ }
123
+ }
124
+ };
125
+ }
126
+ function capabilityFromExecution(id, execution, mapped) {
127
+ const status = execution.status;
128
+ if (status?.status === "skipped") {
129
+ return {
130
+ id,
131
+ status: "skipped",
132
+ message: status.installHint ?? (status.stderr.trim() || `${id} was unavailable (never counted as pass)`)
133
+ };
134
+ }
135
+ if (status?.status === "error" || status?.status === "timeout") {
136
+ return {
137
+ id,
138
+ status: "error",
139
+ message: status.stderr.trim() || status.stdout.trim() || `${id} failed`
140
+ };
141
+ }
142
+ return {
143
+ id,
144
+ status: "available",
145
+ message: `Reused ${id} scan; ${mapped} scoped finding(s) contributed to DPDP evidence`
146
+ };
147
+ }
148
+ /**
149
+ * Run opt-out optional scanners (Presidio, Semgrep) when enabled.
150
+ * Missing tools are skipped — never counted as a pass.
151
+ */
152
+ async function collectOptionalScannerSignals(ctx, candidates, options = {}) {
153
+ const dpdp = ctx.config.checks.dpdp;
154
+ const signals = [];
155
+ const capabilities = [];
156
+ const findings = [];
157
+ const candidateSet = new Set(candidates.map((file) => file.replaceAll("\\", "/")));
158
+ if (options.enabled === false) {
159
+ return {
160
+ signals,
161
+ findings,
162
+ capabilities: [
163
+ { id: "presidio", status: "skipped", message: "Skipped in quick mode" },
164
+ { id: "semgrep", status: "skipped", message: "Skipped in quick mode" }
165
+ ]
166
+ };
167
+ }
168
+ // --- Presidio (default on; opt out with use_presidio: false) ---
169
+ const wantPresidio = dpdp.usePresidio;
170
+ if (!wantPresidio) {
171
+ capabilities.push({
172
+ id: "presidio",
173
+ status: "skipped",
174
+ message: "Opted out (set checks.dpdp.use_presidio: true to re-enable for DPDP evidence)"
175
+ });
176
+ }
177
+ else if (candidates.length === 0) {
178
+ capabilities.push({ id: "presidio", status: "skipped", message: "No DPDP candidate files in scope" });
179
+ }
180
+ else {
181
+ try {
182
+ const reused = ctx.sharedToolResults?.presidio;
183
+ if (reused) {
184
+ const scopedFindings = reused.findings.filter((finding) => inCandidateScope(finding, candidateSet));
185
+ findings.push(...scopedFindings);
186
+ for (const finding of scopedFindings) {
187
+ mapPrivacyLikeFindingToSignals(finding, signals, dpdp.minConfidenceToReport, "presidio");
188
+ }
189
+ capabilities.push(capabilityFromExecution("presidio", reused, scopedFindings.length));
190
+ }
191
+ else {
192
+ const baseCtx = scopedScannerContext(ctx, candidates);
193
+ const presidioCtx = {
194
+ ...baseCtx,
195
+ config: {
196
+ ...baseCtx.config,
197
+ checks: {
198
+ ...baseCtx.config.checks,
199
+ privacy: {
200
+ ...baseCtx.config.checks.privacy,
201
+ enabled: true,
202
+ presidio: { enabled: true },
203
+ minConfidenceToReport: dpdp.minConfidenceToReport,
204
+ maskExamples: dpdp.maskExamples
205
+ }
206
+ }
207
+ }
208
+ };
209
+ if (!(await presidio_1.presidioAdapter.detect(presidioCtx.project, presidioCtx.config))) {
210
+ capabilities.push({
211
+ id: "presidio",
212
+ status: "skipped",
213
+ message: "Presidio not selected for this project"
214
+ });
215
+ }
216
+ else {
217
+ const result = await presidio_1.presidioAdapter.runStandalone?.(presidioCtx);
218
+ const status = result?.status;
219
+ if (!result || status?.status === "skipped") {
220
+ capabilities.push({
221
+ id: "presidio",
222
+ status: "skipped",
223
+ message: status?.installHint ??
224
+ status?.stderr?.trim() ??
225
+ "Presidio not installed or unavailable (never counted as pass)"
226
+ });
227
+ }
228
+ else if (status?.status === "error" || status?.status === "timeout") {
229
+ capabilities.push({
230
+ id: "presidio",
231
+ status: "error",
232
+ message: status.stderr?.trim() || status.stdout?.trim() || "Presidio failed"
233
+ });
234
+ }
235
+ else {
236
+ findings.push(...result.findings);
237
+ for (const finding of result.findings) {
238
+ mapPrivacyLikeFindingToSignals(finding, signals, dpdp.minConfidenceToReport, "presidio");
239
+ }
240
+ capabilities.push({
241
+ id: "presidio",
242
+ status: "available",
243
+ message: `Presidio contributed ${result.findings.length} finding(s) to DPDP evidence`
244
+ });
245
+ }
246
+ }
247
+ }
248
+ }
249
+ catch (error) {
250
+ capabilities.push({
251
+ id: "presidio",
252
+ status: "error",
253
+ message: error instanceof Error ? error.message : String(error)
254
+ });
255
+ }
256
+ }
257
+ // --- Semgrep (default on; opt out with use_semgrep: false) ---
258
+ if (!dpdp.useSemgrep) {
259
+ capabilities.push({
260
+ id: "semgrep",
261
+ status: "skipped",
262
+ message: "Opted out (set checks.dpdp.use_semgrep: true to re-enable for DPDP evidence)"
263
+ });
264
+ }
265
+ else if (candidates.length === 0) {
266
+ capabilities.push({ id: "semgrep", status: "skipped", message: "No DPDP candidate files in scope" });
267
+ }
268
+ else {
269
+ try {
270
+ const reused = ctx.sharedToolResults?.semgrep;
271
+ if (reused) {
272
+ const scopedFindings = reused.findings.filter((finding) => inCandidateScope(finding, candidateSet));
273
+ findings.push(...scopedFindings);
274
+ let mapped = 0;
275
+ for (const finding of scopedFindings) {
276
+ if (isPrivacyRelevantSemgrep(finding)) {
277
+ mapped += 1;
278
+ mapPrivacyLikeFindingToSignals(finding, signals, dpdp.minConfidenceToReport, "semgrep");
279
+ }
280
+ }
281
+ capabilities.push(capabilityFromExecution("semgrep", reused, mapped));
282
+ }
283
+ else {
284
+ const semgrepCtx = scopedScannerContext(ctx, candidates);
285
+ if (!(await semgrep_1.semgrepAdapter.detect(semgrepCtx.project, semgrepCtx.config))) {
286
+ capabilities.push({
287
+ id: "semgrep",
288
+ status: "skipped",
289
+ message: "Semgrep not applicable for this project"
290
+ });
291
+ }
292
+ else if (!semgrep_1.semgrepAdapter.buildScanCommand || !semgrep_1.semgrepAdapter.parseResult) {
293
+ capabilities.push({
294
+ id: "semgrep",
295
+ status: "skipped",
296
+ message: "Semgrep adapter cannot run in this build"
297
+ });
298
+ }
299
+ else {
300
+ const command = semgrep_1.semgrepAdapter.buildScanCommand(semgrepCtx);
301
+ const toolResult = await (0, toolRunner_1.runCommand)(command, semgrep_1.semgrepAdapter.installHint);
302
+ if (toolResult.status === "skipped") {
303
+ capabilities.push({
304
+ id: "semgrep",
305
+ status: "skipped",
306
+ message: toolResult.installHint ??
307
+ toolResult.stderr?.trim() ??
308
+ "Semgrep not installed (never counted as pass)"
309
+ });
310
+ }
311
+ else if (toolResult.status === "error" || toolResult.status === "timeout") {
312
+ capabilities.push({
313
+ id: "semgrep",
314
+ status: "error",
315
+ message: toolResult.stderr?.trim() || "Semgrep failed"
316
+ });
317
+ }
318
+ else {
319
+ const semgrepFindings = semgrep_1.semgrepAdapter.parseResult(toolResult, semgrepCtx);
320
+ findings.push(...semgrepFindings);
321
+ let mapped = 0;
322
+ for (const finding of semgrepFindings) {
323
+ if (!isPrivacyRelevantSemgrep(finding)) {
324
+ continue;
325
+ }
326
+ mapped += 1;
327
+ mapPrivacyLikeFindingToSignals(finding, signals, dpdp.minConfidenceToReport, "semgrep");
328
+ }
329
+ capabilities.push({
330
+ id: "semgrep",
331
+ status: "available",
332
+ message: `Semgrep ran (${semgrepFindings.length} finding(s); ${mapped} privacy-relevant mapped to DPDP evidence)`
333
+ });
334
+ }
335
+ }
336
+ }
337
+ }
338
+ catch (error) {
339
+ capabilities.push({
340
+ id: "semgrep",
341
+ status: "error",
342
+ message: error instanceof Error ? error.message : String(error)
343
+ });
344
+ }
345
+ }
346
+ return { signals, capabilities, findings };
347
+ }
@@ -0,0 +1,13 @@
1
+ import type { ToolAdapterContext } from "../../adapters/shared";
2
+ import type { Finding } from "../../core/finding";
3
+ import type { TechnicalSignalBag } from "../types";
4
+ /** Prefer DPDP confidence/mask settings when invoking the privacy detector from DPDP. */
5
+ export declare function withDpdpPrivacyOverrides(ctx: ToolAdapterContext): ToolAdapterContext;
6
+ /**
7
+ * Distinguish field-name metadata from value-literal detections for hardcoded-PII evaluation.
8
+ */
9
+ export declare function classifyPrivacyFindingTags(file: string | undefined, matchedPattern: string, detectionPath: string): string[];
10
+ export declare function collectPrivacySignals(ctx: ToolAdapterContext, candidates: string[]): Promise<{
11
+ privacyFindings: Finding[];
12
+ signals: TechnicalSignalBag[];
13
+ }>;
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withDpdpPrivacyOverrides = withDpdpPrivacyOverrides;
4
+ exports.classifyPrivacyFindingTags = classifyPrivacyFindingTags;
5
+ exports.collectPrivacySignals = collectPrivacySignals;
6
+ const privacyDetector_1 = require("../../adapters/privacyDetector");
7
+ const evidence_1 = require("../evidence");
8
+ const confidence_1 = require("./confidence");
9
+ const shared_1 = require("./shared");
10
+ const ENTITY_TO_CATEGORY = {
11
+ aadhaar: "aadhaar",
12
+ pan: "pan",
13
+ passport: "passport",
14
+ email: "email",
15
+ phone: "phone",
16
+ date_of_birth: "date_of_birth",
17
+ address: "postal_address",
18
+ ip_address: "ip_device_id",
19
+ device_id: "ip_device_id",
20
+ payment_card: "financial_payment",
21
+ bank_account: "financial_payment",
22
+ health_data: "health_disability",
23
+ financial_attribute: "financial_payment",
24
+ employment_sensitive: "employee_applicant_customer",
25
+ precise_location: "location",
26
+ person_linkable_id: "employee_applicant_customer",
27
+ combination_risk: "other_personal"
28
+ };
29
+ /** Prefer DPDP confidence/mask settings when invoking the privacy detector from DPDP. */
30
+ function withDpdpPrivacyOverrides(ctx) {
31
+ const dpdp = ctx.config.checks.dpdp;
32
+ return {
33
+ ...ctx,
34
+ config: {
35
+ ...ctx.config,
36
+ checks: {
37
+ ...ctx.config.checks,
38
+ privacy: {
39
+ ...ctx.config.checks.privacy,
40
+ minConfidenceToReport: dpdp.minConfidenceToReport,
41
+ maskExamples: dpdp.maskExamples
42
+ }
43
+ }
44
+ }
45
+ };
46
+ }
47
+ function sanitizeSignalSnippet(snippet) {
48
+ if (!snippet) {
49
+ return undefined;
50
+ }
51
+ return (0, evidence_1.redactLikelyPii)(snippet);
52
+ }
53
+ /**
54
+ * Distinguish field-name metadata from value-literal detections for hardcoded-PII evaluation.
55
+ */
56
+ function classifyPrivacyFindingTags(file, matchedPattern, detectionPath) {
57
+ const tags = [];
58
+ const pathText = detectionPath.toLowerCase();
59
+ const pattern = matchedPattern.toLowerCase();
60
+ const isValueLiteral = pathText.includes("regex") || pathText.includes("checksum") || /(-regex|luhn)/i.test(pattern);
61
+ const isFieldMetadata = pathText.includes("metadata") || /-field$/i.test(pattern) || pathText.includes("combination-risk");
62
+ if (isValueLiteral) {
63
+ tags.push("value-literal");
64
+ }
65
+ else if (isFieldMetadata) {
66
+ tags.push("field-metadata");
67
+ }
68
+ if (file && /(^|\/)(fixtures?|seeds?|samples?|mocks?|demos?|testdata)(\/|$)/i.test(file.replaceAll("\\", "/"))) {
69
+ tags.push("fixture-path");
70
+ }
71
+ return tags;
72
+ }
73
+ async function collectPrivacySignals(ctx, candidates) {
74
+ const privacyCfg = ctx.config.checks.privacy;
75
+ const dpdpCfg = ctx.config.checks.dpdp;
76
+ const privacyCtx = withDpdpPrivacyOverrides(ctx);
77
+ const privacyFindings = privacyCfg.enabled || dpdpCfg.enabled
78
+ ? await (0, privacyDetector_1.detectPiiFindings)(privacyCtx, { fileAllowlist: candidates })
79
+ : [];
80
+ const signals = [];
81
+ for (const finding of privacyFindings) {
82
+ if (!(0, confidence_1.confidenceMeetsThreshold)(finding.confidence, dpdpCfg.minConfidenceToReport)) {
83
+ continue;
84
+ }
85
+ const entity = finding.evidence?.entityType ?? "other_personal";
86
+ const category = ENTITY_TO_CATEGORY[entity] ?? "other_personal";
87
+ const snippet = sanitizeSignalSnippet(finding.evidence?.snippet);
88
+ const detectionMethod = finding.evidence?.matchedPattern ?? "privacy-detector";
89
+ const detectionPath = finding.evidence?.detectionPath ?? "";
90
+ const privacyTags = [
91
+ "privacy-detector",
92
+ entity,
93
+ ...(finding.tags ?? []),
94
+ ...classifyPrivacyFindingTags(finding.file, detectionMethod, detectionPath)
95
+ ];
96
+ (0, shared_1.pushSignal)(signals, {
97
+ kind: finding.evidence?.fieldPath ? "field" : "category",
98
+ file: finding.file,
99
+ line: finding.startLine,
100
+ category,
101
+ field: finding.evidence?.fieldPath,
102
+ summary: `${finding.title} (${entity})`,
103
+ snippet,
104
+ confidence: finding.confidence,
105
+ confidenceScore: finding.evidence?.confidenceScore,
106
+ tags: privacyTags,
107
+ detectionMethod,
108
+ provenance: "privacy-detector",
109
+ certainty: finding.confidence === "high" ? "confirmed" : "inferred",
110
+ relatedControls: ["DPDP-APP-001", "DPDP-SEC-007"]
111
+ });
112
+ if (finding.tags.includes("logging") || finding.id.includes("unsanitized-log")) {
113
+ (0, shared_1.pushSignal)(signals, {
114
+ kind: "safeguard_gap",
115
+ file: finding.file,
116
+ line: finding.startLine,
117
+ category,
118
+ summary: "Potential PII in logger call",
119
+ snippet,
120
+ confidence: finding.confidence,
121
+ tags: ["pii-in-logs"],
122
+ detectionMethod: "privacy-detector-log",
123
+ relatedControls: ["DPDP-SEC-001"]
124
+ });
125
+ }
126
+ if (finding.tags.includes("overfetching") || finding.id.includes("api-overfetching")) {
127
+ (0, shared_1.pushSignal)(signals, {
128
+ kind: "safeguard_gap",
129
+ file: finding.file,
130
+ line: finding.startLine,
131
+ summary: "Potential API over-fetching of personal entity",
132
+ confidence: finding.confidence,
133
+ tags: ["api-overfetch"],
134
+ detectionMethod: "privacy-detector-overfetch",
135
+ relatedControls: ["DPDP-MIN-001"]
136
+ });
137
+ }
138
+ if (finding.tags.includes("retention") || finding.id.includes("missing-retention")) {
139
+ (0, shared_1.pushSignal)(signals, {
140
+ kind: "storage",
141
+ file: finding.file,
142
+ line: finding.startLine,
143
+ summary: finding.message,
144
+ confidence: finding.confidence,
145
+ tags: ["missing-retention", "pii-store"],
146
+ detectionMethod: "privacy-detector-retention",
147
+ relatedControls: ["DPDP-RET-001", "DPDP-ERA-002"]
148
+ });
149
+ }
150
+ }
151
+ return { privacyFindings, signals };
152
+ }
@@ -0,0 +1,5 @@
1
+ import type { TechnicalSignalBag } from "../types";
2
+ /**
3
+ * Safeguard / gap detectors with multi-line depth for logs, LLM prompts, and route auth.
4
+ */
5
+ export declare function collectSafeguardSignals(signals: TechnicalSignalBag[], file: string, content: string, lines: string[]): void;