driftdetect-core 0.4.1 → 0.4.2
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/dist/boundaries/boundary-scanner.d.ts +76 -0
- package/dist/boundaries/boundary-scanner.d.ts.map +1 -0
- package/dist/boundaries/boundary-scanner.js +801 -0
- package/dist/boundaries/boundary-scanner.js.map +1 -0
- package/dist/boundaries/data-access-learner.d.ts +126 -0
- package/dist/boundaries/data-access-learner.d.ts.map +1 -0
- package/dist/boundaries/data-access-learner.js +486 -0
- package/dist/boundaries/data-access-learner.js.map +1 -0
- package/dist/boundaries/index.d.ts +6 -0
- package/dist/boundaries/index.d.ts.map +1 -1
- package/dist/boundaries/index.js +6 -0
- package/dist/boundaries/index.js.map +1 -1
- package/dist/boundaries/security-prioritizer.d.ts +118 -0
- package/dist/boundaries/security-prioritizer.d.ts.map +1 -0
- package/dist/boundaries/security-prioritizer.js +316 -0
- package/dist/boundaries/security-prioritizer.js.map +1 -0
- package/dist/call-graph/analysis/coverage-analyzer.d.ts +201 -0
- package/dist/call-graph/analysis/coverage-analyzer.d.ts.map +1 -0
- package/dist/call-graph/analysis/coverage-analyzer.js +553 -0
- package/dist/call-graph/analysis/coverage-analyzer.js.map +1 -0
- package/dist/call-graph/analysis/dead-code-detector.d.ts +145 -0
- package/dist/call-graph/analysis/dead-code-detector.d.ts.map +1 -0
- package/dist/call-graph/analysis/dead-code-detector.js +391 -0
- package/dist/call-graph/analysis/dead-code-detector.js.map +1 -0
- package/dist/call-graph/analysis/graph-builder.d.ts +142 -0
- package/dist/call-graph/analysis/graph-builder.d.ts.map +1 -0
- package/dist/call-graph/analysis/graph-builder.js +624 -0
- package/dist/call-graph/analysis/graph-builder.js.map +1 -0
- package/dist/call-graph/analysis/impact-analyzer.d.ts +150 -0
- package/dist/call-graph/analysis/impact-analyzer.d.ts.map +1 -0
- package/dist/call-graph/analysis/impact-analyzer.js +329 -0
- package/dist/call-graph/analysis/impact-analyzer.js.map +1 -0
- package/dist/call-graph/analysis/index.d.ts +11 -0
- package/dist/call-graph/analysis/index.d.ts.map +1 -0
- package/dist/call-graph/analysis/index.js +9 -0
- package/dist/call-graph/analysis/index.js.map +1 -0
- package/dist/call-graph/analysis/path-finder.d.ts +117 -0
- package/dist/call-graph/analysis/path-finder.d.ts.map +1 -0
- package/dist/call-graph/analysis/path-finder.js +360 -0
- package/dist/call-graph/analysis/path-finder.js.map +1 -0
- package/dist/call-graph/analysis/reachability.d.ts +56 -0
- package/dist/call-graph/analysis/reachability.d.ts.map +1 -0
- package/dist/call-graph/analysis/reachability.js +357 -0
- package/dist/call-graph/analysis/reachability.js.map +1 -0
- package/dist/call-graph/demo.d.ts +11 -0
- package/dist/call-graph/demo.d.ts.map +1 -0
- package/dist/call-graph/demo.js +339 -0
- package/dist/call-graph/demo.js.map +1 -0
- package/dist/call-graph/enrichment/enrichment-engine.d.ts +126 -0
- package/dist/call-graph/enrichment/enrichment-engine.d.ts.map +1 -0
- package/dist/call-graph/enrichment/enrichment-engine.js +760 -0
- package/dist/call-graph/enrichment/enrichment-engine.js.map +1 -0
- package/dist/call-graph/enrichment/impact-scorer.d.ts +59 -0
- package/dist/call-graph/enrichment/impact-scorer.d.ts.map +1 -0
- package/dist/call-graph/enrichment/impact-scorer.js +328 -0
- package/dist/call-graph/enrichment/impact-scorer.js.map +1 -0
- package/dist/call-graph/enrichment/index.d.ts +12 -0
- package/dist/call-graph/enrichment/index.d.ts.map +1 -0
- package/dist/call-graph/enrichment/index.js +15 -0
- package/dist/call-graph/enrichment/index.js.map +1 -0
- package/dist/call-graph/enrichment/remediation-generator.d.ts +41 -0
- package/dist/call-graph/enrichment/remediation-generator.d.ts.map +1 -0
- package/dist/call-graph/enrichment/remediation-generator.js +609 -0
- package/dist/call-graph/enrichment/remediation-generator.js.map +1 -0
- package/dist/call-graph/enrichment/sensitivity-classifier.d.ts +71 -0
- package/dist/call-graph/enrichment/sensitivity-classifier.d.ts.map +1 -0
- package/dist/call-graph/enrichment/sensitivity-classifier.js +454 -0
- package/dist/call-graph/enrichment/sensitivity-classifier.js.map +1 -0
- package/dist/call-graph/enrichment/types.d.ts +402 -0
- package/dist/call-graph/enrichment/types.d.ts.map +1 -0
- package/dist/call-graph/enrichment/types.js +9 -0
- package/dist/call-graph/enrichment/types.js.map +1 -0
- package/dist/call-graph/extractors/base-extractor.d.ts +112 -0
- package/dist/call-graph/extractors/base-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/base-extractor.js +140 -0
- package/dist/call-graph/extractors/base-extractor.js.map +1 -0
- package/dist/call-graph/extractors/csharp-data-access-extractor.d.ts +76 -0
- package/dist/call-graph/extractors/csharp-data-access-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/csharp-data-access-extractor.js +387 -0
- package/dist/call-graph/extractors/csharp-data-access-extractor.js.map +1 -0
- package/dist/call-graph/extractors/csharp-extractor.d.ts +87 -0
- package/dist/call-graph/extractors/csharp-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/csharp-extractor.js +470 -0
- package/dist/call-graph/extractors/csharp-extractor.js.map +1 -0
- package/dist/call-graph/extractors/data-access-extractor.d.ts +76 -0
- package/dist/call-graph/extractors/data-access-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/data-access-extractor.js +234 -0
- package/dist/call-graph/extractors/data-access-extractor.js.map +1 -0
- package/dist/call-graph/extractors/index.d.ts +26 -0
- package/dist/call-graph/extractors/index.d.ts.map +1 -0
- package/dist/call-graph/extractors/index.js +36 -0
- package/dist/call-graph/extractors/index.js.map +1 -0
- package/dist/call-graph/extractors/java-data-access-extractor.d.ts +101 -0
- package/dist/call-graph/extractors/java-data-access-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/java-data-access-extractor.js +611 -0
- package/dist/call-graph/extractors/java-data-access-extractor.js.map +1 -0
- package/dist/call-graph/extractors/java-extractor.d.ts +87 -0
- package/dist/call-graph/extractors/java-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/java-extractor.js +510 -0
- package/dist/call-graph/extractors/java-extractor.js.map +1 -0
- package/dist/call-graph/extractors/php-data-access-extractor.d.ts +93 -0
- package/dist/call-graph/extractors/php-data-access-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/php-data-access-extractor.js +589 -0
- package/dist/call-graph/extractors/php-data-access-extractor.js.map +1 -0
- package/dist/call-graph/extractors/php-extractor.d.ts +104 -0
- package/dist/call-graph/extractors/php-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/php-extractor.js +619 -0
- package/dist/call-graph/extractors/php-extractor.js.map +1 -0
- package/dist/call-graph/extractors/python-data-access-extractor.d.ts +90 -0
- package/dist/call-graph/extractors/python-data-access-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/python-data-access-extractor.js +537 -0
- package/dist/call-graph/extractors/python-data-access-extractor.js.map +1 -0
- package/dist/call-graph/extractors/python-extractor.d.ts +98 -0
- package/dist/call-graph/extractors/python-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/python-extractor.js +681 -0
- package/dist/call-graph/extractors/python-extractor.js.map +1 -0
- package/dist/call-graph/extractors/semantic-data-access-scanner.d.ts +91 -0
- package/dist/call-graph/extractors/semantic-data-access-scanner.d.ts.map +1 -0
- package/dist/call-graph/extractors/semantic-data-access-scanner.js +498 -0
- package/dist/call-graph/extractors/semantic-data-access-scanner.js.map +1 -0
- package/dist/call-graph/extractors/typescript-data-access-extractor.d.ts +122 -0
- package/dist/call-graph/extractors/typescript-data-access-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/typescript-data-access-extractor.js +788 -0
- package/dist/call-graph/extractors/typescript-data-access-extractor.js.map +1 -0
- package/dist/call-graph/extractors/typescript-extractor.d.ts +145 -0
- package/dist/call-graph/extractors/typescript-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/typescript-extractor.js +904 -0
- package/dist/call-graph/extractors/typescript-extractor.js.map +1 -0
- package/dist/call-graph/index.d.ts +127 -0
- package/dist/call-graph/index.d.ts.map +1 -0
- package/dist/call-graph/index.js +247 -0
- package/dist/call-graph/index.js.map +1 -0
- package/dist/call-graph/store/call-graph-store.d.ts +70 -0
- package/dist/call-graph/store/call-graph-store.d.ts.map +1 -0
- package/dist/call-graph/store/call-graph-store.js +210 -0
- package/dist/call-graph/store/call-graph-store.js.map +1 -0
- package/dist/call-graph/store/index.d.ts +7 -0
- package/dist/call-graph/store/index.d.ts.map +1 -0
- package/dist/call-graph/store/index.js +7 -0
- package/dist/call-graph/store/index.js.map +1 -0
- package/dist/call-graph/types.d.ts +376 -0
- package/dist/call-graph/types.d.ts.map +1 -0
- package/dist/call-graph/types.js +8 -0
- package/dist/call-graph/types.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/lake/callgraph-shard-store.d.ts +168 -0
- package/dist/lake/callgraph-shard-store.d.ts.map +1 -0
- package/dist/lake/callgraph-shard-store.js +466 -0
- package/dist/lake/callgraph-shard-store.js.map +1 -0
- package/dist/lake/examples-store.d.ts +127 -0
- package/dist/lake/examples-store.d.ts.map +1 -0
- package/dist/lake/examples-store.js +389 -0
- package/dist/lake/examples-store.js.map +1 -0
- package/dist/lake/index-store.d.ts +82 -0
- package/dist/lake/index-store.d.ts.map +1 -0
- package/dist/lake/index-store.js +359 -0
- package/dist/lake/index-store.js.map +1 -0
- package/dist/lake/index.d.ts +93 -0
- package/dist/lake/index.d.ts.map +1 -0
- package/dist/lake/index.js +138 -0
- package/dist/lake/index.js.map +1 -0
- package/dist/lake/lake.bak/index-store.d.ts +82 -0
- package/dist/lake/lake.bak/index-store.d.ts.map +1 -0
- package/dist/lake/lake.bak/index-store.js +357 -0
- package/dist/lake/lake.bak/index-store.js.map +1 -0
- package/dist/lake/lake.bak/index.d.ts +81 -0
- package/dist/lake/lake.bak/index.d.ts.map +1 -0
- package/dist/lake/lake.bak/index.js +114 -0
- package/dist/lake/lake.bak/index.js.map +1 -0
- package/dist/lake/lake.bak/manifest-store.d.ts +51 -0
- package/dist/lake/lake.bak/manifest-store.d.ts.map +1 -0
- package/dist/lake/lake.bak/manifest-store.js +347 -0
- package/dist/lake/lake.bak/manifest-store.js.map +1 -0
- package/dist/lake/lake.bak/query-engine.d.ts +112 -0
- package/dist/lake/lake.bak/query-engine.d.ts.map +1 -0
- package/dist/lake/lake.bak/query-engine.js +370 -0
- package/dist/lake/lake.bak/query-engine.js.map +1 -0
- package/dist/lake/lake.bak/types.d.ts +428 -0
- package/dist/lake/lake.bak/types.d.ts.map +1 -0
- package/dist/lake/lake.bak/types.js +46 -0
- package/dist/lake/lake.bak/types.js.map +1 -0
- package/dist/lake/lake.bak/view-materializer.d.ts +70 -0
- package/dist/lake/lake.bak/view-materializer.d.ts.map +1 -0
- package/dist/lake/lake.bak/view-materializer.js +314 -0
- package/dist/lake/lake.bak/view-materializer.js.map +1 -0
- package/dist/lake/lake.bak/view-store.d.ts +57 -0
- package/dist/lake/lake.bak/view-store.d.ts.map +1 -0
- package/dist/lake/lake.bak/view-store.js +348 -0
- package/dist/lake/lake.bak/view-store.js.map +1 -0
- package/dist/lake/manifest-store.d.ts +51 -0
- package/dist/lake/manifest-store.d.ts.map +1 -0
- package/dist/lake/manifest-store.js +348 -0
- package/dist/lake/manifest-store.js.map +1 -0
- package/dist/lake/pattern-shard-store.d.ts +87 -0
- package/dist/lake/pattern-shard-store.d.ts.map +1 -0
- package/dist/lake/pattern-shard-store.js +347 -0
- package/dist/lake/pattern-shard-store.js.map +1 -0
- package/dist/lake/query-engine.d.ts +124 -0
- package/dist/lake/query-engine.d.ts.map +1 -0
- package/dist/lake/query-engine.js +453 -0
- package/dist/lake/query-engine.js.map +1 -0
- package/dist/lake/security-shard-store.d.ts +156 -0
- package/dist/lake/security-shard-store.d.ts.map +1 -0
- package/dist/lake/security-shard-store.js +498 -0
- package/dist/lake/security-shard-store.js.map +1 -0
- package/dist/lake/types.d.ts +428 -0
- package/dist/lake/types.d.ts.map +1 -0
- package/dist/lake/types.js +46 -0
- package/dist/lake/types.js.map +1 -0
- package/dist/lake/view-materializer.d.ts +70 -0
- package/dist/lake/view-materializer.d.ts.map +1 -0
- package/dist/lake/view-materializer.js +314 -0
- package/dist/lake/view-materializer.js.map +1 -0
- package/dist/lake/view-store.d.ts +57 -0
- package/dist/lake/view-store.d.ts.map +1 -0
- package/dist/lake/view-store.js +348 -0
- package/dist/lake/view-store.js.map +1 -0
- package/dist/parsers/tree-sitter/index.d.ts +1 -0
- package/dist/parsers/tree-sitter/index.d.ts.map +1 -1
- package/dist/parsers/tree-sitter/index.js +4 -0
- package/dist/parsers/tree-sitter/index.js.map +1 -1
- package/dist/parsers/tree-sitter/typescript-loader.d.ts +58 -0
- package/dist/parsers/tree-sitter/typescript-loader.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/typescript-loader.js +250 -0
- package/dist/parsers/tree-sitter/typescript-loader.js.map +1 -0
- package/dist/store/project-config.d.ts +154 -0
- package/dist/store/project-config.d.ts.map +1 -0
- package/dist/store/project-config.js +235 -0
- package/dist/store/project-config.js.map +1 -0
- package/dist/store/project-registry.d.ts +241 -0
- package/dist/store/project-registry.d.ts.map +1 -0
- package/dist/store/project-registry.js +557 -0
- package/dist/store/project-registry.js.map +1 -0
- package/package.json +4 -2
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Call Graph Demo Script
|
|
4
|
+
*
|
|
5
|
+
* Demonstrates the call-graph system's capabilities on a real Python codebase.
|
|
6
|
+
* Shows: extraction, graph building, reachability analysis, and data flow mapping.
|
|
7
|
+
*
|
|
8
|
+
* Run: node drift/packages/core/dist/call-graph/demo.js
|
|
9
|
+
*/
|
|
10
|
+
import { PythonCallGraphExtractor } from './extractors/python-extractor.js';
|
|
11
|
+
import { GraphBuilder } from './analysis/graph-builder.js';
|
|
12
|
+
import { ReachabilityEngine } from './analysis/reachability.js';
|
|
13
|
+
// ANSI colors for pretty output
|
|
14
|
+
const colors = {
|
|
15
|
+
reset: '\x1b[0m',
|
|
16
|
+
bright: '\x1b[1m',
|
|
17
|
+
dim: '\x1b[2m',
|
|
18
|
+
green: '\x1b[32m',
|
|
19
|
+
yellow: '\x1b[33m',
|
|
20
|
+
blue: '\x1b[34m',
|
|
21
|
+
magenta: '\x1b[35m',
|
|
22
|
+
cyan: '\x1b[36m',
|
|
23
|
+
red: '\x1b[31m',
|
|
24
|
+
};
|
|
25
|
+
function log(msg, color = colors.reset) {
|
|
26
|
+
console.log(`${color}${msg}${colors.reset}`);
|
|
27
|
+
}
|
|
28
|
+
function header(title) {
|
|
29
|
+
console.log('\n' + '═'.repeat(70));
|
|
30
|
+
log(` ${title}`, colors.bright + colors.cyan);
|
|
31
|
+
console.log('═'.repeat(70));
|
|
32
|
+
}
|
|
33
|
+
function subheader(title) {
|
|
34
|
+
console.log('\n' + '─'.repeat(50));
|
|
35
|
+
log(` ${title}`, colors.yellow);
|
|
36
|
+
console.log('─'.repeat(50));
|
|
37
|
+
}
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// Demo Data - Simulating what the Python extractor finds
|
|
40
|
+
// ============================================================================
|
|
41
|
+
/**
|
|
42
|
+
* Demo: Extract from real Python files
|
|
43
|
+
*/
|
|
44
|
+
function demoExtraction() {
|
|
45
|
+
header('🔍 STEP 1: EXTRACTION - What the system discovers');
|
|
46
|
+
const extractor = new PythonCallGraphExtractor();
|
|
47
|
+
// Sample Python code from account_service.py
|
|
48
|
+
const accountServiceCode = `
|
|
49
|
+
class AccountService:
|
|
50
|
+
"""Helper for account and membership lookups."""
|
|
51
|
+
|
|
52
|
+
def __init__(self):
|
|
53
|
+
self.client = get_supabase_service_client()
|
|
54
|
+
|
|
55
|
+
def get_primary_account_id(self, user_id: str) -> str:
|
|
56
|
+
result = self.client.table("users").select("primary_account_id").eq("id", user_id).execute()
|
|
57
|
+
if not result.data:
|
|
58
|
+
raise ValueError(f"User {user_id} has no profile record")
|
|
59
|
+
return result.data[0].get("primary_account_id")
|
|
60
|
+
|
|
61
|
+
def ensure_active_member(self, account_id: str, user_id: str) -> bool:
|
|
62
|
+
membership = self.client.table("account_members").select("role").eq("account_id", account_id).execute()
|
|
63
|
+
return bool(membership.data)
|
|
64
|
+
|
|
65
|
+
def set_clock_pin(self, user_id: str, pin: str) -> str:
|
|
66
|
+
pin_hash, salt_hex = self._derive_pin_hash(pin)
|
|
67
|
+
self.client.table("users").update({"clock_pin_hash": pin_hash}).eq("id", user_id).execute()
|
|
68
|
+
return timestamp
|
|
69
|
+
|
|
70
|
+
def lookup_user_by_pin(self, pin: str):
|
|
71
|
+
result = self.client.table("users").select("id, clock_pin_hash, clock_pin_salt").eq("clock_pin_lookup", lookup_hash).execute()
|
|
72
|
+
return result.data[0] if result.data else None
|
|
73
|
+
`;
|
|
74
|
+
const authRoutesCode = `
|
|
75
|
+
from fastapi import APIRouter, Depends
|
|
76
|
+
from services.account_service import AccountService
|
|
77
|
+
|
|
78
|
+
router = APIRouter()
|
|
79
|
+
|
|
80
|
+
@router.post("/register")
|
|
81
|
+
async def register_user(user_data: UserRegister, response: Response):
|
|
82
|
+
auth_response = supabase.auth.sign_up({"email": user_data.email, "password": user_data.password})
|
|
83
|
+
account_service = AccountService()
|
|
84
|
+
account_id, account_role = account_service.activate_invitation_by_token(invite_token, user_id=user_id, email=user.email)
|
|
85
|
+
jwt_token = create_jwt_token(user_id, account_id, account_role)
|
|
86
|
+
return {"user": {"id": user.id, "email": user.email}}
|
|
87
|
+
|
|
88
|
+
@router.post("/login")
|
|
89
|
+
async def login_user(credentials: UserLogin, response: Response):
|
|
90
|
+
auth_response = supabase.auth.sign_in_with_password({"email": credentials.email, "password": credentials.password})
|
|
91
|
+
account_service = AccountService()
|
|
92
|
+
account_id = account_service.get_primary_account_id(user_id)
|
|
93
|
+
return {"user": {"id": user.id}}
|
|
94
|
+
|
|
95
|
+
@router.get("/me")
|
|
96
|
+
async def get_current_user_profile(user_id: str = Depends(get_current_user)):
|
|
97
|
+
user_profile = service_client.table("users").select("subscription_tier").eq("id", user_id).execute()
|
|
98
|
+
return UserResponse(id=user.id, email=user.email)
|
|
99
|
+
`;
|
|
100
|
+
// Extract from account_service.py
|
|
101
|
+
subheader('Extracting: services/account_service.py');
|
|
102
|
+
const accountResult = extractor.extract(accountServiceCode, 'services/account_service.py');
|
|
103
|
+
log(`\n📦 Classes found: ${accountResult.classes.length}`, colors.green);
|
|
104
|
+
for (const cls of accountResult.classes) {
|
|
105
|
+
log(` • ${cls.name} (lines ${cls.startLine}-${cls.endLine})`, colors.dim);
|
|
106
|
+
log(` Methods: ${cls.methods.join(', ')}`, colors.dim);
|
|
107
|
+
}
|
|
108
|
+
log(`\n📋 Functions/Methods found: ${accountResult.functions.length}`, colors.green);
|
|
109
|
+
for (const func of accountResult.functions) {
|
|
110
|
+
const type = func.isConstructor ? '🔧 constructor' : func.isMethod ? '📎 method' : '📌 function';
|
|
111
|
+
log(` ${type} ${func.qualifiedName}`, colors.dim);
|
|
112
|
+
log(` Line ${func.startLine}, params: [${func.parameters.map(p => p.name).join(', ')}]`, colors.dim);
|
|
113
|
+
}
|
|
114
|
+
log(`\n📞 Calls discovered: ${accountResult.calls.length}`, colors.green);
|
|
115
|
+
const uniqueCalls = [...new Set(accountResult.calls.map(c => c.fullExpression))];
|
|
116
|
+
for (const call of uniqueCalls.slice(0, 10)) {
|
|
117
|
+
log(` • ${call}`, colors.dim);
|
|
118
|
+
}
|
|
119
|
+
if (uniqueCalls.length > 10) {
|
|
120
|
+
log(` ... and ${uniqueCalls.length - 10} more`, colors.dim);
|
|
121
|
+
}
|
|
122
|
+
// Extract from auth.py
|
|
123
|
+
subheader('Extracting: api/routes/auth.py');
|
|
124
|
+
const authResult = extractor.extract(authRoutesCode, 'api/routes/auth.py');
|
|
125
|
+
log(`\n📋 Functions found: ${authResult.functions.length}`, colors.green);
|
|
126
|
+
for (const func of authResult.functions) {
|
|
127
|
+
const decorators = func.decorators.length > 0 ? ` ${func.decorators[0]}` : '';
|
|
128
|
+
log(` 📌 ${func.name}${decorators}`, colors.dim);
|
|
129
|
+
}
|
|
130
|
+
log(`\n📥 Imports found: ${authResult.imports.length}`, colors.green);
|
|
131
|
+
for (const imp of authResult.imports) {
|
|
132
|
+
const names = imp.names.map(n => n.imported).join(', ');
|
|
133
|
+
log(` • from ${imp.source} import ${names}`, colors.dim);
|
|
134
|
+
}
|
|
135
|
+
return { accountResult, authResult };
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Demo: Build the call graph
|
|
139
|
+
*/
|
|
140
|
+
function demoBuildGraph(extractions) {
|
|
141
|
+
header('🏗️ STEP 2: GRAPH BUILDING - Connecting the dots');
|
|
142
|
+
const builder = new GraphBuilder({
|
|
143
|
+
projectRoot: '/project',
|
|
144
|
+
includeUnresolved: true,
|
|
145
|
+
minConfidence: 0.5,
|
|
146
|
+
});
|
|
147
|
+
// Add extractions
|
|
148
|
+
builder.addFile(extractions.accountResult);
|
|
149
|
+
builder.addFile(extractions.authResult);
|
|
150
|
+
// Simulate data access points (what the boundaries module would provide)
|
|
151
|
+
const dataAccessPoints = [
|
|
152
|
+
{ id: 'dap-1', file: 'services/account_service.py', line: 10, column: 0, table: 'users', fields: ['primary_account_id'], operation: 'read', confidence: 0.95, context: 'self.client.table("users").select(...)', isRawSql: false },
|
|
153
|
+
{ id: 'dap-2', file: 'services/account_service.py', line: 15, column: 0, table: 'account_members', fields: ['role'], operation: 'read', confidence: 0.95, context: 'self.client.table("account_members").select(...)', isRawSql: false },
|
|
154
|
+
{ id: 'dap-3', file: 'services/account_service.py', line: 20, column: 0, table: 'users', fields: ['clock_pin_hash'], operation: 'write', confidence: 0.95, context: 'self.client.table("users").update(...)', isRawSql: false },
|
|
155
|
+
{ id: 'dap-4', file: 'services/account_service.py', line: 25, column: 0, table: 'users', fields: ['id', 'clock_pin_hash', 'clock_pin_salt'], operation: 'read', confidence: 0.95, context: 'self.client.table("users").select(...)', isRawSql: false },
|
|
156
|
+
{ id: 'dap-5', file: 'api/routes/auth.py', line: 15, column: 0, table: 'users', fields: ['subscription_tier'], operation: 'read', confidence: 0.9, context: 'service_client.table("users").select(...)', isRawSql: false },
|
|
157
|
+
];
|
|
158
|
+
builder.addDataAccess('services/account_service.py', dataAccessPoints.filter(d => d.file.includes('account_service')));
|
|
159
|
+
builder.addDataAccess('api/routes/auth.py', dataAccessPoints.filter(d => d.file.includes('auth')));
|
|
160
|
+
const graph = builder.build();
|
|
161
|
+
subheader('Graph Statistics');
|
|
162
|
+
log(`\n📊 Total functions: ${graph.stats.totalFunctions}`, colors.green);
|
|
163
|
+
log(`📊 Total call sites: ${graph.stats.totalCallSites}`, colors.green);
|
|
164
|
+
log(`📊 Resolved calls: ${graph.stats.resolvedCallSites} (${Math.round(graph.stats.resolvedCallSites / graph.stats.totalCallSites * 100)}%)`, colors.green);
|
|
165
|
+
log(`📊 Data accessors: ${graph.stats.totalDataAccessors}`, colors.green);
|
|
166
|
+
subheader('Entry Points (API Routes)');
|
|
167
|
+
for (const entryId of graph.entryPoints) {
|
|
168
|
+
const func = graph.functions.get(entryId);
|
|
169
|
+
if (func) {
|
|
170
|
+
log(` 🚪 ${func.qualifiedName} @ ${func.file}:${func.startLine}`, colors.magenta);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
subheader('Data Accessors (Functions that touch the database)');
|
|
174
|
+
for (const accessorId of graph.dataAccessors) {
|
|
175
|
+
const func = graph.functions.get(accessorId);
|
|
176
|
+
if (func) {
|
|
177
|
+
const tables = [...new Set(func.dataAccess.map(d => d.table))];
|
|
178
|
+
log(` 💾 ${func.qualifiedName} → [${tables.join(', ')}]`, colors.blue);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
subheader('Call Graph Edges (Who calls whom)');
|
|
182
|
+
let edgeCount = 0;
|
|
183
|
+
for (const [, func] of graph.functions) {
|
|
184
|
+
for (const call of func.calls) {
|
|
185
|
+
if (call.resolved && call.calleeId) {
|
|
186
|
+
const callee = graph.functions.get(call.calleeId);
|
|
187
|
+
if (callee) {
|
|
188
|
+
log(` ${func.name} ──→ ${callee.name}`, colors.dim);
|
|
189
|
+
edgeCount++;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
log(`\n Total edges: ${edgeCount}`, colors.green);
|
|
195
|
+
return graph;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Demo: Reachability analysis
|
|
199
|
+
*/
|
|
200
|
+
function demoReachability(graph) {
|
|
201
|
+
header('🔎 STEP 3: REACHABILITY ANALYSIS - What data can code access?');
|
|
202
|
+
const engine = new ReachabilityEngine(graph);
|
|
203
|
+
subheader('Query: What data can the /login endpoint access?');
|
|
204
|
+
// Find the login function
|
|
205
|
+
let loginFunc;
|
|
206
|
+
for (const [, func] of graph.functions) {
|
|
207
|
+
if (func.name === 'login_user') {
|
|
208
|
+
loginFunc = func;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (loginFunc) {
|
|
213
|
+
const result = engine.getReachableDataFromFunction(loginFunc.id);
|
|
214
|
+
log(`\n🎯 Starting from: ${loginFunc.qualifiedName}`, colors.cyan);
|
|
215
|
+
log(`📍 Location: ${loginFunc.file}:${loginFunc.startLine}`, colors.dim);
|
|
216
|
+
log(`\n📊 Reachability Results:`, colors.green);
|
|
217
|
+
log(` Tables reachable: [${result.tables.join(', ')}]`, colors.yellow);
|
|
218
|
+
log(` Functions traversed: ${result.functionsTraversed}`, colors.dim);
|
|
219
|
+
log(` Max call depth: ${result.maxDepth}`, colors.dim);
|
|
220
|
+
if (result.sensitiveFields.length > 0) {
|
|
221
|
+
log(`\n⚠️ Sensitive Fields Accessible:`, colors.red);
|
|
222
|
+
for (const sf of result.sensitiveFields) {
|
|
223
|
+
log(` 🔐 ${sf.field.table}.${sf.field.field} (${sf.field.sensitivityType})`, colors.red);
|
|
224
|
+
log(` Access count: ${sf.accessCount}, via ${sf.paths.length} path(s)`, colors.dim);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (result.reachableAccess.length > 0) {
|
|
228
|
+
log(`\n📝 Data Access Points:`, colors.green);
|
|
229
|
+
for (const access of result.reachableAccess) {
|
|
230
|
+
const pathStr = access.path.map(p => p.functionName).join(' → ');
|
|
231
|
+
log(` ${access.access.table}.${access.access.fields.join(',')} (${access.access.operation})`, colors.blue);
|
|
232
|
+
log(` Path: ${pathStr}`, colors.dim);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
subheader('Inverse Query: Who can access users.clock_pin_hash?');
|
|
237
|
+
const inverseResult = engine.getCodePathsToData({
|
|
238
|
+
table: 'users',
|
|
239
|
+
field: 'clock_pin_hash',
|
|
240
|
+
});
|
|
241
|
+
log(`\n🎯 Target: users.clock_pin_hash`, colors.cyan);
|
|
242
|
+
log(`📊 Results:`, colors.green);
|
|
243
|
+
log(` Direct accessors: ${inverseResult.totalAccessors}`, colors.yellow);
|
|
244
|
+
log(` Entry points that can reach it: ${inverseResult.entryPoints.length}`, colors.yellow);
|
|
245
|
+
for (const path of inverseResult.accessPaths) {
|
|
246
|
+
const entryFunc = graph.functions.get(path.entryPoint);
|
|
247
|
+
if (entryFunc) {
|
|
248
|
+
log(`\n 🚪 Entry: ${entryFunc.qualifiedName}`, colors.magenta);
|
|
249
|
+
const pathStr = path.path.map(p => p.functionName).join(' → ');
|
|
250
|
+
log(` Path: ${pathStr}`, colors.dim);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Demo: Security implications
|
|
256
|
+
*/
|
|
257
|
+
function demoSecurityInsights(graph) {
|
|
258
|
+
header('🛡️ STEP 4: SECURITY INSIGHTS - What the system reveals');
|
|
259
|
+
// Engine available for additional queries if needed
|
|
260
|
+
const _engine = new ReachabilityEngine(graph);
|
|
261
|
+
void _engine; // Suppress unused warning
|
|
262
|
+
subheader('Sensitive Data Flow Analysis');
|
|
263
|
+
log(`\nThe call graph reveals:`, colors.green);
|
|
264
|
+
log(``, colors.reset);
|
|
265
|
+
log(`1. 🔐 PIN Authentication Flow:`, colors.yellow);
|
|
266
|
+
log(` /login → AccountService.get_primary_account_id → users table`, colors.dim);
|
|
267
|
+
log(` /register → AccountService.activate_invitation_by_token → account_members`, colors.dim);
|
|
268
|
+
log(``, colors.reset);
|
|
269
|
+
log(`2. 💾 Data Access Boundaries:`, colors.yellow);
|
|
270
|
+
log(` • AccountService can access: users, account_members`, colors.dim);
|
|
271
|
+
log(` • Auth routes can access: users (via AccountService)`, colors.dim);
|
|
272
|
+
log(``, colors.reset);
|
|
273
|
+
log(`3. ⚠️ Potential Security Concerns:`, colors.yellow);
|
|
274
|
+
log(` • clock_pin_hash accessible from public API endpoints`, colors.dim);
|
|
275
|
+
log(` • Multiple paths to sensitive user data`, colors.dim);
|
|
276
|
+
log(``, colors.reset);
|
|
277
|
+
log(`4. 📈 Blast Radius:`, colors.yellow);
|
|
278
|
+
log(` • A bug in AccountService affects: /login, /register, /me`, colors.dim);
|
|
279
|
+
log(` • users table is accessed by ${graph.dataAccessors.length} functions`, colors.dim);
|
|
280
|
+
subheader('What This Enables');
|
|
281
|
+
log(`\n✅ Security Finding Enrichment:`, colors.green);
|
|
282
|
+
log(` "Found SQL injection in account_service.py:25"`, colors.dim);
|
|
283
|
+
log(` → System adds: "Reachable from /login, /register endpoints"`, colors.cyan);
|
|
284
|
+
log(` → System adds: "Can access users.clock_pin_hash (credentials)"`, colors.cyan);
|
|
285
|
+
log(` → System adds: "Blast radius: 3 API endpoints, 2 tables"`, colors.cyan);
|
|
286
|
+
log(``, colors.reset);
|
|
287
|
+
log(`✅ Impact Scoring:`, colors.green);
|
|
288
|
+
log(` → Data sensitivity: HIGH (credentials)`, colors.cyan);
|
|
289
|
+
log(` → Exposure: PUBLIC (API endpoints)`, colors.cyan);
|
|
290
|
+
log(` → Priority: CRITICAL`, colors.cyan);
|
|
291
|
+
log(``, colors.reset);
|
|
292
|
+
log(`✅ Remediation Guidance:`, colors.green);
|
|
293
|
+
log(` → "Parameterize query in get_primary_account_id()"`, colors.cyan);
|
|
294
|
+
log(` → "Add input validation for user_id parameter"`, colors.cyan);
|
|
295
|
+
log(` → "Consider rate limiting on /login endpoint"`, colors.cyan);
|
|
296
|
+
}
|
|
297
|
+
// ============================================================================
|
|
298
|
+
// Main
|
|
299
|
+
// ============================================================================
|
|
300
|
+
function main() {
|
|
301
|
+
console.log('\n');
|
|
302
|
+
log('╔══════════════════════════════════════════════════════════════════════╗', colors.bright);
|
|
303
|
+
log('║ ║', colors.bright);
|
|
304
|
+
log('║ DRIFT CALL GRAPH SYSTEM - LIVE DEMONSTRATION ║', colors.bright);
|
|
305
|
+
log('║ ║', colors.bright);
|
|
306
|
+
log('║ Showing: Python code analysis, graph building, reachability ║', colors.bright);
|
|
307
|
+
log('║ ║', colors.bright);
|
|
308
|
+
log('╚══════════════════════════════════════════════════════════════════════╝', colors.bright);
|
|
309
|
+
try {
|
|
310
|
+
// Step 1: Extract
|
|
311
|
+
const extractions = demoExtraction();
|
|
312
|
+
// Step 2: Build graph
|
|
313
|
+
const graph = demoBuildGraph(extractions);
|
|
314
|
+
// Step 3: Reachability
|
|
315
|
+
demoReachability(graph);
|
|
316
|
+
// Step 4: Security insights
|
|
317
|
+
demoSecurityInsights(graph);
|
|
318
|
+
header('✨ SUMMARY');
|
|
319
|
+
log(`\nThe call-graph system provides:`, colors.green);
|
|
320
|
+
log(``, colors.reset);
|
|
321
|
+
log(` 1. 🔍 Automatic extraction of functions, calls, and imports`, colors.cyan);
|
|
322
|
+
log(` 2. 🏗️ Graph construction with call resolution`, colors.cyan);
|
|
323
|
+
log(` 3. 🔎 Forward reachability: "What data can this code access?"`, colors.cyan);
|
|
324
|
+
log(` 4. 🔄 Inverse reachability: "Who can access this data?"`, colors.cyan);
|
|
325
|
+
log(` 5. 🛡️ Security enrichment: blast radius, sensitivity, priority`, colors.cyan);
|
|
326
|
+
log(``, colors.reset);
|
|
327
|
+
log(`This enables AI agents to understand the IMPACT of security findings,`, colors.yellow);
|
|
328
|
+
log(`not just their location. A finding in a utility function that's called`, colors.yellow);
|
|
329
|
+
log(`by 50 API endpoints is very different from one in dead code.`, colors.yellow);
|
|
330
|
+
console.log('\n');
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
log(`\n❌ Error: ${error}`, colors.red);
|
|
334
|
+
console.error(error);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
// Run if executed directly
|
|
338
|
+
main();
|
|
339
|
+
//# sourceMappingURL=demo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.js","sourceRoot":"","sources":["../../src/call-graph/demo.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIhE,gCAAgC;AAChC,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,SAAS;IACd,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,UAAU;CAChB,CAAC;AAEF,SAAS,GAAG,CAAC,GAAW,EAAE,KAAK,GAAG,MAAM,CAAC,KAAK;IAC5C,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,GAAG,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,C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vF,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACtB,GAAG,CAAC,uEAAuE,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5F,GAAG,CAAC,wEAAwE,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7F,GAAG,CAAC,8DAA8D,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACnF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,cAAc,KAAK,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;QACvC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,2BAA2B;AAC3B,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enrichment Engine
|
|
3
|
+
*
|
|
4
|
+
* Enterprise-grade security finding enrichment.
|
|
5
|
+
* Transforms raw vulnerability findings into actionable intelligence
|
|
6
|
+
* by connecting them to their actual data impact through call graph analysis.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const engine = new EnrichmentEngine(callGraph, boundaryStore);
|
|
11
|
+
*
|
|
12
|
+
* // Enrich a single finding
|
|
13
|
+
* const enriched = await engine.enrich(finding);
|
|
14
|
+
* console.log(enriched.dataImpact.sensitiveFields);
|
|
15
|
+
* console.log(enriched.priority.tier); // 'P0' | 'P1' | 'P2' | 'P3' | 'P4'
|
|
16
|
+
*
|
|
17
|
+
* // Batch enrich with summary
|
|
18
|
+
* const result = await engine.enrichBatch(findings);
|
|
19
|
+
* console.log(result.summary.byPriority);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import type { CallGraph } from '../types.js';
|
|
23
|
+
import type { DataAccessPoint, SensitiveField } from '../../boundaries/types.js';
|
|
24
|
+
import type { SecurityFinding, EnrichedFinding, EnrichmentOptions, EnrichmentResult } from './types.js';
|
|
25
|
+
/**
|
|
26
|
+
* Enterprise-grade security finding enrichment engine
|
|
27
|
+
*/
|
|
28
|
+
export declare class EnrichmentEngine {
|
|
29
|
+
private readonly graph;
|
|
30
|
+
private readonly reachability;
|
|
31
|
+
private readonly classifier;
|
|
32
|
+
private readonly scorer;
|
|
33
|
+
private readonly remediator;
|
|
34
|
+
private readonly dataAccessByFile;
|
|
35
|
+
private readonly sensitiveFields;
|
|
36
|
+
constructor(graph: CallGraph, dataAccessPoints?: DataAccessPoint[], sensitiveFields?: SensitiveField[]);
|
|
37
|
+
/**
|
|
38
|
+
* Enrich a single security finding
|
|
39
|
+
*/
|
|
40
|
+
enrich(finding: SecurityFinding, options?: EnrichmentOptions): Promise<EnrichedFinding>;
|
|
41
|
+
/**
|
|
42
|
+
* Enrich multiple findings with summary statistics
|
|
43
|
+
*/
|
|
44
|
+
enrichBatch(findings: SecurityFinding[], options?: EnrichmentOptions): Promise<EnrichmentResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Analyze data impact for a finding
|
|
47
|
+
*/
|
|
48
|
+
private analyzeDataImpact;
|
|
49
|
+
/**
|
|
50
|
+
* Analyze blast radius for a finding
|
|
51
|
+
*/
|
|
52
|
+
private analyzeBlastRadius;
|
|
53
|
+
/**
|
|
54
|
+
* Find entry points that can reach a function
|
|
55
|
+
*/
|
|
56
|
+
private findEntryPointsToFunction;
|
|
57
|
+
/**
|
|
58
|
+
* Find path between two functions using BFS
|
|
59
|
+
*/
|
|
60
|
+
private findPath;
|
|
61
|
+
/**
|
|
62
|
+
* Find functions affected by a vulnerability
|
|
63
|
+
*/
|
|
64
|
+
private findAffectedFunctions;
|
|
65
|
+
/**
|
|
66
|
+
* Find the function containing a location
|
|
67
|
+
*/
|
|
68
|
+
private findContainingFunction;
|
|
69
|
+
/**
|
|
70
|
+
* Classify entry point type based on decorators and patterns
|
|
71
|
+
*/
|
|
72
|
+
private classifyEntryPointType;
|
|
73
|
+
/**
|
|
74
|
+
* Check if entry point is publicly accessible
|
|
75
|
+
*/
|
|
76
|
+
private isPublicEntryPoint;
|
|
77
|
+
/**
|
|
78
|
+
* Check if entry point requires authentication
|
|
79
|
+
*/
|
|
80
|
+
private requiresAuthentication;
|
|
81
|
+
/**
|
|
82
|
+
* Calculate lines of code in affected functions
|
|
83
|
+
*/
|
|
84
|
+
private calculateLinesOfCode;
|
|
85
|
+
/**
|
|
86
|
+
* Calculate impact score for a single data access
|
|
87
|
+
*/
|
|
88
|
+
private calculateAccessImpactScore;
|
|
89
|
+
/**
|
|
90
|
+
* Build impact rationale string
|
|
91
|
+
*/
|
|
92
|
+
private buildImpactRationale;
|
|
93
|
+
/**
|
|
94
|
+
* Calculate overall confidence in enrichment
|
|
95
|
+
*/
|
|
96
|
+
private calculateConfidence;
|
|
97
|
+
/**
|
|
98
|
+
* Build summary statistics for batch enrichment
|
|
99
|
+
*/
|
|
100
|
+
private buildSummary;
|
|
101
|
+
/**
|
|
102
|
+
* Get base severity score
|
|
103
|
+
*/
|
|
104
|
+
private getBaseSeverityScore;
|
|
105
|
+
/**
|
|
106
|
+
* Get base priority tier from severity
|
|
107
|
+
*/
|
|
108
|
+
private getBaseTier;
|
|
109
|
+
/**
|
|
110
|
+
* Create empty data impact
|
|
111
|
+
*/
|
|
112
|
+
private createEmptyDataImpact;
|
|
113
|
+
/**
|
|
114
|
+
* Create empty blast radius
|
|
115
|
+
*/
|
|
116
|
+
private createEmptyBlastRadius;
|
|
117
|
+
/**
|
|
118
|
+
* Create empty remediation
|
|
119
|
+
*/
|
|
120
|
+
private createEmptyRemediation;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Create a new enrichment engine
|
|
124
|
+
*/
|
|
125
|
+
export declare function createEnrichmentEngine(graph: CallGraph, dataAccessPoints?: DataAccessPoint[], sensitiveFields?: SensitiveField[]): EnrichmentEngine;
|
|
126
|
+
//# sourceMappingURL=enrichment-engine.d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