@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,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectGoDatabaseConnectionsFromConfig = detectGoDatabaseConnectionsFromConfig;
|
|
4
|
+
exports.detectGoAuthFromConfig = detectGoAuthFromConfig;
|
|
5
|
+
exports.detectGoEnvAndConfigFromConfig = detectGoEnvAndConfigFromConfig;
|
|
6
|
+
exports.detectGoRoutesFromConfig = detectGoRoutesFromConfig;
|
|
7
|
+
exports.detectGoServerlessHandlersFromConfig = detectGoServerlessHandlersFromConfig;
|
|
8
|
+
exports.detectGoExternalApisFromConfig = detectGoExternalApisFromConfig;
|
|
9
|
+
const external_url_third_party_1 = require("../../classifier/external-url-third-party");
|
|
10
|
+
const helpers_1 = require("./helpers");
|
|
11
|
+
/**
|
|
12
|
+
* Match a Go import path against a configured path, exactly or as a path
|
|
13
|
+
* prefix. The prefix rule is what makes module major versions and
|
|
14
|
+
* sub-packages work: `github.com/jackc/pgx` matches
|
|
15
|
+
* `github.com/jackc/pgx/v5/pgxpool`.
|
|
16
|
+
*/
|
|
17
|
+
function importMatchesPath(importPath, want) {
|
|
18
|
+
if (!want)
|
|
19
|
+
return false;
|
|
20
|
+
return importPath === want || importPath.startsWith(`${want}/`);
|
|
21
|
+
}
|
|
22
|
+
function hasAnyImport(ctx, paths) {
|
|
23
|
+
if (paths.length === 0)
|
|
24
|
+
return false;
|
|
25
|
+
const imports = ctx.imports ?? [];
|
|
26
|
+
return imports.some((imp) => paths.some((want) => importMatchesPath(imp.module, want)));
|
|
27
|
+
}
|
|
28
|
+
function sourceOf(ctx) {
|
|
29
|
+
return ctx.strippedContent ?? ctx.file.content ?? "";
|
|
30
|
+
}
|
|
31
|
+
function callNameRegex(callNames) {
|
|
32
|
+
const escaped = callNames.map((name) => name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
33
|
+
return new RegExp(`(?:^|[^A-Za-z0-9_.])(?:${escaped.join("|")})\\s*[({]`);
|
|
34
|
+
}
|
|
35
|
+
function detectGoDatabaseConnectionsFromConfig(ctx, config) {
|
|
36
|
+
if (ctx.language !== "go")
|
|
37
|
+
return [];
|
|
38
|
+
const content = sourceOf(ctx);
|
|
39
|
+
const findings = [];
|
|
40
|
+
for (const db of config.go.dbClients) {
|
|
41
|
+
const hasImport = hasAnyImport(ctx, db.importPaths);
|
|
42
|
+
const hasCall = db.callNames.length > 0 && callNameRegex(db.callNames).test(content);
|
|
43
|
+
if (!hasImport && !hasCall)
|
|
44
|
+
continue;
|
|
45
|
+
findings.push({
|
|
46
|
+
pattern: db.patternId,
|
|
47
|
+
name: db.id,
|
|
48
|
+
confidence: db.confidence,
|
|
49
|
+
location: {
|
|
50
|
+
filePath: ctx.file.path,
|
|
51
|
+
startLine: 1,
|
|
52
|
+
endLine: 1,
|
|
53
|
+
},
|
|
54
|
+
properties: {
|
|
55
|
+
client: db.id,
|
|
56
|
+
databaseType: db.databaseType,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// `database/sql` names its engine in the first argument of sql.Open.
|
|
61
|
+
const sqlOpen = config.go.sqlOpen;
|
|
62
|
+
if (sqlOpen) {
|
|
63
|
+
const lines = content.split(/\r?\n/);
|
|
64
|
+
const seenDrivers = new Set();
|
|
65
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
66
|
+
const match = sqlOpen.regex.exec(lines[i]);
|
|
67
|
+
if (!match)
|
|
68
|
+
continue;
|
|
69
|
+
const driver = (match[1] ?? "").trim();
|
|
70
|
+
if (!driver || seenDrivers.has(driver))
|
|
71
|
+
continue;
|
|
72
|
+
seenDrivers.add(driver);
|
|
73
|
+
const databaseType = sqlOpen.drivers[driver.toLowerCase()] ?? sqlOpen.defaultDatabaseType;
|
|
74
|
+
findings.push({
|
|
75
|
+
pattern: sqlOpen.patternId,
|
|
76
|
+
name: `${sqlOpen.name}:${driver}`,
|
|
77
|
+
confidence: sqlOpen.confidence,
|
|
78
|
+
location: {
|
|
79
|
+
filePath: ctx.file.path,
|
|
80
|
+
startLine: i + 1,
|
|
81
|
+
endLine: i + 1,
|
|
82
|
+
code: lines[i].trim(),
|
|
83
|
+
},
|
|
84
|
+
properties: {
|
|
85
|
+
client: sqlOpen.name,
|
|
86
|
+
databaseType,
|
|
87
|
+
driver,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return findings;
|
|
93
|
+
}
|
|
94
|
+
function detectGoAuthFromConfig(ctx, config) {
|
|
95
|
+
if (ctx.language !== "go")
|
|
96
|
+
return [];
|
|
97
|
+
const content = sourceOf(ctx);
|
|
98
|
+
const findings = [];
|
|
99
|
+
for (const lib of config.go.auth.libraries) {
|
|
100
|
+
const hasImport = hasAnyImport(ctx, lib.importPaths);
|
|
101
|
+
const hasCall = lib.callNames.length > 0 && callNameRegex(lib.callNames).test(content);
|
|
102
|
+
const matchesContent = lib.contentRegexes.length > 0 &&
|
|
103
|
+
lib.contentRegexes.some((re) => re.test(content));
|
|
104
|
+
if (!hasImport && !hasCall && !matchesContent)
|
|
105
|
+
continue;
|
|
106
|
+
findings.push({
|
|
107
|
+
pattern: lib.patternId,
|
|
108
|
+
name: lib.id,
|
|
109
|
+
confidence: lib.confidence,
|
|
110
|
+
location: {
|
|
111
|
+
filePath: ctx.file.path,
|
|
112
|
+
startLine: 1,
|
|
113
|
+
endLine: 1,
|
|
114
|
+
},
|
|
115
|
+
properties: {
|
|
116
|
+
...(lib.strategy ? { strategy: lib.strategy } : {}),
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return findings;
|
|
121
|
+
}
|
|
122
|
+
function detectGoEnvAndConfigFromConfig(ctx, config) {
|
|
123
|
+
if (ctx.language !== "go")
|
|
124
|
+
return [];
|
|
125
|
+
const envCfg = config.go.envConfig;
|
|
126
|
+
const content = sourceOf(ctx);
|
|
127
|
+
const findings = [];
|
|
128
|
+
if (envCfg.envVariable) {
|
|
129
|
+
const lines = content.split(/\r?\n/);
|
|
130
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
131
|
+
const line = lines[i];
|
|
132
|
+
const match = envCfg.envVariable.regex.exec(line);
|
|
133
|
+
if (!match)
|
|
134
|
+
continue;
|
|
135
|
+
const key = match[1];
|
|
136
|
+
findings.push({
|
|
137
|
+
pattern: envCfg.envVariable.patternId,
|
|
138
|
+
name: key ? `os.Getenv(${key})` : "env_variable",
|
|
139
|
+
confidence: envCfg.envVariable.confidence,
|
|
140
|
+
location: {
|
|
141
|
+
filePath: ctx.file.path,
|
|
142
|
+
startLine: i + 1,
|
|
143
|
+
endLine: i + 1,
|
|
144
|
+
code: line.trim(),
|
|
145
|
+
},
|
|
146
|
+
properties: key ? { key } : {},
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (envCfg.configLoaders) {
|
|
151
|
+
for (const loader of envCfg.configLoaders.loaders) {
|
|
152
|
+
const hasImport = hasAnyImport(ctx, loader.importPaths);
|
|
153
|
+
const hasCall = loader.callNames.length > 0 &&
|
|
154
|
+
callNameRegex(loader.callNames).test(content);
|
|
155
|
+
if (!hasImport && !hasCall)
|
|
156
|
+
continue;
|
|
157
|
+
findings.push({
|
|
158
|
+
pattern: envCfg.configLoaders.patternId,
|
|
159
|
+
name: loader.id,
|
|
160
|
+
confidence: envCfg.configLoaders.confidence,
|
|
161
|
+
location: {
|
|
162
|
+
filePath: ctx.file.path,
|
|
163
|
+
startLine: 1,
|
|
164
|
+
endLine: 1,
|
|
165
|
+
},
|
|
166
|
+
properties: {},
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (envCfg.configFile) {
|
|
171
|
+
const normalizedPath = (ctx.normalizedPath ?? ctx.file.path).toLowerCase();
|
|
172
|
+
if (envCfg.configFile.fileNameRegex.test(normalizedPath)) {
|
|
173
|
+
findings.push({
|
|
174
|
+
pattern: envCfg.configFile.patternId,
|
|
175
|
+
name: envCfg.configFile.name,
|
|
176
|
+
confidence: envCfg.configFile.confidence,
|
|
177
|
+
location: {
|
|
178
|
+
filePath: ctx.file.path,
|
|
179
|
+
startLine: 1,
|
|
180
|
+
endLine: 1,
|
|
181
|
+
},
|
|
182
|
+
properties: {},
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return findings;
|
|
187
|
+
}
|
|
188
|
+
function detectGoRoutesFromConfig(ctx, config) {
|
|
189
|
+
if (ctx.language !== "go")
|
|
190
|
+
return [];
|
|
191
|
+
const lines = sourceOf(ctx).split(/\r?\n/);
|
|
192
|
+
const findings = [];
|
|
193
|
+
for (const fw of config.go.routes.frameworks) {
|
|
194
|
+
const supportsFramework = fw.importPaths.length === 0 || hasAnyImport(ctx, fw.importPaths);
|
|
195
|
+
if (!supportsFramework)
|
|
196
|
+
continue;
|
|
197
|
+
for (const routeRegex of fw.routeRegexes) {
|
|
198
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
199
|
+
const text = lines[i].trim();
|
|
200
|
+
if (!text)
|
|
201
|
+
continue;
|
|
202
|
+
const match = routeRegex.regex.exec(text);
|
|
203
|
+
if (!match)
|
|
204
|
+
continue;
|
|
205
|
+
const rawMethod = routeRegex.methodGroup != null
|
|
206
|
+
? match[routeRegex.methodGroup]
|
|
207
|
+
: routeRegex.defaultMethod;
|
|
208
|
+
const method = rawMethod ? rawMethod.toUpperCase() : undefined;
|
|
209
|
+
const routePath = routeRegex.pathGroup != null ? match[routeRegex.pathGroup] : undefined;
|
|
210
|
+
const name = method
|
|
211
|
+
? `${method} ${routePath ?? ""}`.trim()
|
|
212
|
+
: `${fw.id.toUpperCase()}_ROUTE ${routePath ?? ""}`.trim();
|
|
213
|
+
findings.push({
|
|
214
|
+
pattern: fw.patternId,
|
|
215
|
+
name,
|
|
216
|
+
confidence: fw.confidence,
|
|
217
|
+
location: {
|
|
218
|
+
filePath: ctx.file.path,
|
|
219
|
+
startLine: i + 1,
|
|
220
|
+
endLine: i + 1,
|
|
221
|
+
code: text,
|
|
222
|
+
},
|
|
223
|
+
properties: {
|
|
224
|
+
framework: fw.id,
|
|
225
|
+
httpMethods: method ? [method] : [],
|
|
226
|
+
...(routePath ? { path: routePath } : {}),
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return findings;
|
|
233
|
+
}
|
|
234
|
+
function detectGoServerlessHandlersFromConfig(ctx, config) {
|
|
235
|
+
if (ctx.language !== "go")
|
|
236
|
+
return [];
|
|
237
|
+
const calls = ctx.moduleLevelCalls ?? [];
|
|
238
|
+
const findings = [];
|
|
239
|
+
for (const handler of config.go.serverless.handlers) {
|
|
240
|
+
const hasImport = hasAnyImport(ctx, handler.importPaths);
|
|
241
|
+
if (!hasImport)
|
|
242
|
+
continue;
|
|
243
|
+
for (const call of calls) {
|
|
244
|
+
const callee = call.callee ?? "";
|
|
245
|
+
if (!handler.callNames.some((name) => callee === name))
|
|
246
|
+
continue;
|
|
247
|
+
findings.push({
|
|
248
|
+
pattern: handler.patternId,
|
|
249
|
+
name: `${handler.id} ${callee}`,
|
|
250
|
+
confidence: handler.confidence,
|
|
251
|
+
location: call.location,
|
|
252
|
+
properties: {
|
|
253
|
+
framework: handler.id,
|
|
254
|
+
handler: callee,
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return findings;
|
|
260
|
+
}
|
|
261
|
+
function detectGoExternalApisFromConfig(ctx, config) {
|
|
262
|
+
if (ctx.language !== "go")
|
|
263
|
+
return [];
|
|
264
|
+
const calls = ctx.moduleLevelCalls ?? [];
|
|
265
|
+
if (calls.length === 0)
|
|
266
|
+
return [];
|
|
267
|
+
const findings = [];
|
|
268
|
+
const urlHostPatterns = (0, helpers_1.buildThirdPartyUrlHostPatterns)(config);
|
|
269
|
+
for (const client of config.go.externalApis.httpClients) {
|
|
270
|
+
const supportsClient = client.importPaths.length === 0 || hasAnyImport(ctx, client.importPaths);
|
|
271
|
+
if (!supportsClient)
|
|
272
|
+
continue;
|
|
273
|
+
for (const call of calls) {
|
|
274
|
+
const callee = call.callee ?? "";
|
|
275
|
+
const matchesCallName = client.callNames.some((name) => callee === name);
|
|
276
|
+
const matchesSuffix = client.callNameSuffixes.some((suffix) => callee.endsWith(suffix));
|
|
277
|
+
if (!matchesCallName && !matchesSuffix)
|
|
278
|
+
continue;
|
|
279
|
+
const snippet = call.argumentsSnippet ?? "";
|
|
280
|
+
const match = client.urlRegex.exec(snippet);
|
|
281
|
+
const url = match?.[1];
|
|
282
|
+
const serviceName = (0, helpers_1.inferServiceNameFromUrl)(url, urlHostPatterns) ??
|
|
283
|
+
(0, external_url_third_party_1.defaultServiceNameFromLiteralPublicUrl)(url) ??
|
|
284
|
+
client.clientName;
|
|
285
|
+
findings.push({
|
|
286
|
+
pattern: client.patternId,
|
|
287
|
+
name: `${client.clientName}_call`,
|
|
288
|
+
confidence: client.confidence,
|
|
289
|
+
location: call.location,
|
|
290
|
+
properties: {
|
|
291
|
+
...(url ? { url } : {}),
|
|
292
|
+
...(serviceName ? { serviceName } : {}),
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return findings;
|
|
298
|
+
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { FileInfo, SourceLocation } from "../../core/types/file";
|
|
2
|
+
import type { PatternContext } from "../engine";
|
|
2
3
|
import type { UnifiedPatternConfig } from "../config";
|
|
4
|
+
/** Prefer comment-stripped source when the analyzer supplies it. */
|
|
5
|
+
export declare function sourceOf(ctx: PatternContext): string;
|
|
3
6
|
export declare function createLocationFromLine(file: FileInfo, line: number, code?: string): SourceLocation;
|
|
4
7
|
export declare function findLineMatches(content: string, regex: RegExp): {
|
|
5
8
|
line: number;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sourceOf = sourceOf;
|
|
3
4
|
exports.createLocationFromLine = createLocationFromLine;
|
|
4
5
|
exports.findLineMatches = findLineMatches;
|
|
5
6
|
exports.findFirstLineMatch = findFirstLineMatch;
|
|
6
7
|
exports.buildThirdPartyUrlHostPatterns = buildThirdPartyUrlHostPatterns;
|
|
7
8
|
exports.inferServiceNameFromUrl = inferServiceNameFromUrl;
|
|
9
|
+
/** Prefer comment-stripped source when the analyzer supplies it. */
|
|
10
|
+
function sourceOf(ctx) {
|
|
11
|
+
return ctx.strippedContent ?? ctx.file.content ?? "";
|
|
12
|
+
}
|
|
8
13
|
function createLocationFromLine(file, line, code) {
|
|
9
14
|
return {
|
|
10
15
|
filePath: file.path,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PatternContext } from "../engine";
|
|
2
|
+
import type { UnifiedPatternConfig } from "../config";
|
|
3
|
+
import type { RawFinding } from "../../core/types/detection";
|
|
4
|
+
export declare function detectJvmDatabaseConnectionsFromConfig(ctx: PatternContext, config: UnifiedPatternConfig): RawFinding[];
|
|
5
|
+
/**
|
|
6
|
+
* JDBC names its engine in the URL sub-protocol. Only the driver token is
|
|
7
|
+
* read: JDBC URLs routinely carry credentials in query parameters, so the
|
|
8
|
+
* value itself never reaches a finding.
|
|
9
|
+
*/
|
|
10
|
+
export declare function detectJdbcUrls(ctx: PatternContext, config: UnifiedPatternConfig, content: string): RawFinding[];
|
|
11
|
+
export declare function detectJvmAuthFromConfig(ctx: PatternContext, config: UnifiedPatternConfig): RawFinding[];
|
|
12
|
+
export declare function detectJvmEnvAndConfigFromConfig(ctx: PatternContext, config: UnifiedPatternConfig): RawFinding[];
|
|
13
|
+
export declare function detectJvmRoutesFromConfig(ctx: PatternContext, config: UnifiedPatternConfig): RawFinding[];
|
|
14
|
+
export declare function detectJvmServerlessHandlersFromConfig(ctx: PatternContext, config: UnifiedPatternConfig): RawFinding[];
|
|
15
|
+
export declare function detectJvmExternalApisFromConfig(ctx: PatternContext, config: UnifiedPatternConfig): RawFinding[];
|