driftdetect-core 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/constants/analysis/categorizer.d.ts +27 -0
- package/dist/constants/analysis/categorizer.d.ts.map +1 -0
- package/dist/constants/analysis/categorizer.js +364 -0
- package/dist/constants/analysis/categorizer.js.map +1 -0
- package/dist/constants/analysis/consistency-analyzer.d.ts +77 -0
- package/dist/constants/analysis/consistency-analyzer.d.ts.map +1 -0
- package/dist/constants/analysis/consistency-analyzer.js +176 -0
- package/dist/constants/analysis/consistency-analyzer.js.map +1 -0
- package/dist/constants/analysis/dead-constant-detector.d.ts +79 -0
- package/dist/constants/analysis/dead-constant-detector.d.ts.map +1 -0
- package/dist/constants/analysis/dead-constant-detector.js +242 -0
- package/dist/constants/analysis/dead-constant-detector.js.map +1 -0
- package/dist/constants/analysis/magic-detector.d.ts +116 -0
- package/dist/constants/analysis/magic-detector.d.ts.map +1 -0
- package/dist/constants/analysis/magic-detector.js +425 -0
- package/dist/constants/analysis/magic-detector.js.map +1 -0
- package/dist/constants/analysis/reference-finder.d.ts +87 -0
- package/dist/constants/analysis/reference-finder.d.ts.map +1 -0
- package/dist/constants/analysis/reference-finder.js +269 -0
- package/dist/constants/analysis/reference-finder.js.map +1 -0
- package/dist/constants/analysis/security-scanner.d.ts +115 -0
- package/dist/constants/analysis/security-scanner.d.ts.map +1 -0
- package/dist/constants/analysis/security-scanner.js +429 -0
- package/dist/constants/analysis/security-scanner.js.map +1 -0
- package/dist/constants/extractors/base-extractor.d.ts +97 -0
- package/dist/constants/extractors/base-extractor.d.ts.map +1 -0
- package/dist/constants/extractors/base-extractor.js +285 -0
- package/dist/constants/extractors/base-extractor.js.map +1 -0
- package/dist/constants/extractors/regex/base-regex.d.ts +67 -0
- package/dist/constants/extractors/regex/base-regex.d.ts.map +1 -0
- package/dist/constants/extractors/regex/base-regex.js +209 -0
- package/dist/constants/extractors/regex/base-regex.js.map +1 -0
- package/dist/constants/extractors/regex/csharp-regex.d.ts +39 -0
- package/dist/constants/extractors/regex/csharp-regex.d.ts.map +1 -0
- package/dist/constants/extractors/regex/csharp-regex.js +316 -0
- package/dist/constants/extractors/regex/csharp-regex.js.map +1 -0
- package/dist/constants/extractors/regex/go-regex.d.ts +40 -0
- package/dist/constants/extractors/regex/go-regex.d.ts.map +1 -0
- package/dist/constants/extractors/regex/go-regex.js +297 -0
- package/dist/constants/extractors/regex/go-regex.js.map +1 -0
- package/dist/constants/extractors/regex/java-regex.d.ts +43 -0
- package/dist/constants/extractors/regex/java-regex.d.ts.map +1 -0
- package/dist/constants/extractors/regex/java-regex.js +276 -0
- package/dist/constants/extractors/regex/java-regex.js.map +1 -0
- package/dist/constants/extractors/regex/php-regex.d.ts +39 -0
- package/dist/constants/extractors/regex/php-regex.d.ts.map +1 -0
- package/dist/constants/extractors/regex/php-regex.js +270 -0
- package/dist/constants/extractors/regex/php-regex.js.map +1 -0
- package/dist/constants/extractors/regex/python-regex.d.ts +39 -0
- package/dist/constants/extractors/regex/python-regex.d.ts.map +1 -0
- package/dist/constants/extractors/regex/python-regex.js +287 -0
- package/dist/constants/extractors/regex/python-regex.js.map +1 -0
- package/dist/constants/extractors/regex/typescript-regex.d.ts +35 -0
- package/dist/constants/extractors/regex/typescript-regex.d.ts.map +1 -0
- package/dist/constants/extractors/regex/typescript-regex.js +313 -0
- package/dist/constants/extractors/regex/typescript-regex.js.map +1 -0
- package/dist/constants/index.d.ts +26 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +36 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/integration/callgraph-adapter.d.ts +167 -0
- package/dist/constants/integration/callgraph-adapter.d.ts.map +1 -0
- package/dist/constants/integration/callgraph-adapter.js +287 -0
- package/dist/constants/integration/callgraph-adapter.js.map +1 -0
- package/dist/constants/integration/index.d.ts +10 -0
- package/dist/constants/integration/index.d.ts.map +1 -0
- package/dist/constants/integration/index.js +13 -0
- package/dist/constants/integration/index.js.map +1 -0
- package/dist/constants/integration/pattern-adapter.d.ts +171 -0
- package/dist/constants/integration/pattern-adapter.d.ts.map +1 -0
- package/dist/constants/integration/pattern-adapter.js +331 -0
- package/dist/constants/integration/pattern-adapter.js.map +1 -0
- package/dist/constants/integration/scanner-adapter.d.ts +153 -0
- package/dist/constants/integration/scanner-adapter.d.ts.map +1 -0
- package/dist/constants/integration/scanner-adapter.js +337 -0
- package/dist/constants/integration/scanner-adapter.js.map +1 -0
- package/dist/constants/store/constant-store.d.ts +117 -0
- package/dist/constants/store/constant-store.d.ts.map +1 -0
- package/dist/constants/store/constant-store.js +367 -0
- package/dist/constants/store/constant-store.js.map +1 -0
- package/dist/constants/types.d.ts +423 -0
- package/dist/constants/types.d.ts.map +1 -0
- package/dist/constants/types.js +43 -0
- package/dist/constants/types.js.map +1 -0
- package/dist/environment/env-scanner.d.ts +53 -0
- package/dist/environment/env-scanner.d.ts.map +1 -0
- package/dist/environment/env-scanner.js +290 -0
- package/dist/environment/env-scanner.js.map +1 -0
- package/dist/environment/env-store.d.ts +70 -0
- package/dist/environment/env-store.d.ts.map +1 -0
- package/dist/environment/env-store.js +201 -0
- package/dist/environment/env-store.js.map +1 -0
- package/dist/environment/extractors/base-env-extractor.d.ts +56 -0
- package/dist/environment/extractors/base-env-extractor.d.ts.map +1 -0
- package/dist/environment/extractors/base-env-extractor.js +74 -0
- package/dist/environment/extractors/base-env-extractor.js.map +1 -0
- package/dist/environment/extractors/csharp-env-extractor.d.ts +49 -0
- package/dist/environment/extractors/csharp-env-extractor.d.ts.map +1 -0
- package/dist/environment/extractors/csharp-env-extractor.js +240 -0
- package/dist/environment/extractors/csharp-env-extractor.js.map +1 -0
- package/dist/environment/extractors/go-env-extractor.d.ts +53 -0
- package/dist/environment/extractors/go-env-extractor.d.ts.map +1 -0
- package/dist/environment/extractors/go-env-extractor.js +267 -0
- package/dist/environment/extractors/go-env-extractor.js.map +1 -0
- package/dist/environment/extractors/index.d.ts +13 -0
- package/dist/environment/extractors/index.d.ts.map +1 -0
- package/dist/environment/extractors/index.js +13 -0
- package/dist/environment/extractors/index.js.map +1 -0
- package/dist/environment/extractors/java-env-extractor.d.ts +58 -0
- package/dist/environment/extractors/java-env-extractor.d.ts.map +1 -0
- package/dist/environment/extractors/java-env-extractor.js +219 -0
- package/dist/environment/extractors/java-env-extractor.js.map +1 -0
- package/dist/environment/extractors/php-env-extractor.d.ts +58 -0
- package/dist/environment/extractors/php-env-extractor.d.ts.map +1 -0
- package/dist/environment/extractors/php-env-extractor.js +231 -0
- package/dist/environment/extractors/php-env-extractor.js.map +1 -0
- package/dist/environment/extractors/python-env-extractor.d.ts +50 -0
- package/dist/environment/extractors/python-env-extractor.d.ts.map +1 -0
- package/dist/environment/extractors/python-env-extractor.js +219 -0
- package/dist/environment/extractors/python-env-extractor.js.map +1 -0
- package/dist/environment/extractors/typescript-env-extractor.d.ts +54 -0
- package/dist/environment/extractors/typescript-env-extractor.d.ts.map +1 -0
- package/dist/environment/extractors/typescript-env-extractor.js +228 -0
- package/dist/environment/extractors/typescript-env-extractor.js.map +1 -0
- package/dist/environment/index.d.ts +11 -0
- package/dist/environment/index.d.ts.map +1 -0
- package/dist/environment/index.js +15 -0
- package/dist/environment/index.js.map +1 -0
- package/dist/environment/types.d.ts +145 -0
- package/dist/environment/types.d.ts.map +1 -0
- package/dist/environment/types.js +84 -0
- package/dist/environment/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constant & Enum Extraction Types
|
|
3
|
+
*
|
|
4
|
+
* Core types for extracting and tracking constants, enums, and exported values
|
|
5
|
+
* across all supported languages.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Supported languages for constant extraction
|
|
9
|
+
*/
|
|
10
|
+
export type ConstantLanguage = 'typescript' | 'javascript' | 'python' | 'java' | 'csharp' | 'php' | 'go';
|
|
11
|
+
/**
|
|
12
|
+
* What kind of constant this is
|
|
13
|
+
*/
|
|
14
|
+
export type ConstantKind = 'primitive' | 'enum' | 'enum_member' | 'object' | 'array' | 'computed' | 'class_constant' | 'interface_constant';
|
|
15
|
+
/**
|
|
16
|
+
* Inferred category for the constant
|
|
17
|
+
*/
|
|
18
|
+
export type ConstantCategory = 'config' | 'api' | 'status' | 'error' | 'feature_flag' | 'limit' | 'regex' | 'path' | 'env' | 'security' | 'uncategorized';
|
|
19
|
+
/**
|
|
20
|
+
* Severity level for issues
|
|
21
|
+
*/
|
|
22
|
+
export type IssueSeverity = 'info' | 'low' | 'medium' | 'high' | 'critical';
|
|
23
|
+
/**
|
|
24
|
+
* A constant definition extracted from source code
|
|
25
|
+
*/
|
|
26
|
+
export interface ConstantExtraction {
|
|
27
|
+
/** Unique ID: "file:name:line" */
|
|
28
|
+
id: string;
|
|
29
|
+
/** Constant name */
|
|
30
|
+
name: string;
|
|
31
|
+
/** Qualified name (Class.CONST or module.CONST) */
|
|
32
|
+
qualifiedName: string;
|
|
33
|
+
/** Source file path */
|
|
34
|
+
file: string;
|
|
35
|
+
/** Line number */
|
|
36
|
+
line: number;
|
|
37
|
+
/** Column number */
|
|
38
|
+
column: number;
|
|
39
|
+
/** End line */
|
|
40
|
+
endLine: number;
|
|
41
|
+
/** Language */
|
|
42
|
+
language: ConstantLanguage;
|
|
43
|
+
/** What kind of constant */
|
|
44
|
+
kind: ConstantKind;
|
|
45
|
+
/** Inferred category */
|
|
46
|
+
category: ConstantCategory;
|
|
47
|
+
/** Value if extractable (primitives, up to 500 chars) */
|
|
48
|
+
value?: string | number | boolean | null;
|
|
49
|
+
/** Raw value text from source */
|
|
50
|
+
rawValue?: string;
|
|
51
|
+
/** Type annotation if present */
|
|
52
|
+
type?: string;
|
|
53
|
+
/** Is exported/public */
|
|
54
|
+
isExported: boolean;
|
|
55
|
+
/** Parent class/enum/interface name */
|
|
56
|
+
parentName?: string;
|
|
57
|
+
/** Parent type (class, interface, enum, module) */
|
|
58
|
+
parentType?: 'class' | 'interface' | 'enum' | 'module' | 'namespace';
|
|
59
|
+
/** Documentation comment */
|
|
60
|
+
docComment?: string;
|
|
61
|
+
/** Decorators/attributes */
|
|
62
|
+
decorators: string[];
|
|
63
|
+
/** Modifiers (static, final, readonly, etc.) */
|
|
64
|
+
modifiers: string[];
|
|
65
|
+
/** Extraction confidence (0-1) */
|
|
66
|
+
confidence: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* An enum definition extracted from source code
|
|
70
|
+
*/
|
|
71
|
+
export interface EnumExtraction {
|
|
72
|
+
/** Unique ID: "file:name:line" */
|
|
73
|
+
id: string;
|
|
74
|
+
/** Enum name */
|
|
75
|
+
name: string;
|
|
76
|
+
/** Qualified name */
|
|
77
|
+
qualifiedName: string;
|
|
78
|
+
/** Source file path */
|
|
79
|
+
file: string;
|
|
80
|
+
/** Line number */
|
|
81
|
+
line: number;
|
|
82
|
+
/** End line */
|
|
83
|
+
endLine: number;
|
|
84
|
+
/** Language */
|
|
85
|
+
language: ConstantLanguage;
|
|
86
|
+
/** Is exported/public */
|
|
87
|
+
isExported: boolean;
|
|
88
|
+
/** Enum members */
|
|
89
|
+
members: EnumMember[];
|
|
90
|
+
/** Is flags enum (C# [Flags]) */
|
|
91
|
+
isFlags: boolean;
|
|
92
|
+
/** Is string enum */
|
|
93
|
+
isStringEnum: boolean;
|
|
94
|
+
/** Backing type (string, int, etc.) */
|
|
95
|
+
backingType?: string;
|
|
96
|
+
/** Documentation comment */
|
|
97
|
+
docComment?: string;
|
|
98
|
+
/** Decorators/attributes */
|
|
99
|
+
decorators: string[];
|
|
100
|
+
/** Modifiers */
|
|
101
|
+
modifiers: string[];
|
|
102
|
+
/** Extraction confidence (0-1) */
|
|
103
|
+
confidence: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* An individual enum member
|
|
107
|
+
*/
|
|
108
|
+
export interface EnumMember {
|
|
109
|
+
/** Member name */
|
|
110
|
+
name: string;
|
|
111
|
+
/** Value if specified */
|
|
112
|
+
value?: string | number;
|
|
113
|
+
/** Line number */
|
|
114
|
+
line: number;
|
|
115
|
+
/** Documentation comment */
|
|
116
|
+
docComment?: string;
|
|
117
|
+
/** Is auto-generated value */
|
|
118
|
+
isAutoValue: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A reference to a constant in code
|
|
122
|
+
*/
|
|
123
|
+
export interface ConstantReference {
|
|
124
|
+
/** The constant being referenced */
|
|
125
|
+
constantId: string;
|
|
126
|
+
/** Constant name (for display) */
|
|
127
|
+
constantName: string;
|
|
128
|
+
/** File containing the reference */
|
|
129
|
+
file: string;
|
|
130
|
+
/** Line number */
|
|
131
|
+
line: number;
|
|
132
|
+
/** Column number */
|
|
133
|
+
column: number;
|
|
134
|
+
/** Context snippet */
|
|
135
|
+
context?: string;
|
|
136
|
+
/** Function/method containing the reference */
|
|
137
|
+
containingFunction?: string;
|
|
138
|
+
/** Class containing the reference */
|
|
139
|
+
containingClass?: string;
|
|
140
|
+
/** Reference type */
|
|
141
|
+
referenceType: 'read' | 'assignment' | 'parameter' | 'comparison';
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Result of extracting constants from a single file
|
|
145
|
+
*/
|
|
146
|
+
export interface FileConstantResult {
|
|
147
|
+
/** File path */
|
|
148
|
+
file: string;
|
|
149
|
+
/** Language */
|
|
150
|
+
language: ConstantLanguage;
|
|
151
|
+
/** Extracted constants */
|
|
152
|
+
constants: ConstantExtraction[];
|
|
153
|
+
/** Extracted enums */
|
|
154
|
+
enums: EnumExtraction[];
|
|
155
|
+
/** Constant references (if tracking enabled) */
|
|
156
|
+
references: ConstantReference[];
|
|
157
|
+
/** Extraction errors */
|
|
158
|
+
errors: string[];
|
|
159
|
+
/** Extraction quality metrics */
|
|
160
|
+
quality: ConstantExtractionQuality;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Quality metrics for constant extraction
|
|
164
|
+
*/
|
|
165
|
+
export interface ConstantExtractionQuality {
|
|
166
|
+
/** Extraction method used */
|
|
167
|
+
method: 'tree-sitter' | 'regex' | 'hybrid';
|
|
168
|
+
/** Confidence score (0-1) */
|
|
169
|
+
confidence: number;
|
|
170
|
+
/** Coverage estimate (0-100) */
|
|
171
|
+
coveragePercent: number;
|
|
172
|
+
/** Number of items extracted */
|
|
173
|
+
itemsExtracted: number;
|
|
174
|
+
/** Number of parse errors */
|
|
175
|
+
parseErrors: number;
|
|
176
|
+
/** Warnings */
|
|
177
|
+
warnings: string[];
|
|
178
|
+
/** Whether fallback was used */
|
|
179
|
+
usedFallback: boolean;
|
|
180
|
+
/** Extraction time in ms */
|
|
181
|
+
extractionTimeMs: number;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* A magic value detected in code
|
|
185
|
+
*/
|
|
186
|
+
export interface MagicValue {
|
|
187
|
+
/** The literal value */
|
|
188
|
+
value: string | number;
|
|
189
|
+
/** Value type */
|
|
190
|
+
type: 'string' | 'number';
|
|
191
|
+
/** All occurrences */
|
|
192
|
+
occurrences: MagicValueOccurrence[];
|
|
193
|
+
/** Suggested constant name */
|
|
194
|
+
suggestedName: string;
|
|
195
|
+
/** Suggested category */
|
|
196
|
+
suggestedCategory: ConstantCategory;
|
|
197
|
+
/** Severity */
|
|
198
|
+
severity: IssueSeverity;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* A single occurrence of a magic value
|
|
202
|
+
*/
|
|
203
|
+
export interface MagicValueOccurrence {
|
|
204
|
+
/** File path */
|
|
205
|
+
file: string;
|
|
206
|
+
/** Line number */
|
|
207
|
+
line: number;
|
|
208
|
+
/** Column */
|
|
209
|
+
column: number;
|
|
210
|
+
/** Context snippet */
|
|
211
|
+
context: string;
|
|
212
|
+
/** Containing function */
|
|
213
|
+
containingFunction?: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* A potential hardcoded secret
|
|
217
|
+
*/
|
|
218
|
+
export interface PotentialSecret {
|
|
219
|
+
/** Constant ID if it's a constant */
|
|
220
|
+
constantId?: string;
|
|
221
|
+
/** Name */
|
|
222
|
+
name: string;
|
|
223
|
+
/** File path */
|
|
224
|
+
file: string;
|
|
225
|
+
/** Line number */
|
|
226
|
+
line: number;
|
|
227
|
+
/** Masked value (first/last chars visible) */
|
|
228
|
+
maskedValue: string;
|
|
229
|
+
/** Secret type detected */
|
|
230
|
+
secretType: SecretType;
|
|
231
|
+
/** Severity */
|
|
232
|
+
severity: IssueSeverity;
|
|
233
|
+
/** Recommendation */
|
|
234
|
+
recommendation: string;
|
|
235
|
+
/** Confidence (0-1) */
|
|
236
|
+
confidence: number;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Types of secrets we detect
|
|
240
|
+
*/
|
|
241
|
+
export type SecretType = 'api_key' | 'secret_key' | 'password' | 'private_key' | 'connection_string' | 'token' | 'certificate' | 'aws_key' | 'stripe_key' | 'github_token' | 'generic_secret';
|
|
242
|
+
/**
|
|
243
|
+
* An inconsistent constant (same name, different values)
|
|
244
|
+
*/
|
|
245
|
+
export interface InconsistentConstant {
|
|
246
|
+
/** Constant name */
|
|
247
|
+
name: string;
|
|
248
|
+
/** All instances with different values */
|
|
249
|
+
instances: ConstantInstance[];
|
|
250
|
+
/** Recommendation */
|
|
251
|
+
recommendation: string;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* A single instance of a constant
|
|
255
|
+
*/
|
|
256
|
+
export interface ConstantInstance {
|
|
257
|
+
/** Constant ID */
|
|
258
|
+
id: string;
|
|
259
|
+
/** File path */
|
|
260
|
+
file: string;
|
|
261
|
+
/** Line number */
|
|
262
|
+
line: number;
|
|
263
|
+
/** Value */
|
|
264
|
+
value: string | number | boolean | null;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* A dead (unused) constant
|
|
268
|
+
*/
|
|
269
|
+
export interface DeadConstant {
|
|
270
|
+
/** Constant ID */
|
|
271
|
+
id: string;
|
|
272
|
+
/** Constant name */
|
|
273
|
+
name: string;
|
|
274
|
+
/** File path */
|
|
275
|
+
file: string;
|
|
276
|
+
/** Line number */
|
|
277
|
+
line: number;
|
|
278
|
+
/** Last modified date (from git) */
|
|
279
|
+
lastModified?: string;
|
|
280
|
+
/** Confidence that it's unused (0-1) */
|
|
281
|
+
confidence: number;
|
|
282
|
+
/** Reason for flagging */
|
|
283
|
+
reason: 'no_references' | 'only_test_references' | 'deprecated_annotation';
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Per-file shard stored in .drift/lake/constants/files/
|
|
287
|
+
*/
|
|
288
|
+
export interface ConstantFileShard {
|
|
289
|
+
/** Schema version */
|
|
290
|
+
version: '1.0';
|
|
291
|
+
/** File path */
|
|
292
|
+
file: string;
|
|
293
|
+
/** Content hash for change detection */
|
|
294
|
+
contentHash: string;
|
|
295
|
+
/** Extraction timestamp */
|
|
296
|
+
extractedAt: string;
|
|
297
|
+
/** Constants in this file */
|
|
298
|
+
constants: ConstantExtraction[];
|
|
299
|
+
/** Enums in this file */
|
|
300
|
+
enums: EnumExtraction[];
|
|
301
|
+
/** References in this file (if tracking enabled) */
|
|
302
|
+
references: ConstantReference[];
|
|
303
|
+
/** Extraction quality */
|
|
304
|
+
quality: ConstantExtractionQuality;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Main index stored in .drift/lake/constants/index.json
|
|
308
|
+
*/
|
|
309
|
+
export interface ConstantIndex {
|
|
310
|
+
/** Schema version */
|
|
311
|
+
version: '1.0';
|
|
312
|
+
/** Generation timestamp */
|
|
313
|
+
generatedAt: string;
|
|
314
|
+
/** Project root */
|
|
315
|
+
projectRoot: string;
|
|
316
|
+
/** Constants by category */
|
|
317
|
+
byCategory: Record<ConstantCategory, string[]>;
|
|
318
|
+
/** Constants by file */
|
|
319
|
+
byFile: Record<string, string[]>;
|
|
320
|
+
/** Constants by name (for quick lookup) */
|
|
321
|
+
byName: Record<string, string[]>;
|
|
322
|
+
/** Enums by file */
|
|
323
|
+
enumsByFile: Record<string, string[]>;
|
|
324
|
+
/** Statistics */
|
|
325
|
+
stats: ConstantStats;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Statistics about constants in the codebase
|
|
329
|
+
*/
|
|
330
|
+
export interface ConstantStats {
|
|
331
|
+
/** Total constants */
|
|
332
|
+
totalConstants: number;
|
|
333
|
+
/** Total enums */
|
|
334
|
+
totalEnums: number;
|
|
335
|
+
/** Total enum members */
|
|
336
|
+
totalEnumMembers: number;
|
|
337
|
+
/** By language */
|
|
338
|
+
byLanguage: Record<ConstantLanguage, number>;
|
|
339
|
+
/** By category */
|
|
340
|
+
byCategory: Record<ConstantCategory, number>;
|
|
341
|
+
/** By kind */
|
|
342
|
+
byKind: Record<ConstantKind, number>;
|
|
343
|
+
/** Issue counts */
|
|
344
|
+
issues: {
|
|
345
|
+
magicValues: number;
|
|
346
|
+
deadConstants: number;
|
|
347
|
+
potentialSecrets: number;
|
|
348
|
+
inconsistentValues: number;
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Configuration for constant extraction
|
|
353
|
+
*/
|
|
354
|
+
export interface ConstantExtractionConfig {
|
|
355
|
+
/** Enable constant extraction */
|
|
356
|
+
enabled: boolean;
|
|
357
|
+
/** Track references to constants */
|
|
358
|
+
trackReferences: boolean;
|
|
359
|
+
/** Custom category patterns */
|
|
360
|
+
categoryPatterns?: Record<string, RegExp[]>;
|
|
361
|
+
/** Magic value detection settings */
|
|
362
|
+
magicValues: {
|
|
363
|
+
/** Minimum occurrences to flag */
|
|
364
|
+
minOccurrences: number;
|
|
365
|
+
/** Values to ignore */
|
|
366
|
+
ignoreValues: (string | number)[];
|
|
367
|
+
/** File patterns to ignore */
|
|
368
|
+
ignorePatterns: string[];
|
|
369
|
+
/** Include string literals */
|
|
370
|
+
includeStrings: boolean;
|
|
371
|
+
/** Include numeric literals */
|
|
372
|
+
includeNumbers: boolean;
|
|
373
|
+
};
|
|
374
|
+
/** Secret detection settings */
|
|
375
|
+
secrets: {
|
|
376
|
+
/** Enable secret detection */
|
|
377
|
+
enabled: boolean;
|
|
378
|
+
/** Custom patterns */
|
|
379
|
+
customPatterns: SecretPattern[];
|
|
380
|
+
/** Files to allowlist */
|
|
381
|
+
allowlist: string[];
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* A custom secret detection pattern
|
|
386
|
+
*/
|
|
387
|
+
export interface SecretPattern {
|
|
388
|
+
/** Pattern to match */
|
|
389
|
+
pattern: string;
|
|
390
|
+
/** Secret type */
|
|
391
|
+
type: SecretType;
|
|
392
|
+
/** Severity */
|
|
393
|
+
severity: IssueSeverity;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Default configuration
|
|
397
|
+
*/
|
|
398
|
+
export declare const DEFAULT_CONSTANT_CONFIG: ConstantExtractionConfig;
|
|
399
|
+
/**
|
|
400
|
+
* Configuration for hybrid extractors
|
|
401
|
+
*/
|
|
402
|
+
export interface ConstantHybridConfig {
|
|
403
|
+
/** Enable tree-sitter extraction */
|
|
404
|
+
enableTreeSitter?: boolean;
|
|
405
|
+
/** Enable regex fallback */
|
|
406
|
+
enableRegexFallback?: boolean;
|
|
407
|
+
/** Extract references */
|
|
408
|
+
extractReferences?: boolean;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Default hybrid config
|
|
412
|
+
*/
|
|
413
|
+
export declare const DEFAULT_CONSTANT_HYBRID_CONFIG: Required<ConstantHybridConfig>;
|
|
414
|
+
/**
|
|
415
|
+
* Confidence levels for extraction methods
|
|
416
|
+
*/
|
|
417
|
+
export declare const CONSTANT_EXTRACTION_CONFIDENCE: {
|
|
418
|
+
readonly TREE_SITTER: 0.95;
|
|
419
|
+
readonly REGEX: 0.75;
|
|
420
|
+
readonly HYBRID: 0.9;
|
|
421
|
+
readonly UNKNOWN: 0.5;
|
|
422
|
+
};
|
|
423
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/constants/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,YAAY,GACZ,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,KAAK,GACL,IAAI,CAAC;AAET;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,MAAM,GACN,aAAa,GACb,QAAQ,GACR,OAAO,GACP,UAAU,GACV,gBAAgB,GAChB,oBAAoB,CAAC;AAEzB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,KAAK,GACL,QAAQ,GACR,OAAO,GACP,cAAc,GACd,OAAO,GACP,OAAO,GACP,MAAM,GACN,KAAK,GACL,UAAU,GACV,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAM5E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IAEX,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IAEb,mDAAmD;IACnD,aAAa,EAAE,MAAM,CAAC;IAEtB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IAEb,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IAEb,oBAAoB;IACpB,MAAM,EAAE,MAAM,CAAC;IAEf,eAAe;IACf,OAAO,EAAE,MAAM,CAAC;IAEhB,eAAe;IACf,QAAQ,EAAE,gBAAgB,CAAC;IAE3B,4BAA4B;IAC5B,IAAI,EAAE,YAAY,CAAC;IAEnB,wBAAwB;IACxB,QAAQ,EA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,EAAE,CAAC;KACrB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAEhB,kBAAkB;IAClB,IAAI,EAAE,UAAU,CAAC;IAEjB,eAAe;IACf,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,wBAerC,CAAC;AAMF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,oCAAoC;IACpC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,4BAA4B;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,yBAAyB;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,oBAAoB,CAIzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B;;;;;CAKjC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constant & Enum Extraction Types
|
|
3
|
+
*
|
|
4
|
+
* Core types for extracting and tracking constants, enums, and exported values
|
|
5
|
+
* across all supported languages.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default configuration
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_CONSTANT_CONFIG = {
|
|
11
|
+
enabled: true,
|
|
12
|
+
trackReferences: true,
|
|
13
|
+
magicValues: {
|
|
14
|
+
minOccurrences: 2,
|
|
15
|
+
ignoreValues: [0, 1, -1, '', 'true', 'false', 'null', 'undefined'],
|
|
16
|
+
ignorePatterns: ['test', 'spec', 'mock', '__tests__', '__mocks__'],
|
|
17
|
+
includeStrings: true,
|
|
18
|
+
includeNumbers: true,
|
|
19
|
+
},
|
|
20
|
+
secrets: {
|
|
21
|
+
enabled: true,
|
|
22
|
+
customPatterns: [],
|
|
23
|
+
allowlist: ['**/test/**', '**/*.test.*', '**/*.spec.*'],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Default hybrid config
|
|
28
|
+
*/
|
|
29
|
+
export const DEFAULT_CONSTANT_HYBRID_CONFIG = {
|
|
30
|
+
enableTreeSitter: true,
|
|
31
|
+
enableRegexFallback: true,
|
|
32
|
+
extractReferences: false, // Off by default for performance
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Confidence levels for extraction methods
|
|
36
|
+
*/
|
|
37
|
+
export const CONSTANT_EXTRACTION_CONFIDENCE = {
|
|
38
|
+
TREE_SITTER: 0.95,
|
|
39
|
+
REGEX: 0.75,
|
|
40
|
+
HYBRID: 0.90,
|
|
41
|
+
UNKNOWN: 0.5,
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/constants/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAglBH;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAA6B;IAC/D,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,IAAI;IACrB,WAAW,EAAE;QACX,cAAc,EAAE,CAAC;QACjB,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC;QAClE,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC;QAClE,cAAc,EAAE,IAAI;QACpB,cAAc,EAAE,IAAI;KACrB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,EAAE;QAClB,SAAS,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,aAAa,CAAC;KACxD;CACF,CAAC;AAoBF;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAmC;IAC5E,gBAAgB,EAAE,IAAI;IACtB,mBAAmB,EAAE,IAAI;IACzB,iBAAiB,EAAE,KAAK,EAAE,iCAAiC;CAC5D,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,WAAW,EAAE,IAAI;IACjB,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,GAAG;CACJ,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Variable Scanner
|
|
3
|
+
*
|
|
4
|
+
* Unified scanner for detecting environment variable access patterns
|
|
5
|
+
* across all supported languages.
|
|
6
|
+
*/
|
|
7
|
+
import type { EnvScanResult } from './types.js';
|
|
8
|
+
export interface EnvScannerConfig {
|
|
9
|
+
rootDir: string;
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Environment Variable Scanner
|
|
14
|
+
*
|
|
15
|
+
* Scans codebases for environment variable access patterns.
|
|
16
|
+
*/
|
|
17
|
+
export declare class EnvScanner {
|
|
18
|
+
private readonly config;
|
|
19
|
+
private readonly extractors;
|
|
20
|
+
constructor(config: EnvScannerConfig);
|
|
21
|
+
/**
|
|
22
|
+
* Scan files for environment variable access patterns
|
|
23
|
+
*/
|
|
24
|
+
scanFiles(files: string[]): Promise<EnvScanResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Scan directory with glob patterns
|
|
27
|
+
*/
|
|
28
|
+
scanDirectory(options?: {
|
|
29
|
+
patterns?: string[];
|
|
30
|
+
ignorePatterns?: string[];
|
|
31
|
+
}): Promise<EnvScanResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Get the appropriate extractor for a file
|
|
34
|
+
*/
|
|
35
|
+
private getExtractor;
|
|
36
|
+
/**
|
|
37
|
+
* Quick check if file might have environment access
|
|
38
|
+
*/
|
|
39
|
+
private mightHaveEnvAccess;
|
|
40
|
+
/**
|
|
41
|
+
* Build the access map from extracted access points
|
|
42
|
+
*/
|
|
43
|
+
private buildAccessMap;
|
|
44
|
+
/**
|
|
45
|
+
* Find files matching patterns
|
|
46
|
+
*/
|
|
47
|
+
private findFiles;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a new EnvScanner instance
|
|
51
|
+
*/
|
|
52
|
+
export declare function createEnvScanner(config: EnvScannerConfig): EnvScanner;
|
|
53
|
+
//# sourceMappingURL=env-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-scanner.d.ts","sourceRoot":"","sources":["../../src/environment/env-scanner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAIV,aAAa,EACd,MAAM,YAAY,CAAC;AAapB,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAMD;;;;GAIG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;gBAEpC,MAAM,EAAE,gBAAgB;IAcpC;;OAEG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IA2DxD;;OAEG;IACG,aAAa,CAAC,OAAO,GAAE;QAC3B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;KACtB,GAAG,OAAO,CAAC,aAAa,CAAC;IA+B/B;;OAEG;IACH,OAAO,CAAC,YAAY;IASpB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAuC1B;;OAEG;IACH,OAAO,CAAC,cAAc;IAwEtB;;OAEG;YACW,SAAS;CAiCxB;AAMD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAErE"}
|