driftdetect-core 0.6.1 → 0.7.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/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/constraints/store/constraint-store.d.ts.map +1 -1
- package/dist/constraints/store/constraint-store.js +37 -2
- package/dist/constraints/store/constraint-store.js.map +1 -1
- 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,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call Graph Adapter
|
|
3
|
+
*
|
|
4
|
+
* Links constant extraction to the call graph system.
|
|
5
|
+
* Enables tracking of constant usage through function calls.
|
|
6
|
+
*/
|
|
7
|
+
import { ConstantStore } from '../store/constant-store.js';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Call Graph Adapter
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Adapter for linking constants to the call graph
|
|
13
|
+
*/
|
|
14
|
+
export class ConstantCallGraphAdapter {
|
|
15
|
+
config;
|
|
16
|
+
store;
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.config = {
|
|
19
|
+
rootDir: config.rootDir,
|
|
20
|
+
maxDepth: config.maxDepth ?? 10,
|
|
21
|
+
includeTests: config.includeTests ?? false,
|
|
22
|
+
};
|
|
23
|
+
this.store = new ConstantStore({ rootDir: config.rootDir });
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get constant with call graph context
|
|
27
|
+
*/
|
|
28
|
+
async getConstantWithContext(constantId, callGraph) {
|
|
29
|
+
const constant = await this.store.getConstantById(constantId);
|
|
30
|
+
if (!constant) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
// Get all references to this constant
|
|
34
|
+
const allConstants = await this.store.getAllConstants();
|
|
35
|
+
const references = await this.findReferencesForConstant(constant, allConstants);
|
|
36
|
+
// Build function usage list
|
|
37
|
+
const usedByFunctions = references.map((ref) => ({
|
|
38
|
+
functionName: ref.containingFunction ?? 'module-level',
|
|
39
|
+
file: ref.file,
|
|
40
|
+
line: ref.line,
|
|
41
|
+
usageType: ref.referenceType,
|
|
42
|
+
depth: 0, // Would need call graph to calculate
|
|
43
|
+
}));
|
|
44
|
+
// Get entry points if call graph is available
|
|
45
|
+
const reachableFromEntryPoints = [];
|
|
46
|
+
const dataFlowPaths = [];
|
|
47
|
+
if (callGraph) {
|
|
48
|
+
// Find entry points that can reach functions using this constant
|
|
49
|
+
for (const usage of usedByFunctions) {
|
|
50
|
+
const entryPoints = await this.findEntryPointsForFunction(usage.functionName, usage.file, callGraph);
|
|
51
|
+
reachableFromEntryPoints.push(...entryPoints);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
constant,
|
|
56
|
+
usedByFunctions,
|
|
57
|
+
reachableFromEntryPoints: [...new Set(reachableFromEntryPoints)],
|
|
58
|
+
dataFlowPaths,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Analyze impact of changing a constant
|
|
63
|
+
*/
|
|
64
|
+
async analyzeConstantImpact(constantId, callGraph) {
|
|
65
|
+
const constant = await this.store.getConstantById(constantId);
|
|
66
|
+
if (!constant) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
// Get all references
|
|
70
|
+
const allConstants = await this.store.getAllConstants();
|
|
71
|
+
const directUsages = await this.findReferencesForConstant(constant, allConstants);
|
|
72
|
+
// Build affected functions list
|
|
73
|
+
const affectedFunctions = [];
|
|
74
|
+
const seenFunctions = new Set();
|
|
75
|
+
for (const usage of directUsages) {
|
|
76
|
+
const key = `${usage.file}:${usage.containingFunction ?? 'module'}`;
|
|
77
|
+
if (!seenFunctions.has(key)) {
|
|
78
|
+
seenFunctions.add(key);
|
|
79
|
+
affectedFunctions.push({
|
|
80
|
+
name: usage.containingFunction ?? 'module-level',
|
|
81
|
+
file: usage.file,
|
|
82
|
+
line: usage.line,
|
|
83
|
+
affectedBy: 'direct_usage',
|
|
84
|
+
depth: 0,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Find affected entry points
|
|
89
|
+
const affectedEntryPoints = [];
|
|
90
|
+
if (callGraph) {
|
|
91
|
+
for (const func of affectedFunctions) {
|
|
92
|
+
const entryPoints = await this.findEntryPointsForFunction(func.name, func.file, callGraph);
|
|
93
|
+
affectedEntryPoints.push(...entryPoints);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Calculate impact score
|
|
97
|
+
const impactScore = this.calculateImpactScore(directUsages.length, affectedFunctions.length, affectedEntryPoints.length, constant);
|
|
98
|
+
// Determine risk level
|
|
99
|
+
const riskLevel = this.determineRiskLevel(impactScore, constant);
|
|
100
|
+
return {
|
|
101
|
+
constant,
|
|
102
|
+
directUsages,
|
|
103
|
+
affectedFunctions,
|
|
104
|
+
affectedEntryPoints: [...new Set(affectedEntryPoints)],
|
|
105
|
+
impactScore,
|
|
106
|
+
riskLevel,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Find all constants used by a function
|
|
111
|
+
*/
|
|
112
|
+
async findConstantsUsedByFunction(_functionName, filePath) {
|
|
113
|
+
const allConstants = await this.store.getAllConstants();
|
|
114
|
+
const usedConstants = [];
|
|
115
|
+
// Check which constants are referenced in the function
|
|
116
|
+
// This is a simplified check - full implementation would parse the function body
|
|
117
|
+
for (const constant of allConstants) {
|
|
118
|
+
// Check if constant is from same file or imported
|
|
119
|
+
if (constant.file === filePath || constant.isExported) {
|
|
120
|
+
usedConstants.push(constant);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return usedConstants;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Find constants that flow to a specific data sink
|
|
127
|
+
*/
|
|
128
|
+
async findConstantsFlowingToSink(_sinkFunction, sinkFile, _callGraph) {
|
|
129
|
+
const flowingConstants = [];
|
|
130
|
+
// Find constants used in those functions
|
|
131
|
+
const fileConstants = await this.store.getConstantsByFile(sinkFile);
|
|
132
|
+
flowingConstants.push(...fileConstants);
|
|
133
|
+
return flowingConstants;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get constants by entry point
|
|
137
|
+
*/
|
|
138
|
+
async getConstantsByEntryPoint(entryPoint, callGraph) {
|
|
139
|
+
const allConstants = await this.store.getAllConstants();
|
|
140
|
+
if (!callGraph) {
|
|
141
|
+
// Without call graph, return all exported constants
|
|
142
|
+
return allConstants.filter((c) => c.isExported);
|
|
143
|
+
}
|
|
144
|
+
// With call graph, find all functions reachable from entry point
|
|
145
|
+
// and return constants used by those functions
|
|
146
|
+
const reachableFunctions = await this.getReachableFunctions(entryPoint, callGraph);
|
|
147
|
+
const usedConstants = [];
|
|
148
|
+
const seenIds = new Set();
|
|
149
|
+
for (const func of reachableFunctions) {
|
|
150
|
+
const funcConstants = await this.findConstantsUsedByFunction(func.name, func.file);
|
|
151
|
+
for (const constant of funcConstants) {
|
|
152
|
+
if (!seenIds.has(constant.id)) {
|
|
153
|
+
seenIds.add(constant.id);
|
|
154
|
+
usedConstants.push(constant);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return usedConstants;
|
|
159
|
+
}
|
|
160
|
+
// ============================================================================
|
|
161
|
+
// Private Methods
|
|
162
|
+
// ============================================================================
|
|
163
|
+
/**
|
|
164
|
+
* Find references for a specific constant
|
|
165
|
+
*/
|
|
166
|
+
async findReferencesForConstant(_constant, _allConstants) {
|
|
167
|
+
// This would need file content to find actual references
|
|
168
|
+
// For now, return empty array - full implementation would scan files
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Find entry points that can reach a function
|
|
173
|
+
*/
|
|
174
|
+
async findEntryPointsForFunction(functionName, filePath, callGraph) {
|
|
175
|
+
// Use call graph to find entry points
|
|
176
|
+
const entryPoints = [];
|
|
177
|
+
try {
|
|
178
|
+
const callers = await callGraph.getCallers(functionName, filePath);
|
|
179
|
+
for (const caller of callers) {
|
|
180
|
+
if (caller.isEntryPoint) {
|
|
181
|
+
entryPoints.push(`${caller.file}:${caller.name}`);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
// Recursively find entry points
|
|
185
|
+
const parentEntryPoints = await this.findEntryPointsForFunction(caller.name, caller.file, callGraph);
|
|
186
|
+
entryPoints.push(...parentEntryPoints);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
// Call graph not available or error
|
|
192
|
+
}
|
|
193
|
+
return entryPoints;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get all functions reachable from an entry point
|
|
197
|
+
*/
|
|
198
|
+
async getReachableFunctions(entryPoint, callGraph) {
|
|
199
|
+
const reachable = [];
|
|
200
|
+
const visited = new Set();
|
|
201
|
+
const traverse = async (funcName, filePath, depth) => {
|
|
202
|
+
if (depth > this.config.maxDepth)
|
|
203
|
+
return;
|
|
204
|
+
const key = `${filePath}:${funcName}`;
|
|
205
|
+
if (visited.has(key))
|
|
206
|
+
return;
|
|
207
|
+
visited.add(key);
|
|
208
|
+
reachable.push({ name: funcName, file: filePath });
|
|
209
|
+
try {
|
|
210
|
+
const callees = await callGraph.getCallees(funcName, filePath);
|
|
211
|
+
for (const callee of callees) {
|
|
212
|
+
await traverse(callee.name, callee.file, depth + 1);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
// Ignore errors
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const [file, name] = entryPoint.split(':');
|
|
220
|
+
if (file && name) {
|
|
221
|
+
await traverse(name, file, 0);
|
|
222
|
+
}
|
|
223
|
+
return reachable;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Calculate impact score for a constant
|
|
227
|
+
*/
|
|
228
|
+
calculateImpactScore(directUsages, affectedFunctions, affectedEntryPoints, constant) {
|
|
229
|
+
let score = 0;
|
|
230
|
+
// Base score from usage count
|
|
231
|
+
score += Math.min(directUsages * 5, 30);
|
|
232
|
+
// Score from affected functions
|
|
233
|
+
score += Math.min(affectedFunctions * 3, 25);
|
|
234
|
+
// Score from affected entry points
|
|
235
|
+
score += Math.min(affectedEntryPoints * 10, 30);
|
|
236
|
+
// Bonus for exported constants
|
|
237
|
+
if (constant.isExported) {
|
|
238
|
+
score += 10;
|
|
239
|
+
}
|
|
240
|
+
// Bonus for security-sensitive categories
|
|
241
|
+
if (constant.category === 'security' || constant.category === 'api') {
|
|
242
|
+
score += 5;
|
|
243
|
+
}
|
|
244
|
+
return Math.min(score, 100);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Determine risk level from impact score
|
|
248
|
+
*/
|
|
249
|
+
determineRiskLevel(impactScore, constant) {
|
|
250
|
+
// Security constants are always at least medium risk
|
|
251
|
+
if (constant.category === 'security') {
|
|
252
|
+
if (impactScore >= 50)
|
|
253
|
+
return 'critical';
|
|
254
|
+
if (impactScore >= 25)
|
|
255
|
+
return 'high';
|
|
256
|
+
return 'medium';
|
|
257
|
+
}
|
|
258
|
+
// API constants are higher risk
|
|
259
|
+
if (constant.category === 'api') {
|
|
260
|
+
if (impactScore >= 60)
|
|
261
|
+
return 'critical';
|
|
262
|
+
if (impactScore >= 40)
|
|
263
|
+
return 'high';
|
|
264
|
+
if (impactScore >= 20)
|
|
265
|
+
return 'medium';
|
|
266
|
+
return 'low';
|
|
267
|
+
}
|
|
268
|
+
// Standard risk levels
|
|
269
|
+
if (impactScore >= 70)
|
|
270
|
+
return 'critical';
|
|
271
|
+
if (impactScore >= 50)
|
|
272
|
+
return 'high';
|
|
273
|
+
if (impactScore >= 25)
|
|
274
|
+
return 'medium';
|
|
275
|
+
return 'low';
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
// ============================================================================
|
|
279
|
+
// Factory Functions
|
|
280
|
+
// ============================================================================
|
|
281
|
+
/**
|
|
282
|
+
* Create a call graph adapter
|
|
283
|
+
*/
|
|
284
|
+
export function createCallGraphAdapter(config) {
|
|
285
|
+
return new ConstantCallGraphAdapter(config);
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=callgraph-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callgraph-adapter.js","sourceRoot":"","sources":["../../../src/constants/integration/callgraph-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAkH3D,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;GAEG;AACH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,IAAI,WAAW,IAAI,EAAE;YAAE,OAAO,MAAM,CAAC;QACrC,IAAI,WAAW,IAAI,EAAE;YAAE,OAAO,QAAQ,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAiCD,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAA8B;IAE9B,OAAO,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants Integration Module
|
|
3
|
+
*
|
|
4
|
+
* Adapters for integrating constant extraction with the scanner,
|
|
5
|
+
* call graph, and pattern detection systems.
|
|
6
|
+
*/
|
|
7
|
+
export { ConstantScannerAdapter, createConstantScanner, getConstantLanguage, hashContent, processConstantTask, createDefaultConstantQuality, type ConstantScannerConfig, type ConstantScanResult, type ConstantBatchScanResult, type ConstantWorkerTask, type ConstantWorkerResult, } from './scanner-adapter.js';
|
|
8
|
+
export { ConstantCallGraphAdapter, createCallGraphAdapter, type CallGraphAdapterConfig, type CallGraphInterface, type ConstantWithContext, type ConstantImpactAnalysis, type FunctionUsage, type DataFlowPath, type AffectedFunction, } from './callgraph-adapter.js';
|
|
9
|
+
export { ConstantPatternAdapter, createPatternAdapter, severityToNumber, compareSeverity, type PatternAdapterConfig, type ConstantPattern, type ConstantPatternCategory, type ConstantPatternResult, type PatternLocation, type ManifestPattern, } from './pattern-adapter.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constants/integration/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,4BAA4B,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants Integration Module
|
|
3
|
+
*
|
|
4
|
+
* Adapters for integrating constant extraction with the scanner,
|
|
5
|
+
* call graph, and pattern detection systems.
|
|
6
|
+
*/
|
|
7
|
+
// Scanner Adapter
|
|
8
|
+
export { ConstantScannerAdapter, createConstantScanner, getConstantLanguage, hashContent, processConstantTask, createDefaultConstantQuality, } from './scanner-adapter.js';
|
|
9
|
+
// Call Graph Adapter
|
|
10
|
+
export { ConstantCallGraphAdapter, createCallGraphAdapter, } from './callgraph-adapter.js';
|
|
11
|
+
// Pattern Adapter
|
|
12
|
+
export { ConstantPatternAdapter, createPatternAdapter, severityToNumber, compareSeverity, } from './pattern-adapter.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/integration/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,kBAAkB;AAClB,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,4BAA4B,GAM7B,MAAM,sBAAsB,CAAC;AAE9B,qBAAqB;AACrB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GAQvB,MAAM,wBAAwB,CAAC;AAEhC,kBAAkB;AAClB,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,GAOhB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern Adapter
|
|
3
|
+
*
|
|
4
|
+
* Feeds constant analysis into the pattern detection system.
|
|
5
|
+
* Creates patterns for constant consistency, magic values, and security issues.
|
|
6
|
+
*/
|
|
7
|
+
import type { IssueSeverity } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* A pattern detected from constant analysis
|
|
10
|
+
*/
|
|
11
|
+
export interface ConstantPattern {
|
|
12
|
+
/** Pattern ID */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Pattern name */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Pattern category */
|
|
17
|
+
category: ConstantPatternCategory;
|
|
18
|
+
/** Subcategory */
|
|
19
|
+
subcategory: string;
|
|
20
|
+
/** Description */
|
|
21
|
+
description: string;
|
|
22
|
+
/** Severity */
|
|
23
|
+
severity: IssueSeverity;
|
|
24
|
+
/** Confidence (0-1) */
|
|
25
|
+
confidence: number;
|
|
26
|
+
/** Locations where pattern is found */
|
|
27
|
+
locations: PatternLocation[];
|
|
28
|
+
/** Metadata */
|
|
29
|
+
metadata: Record<string, unknown>;
|
|
30
|
+
/** First seen timestamp */
|
|
31
|
+
firstSeen: string;
|
|
32
|
+
/** Last seen timestamp */
|
|
33
|
+
lastSeen: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Pattern categories for constants
|
|
37
|
+
*/
|
|
38
|
+
export type ConstantPatternCategory = 'config' | 'security' | 'consistency' | 'maintenance';
|
|
39
|
+
/**
|
|
40
|
+
* Location of a pattern
|
|
41
|
+
*/
|
|
42
|
+
export interface PatternLocation {
|
|
43
|
+
/** File path */
|
|
44
|
+
file: string;
|
|
45
|
+
/** Line number */
|
|
46
|
+
line: number;
|
|
47
|
+
/** Column */
|
|
48
|
+
column: number;
|
|
49
|
+
/** Code snippet */
|
|
50
|
+
snippet?: string;
|
|
51
|
+
/** Additional context */
|
|
52
|
+
context?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Pattern detection result
|
|
56
|
+
*/
|
|
57
|
+
export interface ConstantPatternResult {
|
|
58
|
+
/** Detected patterns */
|
|
59
|
+
patterns: ConstantPattern[];
|
|
60
|
+
/** Statistics */
|
|
61
|
+
stats: {
|
|
62
|
+
totalPatterns: number;
|
|
63
|
+
byCategory: Record<ConstantPatternCategory, number>;
|
|
64
|
+
bySeverity: Record<IssueSeverity, number>;
|
|
65
|
+
};
|
|
66
|
+
/** Detection timestamp */
|
|
67
|
+
detectedAt: string;
|
|
68
|
+
/** Duration in ms */
|
|
69
|
+
duration: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Configuration for pattern adapter
|
|
73
|
+
*/
|
|
74
|
+
export interface PatternAdapterConfig {
|
|
75
|
+
/** Root directory */
|
|
76
|
+
rootDir: string;
|
|
77
|
+
/** Enable magic value detection */
|
|
78
|
+
detectMagicValues?: boolean;
|
|
79
|
+
/** Enable security scanning */
|
|
80
|
+
detectSecrets?: boolean;
|
|
81
|
+
/** Enable consistency checking */
|
|
82
|
+
detectInconsistencies?: boolean;
|
|
83
|
+
/** Enable dead constant detection */
|
|
84
|
+
detectDeadConstants?: boolean;
|
|
85
|
+
/** Minimum occurrences for magic values */
|
|
86
|
+
magicValueMinOccurrences?: number;
|
|
87
|
+
/** Secret detection severity threshold */
|
|
88
|
+
secretSeverityThreshold?: IssueSeverity;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Adapter for feeding constant analysis into the pattern system
|
|
92
|
+
*/
|
|
93
|
+
export declare class ConstantPatternAdapter {
|
|
94
|
+
private readonly config;
|
|
95
|
+
private readonly store;
|
|
96
|
+
private readonly securityScanner;
|
|
97
|
+
private readonly consistencyAnalyzer;
|
|
98
|
+
constructor(config: PatternAdapterConfig);
|
|
99
|
+
/**
|
|
100
|
+
* Detect all constant-related patterns
|
|
101
|
+
*/
|
|
102
|
+
detectPatterns(): Promise<ConstantPatternResult>;
|
|
103
|
+
/**
|
|
104
|
+
* Detect magic value patterns
|
|
105
|
+
*/
|
|
106
|
+
private detectMagicValuePatterns;
|
|
107
|
+
/**
|
|
108
|
+
* Detect secret patterns
|
|
109
|
+
*/
|
|
110
|
+
private detectSecretPatterns;
|
|
111
|
+
/**
|
|
112
|
+
* Detect inconsistency patterns
|
|
113
|
+
*/
|
|
114
|
+
private detectInconsistencyPatterns;
|
|
115
|
+
/**
|
|
116
|
+
* Detect dead constant patterns
|
|
117
|
+
*/
|
|
118
|
+
private detectDeadConstantPatterns;
|
|
119
|
+
/**
|
|
120
|
+
* Get severity for an inconsistency
|
|
121
|
+
*/
|
|
122
|
+
private getInconsistencySeverity;
|
|
123
|
+
/**
|
|
124
|
+
* Calculate statistics from patterns
|
|
125
|
+
*/
|
|
126
|
+
private calculateStats;
|
|
127
|
+
/**
|
|
128
|
+
* Convert constant patterns to manifest format
|
|
129
|
+
*/
|
|
130
|
+
toManifestPatterns(patterns: ConstantPattern[]): ManifestPattern[];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Pattern format for manifest storage
|
|
134
|
+
*/
|
|
135
|
+
export interface ManifestPattern {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
category: string;
|
|
139
|
+
subcategory: string;
|
|
140
|
+
status: 'discovered' | 'approved' | 'ignored';
|
|
141
|
+
confidence: number;
|
|
142
|
+
locations: Array<{
|
|
143
|
+
file: string;
|
|
144
|
+
hash: string;
|
|
145
|
+
range: {
|
|
146
|
+
start: number;
|
|
147
|
+
end: number;
|
|
148
|
+
};
|
|
149
|
+
type: string;
|
|
150
|
+
name: string;
|
|
151
|
+
confidence: number;
|
|
152
|
+
language: string;
|
|
153
|
+
}>;
|
|
154
|
+
outliers: unknown[];
|
|
155
|
+
description: string;
|
|
156
|
+
firstSeen: string;
|
|
157
|
+
lastSeen: string;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Create a pattern adapter
|
|
161
|
+
*/
|
|
162
|
+
export declare function createPatternAdapter(config: PatternAdapterConfig): ConstantPatternAdapter;
|
|
163
|
+
/**
|
|
164
|
+
* Convert severity to numeric value for comparison
|
|
165
|
+
*/
|
|
166
|
+
export declare function severityToNumber(severity: IssueSeverity): number;
|
|
167
|
+
/**
|
|
168
|
+
* Compare severities
|
|
169
|
+
*/
|
|
170
|
+
export declare function compareSeverity(a: IssueSeverity, b: IssueSeverity): number;
|
|
171
|
+
//# sourceMappingURL=pattern-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-adapter.d.ts","sourceRoot":"","sources":["../../../src/constants/integration/pattern-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAIV,aAAa,EACd,MAAM,aAAa,CAAC;AASrB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,iBAAiB;IACjB,EAAE,EAAE,MAAM,CAAC;IAEX,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IAEb,uBAAuB;IACvB,QAAQ,EAAE,uBAAuB,CAAC;IAElC,kBAAkB;IAClB,WAAW,EAAE,MAAM,CAAC;IAEpB,kBAAkB;IAClB,WAAW,EAAE,MAAM,CAAC;IAEpB,eAAe;IACf,QAAQ,EAAE,aAAa,CAAC;IAExB,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IAEnB,uCAAuC;IACvC,SAAS,EAAE,eAAe,EAAE,CAAC;IAE7B,eAAe;IACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElC,2BAA2B;IAC3B,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