@dataparade/cli 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/package.json +1 -1
- package/dist/src/ai-enrichment/lambda-init-error.d.ts +5 -0
- package/dist/src/ai-enrichment/lambda-init-error.js +38 -0
- package/dist/src/ai-enrichment/providers/platform-proxy-provider.d.ts +5 -0
- package/dist/src/ai-enrichment/providers/platform-proxy-provider.js +27 -1
- package/dist/src/analyzers/cpp/cpp-detection-config.d.ts +73 -0
- package/dist/src/analyzers/cpp/cpp-detection-config.js +137 -0
- package/dist/src/analyzers/cpp/dependency-manifests.d.ts +8 -0
- package/dist/src/analyzers/cpp/dependency-manifests.js +130 -0
- package/dist/src/analyzers/cpp/detector.d.ts +3 -0
- package/dist/src/analyzers/cpp/detector.js +21 -0
- package/dist/src/analyzers/cpp/index.d.ts +2 -0
- package/dist/src/analyzers/cpp/index.js +11 -0
- package/dist/src/analyzers/cpp/manifest-parsers.d.ts +13 -0
- package/dist/src/analyzers/cpp/manifest-parsers.js +104 -0
- package/dist/src/analyzers/cpp/parser.d.ts +35 -0
- package/dist/src/analyzers/cpp/parser.js +206 -0
- package/dist/src/analyzers/cpp/patterns.d.ts +3 -0
- package/dist/src/analyzers/cpp/patterns.js +37 -0
- package/dist/src/analyzers/csharp/csharp-detection-config.d.ts +100 -0
- package/dist/src/analyzers/csharp/csharp-detection-config.js +160 -0
- package/dist/src/analyzers/csharp/dependency-manifests.d.ts +13 -0
- package/dist/src/analyzers/csharp/dependency-manifests.js +184 -0
- package/dist/src/analyzers/csharp/detector.d.ts +3 -0
- package/dist/src/analyzers/csharp/detector.js +21 -0
- package/dist/src/analyzers/csharp/index.d.ts +2 -0
- package/dist/src/analyzers/csharp/index.js +11 -0
- package/dist/src/analyzers/csharp/manifest-parsers.d.ts +34 -0
- package/dist/src/analyzers/csharp/manifest-parsers.js +130 -0
- package/dist/src/analyzers/csharp/parser.d.ts +48 -0
- package/dist/src/analyzers/csharp/parser.js +277 -0
- package/dist/src/analyzers/csharp/patterns.d.ts +3 -0
- package/dist/src/analyzers/csharp/patterns.js +57 -0
- package/dist/src/analyzers/go/dependency-manifests.d.ts +10 -0
- package/dist/src/analyzers/go/dependency-manifests.js +117 -0
- package/dist/src/analyzers/go/detector.d.ts +3 -0
- package/dist/src/analyzers/go/detector.js +21 -0
- package/dist/src/analyzers/go/go-detection-config.d.ts +97 -0
- package/dist/src/analyzers/go/go-detection-config.js +164 -0
- package/dist/src/analyzers/go/index.d.ts +2 -0
- package/dist/src/analyzers/go/index.js +11 -0
- package/dist/src/analyzers/go/manifest-parsers.d.ts +20 -0
- package/dist/src/analyzers/go/manifest-parsers.js +104 -0
- package/dist/src/analyzers/go/parser.d.ts +40 -0
- package/dist/src/analyzers/go/parser.js +186 -0
- package/dist/src/analyzers/go/patterns.d.ts +3 -0
- package/dist/src/analyzers/go/patterns.js +50 -0
- package/dist/src/analyzers/jvm/dependency-manifests.d.ts +16 -0
- package/dist/src/analyzers/jvm/dependency-manifests.js +205 -0
- package/dist/src/analyzers/jvm/detector.d.ts +3 -0
- package/dist/src/analyzers/jvm/detector.js +21 -0
- package/dist/src/analyzers/jvm/index.d.ts +9 -0
- package/dist/src/analyzers/jvm/index.js +18 -0
- package/dist/src/analyzers/jvm/jvm-detection-config.d.ts +136 -0
- package/dist/src/analyzers/jvm/jvm-detection-config.js +195 -0
- package/dist/src/analyzers/jvm/manifest-parsers.d.ts +61 -0
- package/dist/src/analyzers/jvm/manifest-parsers.js +246 -0
- package/dist/src/analyzers/jvm/parser.d.ts +54 -0
- package/dist/src/analyzers/jvm/parser.js +419 -0
- package/dist/src/analyzers/jvm/patterns.d.ts +3 -0
- package/dist/src/analyzers/jvm/patterns.js +64 -0
- package/dist/src/analyzers/python/detector.js +1 -1
- package/dist/src/analyzers/python/parser.d.ts +1 -0
- package/dist/src/analyzers/python/parser.js +7 -0
- package/dist/src/analyzers/python/patterns.d.ts +1 -0
- package/dist/src/analyzers/python/patterns.js +22 -77
- package/dist/src/analyzers/python/python-detection-config.d.ts +18 -0
- package/dist/src/analyzers/python/python-detection-config.js +20 -0
- package/dist/src/analyzers/registry.js +15 -0
- package/dist/src/analyzers/shared/c-family-calls.d.ts +26 -0
- package/dist/src/analyzers/shared/c-family-calls.js +118 -0
- package/dist/src/analyzers/shared/strip-comments.d.ts +32 -0
- package/dist/src/analyzers/shared/strip-comments.js +167 -0
- package/dist/src/analyzers/typescript/detector.js +1 -1
- package/dist/src/analyzers/typescript/typescript-detection-config.d.ts +37 -0
- package/dist/src/analyzers/typescript/typescript-detection-config.js +48 -0
- package/dist/src/analyzers/typescript/typescript-detection.d.ts +1 -0
- package/dist/src/analyzers/typescript/typescript-detection.js +27 -29
- package/dist/src/cli.js +28 -1
- package/dist/src/config/file.js +5 -0
- package/dist/src/config/resolve.js +5 -0
- package/dist/src/core/pipeline/graph-mapping.js +3 -0
- package/dist/src/core/pipeline/structural-scan.js +154 -31
- package/dist/src/core/schema/scan-config.schema.d.ts +5 -0
- package/dist/src/core/schema/scan-config.schema.js +5 -0
- package/dist/src/core/schema/scan-result.schema.d.ts +5 -0
- package/dist/src/core/schema/scan-result.schema.js +5 -0
- package/dist/src/core/sectioning/discover-service-sections.js +27 -1
- package/dist/src/core/types/file.d.ts +1 -1
- package/dist/src/ingest/file-system.js +27 -0
- package/dist/src/patterns/config.d.ts +8 -0
- package/dist/src/patterns/config.js +136 -0
- package/dist/src/patterns/detectors/cpp.d.ts +8 -0
- package/dist/src/patterns/detectors/cpp.js +243 -0
- package/dist/src/patterns/detectors/csharp.d.ts +9 -0
- package/dist/src/patterns/detectors/csharp.js +385 -0
- package/dist/src/patterns/detectors/go.d.ts +9 -0
- package/dist/src/patterns/detectors/go.js +298 -0
- package/dist/src/patterns/detectors/helpers.d.ts +3 -0
- package/dist/src/patterns/detectors/helpers.js +5 -0
- package/dist/src/patterns/detectors/jvm.d.ts +15 -0
- package/dist/src/patterns/detectors/jvm.js +537 -0
- package/dist/src/patterns/detectors/python.d.ts +1 -0
- package/dist/src/patterns/detectors/python.js +92 -5
- package/dist/src/patterns/detectors/typescript.d.ts +2 -0
- package/dist/src/patterns/detectors/typescript.js +156 -4
- package/dist/src/patterns/engine.d.ts +18 -0
- package/dist/src/patterns/engine.js +30 -0
- package/dist/src/patterns/scan-exclusions.js +20 -0
- package/dist/src/platform-api/telemetry-client.d.ts +6 -0
- package/dist/src/platform-api/telemetry-client.js +65 -0
- package/dist/src/platform-api/telemetry.types.d.ts +13 -0
- package/dist/src/platform-api/telemetry.types.js +2 -0
- package/dist/src/platform-api/upload-client.d.ts +2 -0
- package/dist/src/platform-api/upload-client.js +4 -0
- package/dist/src/platform-api/upload.types.d.ts +2 -0
- package/dist/src/upload/build-preview-url.d.ts +2 -2
- package/dist/src/upload/build-preview-url.js +10 -3
- package/dist/src/upload/run-upload.js +62 -19
- package/dist/src/upload/types.d.ts +2 -0
- package/dist/tests/unit/ai-enrichment/lambda-init-error.spec.d.ts +1 -0
- package/dist/tests/unit/ai-enrichment/lambda-init-error.spec.js +11 -0
- package/dist/tests/unit/ai-enrichment/platform-proxy-provider.spec.js +80 -0
- package/dist/tests/unit/analyzers/cpp/dependency-manifests.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/cpp/dependency-manifests.spec.js +66 -0
- package/dist/tests/unit/analyzers/cpp/parser.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/cpp/parser.spec.js +80 -0
- package/dist/tests/unit/analyzers/cpp/patterns.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/cpp/patterns.spec.js +141 -0
- package/dist/tests/unit/analyzers/csharp/dependency-manifests.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/csharp/dependency-manifests.spec.js +75 -0
- package/dist/tests/unit/analyzers/csharp/parser.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/csharp/parser.spec.js +118 -0
- package/dist/tests/unit/analyzers/csharp/patterns.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/csharp/patterns.spec.js +210 -0
- package/dist/tests/unit/analyzers/go/dependency-manifests.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/go/dependency-manifests.spec.js +96 -0
- package/dist/tests/unit/analyzers/go/parser.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/go/parser.spec.js +110 -0
- package/dist/tests/unit/analyzers/go/patterns.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/go/patterns.spec.js +239 -0
- package/dist/tests/unit/analyzers/jvm/dependency-manifests.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/jvm/dependency-manifests.spec.js +179 -0
- package/dist/tests/unit/analyzers/jvm/parser.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/jvm/parser.spec.js +195 -0
- package/dist/tests/unit/analyzers/jvm/patterns.spec.d.ts +1 -0
- package/dist/tests/unit/analyzers/jvm/patterns.spec.js +284 -0
- package/dist/tests/unit/analyzers/python/patterns.spec.js +169 -0
- package/dist/tests/unit/analyzers/typescript/detector.spec.js +188 -0
- package/dist/tests/unit/core/cpp-dotnet-scan.spec.d.ts +1 -0
- package/dist/tests/unit/core/cpp-dotnet-scan.spec.js +67 -0
- package/dist/tests/unit/core/cpp-dotnet-sections.spec.d.ts +1 -0
- package/dist/tests/unit/core/cpp-dotnet-sections.spec.js +46 -0
- package/dist/tests/unit/core/go-scan.spec.d.ts +1 -0
- package/dist/tests/unit/core/go-scan.spec.js +78 -0
- package/dist/tests/unit/core/graph-mapping.spec.js +75 -0
- package/dist/tests/unit/core/jvm-scan.spec.d.ts +1 -0
- package/dist/tests/unit/core/jvm-scan.spec.js +94 -0
- package/dist/tests/unit/ingest/cpp-dotnet-languages.spec.d.ts +1 -0
- package/dist/tests/unit/ingest/cpp-dotnet-languages.spec.js +56 -0
- package/dist/tests/unit/ingest/jvm-languages.spec.d.ts +1 -0
- package/dist/tests/unit/ingest/jvm-languages.spec.js +47 -0
- package/dist/tests/unit/platform-api/telemetry-client.spec.d.ts +1 -0
- package/dist/tests/unit/platform-api/telemetry-client.spec.js +48 -0
- package/dist/tests/unit/upload/build-preview-url.spec.js +10 -0
- package/dist/tests/unit/upload/run-upload.spec.js +18 -0
- package/package.json +1 -1
- package/patterns/cpp.md +176 -0
- package/patterns/cpp.patterns.yaml +314 -0
- package/patterns/csharp.md +211 -0
- package/patterns/csharp.patterns.yaml +375 -0
- package/patterns/go.md +211 -0
- package/patterns/go.patterns.yaml +429 -0
- package/patterns/jvm.md +160 -0
- package/patterns/jvm.patterns.yaml +884 -0
- package/patterns/python.patterns.yaml +177 -0
- package/patterns/third-party.patterns.yaml +5 -0
- package/patterns/typescript.patterns.yaml +222 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Dependency extraction for JVM build manifests.
|
|
4
|
+
*
|
|
5
|
+
* Covers Maven (`pom.xml`), Gradle in both the Groovy and Kotlin DSLs
|
|
6
|
+
* (`build.gradle`, `build.gradle.kts`), and Gradle version catalogs
|
|
7
|
+
* (`gradle/libs.versions.toml`).
|
|
8
|
+
*
|
|
9
|
+
* All three normalize to a Maven coordinate — `groupId:artifactId`, version
|
|
10
|
+
* dropped. Unlike Go, that token is *not* what appears in an `import`
|
|
11
|
+
* statement (`org.springframework.boot:spring-boot-starter-data-jpa` versus
|
|
12
|
+
* `org.springframework.data.jpa.repository`), which is why JVM rules carry
|
|
13
|
+
* `packageCoordinates` separately from `importPackages`.
|
|
14
|
+
*/
|
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.extractCoordinatesFromPom = extractCoordinatesFromPom;
|
|
20
|
+
exports.extractCoordinatesFromGradle = extractCoordinatesFromGradle;
|
|
21
|
+
exports.extractCoordinatesFromVersionCatalog = extractCoordinatesFromVersionCatalog;
|
|
22
|
+
exports.driverTokenFromUri = driverTokenFromUri;
|
|
23
|
+
exports.extractDatasourceRefsFromProperties = extractDatasourceRefsFromProperties;
|
|
24
|
+
exports.extractDatasourceRefsFromYaml = extractDatasourceRefsFromYaml;
|
|
25
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
26
|
+
/**
|
|
27
|
+
* Gradle configurations that put a dependency into the running application.
|
|
28
|
+
*
|
|
29
|
+
* Test configurations are absent by construction rather than filtered: they
|
|
30
|
+
* are spelled `testImplementation`, `androidTestImplementation`, and so on,
|
|
31
|
+
* so the capitalised infix means the `\b`-anchored lowercase names below
|
|
32
|
+
* cannot match them. That keeps the test harness out of the service graph.
|
|
33
|
+
*/
|
|
34
|
+
const GRADLE_DEPENDENCY_CONFIGURATIONS = [
|
|
35
|
+
"implementation",
|
|
36
|
+
"api",
|
|
37
|
+
"compileOnly",
|
|
38
|
+
"compileOnlyApi",
|
|
39
|
+
"runtimeOnly",
|
|
40
|
+
"developmentOnly",
|
|
41
|
+
"annotationProcessor",
|
|
42
|
+
"kapt",
|
|
43
|
+
"ksp",
|
|
44
|
+
"classpath",
|
|
45
|
+
"compile",
|
|
46
|
+
"providedRuntime",
|
|
47
|
+
].join("|");
|
|
48
|
+
/** Wrappers a coordinate may sit inside: `implementation(platform("g:a:v"))`. */
|
|
49
|
+
const GRADLE_COORDINATE_WRAPPERS = "platform|enforcedPlatform|testFixtures";
|
|
50
|
+
function normalizeCoordinate(groupId, artifactId) {
|
|
51
|
+
const group = groupId?.trim();
|
|
52
|
+
const artifact = artifactId?.trim();
|
|
53
|
+
if (!group || !artifact)
|
|
54
|
+
return null;
|
|
55
|
+
// Reject unresolved Maven/Gradle property placeholders (`${spring.group}`).
|
|
56
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(group))
|
|
57
|
+
return null;
|
|
58
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(artifact))
|
|
59
|
+
return null;
|
|
60
|
+
return `${group}:${artifact}`;
|
|
61
|
+
}
|
|
62
|
+
function firstTagValue(block, tag) {
|
|
63
|
+
const match = block.match(new RegExp(`<${tag}>([^<]*)</${tag}>`));
|
|
64
|
+
return match?.[1];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Maven `pom.xml`. The `<parent>` coordinate is included: on Spring Boot
|
|
68
|
+
* projects it is `spring-boot-starter-parent`, which is often the clearest
|
|
69
|
+
* statement of what the module is.
|
|
70
|
+
*/
|
|
71
|
+
function extractCoordinatesFromPom(content) {
|
|
72
|
+
const coordinates = new Set();
|
|
73
|
+
const parentMatch = content.match(/<parent>([\s\S]*?)<\/parent>/);
|
|
74
|
+
if (parentMatch) {
|
|
75
|
+
const coordinate = normalizeCoordinate(firstTagValue(parentMatch[1], "groupId"), firstTagValue(parentMatch[1], "artifactId"));
|
|
76
|
+
if (coordinate)
|
|
77
|
+
coordinates.add(coordinate);
|
|
78
|
+
}
|
|
79
|
+
const dependencyRegex = /<dependency>([\s\S]*?)<\/dependency>/g;
|
|
80
|
+
let match;
|
|
81
|
+
while ((match = dependencyRegex.exec(content)) !== null) {
|
|
82
|
+
const block = match[1];
|
|
83
|
+
// Test-scoped dependencies describe the test harness, not the service.
|
|
84
|
+
const scope = firstTagValue(block, "scope");
|
|
85
|
+
if (scope && scope.trim().toLowerCase() === "test")
|
|
86
|
+
continue;
|
|
87
|
+
const coordinate = normalizeCoordinate(firstTagValue(block, "groupId"), firstTagValue(block, "artifactId"));
|
|
88
|
+
if (coordinate)
|
|
89
|
+
coordinates.add(coordinate);
|
|
90
|
+
}
|
|
91
|
+
return Array.from(coordinates);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Gradle build scripts, Groovy and Kotlin DSL alike:
|
|
95
|
+
*
|
|
96
|
+
* implementation 'org.postgresql:postgresql:42.7.1'
|
|
97
|
+
* implementation("org.postgresql:postgresql:42.7.1")
|
|
98
|
+
* implementation group: 'org.postgresql', name: 'postgresql'
|
|
99
|
+
*
|
|
100
|
+
* Version-catalog references (`implementation(libs.spring.boot.web)`) carry no
|
|
101
|
+
* coordinate here; they resolve from `gradle/libs.versions.toml` instead.
|
|
102
|
+
*/
|
|
103
|
+
function extractCoordinatesFromGradle(content) {
|
|
104
|
+
const coordinates = new Set();
|
|
105
|
+
const stringNotation = new RegExp(`\\b(?:${GRADLE_DEPENDENCY_CONFIGURATIONS})\\s*\\(?\\s*(?:(?:${GRADLE_COORDINATE_WRAPPERS})\\s*\\(\\s*)?["']([^"']+)["']`, "g");
|
|
106
|
+
const mapNotation = new RegExp(`\\b(?:${GRADLE_DEPENDENCY_CONFIGURATIONS})\\s*\\(?\\s*group\\s*[:=]\\s*["']([^"']+)["']\\s*,\\s*name\\s*[:=]\\s*["']([^"']+)["']`, "g");
|
|
107
|
+
let match;
|
|
108
|
+
while ((match = mapNotation.exec(content)) !== null) {
|
|
109
|
+
const coordinate = normalizeCoordinate(match[1], match[2]);
|
|
110
|
+
if (coordinate)
|
|
111
|
+
coordinates.add(coordinate);
|
|
112
|
+
}
|
|
113
|
+
while ((match = stringNotation.exec(content)) !== null) {
|
|
114
|
+
const segments = match[1].split(":");
|
|
115
|
+
if (segments.length < 2)
|
|
116
|
+
continue;
|
|
117
|
+
const coordinate = normalizeCoordinate(segments[0], segments[1]);
|
|
118
|
+
if (coordinate)
|
|
119
|
+
coordinates.add(coordinate);
|
|
120
|
+
}
|
|
121
|
+
return Array.from(coordinates);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Gradle version catalog (`gradle/libs.versions.toml`), `[libraries]` section:
|
|
125
|
+
*
|
|
126
|
+
* postgres = { module = "org.postgresql:postgresql", version.ref = "pg" }
|
|
127
|
+
* jedis = { group = "redis.clients", name = "jedis" }
|
|
128
|
+
*/
|
|
129
|
+
function extractCoordinatesFromVersionCatalog(content) {
|
|
130
|
+
const coordinates = new Set();
|
|
131
|
+
let inLibraries = false;
|
|
132
|
+
for (const rawLine of content.split(/\r?\n/)) {
|
|
133
|
+
const line = rawLine.trim();
|
|
134
|
+
if (!line || line.startsWith("#"))
|
|
135
|
+
continue;
|
|
136
|
+
if (line.startsWith("[")) {
|
|
137
|
+
inLibraries = line === "[libraries]";
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (!inLibraries)
|
|
141
|
+
continue;
|
|
142
|
+
const moduleMatch = line.match(/\bmodule\s*=\s*"([^"]+)"/);
|
|
143
|
+
if (moduleMatch) {
|
|
144
|
+
const segments = moduleMatch[1].split(":");
|
|
145
|
+
const coordinate = normalizeCoordinate(segments[0], segments[1]);
|
|
146
|
+
if (coordinate)
|
|
147
|
+
coordinates.add(coordinate);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const groupMatch = line.match(/\bgroup\s*=\s*"([^"]+)"/);
|
|
151
|
+
const nameMatch = line.match(/\bname\s*=\s*"([^"]+)"/);
|
|
152
|
+
if (groupMatch && nameMatch) {
|
|
153
|
+
const coordinate = normalizeCoordinate(groupMatch[1], nameMatch[1]);
|
|
154
|
+
if (coordinate)
|
|
155
|
+
coordinates.add(coordinate);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return Array.from(coordinates);
|
|
159
|
+
}
|
|
160
|
+
const DATASOURCE_KEY_REGEX = /(^|\.)(url|uri|jdbc-url|jdbcUrl|contact-points|contactPoints|uris|host)$/;
|
|
161
|
+
/**
|
|
162
|
+
* Read the engine out of a Spring datasource URI.
|
|
163
|
+
*
|
|
164
|
+
* Only the driver token is returned. These values routinely embed credentials
|
|
165
|
+
* (`jdbc:postgresql://user:password@host/db`), so the URI itself never leaves
|
|
166
|
+
* this function.
|
|
167
|
+
*/
|
|
168
|
+
function driverTokenFromUri(value) {
|
|
169
|
+
const trimmed = value.trim();
|
|
170
|
+
const jdbcMatch = trimmed.match(/^(?:jdbc|r2dbc):([a-z0-9]+):/i);
|
|
171
|
+
if (jdbcMatch)
|
|
172
|
+
return jdbcMatch[1].toLowerCase();
|
|
173
|
+
const schemeMatch = trimmed.match(/^([a-z][a-z0-9+.-]*):\/\//i);
|
|
174
|
+
if (schemeMatch) {
|
|
175
|
+
const scheme = schemeMatch[1].toLowerCase();
|
|
176
|
+
if (scheme === "mongodb+srv")
|
|
177
|
+
return "mongodb";
|
|
178
|
+
return scheme;
|
|
179
|
+
}
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
/** `application.properties` — flat `key=value` lines. */
|
|
183
|
+
function extractDatasourceRefsFromProperties(content) {
|
|
184
|
+
const refs = [];
|
|
185
|
+
for (const rawLine of content.split(/\r?\n/)) {
|
|
186
|
+
const line = rawLine.trim();
|
|
187
|
+
if (!line || line.startsWith("#") || line.startsWith("!"))
|
|
188
|
+
continue;
|
|
189
|
+
const separatorIndex = line.search(/[=:]/);
|
|
190
|
+
if (separatorIndex === -1)
|
|
191
|
+
continue;
|
|
192
|
+
const key = line.slice(0, separatorIndex).trim();
|
|
193
|
+
const value = line.slice(separatorIndex + 1).trim();
|
|
194
|
+
if (!key || !value || !DATASOURCE_KEY_REGEX.test(key))
|
|
195
|
+
continue;
|
|
196
|
+
const driver = driverTokenFromUri(value);
|
|
197
|
+
if (driver)
|
|
198
|
+
refs.push({ key, driver });
|
|
199
|
+
}
|
|
200
|
+
return refs;
|
|
201
|
+
}
|
|
202
|
+
function flattenYamlNode(node, prefix, out) {
|
|
203
|
+
if (node === null || node === undefined)
|
|
204
|
+
return;
|
|
205
|
+
if (typeof node === "string") {
|
|
206
|
+
if (prefix)
|
|
207
|
+
out.push({ key: prefix, value: node });
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (Array.isArray(node)) {
|
|
211
|
+
for (const item of node)
|
|
212
|
+
flattenYamlNode(item, prefix, out);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (typeof node === "object") {
|
|
216
|
+
for (const [childKey, childValue] of Object.entries(node)) {
|
|
217
|
+
flattenYamlNode(childValue, prefix ? `${prefix}.${childKey}` : childKey, out);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* `application.yml` — nested, and frequently multi-document, since Spring
|
|
223
|
+
* separates per-profile configuration with `---`.
|
|
224
|
+
*/
|
|
225
|
+
function extractDatasourceRefsFromYaml(content) {
|
|
226
|
+
let documents;
|
|
227
|
+
try {
|
|
228
|
+
documents = yaml_1.default.parseAllDocuments(content).map((doc) => doc.toJS());
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
const refs = [];
|
|
234
|
+
const flattened = [];
|
|
235
|
+
for (const document of documents) {
|
|
236
|
+
flattenYamlNode(document, "", flattened);
|
|
237
|
+
}
|
|
238
|
+
for (const entry of flattened) {
|
|
239
|
+
if (!DATASOURCE_KEY_REGEX.test(entry.key))
|
|
240
|
+
continue;
|
|
241
|
+
const driver = driverTokenFromUri(entry.value);
|
|
242
|
+
if (driver)
|
|
243
|
+
refs.push({ key: entry.key, driver });
|
|
244
|
+
}
|
|
245
|
+
return refs;
|
|
246
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { FileInfo, SourceLocation } from "../../core/types/file";
|
|
2
|
+
import { type CFamilyCallEntry } from "../shared/c-family-calls";
|
|
3
|
+
export interface JvmImportEntry {
|
|
4
|
+
/**
|
|
5
|
+
* Fully qualified name as written, with any trailing `.*` removed:
|
|
6
|
+
* `org.springframework.web.bind.annotation.RestController`, or
|
|
7
|
+
* `org.springframework.web.bind.annotation` for a wildcard import.
|
|
8
|
+
*/
|
|
9
|
+
qualifiedName: string;
|
|
10
|
+
/** Alias for Kotlin's `import a.b.C as D`. */
|
|
11
|
+
alias?: string;
|
|
12
|
+
isStatic: boolean;
|
|
13
|
+
isWildcard: boolean;
|
|
14
|
+
location: SourceLocation;
|
|
15
|
+
}
|
|
16
|
+
export interface JvmAnnotationEntry {
|
|
17
|
+
/** Annotation name without `@` or Kotlin use-site target, e.g. `GetMapping`. */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Argument list as written, e.g. `"users/{id}"` or `value = "/api"`. */
|
|
20
|
+
argumentsSnippet: string;
|
|
21
|
+
/** Full annotation text without `@`, e.g. `GetMapping("users/{id}")`. */
|
|
22
|
+
raw: string;
|
|
23
|
+
}
|
|
24
|
+
export interface JvmTypeEntry {
|
|
25
|
+
name: string;
|
|
26
|
+
kind: "class" | "interface" | "enum" | "record" | "object" | "annotation";
|
|
27
|
+
/** Supertypes from `extends`/`implements` (Java) or the `:` list (Kotlin). */
|
|
28
|
+
baseTypes: string[];
|
|
29
|
+
annotations: JvmAnnotationEntry[];
|
|
30
|
+
location: SourceLocation;
|
|
31
|
+
}
|
|
32
|
+
export interface JvmMethodEntry {
|
|
33
|
+
name: string;
|
|
34
|
+
annotations: JvmAnnotationEntry[];
|
|
35
|
+
/** Enclosing type name when the method is declared inside one. */
|
|
36
|
+
declaringType?: string;
|
|
37
|
+
location: SourceLocation;
|
|
38
|
+
}
|
|
39
|
+
export type JvmCallEntry = CFamilyCallEntry;
|
|
40
|
+
export interface JvmSourceFileModel {
|
|
41
|
+
file: FileInfo;
|
|
42
|
+
normalizedPath: string;
|
|
43
|
+
/** Source with comments blanked out; line/column offsets are preserved. */
|
|
44
|
+
strippedContent: string;
|
|
45
|
+
/** True for `.kt`/`.kts` sources; selects the Kotlin declaration grammar. */
|
|
46
|
+
isKotlin: boolean;
|
|
47
|
+
packageName?: string;
|
|
48
|
+
imports: JvmImportEntry[];
|
|
49
|
+
types: JvmTypeEntry[];
|
|
50
|
+
methods: JvmMethodEntry[];
|
|
51
|
+
calls: JvmCallEntry[];
|
|
52
|
+
warnings: string[];
|
|
53
|
+
}
|
|
54
|
+
export declare function parseJvmSourceFile(file: FileInfo): JvmSourceFileModel;
|