@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,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trustForState = trustForState;
|
|
4
|
+
exports.isCoverageGap = isCoverageGap;
|
|
5
|
+
exports.didRun = didRun;
|
|
6
|
+
exports.buildCapabilityMatrix = buildCapabilityMatrix;
|
|
7
|
+
exports.capabilityStateLabel = capabilityStateLabel;
|
|
8
|
+
exports.renderCapabilityMatrixLines = renderCapabilityMatrixLines;
|
|
9
|
+
const COMPLETE_STATES = new Set(["completed"]);
|
|
10
|
+
const RAN_STATES = new Set(["completed", "partial", "timed_out", "failed"]);
|
|
11
|
+
function trustForState(state) {
|
|
12
|
+
if (COMPLETE_STATES.has(state)) {
|
|
13
|
+
return "authoritative";
|
|
14
|
+
}
|
|
15
|
+
if (state === "partial") {
|
|
16
|
+
return "partial";
|
|
17
|
+
}
|
|
18
|
+
// "not_applicable", "disabled" and "not_selected" are deliberate: there is no
|
|
19
|
+
// missing coverage to disclose, so they do not weaken the report.
|
|
20
|
+
if (state === "not_applicable" || state === "disabled" || state === "not_selected") {
|
|
21
|
+
return "authoritative";
|
|
22
|
+
}
|
|
23
|
+
return "absent";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* States that mean "this check did not happen and you should know". Deliberate
|
|
27
|
+
* exclusions are not gaps; a tool that timed out or is missing is.
|
|
28
|
+
*/
|
|
29
|
+
function isCoverageGap(capability) {
|
|
30
|
+
return capability.trust === "absent" || capability.trust === "partial";
|
|
31
|
+
}
|
|
32
|
+
function didRun(capability) {
|
|
33
|
+
return RAN_STATES.has(capability.state);
|
|
34
|
+
}
|
|
35
|
+
const EMPTY_COUNTS = {
|
|
36
|
+
completed: 0,
|
|
37
|
+
partial: 0,
|
|
38
|
+
timed_out: 0,
|
|
39
|
+
failed: 0,
|
|
40
|
+
not_installed: 0,
|
|
41
|
+
runtime_incompatible: 0,
|
|
42
|
+
deferred: 0,
|
|
43
|
+
disabled: 0,
|
|
44
|
+
not_applicable: 0,
|
|
45
|
+
not_selected: 0
|
|
46
|
+
};
|
|
47
|
+
function buildCapabilityMatrix(tools, requiredTools) {
|
|
48
|
+
const sorted = [...tools].sort((left, right) => left.id.localeCompare(right.id));
|
|
49
|
+
const counts = { ...EMPTY_COUNTS };
|
|
50
|
+
for (const tool of sorted) {
|
|
51
|
+
counts[tool.state] += 1;
|
|
52
|
+
}
|
|
53
|
+
const gaps = sorted.filter(isCoverageGap).map((tool) => tool.id);
|
|
54
|
+
const required = new Set(requiredTools);
|
|
55
|
+
return {
|
|
56
|
+
tools: sorted,
|
|
57
|
+
counts,
|
|
58
|
+
gaps,
|
|
59
|
+
requiredGaps: gaps.filter((id) => required.has(id)),
|
|
60
|
+
fullCoverage: sorted.every((tool) => !isCoverageGap(tool))
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const STATE_LABELS = {
|
|
64
|
+
completed: "completed",
|
|
65
|
+
partial: "partial",
|
|
66
|
+
timed_out: "timed out",
|
|
67
|
+
failed: "failed",
|
|
68
|
+
not_installed: "not installed",
|
|
69
|
+
runtime_incompatible: "runtime mismatch",
|
|
70
|
+
deferred: "deferred",
|
|
71
|
+
disabled: "disabled",
|
|
72
|
+
not_applicable: "not applicable",
|
|
73
|
+
not_selected: "not selected"
|
|
74
|
+
};
|
|
75
|
+
function capabilityStateLabel(state) {
|
|
76
|
+
return STATE_LABELS[state];
|
|
77
|
+
}
|
|
78
|
+
function formatDuration(durationMs) {
|
|
79
|
+
if (durationMs === undefined) {
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
82
|
+
return durationMs >= 1000 ? `${(durationMs / 1000).toFixed(1)}s` : `${durationMs}ms`;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Renders the matrix as aligned text. Every row states what happened, why, and
|
|
86
|
+
* what to do — including the findings-reported vs findings-surfaced split, so a
|
|
87
|
+
* tool that ran but had everything filtered out cannot look like a tool that
|
|
88
|
+
* found nothing.
|
|
89
|
+
*/
|
|
90
|
+
function renderCapabilityMatrixLines(matrix) {
|
|
91
|
+
if (matrix.tools.length === 0) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
const rows = matrix.tools.map((tool) => ({
|
|
95
|
+
id: tool.id,
|
|
96
|
+
state: capabilityStateLabel(tool.state),
|
|
97
|
+
findings: tool.findingsReported === tool.findingsSurfaced
|
|
98
|
+
? String(tool.findingsSurfaced)
|
|
99
|
+
: `${tool.findingsSurfaced} of ${tool.findingsReported}`,
|
|
100
|
+
time: formatDuration(tool.durationMs),
|
|
101
|
+
detail: tool.reason
|
|
102
|
+
}));
|
|
103
|
+
const idWidth = Math.max(4, ...rows.map((row) => row.id.length));
|
|
104
|
+
const stateWidth = Math.max(6, ...rows.map((row) => row.state.length));
|
|
105
|
+
const findingsWidth = Math.max(8, ...rows.map((row) => row.findings.length));
|
|
106
|
+
const timeWidth = Math.max(4, ...rows.map((row) => row.time.length));
|
|
107
|
+
const lines = [
|
|
108
|
+
`${"TOOL".padEnd(idWidth)} ${"STATE".padEnd(stateWidth)} ${"FINDINGS".padEnd(findingsWidth)} ${"TIME".padEnd(timeWidth)} DETAIL`
|
|
109
|
+
];
|
|
110
|
+
for (const row of rows) {
|
|
111
|
+
lines.push(`${row.id.padEnd(idWidth)} ${row.state.padEnd(stateWidth)} ${row.findings.padEnd(findingsWidth)} ${row.time.padEnd(timeWidth)} ${row.detail}`);
|
|
112
|
+
}
|
|
113
|
+
const remediations = matrix.tools.filter((tool) => tool.remediation && isCoverageGap(tool));
|
|
114
|
+
if (remediations.length > 0) {
|
|
115
|
+
lines.push("");
|
|
116
|
+
lines.push("TO RESTORE COVERAGE");
|
|
117
|
+
for (const tool of remediations) {
|
|
118
|
+
lines.push(`- ${tool.id}: ${tool.remediation}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return lines;
|
|
122
|
+
}
|
package/dist/core/config.d.ts
CHANGED
|
@@ -22,6 +22,42 @@ export type VibeDoctorConfig = {
|
|
|
22
22
|
toolTimeouts: Record<string, number>;
|
|
23
23
|
requiredTools: string[];
|
|
24
24
|
failOnIncompleteScan: boolean;
|
|
25
|
+
/** Wall-clock ceiling for the whole scan. 0 disables the ceiling. */
|
|
26
|
+
totalBudgetSeconds: number;
|
|
27
|
+
/**
|
|
28
|
+
* What to do when a tool exhausts its budget. `scoped_retry` reruns it over
|
|
29
|
+
* changed files only and reports the partial coverage, which beats losing
|
|
30
|
+
* the check entirely on a repository the tool cannot finish.
|
|
31
|
+
*/
|
|
32
|
+
onTimeout: "scoped_retry" | "skip" | "fail";
|
|
33
|
+
/** Budget for the narrowed retry. */
|
|
34
|
+
scopedRetryTimeoutSeconds: number;
|
|
35
|
+
/** Tools deliberately not run, with the report saying so rather than implying they passed. */
|
|
36
|
+
deferredTools: string[];
|
|
37
|
+
/** Verify each tool resolves and runs before trusting its absence of findings. */
|
|
38
|
+
verifyToolsBeforeScan: boolean;
|
|
39
|
+
};
|
|
40
|
+
relevance: {
|
|
41
|
+
enabled: boolean;
|
|
42
|
+
minConfidence: "low" | "medium" | "high";
|
|
43
|
+
maxFindingsPerTool: number;
|
|
44
|
+
maxFindingsTotal: number;
|
|
45
|
+
syntheticFilePolicy: "keep" | "downgrade" | "drop";
|
|
46
|
+
validateSecrets: boolean;
|
|
47
|
+
perTool: Record<string, {
|
|
48
|
+
minConfidence?: "low" | "medium" | "high";
|
|
49
|
+
minEvidenceGrade?: "unproven" | "heuristic" | "observed" | "verified";
|
|
50
|
+
maxFindings?: number;
|
|
51
|
+
requireCorroboration?: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
/** Extra globs that classify files as tests, fixtures, generated, and so on. */
|
|
54
|
+
fileRoles: Partial<Record<"source" | "test" | "fixture" | "generated" | "vendor" | "config" | "docs", string[]>>;
|
|
55
|
+
};
|
|
56
|
+
suppressions: {
|
|
57
|
+
enabled: boolean;
|
|
58
|
+
file: string;
|
|
59
|
+
/** Reject acknowledgements with no expiry date. */
|
|
60
|
+
requireExpiry: boolean;
|
|
25
61
|
};
|
|
26
62
|
checks: {
|
|
27
63
|
security: {
|
|
@@ -84,6 +120,27 @@ export type VibeDoctorConfig = {
|
|
|
84
120
|
enabled: boolean;
|
|
85
121
|
};
|
|
86
122
|
};
|
|
123
|
+
dpdp: {
|
|
124
|
+
enabled: boolean;
|
|
125
|
+
include: string[];
|
|
126
|
+
exclude: string[];
|
|
127
|
+
minConfidenceToReport: "low" | "medium" | "high";
|
|
128
|
+
maskExamples: boolean;
|
|
129
|
+
usePresidio: boolean;
|
|
130
|
+
useSemgrep: boolean;
|
|
131
|
+
legalSourceVersion: string;
|
|
132
|
+
contextFile: string;
|
|
133
|
+
evidenceFile: string;
|
|
134
|
+
failOnSeverity: Array<"info" | "low" | "medium" | "high" | "critical">;
|
|
135
|
+
failOnViolatedControls: string[];
|
|
136
|
+
failOnlyOnNew: boolean;
|
|
137
|
+
organization: {
|
|
138
|
+
processesPersonalData: "true" | "false" | "unknown";
|
|
139
|
+
isSignificantDataFiduciary: "true" | "false" | "unknown";
|
|
140
|
+
processesChildrenData: "true" | "false" | "unknown";
|
|
141
|
+
hasCrossBorderTransfer: "true" | "false" | "unknown";
|
|
142
|
+
};
|
|
143
|
+
};
|
|
87
144
|
};
|
|
88
145
|
output: {
|
|
89
146
|
terminal: boolean;
|
package/dist/core/config.js
CHANGED
|
@@ -10,6 +10,8 @@ const node_fs_1 = require("node:fs");
|
|
|
10
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
11
11
|
const yaml_1 = __importDefault(require("yaml"));
|
|
12
12
|
const paths_1 = require("./paths");
|
|
13
|
+
const relevance_1 = require("./relevance");
|
|
14
|
+
const suppressions_1 = require("./suppressions");
|
|
13
15
|
exports.defaultConfig = {
|
|
14
16
|
version: 1,
|
|
15
17
|
profile: "startup",
|
|
@@ -55,7 +57,27 @@ exports.defaultConfig = {
|
|
|
55
57
|
semgrep: 300
|
|
56
58
|
},
|
|
57
59
|
requiredTools: [],
|
|
58
|
-
failOnIncompleteScan: false
|
|
60
|
+
failOnIncompleteScan: false,
|
|
61
|
+
totalBudgetSeconds: 0,
|
|
62
|
+
onTimeout: "scoped_retry",
|
|
63
|
+
scopedRetryTimeoutSeconds: 60,
|
|
64
|
+
deferredTools: [],
|
|
65
|
+
verifyToolsBeforeScan: true
|
|
66
|
+
},
|
|
67
|
+
relevance: {
|
|
68
|
+
enabled: true,
|
|
69
|
+
minConfidence: relevance_1.defaultRelevanceConfig.minConfidence,
|
|
70
|
+
maxFindingsPerTool: relevance_1.defaultRelevanceConfig.maxFindingsPerTool,
|
|
71
|
+
maxFindingsTotal: relevance_1.defaultRelevanceConfig.maxFindingsTotal,
|
|
72
|
+
syntheticFilePolicy: relevance_1.defaultRelevanceConfig.syntheticFilePolicy,
|
|
73
|
+
validateSecrets: relevance_1.defaultRelevanceConfig.validateSecrets,
|
|
74
|
+
perTool: relevance_1.defaultRelevanceConfig.perTool,
|
|
75
|
+
fileRoles: {}
|
|
76
|
+
},
|
|
77
|
+
suppressions: {
|
|
78
|
+
enabled: true,
|
|
79
|
+
file: suppressions_1.SUPPRESSIONS_FILE,
|
|
80
|
+
requireExpiry: false
|
|
59
81
|
},
|
|
60
82
|
checks: {
|
|
61
83
|
security: {
|
|
@@ -115,7 +137,30 @@ exports.defaultConfig = {
|
|
|
115
137
|
includeRawValues: false
|
|
116
138
|
},
|
|
117
139
|
presidio: {
|
|
118
|
-
|
|
140
|
+
// Opt-out: try Presidio on normal privacy scans; skip gracefully if not installed.
|
|
141
|
+
enabled: true
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
dpdp: {
|
|
145
|
+
enabled: true,
|
|
146
|
+
include: [],
|
|
147
|
+
exclude: [],
|
|
148
|
+
minConfidenceToReport: "medium",
|
|
149
|
+
maskExamples: true,
|
|
150
|
+
// Opt-out: DPDP tries these by default so agents get full coverage without extra flags.
|
|
151
|
+
usePresidio: true,
|
|
152
|
+
useSemgrep: true,
|
|
153
|
+
legalSourceVersion: "2025.2-final-corrigendum",
|
|
154
|
+
contextFile: ".vibedoctor/dpdp/context.yml",
|
|
155
|
+
evidenceFile: ".vibedoctor/dpdp/evidence.yml",
|
|
156
|
+
failOnSeverity: [],
|
|
157
|
+
failOnViolatedControls: [],
|
|
158
|
+
failOnlyOnNew: true,
|
|
159
|
+
organization: {
|
|
160
|
+
processesPersonalData: "unknown",
|
|
161
|
+
isSignificantDataFiduciary: "unknown",
|
|
162
|
+
processesChildrenData: "unknown",
|
|
163
|
+
hasCrossBorderTransfer: "unknown"
|
|
119
164
|
}
|
|
120
165
|
}
|
|
121
166
|
},
|
|
@@ -131,6 +176,15 @@ const CONFIG_FILES = ["vibedoctor.yml", "vibedoctor.yaml", "vibedoctor.json"];
|
|
|
131
176
|
function isRecord(value) {
|
|
132
177
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
133
178
|
}
|
|
179
|
+
function normalizeStringArray(value, fallback) {
|
|
180
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [...fallback];
|
|
181
|
+
}
|
|
182
|
+
function normalizeSeverityArray(value, fallback) {
|
|
183
|
+
const allowed = new Set(["info", "low", "medium", "high", "critical"]);
|
|
184
|
+
return Array.isArray(value)
|
|
185
|
+
? value.filter((item) => typeof item === "string" && allowed.has(item))
|
|
186
|
+
: [...fallback];
|
|
187
|
+
}
|
|
134
188
|
function deepMerge(base, override) {
|
|
135
189
|
if (override === undefined) {
|
|
136
190
|
return base;
|
|
@@ -157,9 +211,66 @@ async function findConfigFile(root) {
|
|
|
157
211
|
}
|
|
158
212
|
return undefined;
|
|
159
213
|
}
|
|
214
|
+
function normalizeTimeoutPolicy(value, fallback) {
|
|
215
|
+
return value === "scoped_retry" || value === "skip" || value === "fail" ? value : fallback;
|
|
216
|
+
}
|
|
217
|
+
function normalizeConfidence(value, fallback) {
|
|
218
|
+
return value === "low" || value === "medium" || value === "high" ? value : fallback;
|
|
219
|
+
}
|
|
220
|
+
function normalizeRelevance(raw) {
|
|
221
|
+
const defaults = exports.defaultConfig.relevance;
|
|
222
|
+
const rawPerTool = (raw.perTool ?? raw.per_tool ?? {});
|
|
223
|
+
const rawFileRoles = (raw.fileRoles ?? raw.file_roles ?? {});
|
|
224
|
+
const policy = raw.syntheticFilePolicy ?? raw.synthetic_file_policy;
|
|
225
|
+
const perTool = { ...defaults.perTool };
|
|
226
|
+
for (const [tool, rawToolPolicy] of Object.entries(rawPerTool)) {
|
|
227
|
+
const existing = perTool[tool] ?? {};
|
|
228
|
+
const minConfidence = rawToolPolicy.minConfidence ?? rawToolPolicy.min_confidence;
|
|
229
|
+
const minEvidenceGrade = rawToolPolicy.minEvidenceGrade ?? rawToolPolicy.min_evidence_grade;
|
|
230
|
+
const maxFindings = rawToolPolicy.maxFindings ?? rawToolPolicy.max_findings;
|
|
231
|
+
const requireCorroboration = rawToolPolicy.requireCorroboration ?? rawToolPolicy.require_corroboration;
|
|
232
|
+
perTool[tool] = {
|
|
233
|
+
...existing,
|
|
234
|
+
...(minConfidence !== undefined ? { minConfidence: normalizeConfidence(minConfidence, "low") } : {}),
|
|
235
|
+
...(minEvidenceGrade === "unproven" ||
|
|
236
|
+
minEvidenceGrade === "heuristic" ||
|
|
237
|
+
minEvidenceGrade === "observed" ||
|
|
238
|
+
minEvidenceGrade === "verified"
|
|
239
|
+
? { minEvidenceGrade }
|
|
240
|
+
: {}),
|
|
241
|
+
...(typeof maxFindings === "number" ? { maxFindings } : {}),
|
|
242
|
+
...(typeof requireCorroboration === "boolean" ? { requireCorroboration } : {})
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
const fileRoles = {};
|
|
246
|
+
for (const role of ["source", "test", "fixture", "generated", "vendor", "config", "docs"]) {
|
|
247
|
+
const patterns = normalizeStringArray(rawFileRoles[role], []);
|
|
248
|
+
if (patterns.length > 0) {
|
|
249
|
+
fileRoles[role] = patterns;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
enabled: raw.enabled ?? defaults.enabled,
|
|
254
|
+
minConfidence: normalizeConfidence(raw.minConfidence ?? raw.min_confidence, defaults.minConfidence),
|
|
255
|
+
maxFindingsPerTool: raw.maxFindingsPerTool ??
|
|
256
|
+
raw.max_findings_per_tool ??
|
|
257
|
+
defaults.maxFindingsPerTool,
|
|
258
|
+
maxFindingsTotal: raw.maxFindingsTotal ??
|
|
259
|
+
raw.max_findings_total ??
|
|
260
|
+
defaults.maxFindingsTotal,
|
|
261
|
+
syntheticFilePolicy: policy === "keep" || policy === "downgrade" || policy === "drop" ? policy : defaults.syntheticFilePolicy,
|
|
262
|
+
validateSecrets: raw.validateSecrets ??
|
|
263
|
+
raw.validate_secrets ??
|
|
264
|
+
defaults.validateSecrets,
|
|
265
|
+
perTool,
|
|
266
|
+
fileRoles
|
|
267
|
+
};
|
|
268
|
+
}
|
|
160
269
|
function normalizeRawConfig(raw) {
|
|
161
|
-
const { baseline: _baseline, checks: _checks, output: _output, runtime: _runtime, ...rest } = raw;
|
|
270
|
+
const { baseline: _baseline, checks: _checks, output: _output, runtime: _runtime, relevance: _relevance, suppressions: _suppressions, ...rest } = raw;
|
|
162
271
|
const rawChecks = raw.checks;
|
|
272
|
+
const rawRelevance = raw.relevance;
|
|
273
|
+
const rawSuppressions = raw.suppressions;
|
|
163
274
|
const rawBaseline = raw.baseline;
|
|
164
275
|
const rawOutput = raw.output;
|
|
165
276
|
const rawRuntime = raw.runtime;
|
|
@@ -173,6 +284,8 @@ function normalizeRawConfig(raw) {
|
|
|
173
284
|
const rawPrivacy = rawChecks?.privacy;
|
|
174
285
|
const rawPrivacyAi = (rawPrivacy?.ai ?? {});
|
|
175
286
|
const rawPresidio = (rawPrivacy?.presidio ?? {});
|
|
287
|
+
const rawDpdp = rawChecks?.dpdp;
|
|
288
|
+
const rawDpdpOrg = (rawDpdp?.organization ?? rawDpdp?.organisation ?? {});
|
|
176
289
|
return {
|
|
177
290
|
...rest,
|
|
178
291
|
...(rawRuntime
|
|
@@ -189,7 +302,30 @@ function normalizeRawConfig(raw) {
|
|
|
189
302
|
exports.defaultConfig.runtime.requiredTools,
|
|
190
303
|
failOnIncompleteScan: rawRuntime.failOnIncompleteScan ??
|
|
191
304
|
rawRuntime.fail_on_incomplete_scan ??
|
|
192
|
-
exports.defaultConfig.runtime.failOnIncompleteScan
|
|
305
|
+
exports.defaultConfig.runtime.failOnIncompleteScan,
|
|
306
|
+
totalBudgetSeconds: rawRuntime.totalBudgetSeconds ??
|
|
307
|
+
rawRuntime.total_budget_seconds ??
|
|
308
|
+
exports.defaultConfig.runtime.totalBudgetSeconds,
|
|
309
|
+
onTimeout: normalizeTimeoutPolicy(rawRuntime.onTimeout ?? rawRuntime.on_timeout, exports.defaultConfig.runtime.onTimeout),
|
|
310
|
+
scopedRetryTimeoutSeconds: rawRuntime.scopedRetryTimeoutSeconds ??
|
|
311
|
+
rawRuntime.scoped_retry_timeout_seconds ??
|
|
312
|
+
exports.defaultConfig.runtime.scopedRetryTimeoutSeconds,
|
|
313
|
+
deferredTools: normalizeStringArray(rawRuntime.deferredTools ?? rawRuntime.deferred_tools, exports.defaultConfig.runtime.deferredTools),
|
|
314
|
+
verifyToolsBeforeScan: rawRuntime.verifyToolsBeforeScan ??
|
|
315
|
+
rawRuntime.verify_tools_before_scan ??
|
|
316
|
+
exports.defaultConfig.runtime.verifyToolsBeforeScan
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
: {}),
|
|
320
|
+
...(rawRelevance ? { relevance: normalizeRelevance(rawRelevance) } : {}),
|
|
321
|
+
...(rawSuppressions
|
|
322
|
+
? {
|
|
323
|
+
suppressions: {
|
|
324
|
+
enabled: rawSuppressions.enabled ?? exports.defaultConfig.suppressions.enabled,
|
|
325
|
+
file: rawSuppressions.file ?? exports.defaultConfig.suppressions.file,
|
|
326
|
+
requireExpiry: rawSuppressions.requireExpiry ??
|
|
327
|
+
rawSuppressions.require_expiry ??
|
|
328
|
+
exports.defaultConfig.suppressions.requireExpiry
|
|
193
329
|
}
|
|
194
330
|
}
|
|
195
331
|
: {}),
|
|
@@ -355,19 +491,70 @@ function normalizeRawConfig(raw) {
|
|
|
355
491
|
enabled: rawPresidio.enabled ?? exports.defaultConfig.checks.privacy.presidio.enabled
|
|
356
492
|
}
|
|
357
493
|
}
|
|
358
|
-
: exports.defaultConfig.checks.privacy
|
|
494
|
+
: exports.defaultConfig.checks.privacy,
|
|
495
|
+
dpdp: rawDpdp
|
|
496
|
+
? {
|
|
497
|
+
enabled: rawDpdp.enabled ?? exports.defaultConfig.checks.dpdp.enabled,
|
|
498
|
+
include: normalizeStringArray(rawDpdp.include, exports.defaultConfig.checks.dpdp.include),
|
|
499
|
+
exclude: normalizeStringArray(rawDpdp.exclude, exports.defaultConfig.checks.dpdp.exclude),
|
|
500
|
+
minConfidenceToReport: rawDpdp.minConfidenceToReport ??
|
|
501
|
+
rawDpdp.min_confidence_to_report ??
|
|
502
|
+
exports.defaultConfig.checks.dpdp.minConfidenceToReport,
|
|
503
|
+
maskExamples: rawDpdp.maskExamples ??
|
|
504
|
+
rawDpdp.mask_examples ??
|
|
505
|
+
exports.defaultConfig.checks.dpdp.maskExamples,
|
|
506
|
+
usePresidio: rawDpdp.usePresidio ??
|
|
507
|
+
rawDpdp.use_presidio ??
|
|
508
|
+
exports.defaultConfig.checks.dpdp.usePresidio,
|
|
509
|
+
useSemgrep: rawDpdp.useSemgrep ??
|
|
510
|
+
rawDpdp.use_semgrep ??
|
|
511
|
+
exports.defaultConfig.checks.dpdp.useSemgrep,
|
|
512
|
+
legalSourceVersion: rawDpdp.legalSourceVersion ??
|
|
513
|
+
rawDpdp.legal_source_version ??
|
|
514
|
+
exports.defaultConfig.checks.dpdp.legalSourceVersion,
|
|
515
|
+
contextFile: rawDpdp.contextFile ??
|
|
516
|
+
rawDpdp.context_file ??
|
|
517
|
+
exports.defaultConfig.checks.dpdp.contextFile,
|
|
518
|
+
evidenceFile: rawDpdp.evidenceFile ??
|
|
519
|
+
rawDpdp.evidence_file ??
|
|
520
|
+
exports.defaultConfig.checks.dpdp.evidenceFile,
|
|
521
|
+
failOnSeverity: normalizeSeverityArray(rawDpdp.failOnSeverity ?? rawDpdp.fail_on_severity, exports.defaultConfig.checks.dpdp.failOnSeverity),
|
|
522
|
+
failOnViolatedControls: normalizeStringArray(rawDpdp.failOnViolatedControls ?? rawDpdp.fail_on_violated_controls, exports.defaultConfig.checks.dpdp.failOnViolatedControls),
|
|
523
|
+
failOnlyOnNew: rawDpdp.failOnlyOnNew ??
|
|
524
|
+
rawDpdp.fail_only_on_new ??
|
|
525
|
+
exports.defaultConfig.checks.dpdp.failOnlyOnNew,
|
|
526
|
+
organization: {
|
|
527
|
+
processesPersonalData: normalizeTriState(rawDpdpOrg.processesPersonalData ?? rawDpdpOrg.processes_personal_data, exports.defaultConfig.checks.dpdp.organization.processesPersonalData),
|
|
528
|
+
isSignificantDataFiduciary: normalizeTriState(rawDpdpOrg.isSignificantDataFiduciary ?? rawDpdpOrg.is_significant_data_fiduciary, exports.defaultConfig.checks.dpdp.organization.isSignificantDataFiduciary),
|
|
529
|
+
processesChildrenData: normalizeTriState(rawDpdpOrg.processesChildrenData ?? rawDpdpOrg.processes_children_data, exports.defaultConfig.checks.dpdp.organization.processesChildrenData),
|
|
530
|
+
hasCrossBorderTransfer: normalizeTriState(rawDpdpOrg.hasCrossBorderTransfer ?? rawDpdpOrg.has_cross_border_transfer, exports.defaultConfig.checks.dpdp.organization.hasCrossBorderTransfer)
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
: exports.defaultConfig.checks.dpdp
|
|
359
534
|
}
|
|
360
535
|
}
|
|
361
536
|
: {})
|
|
362
537
|
};
|
|
363
538
|
}
|
|
539
|
+
function normalizeTriState(value, fallback) {
|
|
540
|
+
if (value === true || value === "true" || value === "yes") {
|
|
541
|
+
return "true";
|
|
542
|
+
}
|
|
543
|
+
if (value === false || value === "false" || value === "no") {
|
|
544
|
+
return "false";
|
|
545
|
+
}
|
|
546
|
+
if (value === "unknown" || value === undefined || value === null) {
|
|
547
|
+
return value === "unknown" ? "unknown" : fallback;
|
|
548
|
+
}
|
|
549
|
+
return fallback;
|
|
550
|
+
}
|
|
364
551
|
async function loadConfig(root) {
|
|
365
552
|
const configPath = await findConfigFile(root);
|
|
366
553
|
if (!configPath) {
|
|
367
|
-
return { config: exports.defaultConfig };
|
|
554
|
+
return { config: structuredClone(exports.defaultConfig) };
|
|
368
555
|
}
|
|
369
556
|
const content = await node_fs_1.promises.readFile(configPath, "utf8");
|
|
370
557
|
const parsed = configPath.endsWith(".json") ? JSON.parse(content) : yaml_1.default.parse(content);
|
|
371
|
-
const config = deepMerge(exports.defaultConfig, normalizeRawConfig(parsed));
|
|
558
|
+
const config = deepMerge(structuredClone(exports.defaultConfig), normalizeRawConfig(parsed));
|
|
372
559
|
return { config, configPath };
|
|
373
560
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decides whether a string is plausibly a credential.
|
|
3
|
+
*
|
|
4
|
+
* Secret scanners match on assignment shape, so any identifier whose name ends
|
|
5
|
+
* in `key`, `token`, or `secret` can be reported as a critical leak — including
|
|
6
|
+
* ordinary map keys like `format_key` or `thread_key`. Reporting those at
|
|
7
|
+
* critical severity trains users to ignore the secrets category entirely, which
|
|
8
|
+
* costs more than the occasional missed finding. This evaluates the matched text
|
|
9
|
+
* itself: a real credential is high-entropy and structureless, while an
|
|
10
|
+
* identifier is short, lowercase, and made of dictionary-shaped words.
|
|
11
|
+
*/
|
|
12
|
+
export type CredentialAssessment = {
|
|
13
|
+
/** Best guess at what the matched text is. */
|
|
14
|
+
verdict: "credential" | "identifier" | "placeholder" | "unknown";
|
|
15
|
+
/** Shannon entropy in bits per character. */
|
|
16
|
+
entropy: number;
|
|
17
|
+
/** Why the verdict was reached, for the report. */
|
|
18
|
+
reason: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function shannonEntropy(value: string): number;
|
|
21
|
+
export declare function assessCredential(value: string | undefined): CredentialAssessment;
|
|
22
|
+
/** Masks a value for reporting, keeping enough to recognise it. */
|
|
23
|
+
export declare function maskValue(value: string | undefined): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Pulls the candidate secret out of a source line. Scanners often redact their
|
|
26
|
+
* own output, so the line the finding points at is the only place left to look.
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractAssignedValue(line: string | undefined): string | undefined;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Decides whether a string is plausibly a credential.
|
|
4
|
+
*
|
|
5
|
+
* Secret scanners match on assignment shape, so any identifier whose name ends
|
|
6
|
+
* in `key`, `token`, or `secret` can be reported as a critical leak — including
|
|
7
|
+
* ordinary map keys like `format_key` or `thread_key`. Reporting those at
|
|
8
|
+
* critical severity trains users to ignore the secrets category entirely, which
|
|
9
|
+
* costs more than the occasional missed finding. This evaluates the matched text
|
|
10
|
+
* itself: a real credential is high-entropy and structureless, while an
|
|
11
|
+
* identifier is short, lowercase, and made of dictionary-shaped words.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.shannonEntropy = shannonEntropy;
|
|
15
|
+
exports.assessCredential = assessCredential;
|
|
16
|
+
exports.maskValue = maskValue;
|
|
17
|
+
exports.extractAssignedValue = extractAssignedValue;
|
|
18
|
+
/** Prefixes that are self-identifying credentials regardless of entropy. */
|
|
19
|
+
const KNOWN_CREDENTIAL_PREFIXES = [
|
|
20
|
+
"sk-",
|
|
21
|
+
"pk-",
|
|
22
|
+
"rk_",
|
|
23
|
+
"ghp_",
|
|
24
|
+
"gho_",
|
|
25
|
+
"ghu_",
|
|
26
|
+
"ghs_",
|
|
27
|
+
"ghr_",
|
|
28
|
+
"github_pat_",
|
|
29
|
+
"glpat-",
|
|
30
|
+
"xox",
|
|
31
|
+
"AKIA",
|
|
32
|
+
"ASIA",
|
|
33
|
+
"AIza",
|
|
34
|
+
"ya29.",
|
|
35
|
+
"SG.",
|
|
36
|
+
"dop_v1_",
|
|
37
|
+
"shpat_",
|
|
38
|
+
"npm_",
|
|
39
|
+
"hf_",
|
|
40
|
+
"-----BEGIN"
|
|
41
|
+
];
|
|
42
|
+
/** Values that exist to be replaced, not protected. */
|
|
43
|
+
const PLACEHOLDER_PATTERNS = [
|
|
44
|
+
/^(?:x{3,}|\*{3,}|\.{3,}|-{3,})$/i,
|
|
45
|
+
/^(?:your|my|the)[-_ ]?(?:api[-_ ]?)?(?:key|token|secret|password)$/i,
|
|
46
|
+
/^(?:changeme|change[-_ ]me|replace[-_ ]me|todo|tbd|none|null|undefined|empty|example|sample|dummy|test|fake|foo|bar|baz)$/i,
|
|
47
|
+
/^(?:REDACTED|MASKED|HIDDEN|SECRET|PASSWORD|API[-_]?KEY)$/i,
|
|
48
|
+
/^\$\{?[A-Z0-9_]+\}?$/,
|
|
49
|
+
/^<[^>]+>$/,
|
|
50
|
+
/^\{\{.*\}\}$/,
|
|
51
|
+
/^process\.env\./,
|
|
52
|
+
/^os\.(?:environ|getenv)/
|
|
53
|
+
];
|
|
54
|
+
/** Shapes a programmer writes deliberately: identifiers, paths, dotted names. */
|
|
55
|
+
const IDENTIFIER_PATTERN = /^[a-z][a-z0-9]*(?:[_-][a-z0-9]+)*$/;
|
|
56
|
+
const CAMEL_CASE_PATTERN = /^[a-z][a-zA-Z0-9]*$/;
|
|
57
|
+
const DOTTED_PATH_PATTERN = /^[a-zA-Z_][\w-]*(?:[./][\w-]+)+$/;
|
|
58
|
+
function shannonEntropy(value) {
|
|
59
|
+
if (value.length === 0) {
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
const counts = new Map();
|
|
63
|
+
for (const character of value) {
|
|
64
|
+
counts.set(character, (counts.get(character) ?? 0) + 1);
|
|
65
|
+
}
|
|
66
|
+
let entropy = 0;
|
|
67
|
+
for (const count of counts.values()) {
|
|
68
|
+
const probability = count / value.length;
|
|
69
|
+
entropy -= probability * Math.log2(probability);
|
|
70
|
+
}
|
|
71
|
+
return entropy;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Splits on case and separator boundaries. An identifier made entirely of short
|
|
75
|
+
* word-like segments is a name; a credential is not decomposable that way.
|
|
76
|
+
*/
|
|
77
|
+
function wordSegments(value) {
|
|
78
|
+
return value
|
|
79
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
80
|
+
.split(/[\s_\-./]+/)
|
|
81
|
+
.filter(Boolean);
|
|
82
|
+
}
|
|
83
|
+
function looksLikeWords(value) {
|
|
84
|
+
const segments = wordSegments(value);
|
|
85
|
+
if (segments.length === 0) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
// Every segment alphabetic and of pronounceable length.
|
|
89
|
+
return segments.every((segment) => /^[A-Za-z]{2,14}$/.test(segment));
|
|
90
|
+
}
|
|
91
|
+
const MIN_CREDENTIAL_LENGTH = 16;
|
|
92
|
+
const CREDENTIAL_ENTROPY_THRESHOLD = 3.2;
|
|
93
|
+
function assessCredential(value) {
|
|
94
|
+
const trimmed = value?.trim().replace(/^["'`]|["'`]$/g, "") ?? "";
|
|
95
|
+
if (!trimmed) {
|
|
96
|
+
return { verdict: "unknown", entropy: 0, reason: "No matched value was available to evaluate." };
|
|
97
|
+
}
|
|
98
|
+
if (KNOWN_CREDENTIAL_PREFIXES.some((prefix) => trimmed.startsWith(prefix))) {
|
|
99
|
+
return {
|
|
100
|
+
verdict: "credential",
|
|
101
|
+
entropy: shannonEntropy(trimmed),
|
|
102
|
+
reason: "Value carries a recognised credential prefix."
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
if (PLACEHOLDER_PATTERNS.some((pattern) => pattern.test(trimmed))) {
|
|
106
|
+
return {
|
|
107
|
+
verdict: "placeholder",
|
|
108
|
+
entropy: shannonEntropy(trimmed),
|
|
109
|
+
reason: "Value is a placeholder or an environment-variable reference, not a literal credential."
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const entropy = shannonEntropy(trimmed);
|
|
113
|
+
if (trimmed.length < MIN_CREDENTIAL_LENGTH && (IDENTIFIER_PATTERN.test(trimmed) || CAMEL_CASE_PATTERN.test(trimmed))) {
|
|
114
|
+
return {
|
|
115
|
+
verdict: "identifier",
|
|
116
|
+
entropy,
|
|
117
|
+
reason: `Value is a ${trimmed.length}-character identifier ("${trimmed}"), too short and too structured to be a credential.`
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (DOTTED_PATH_PATTERN.test(trimmed) && entropy < CREDENTIAL_ENTROPY_THRESHOLD) {
|
|
121
|
+
return {
|
|
122
|
+
verdict: "identifier",
|
|
123
|
+
entropy,
|
|
124
|
+
reason: "Value is a dotted or path-like name rather than an opaque token."
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (looksLikeWords(trimmed) && entropy < CREDENTIAL_ENTROPY_THRESHOLD) {
|
|
128
|
+
return {
|
|
129
|
+
verdict: "identifier",
|
|
130
|
+
entropy,
|
|
131
|
+
reason: `Value decomposes into dictionary-shaped words (entropy ${entropy.toFixed(2)} bits/char).`
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (entropy < CREDENTIAL_ENTROPY_THRESHOLD && trimmed.length < 32) {
|
|
135
|
+
return {
|
|
136
|
+
verdict: "identifier",
|
|
137
|
+
entropy,
|
|
138
|
+
reason: `Entropy ${entropy.toFixed(2)} bits/char over ${trimmed.length} characters is below what a generated credential shows.`
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
verdict: "credential",
|
|
143
|
+
entropy,
|
|
144
|
+
reason: `Entropy ${entropy.toFixed(2)} bits/char over ${trimmed.length} characters is consistent with a generated credential.`
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** Masks a value for reporting, keeping enough to recognise it. */
|
|
148
|
+
function maskValue(value) {
|
|
149
|
+
if (!value) {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
const trimmed = value.trim();
|
|
153
|
+
if (trimmed.length <= 8) {
|
|
154
|
+
return `${trimmed.slice(0, 2)}${"*".repeat(Math.max(0, trimmed.length - 2))}`;
|
|
155
|
+
}
|
|
156
|
+
return `${trimmed.slice(0, 4)}${"*".repeat(6)}${trimmed.slice(-2)}`;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Pulls the candidate secret out of a source line. Scanners often redact their
|
|
160
|
+
* own output, so the line the finding points at is the only place left to look.
|
|
161
|
+
*/
|
|
162
|
+
function extractAssignedValue(line) {
|
|
163
|
+
if (!line) {
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
// Quoted literal on the right of an assignment, mapping, or argument.
|
|
167
|
+
const quoted = /(?::|=|=>|,)\s*(?:r|b|f|u)?(["'`])((?:(?!\1).){3,})\1/.exec(line);
|
|
168
|
+
if (quoted) {
|
|
169
|
+
return quoted[2];
|
|
170
|
+
}
|
|
171
|
+
// Bare value after an assignment (env files, YAML, INI).
|
|
172
|
+
const bare = /^[\s#-]*[A-Za-z_][\w.-]*\s*[:=]\s*([^\s"'#]{3,})\s*$/.exec(line);
|
|
173
|
+
if (bare) {
|
|
174
|
+
return bare[1];
|
|
175
|
+
}
|
|
176
|
+
// Any long quoted literal anywhere on the line.
|
|
177
|
+
const anyQuoted = /(["'`])((?:(?!\1).){8,})\1/.exec(line);
|
|
178
|
+
return anyQuoted?.[2];
|
|
179
|
+
}
|