@dataparade/cli 0.0.8 → 0.0.10
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 +10 -10
- 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 +1 -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/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/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
|
@@ -6,3 +6,5 @@ export declare function detectTypeScriptRoutesFromConfig(ctx: PatternContext, co
|
|
|
6
6
|
export declare function detectTypeScriptDatabaseFromConfig(ctx: PatternContext, config: UnifiedPatternConfig): RawFinding[];
|
|
7
7
|
export declare function detectTypeScriptAuthFromConfig(ctx: PatternContext, config: UnifiedPatternConfig): RawFinding[];
|
|
8
8
|
export declare function detectTypeScriptEnvAndConfigFromConfig(ctx: PatternContext, config: UnifiedPatternConfig): RawFinding[];
|
|
9
|
+
export declare function detectTypeScriptServerlessHandlersFromConfig(ctx: PatternContext, config: UnifiedPatternConfig): RawFinding[];
|
|
10
|
+
export declare function detectTypeScriptExternalApisFromConfig(ctx: PatternContext, config: UnifiedPatternConfig): RawFinding[];
|
|
@@ -5,6 +5,8 @@ exports.detectTypeScriptRoutesFromConfig = detectTypeScriptRoutesFromConfig;
|
|
|
5
5
|
exports.detectTypeScriptDatabaseFromConfig = detectTypeScriptDatabaseFromConfig;
|
|
6
6
|
exports.detectTypeScriptAuthFromConfig = detectTypeScriptAuthFromConfig;
|
|
7
7
|
exports.detectTypeScriptEnvAndConfigFromConfig = detectTypeScriptEnvAndConfigFromConfig;
|
|
8
|
+
exports.detectTypeScriptServerlessHandlersFromConfig = detectTypeScriptServerlessHandlersFromConfig;
|
|
9
|
+
exports.detectTypeScriptExternalApisFromConfig = detectTypeScriptExternalApisFromConfig;
|
|
8
10
|
const external_url_third_party_1 = require("../../classifier/external-url-third-party");
|
|
9
11
|
const helpers_1 = require("./helpers");
|
|
10
12
|
function detectTypeScriptJavaScriptExternalApisFromHttpClients(ctx, config) {
|
|
@@ -50,9 +52,10 @@ function detectTypeScriptRoutesFromConfig(ctx, config) {
|
|
|
50
52
|
!ctx.normalizedPath) {
|
|
51
53
|
return [];
|
|
52
54
|
}
|
|
53
|
-
const content = ctx
|
|
55
|
+
const content = (0, helpers_1.sourceOf)(ctx);
|
|
54
56
|
const findings = [];
|
|
55
57
|
const tsCfg = config.typescript;
|
|
58
|
+
const lines = content.split(/\r?\n/);
|
|
56
59
|
for (const fw of tsCfg.routes.frameworks) {
|
|
57
60
|
const hasFrameworkImport = fw.imports.length === 0
|
|
58
61
|
? false
|
|
@@ -78,6 +81,7 @@ function detectTypeScriptRoutesFromConfig(ctx, config) {
|
|
|
78
81
|
framework: "express",
|
|
79
82
|
httpMethods: [upperMethod],
|
|
80
83
|
path,
|
|
84
|
+
handlerType: "route_handler",
|
|
81
85
|
},
|
|
82
86
|
});
|
|
83
87
|
}
|
|
@@ -117,6 +121,38 @@ function detectTypeScriptRoutesFromConfig(ctx, config) {
|
|
|
117
121
|
framework: "nest",
|
|
118
122
|
httpMethods: [upperMethod],
|
|
119
123
|
path: routePath || "/",
|
|
124
|
+
handlerType: "controller_action",
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (fw.routeRegexes.length > 0) {
|
|
131
|
+
for (const routeRegex of fw.routeRegexes) {
|
|
132
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
133
|
+
const text = lines[i]?.trim() ?? "";
|
|
134
|
+
if (!text)
|
|
135
|
+
continue;
|
|
136
|
+
const match = routeRegex.regex.exec(text);
|
|
137
|
+
if (!match)
|
|
138
|
+
continue;
|
|
139
|
+
const rawMethod = routeRegex.methodGroup != null
|
|
140
|
+
? match[routeRegex.methodGroup]
|
|
141
|
+
: routeRegex.defaultMethod;
|
|
142
|
+
const method = rawMethod ? rawMethod.toUpperCase() : undefined;
|
|
143
|
+
const routePath = routeRegex.pathGroup != null ? match[routeRegex.pathGroup] : undefined;
|
|
144
|
+
findings.push({
|
|
145
|
+
pattern: fw.patternId,
|
|
146
|
+
name: method
|
|
147
|
+
? `${method} ${routePath ?? fw.id}`.trim()
|
|
148
|
+
: `${fw.id.toUpperCase()} ${routePath ?? "service"}`.trim(),
|
|
149
|
+
confidence: fw.confidence,
|
|
150
|
+
location: (0, helpers_1.createLocationFromLine)(ctx.file, i + 1, text),
|
|
151
|
+
properties: {
|
|
152
|
+
framework: fw.id,
|
|
153
|
+
httpMethods: method ? [method] : [],
|
|
154
|
+
...(routePath ? { path: routePath } : {}),
|
|
155
|
+
handlerType: "grpc_service",
|
|
120
156
|
},
|
|
121
157
|
});
|
|
122
158
|
}
|
|
@@ -151,7 +187,7 @@ function detectTypeScriptDatabaseFromConfig(ctx, config) {
|
|
|
151
187
|
!ctx.normalizedPath) {
|
|
152
188
|
return [];
|
|
153
189
|
}
|
|
154
|
-
const content = ctx
|
|
190
|
+
const content = (0, helpers_1.sourceOf)(ctx);
|
|
155
191
|
const findings = [];
|
|
156
192
|
const tsCfg = config.typescript;
|
|
157
193
|
for (const client of tsCfg.dbClients) {
|
|
@@ -212,10 +248,29 @@ function detectTypeScriptAuthFromConfig(ctx, config) {
|
|
|
212
248
|
!ctx.normalizedPath) {
|
|
213
249
|
return [];
|
|
214
250
|
}
|
|
215
|
-
const content = ctx
|
|
251
|
+
const content = (0, helpers_1.sourceOf)(ctx);
|
|
216
252
|
const findings = [];
|
|
217
253
|
const tsCfg = config.typescript;
|
|
218
254
|
for (const lib of tsCfg.auth.libraries) {
|
|
255
|
+
if (lib.contentRegexes.length > 0) {
|
|
256
|
+
for (const regex of lib.contentRegexes) {
|
|
257
|
+
const contentMatches = (0, helpers_1.findLineMatches)(content, regex);
|
|
258
|
+
for (const { line, match } of contentMatches) {
|
|
259
|
+
findings.push({
|
|
260
|
+
pattern: lib.patternId,
|
|
261
|
+
name: lib.id,
|
|
262
|
+
confidence: lib.confidence,
|
|
263
|
+
location: (0, helpers_1.createLocationFromLine)(ctx.file, line, match[0]),
|
|
264
|
+
properties: {
|
|
265
|
+
...(lib.strategy ? { strategy: lib.strategy } : {}),
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (lib.importFragments.length === 0) {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
219
274
|
const hasLibraryImport = lib.importFragments.some((frag) => (ctx.imports ?? []).some((imp) => imp.module === frag ||
|
|
220
275
|
imp.module.includes(frag) ||
|
|
221
276
|
imp.names.some((name) => name === frag || name.includes(frag))));
|
|
@@ -261,6 +316,7 @@ function detectTypeScriptAuthFromConfig(ctx, config) {
|
|
|
261
316
|
location: (0, helpers_1.createLocationFromLine)(ctx.file, 1),
|
|
262
317
|
properties: {
|
|
263
318
|
library: "jsonwebtoken",
|
|
319
|
+
...(lib.strategy ? { strategy: lib.strategy } : {}),
|
|
264
320
|
},
|
|
265
321
|
});
|
|
266
322
|
}
|
|
@@ -278,6 +334,18 @@ function detectTypeScriptAuthFromConfig(ctx, config) {
|
|
|
278
334
|
});
|
|
279
335
|
}
|
|
280
336
|
}
|
|
337
|
+
else if (lib.id === "oauth2") {
|
|
338
|
+
findings.push({
|
|
339
|
+
pattern: lib.patternId,
|
|
340
|
+
name: lib.id,
|
|
341
|
+
confidence: lib.confidence,
|
|
342
|
+
location: (0, helpers_1.createLocationFromLine)(ctx.file, 1),
|
|
343
|
+
properties: {
|
|
344
|
+
library: lib.id,
|
|
345
|
+
...(lib.strategy ? { strategy: lib.strategy } : {}),
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
}
|
|
281
349
|
}
|
|
282
350
|
return findings;
|
|
283
351
|
}
|
|
@@ -286,7 +354,7 @@ function detectTypeScriptEnvAndConfigFromConfig(ctx, config) {
|
|
|
286
354
|
!ctx.normalizedPath) {
|
|
287
355
|
return [];
|
|
288
356
|
}
|
|
289
|
-
const content = ctx
|
|
357
|
+
const content = (0, helpers_1.sourceOf)(ctx);
|
|
290
358
|
const findings = [];
|
|
291
359
|
const tsCfg = config.typescript;
|
|
292
360
|
const { regex: envRegex, confidence: envConfidence } = tsCfg.heuristics.processEnv;
|
|
@@ -324,5 +392,89 @@ function detectTypeScriptEnvAndConfigFromConfig(ctx, config) {
|
|
|
324
392
|
});
|
|
325
393
|
}
|
|
326
394
|
}
|
|
395
|
+
for (const loader of tsCfg.configLoaders) {
|
|
396
|
+
const hasLoaderImport = loader.importFragments.some((frag) => (ctx.imports ?? []).some((imp) => imp.module === frag ||
|
|
397
|
+
imp.module.includes(frag) ||
|
|
398
|
+
imp.names.some((name) => name === frag || name.includes(frag))));
|
|
399
|
+
if (!hasLoaderImport)
|
|
400
|
+
continue;
|
|
401
|
+
const hasCall = loader.callRegexes.length === 0 ||
|
|
402
|
+
loader.callRegexes.some((regex) => regex.test(content));
|
|
403
|
+
if (!hasCall)
|
|
404
|
+
continue;
|
|
405
|
+
findings.push({
|
|
406
|
+
pattern: loader.patternId,
|
|
407
|
+
name: loader.name,
|
|
408
|
+
confidence: loader.confidence,
|
|
409
|
+
location: (0, helpers_1.createLocationFromLine)(ctx.file, 1),
|
|
410
|
+
properties: {
|
|
411
|
+
loader: loader.id,
|
|
412
|
+
},
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
return findings;
|
|
416
|
+
}
|
|
417
|
+
function detectTypeScriptServerlessHandlersFromConfig(ctx, config) {
|
|
418
|
+
if (ctx.language !== "typescript" && ctx.language !== "javascript") {
|
|
419
|
+
return [];
|
|
420
|
+
}
|
|
421
|
+
const content = (0, helpers_1.sourceOf)(ctx);
|
|
422
|
+
const findings = [];
|
|
423
|
+
for (const handler of config.typescript.serverless.handlers) {
|
|
424
|
+
const hasImport = handler.importModules.length === 0
|
|
425
|
+
? false
|
|
426
|
+
: handler.importModules.some((mod) => (ctx.imports ?? []).some((imp) => imp.module === mod ||
|
|
427
|
+
imp.module.includes(mod) ||
|
|
428
|
+
imp.names.some((name) => name === mod || name.includes(mod))));
|
|
429
|
+
const hasTypeSignal = handler.typeNames.some((typeName) => content.includes(typeName));
|
|
430
|
+
for (const regex of handler.handlerRegexes) {
|
|
431
|
+
const matches = (0, helpers_1.findLineMatches)(content, regex);
|
|
432
|
+
for (const { line, match } of matches) {
|
|
433
|
+
if (!hasImport && !hasTypeSignal)
|
|
434
|
+
continue;
|
|
435
|
+
findings.push({
|
|
436
|
+
pattern: handler.patternId,
|
|
437
|
+
name: `${handler.id} handler`,
|
|
438
|
+
confidence: handler.confidence,
|
|
439
|
+
location: (0, helpers_1.createLocationFromLine)(ctx.file, line, match[0]),
|
|
440
|
+
properties: {
|
|
441
|
+
framework: handler.id,
|
|
442
|
+
handler: "handler",
|
|
443
|
+
handlerType: "serverless_handler",
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return findings;
|
|
450
|
+
}
|
|
451
|
+
function detectTypeScriptExternalApisFromConfig(ctx, config) {
|
|
452
|
+
if (ctx.language !== "typescript" && ctx.language !== "javascript") {
|
|
453
|
+
return [];
|
|
454
|
+
}
|
|
455
|
+
const content = (0, helpers_1.sourceOf)(ctx);
|
|
456
|
+
const findings = [];
|
|
457
|
+
for (const client of config.typescript.externalApis.httpClients) {
|
|
458
|
+
const hasClientImport = client.importFragments.length === 0 ||
|
|
459
|
+
client.importFragments.some((frag) => (ctx.imports ?? []).some((imp) => imp.module === frag ||
|
|
460
|
+
imp.module.includes(frag) ||
|
|
461
|
+
imp.names.some((name) => name === frag || name.includes(frag))));
|
|
462
|
+
if (!hasClientImport)
|
|
463
|
+
continue;
|
|
464
|
+
for (const regex of client.callRegexes) {
|
|
465
|
+
const matches = (0, helpers_1.findLineMatches)(content, regex);
|
|
466
|
+
for (const { line, match } of matches) {
|
|
467
|
+
findings.push({
|
|
468
|
+
pattern: client.patternId,
|
|
469
|
+
name: `${client.clientName}_call`,
|
|
470
|
+
confidence: client.confidence,
|
|
471
|
+
location: (0, helpers_1.createLocationFromLine)(ctx.file, line, match[0]),
|
|
472
|
+
properties: {
|
|
473
|
+
client: client.clientName,
|
|
474
|
+
},
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
327
479
|
return findings;
|
|
328
480
|
}
|
|
@@ -15,6 +15,12 @@ export interface PatternContext {
|
|
|
15
15
|
*/
|
|
16
16
|
includeThirdPartyHttpLinePatterns?: boolean;
|
|
17
17
|
imports?: ImportLike[];
|
|
18
|
+
/**
|
|
19
|
+
* Source with comments blanked out and line/column layout preserved.
|
|
20
|
+
* Supplied by the C-family analyzers (C++, C#) so line-based rules do not
|
|
21
|
+
* match commented-out code. Falls back to `file.content` when absent.
|
|
22
|
+
*/
|
|
23
|
+
strippedContent?: string;
|
|
18
24
|
moduleLevelCalls?: {
|
|
19
25
|
callee: string;
|
|
20
26
|
argumentsSnippet: string;
|
|
@@ -25,6 +31,18 @@ export interface PatternContext {
|
|
|
25
31
|
decorators: string[];
|
|
26
32
|
location: SourceLocation;
|
|
27
33
|
}[];
|
|
34
|
+
/**
|
|
35
|
+
* Declared types (classes, records, structs). `decorators` carries language
|
|
36
|
+
* annotations attached to the declaration — C# attributes such as
|
|
37
|
+
* `Route("api/[controller]")`.
|
|
38
|
+
*/
|
|
39
|
+
types?: {
|
|
40
|
+
name: string;
|
|
41
|
+
kind?: string;
|
|
42
|
+
baseTypes?: string[];
|
|
43
|
+
decorators?: string[];
|
|
44
|
+
location: SourceLocation;
|
|
45
|
+
}[];
|
|
28
46
|
normalizedPath?: string;
|
|
29
47
|
}
|
|
30
48
|
/**
|
|
@@ -4,6 +4,10 @@ exports.detectThirdPartyServicesFromImports = detectThirdPartyServicesFromImport
|
|
|
4
4
|
exports.matchPatterns = matchPatterns;
|
|
5
5
|
const config_1 = require("./config");
|
|
6
6
|
const python_1 = require("./detectors/python");
|
|
7
|
+
const cpp_1 = require("./detectors/cpp");
|
|
8
|
+
const csharp_1 = require("./detectors/csharp");
|
|
9
|
+
const go_1 = require("./detectors/go");
|
|
10
|
+
const jvm_1 = require("./detectors/jvm");
|
|
7
11
|
const typescript_1 = require("./detectors/typescript");
|
|
8
12
|
function findFirstLineMatch(content, regex) {
|
|
9
13
|
if (!regex)
|
|
@@ -103,9 +107,35 @@ function matchPatterns(ctx) {
|
|
|
103
107
|
findings.push(...(0, python_1.detectPythonEnvAndConfigFromConfig)(ctx, config));
|
|
104
108
|
findings.push(...(0, python_1.detectPythonExternalApisFromConfig)(ctx, config));
|
|
105
109
|
findings.push(...(0, python_1.detectPythonRoutesFromConfig)(ctx, config));
|
|
110
|
+
findings.push(...(0, python_1.detectPythonServerlessHandlersFromConfig)(ctx, config));
|
|
111
|
+
findings.push(...(0, cpp_1.detectCppDatabaseConnectionsFromConfig)(ctx, config));
|
|
112
|
+
findings.push(...(0, cpp_1.detectCppAuthFromConfig)(ctx, config));
|
|
113
|
+
findings.push(...(0, cpp_1.detectCppEnvAndConfigFromConfig)(ctx, config));
|
|
114
|
+
findings.push(...(0, cpp_1.detectCppExternalApisFromConfig)(ctx, config));
|
|
115
|
+
findings.push(...(0, cpp_1.detectCppRoutesFromConfig)(ctx, config));
|
|
116
|
+
findings.push(...(0, csharp_1.detectCSharpDatabaseConnectionsFromConfig)(ctx, config));
|
|
117
|
+
findings.push(...(0, csharp_1.detectCSharpAuthFromConfig)(ctx, config));
|
|
118
|
+
findings.push(...(0, csharp_1.detectCSharpEnvAndConfigFromConfig)(ctx, config));
|
|
119
|
+
findings.push(...(0, csharp_1.detectCSharpExternalApisFromConfig)(ctx, config));
|
|
120
|
+
findings.push(...(0, csharp_1.detectCSharpRoutesFromConfig)(ctx, config));
|
|
121
|
+
findings.push(...(0, csharp_1.detectCSharpServerlessHandlersFromConfig)(ctx, config));
|
|
122
|
+
findings.push(...(0, go_1.detectGoDatabaseConnectionsFromConfig)(ctx, config));
|
|
123
|
+
findings.push(...(0, go_1.detectGoAuthFromConfig)(ctx, config));
|
|
124
|
+
findings.push(...(0, go_1.detectGoEnvAndConfigFromConfig)(ctx, config));
|
|
125
|
+
findings.push(...(0, go_1.detectGoExternalApisFromConfig)(ctx, config));
|
|
126
|
+
findings.push(...(0, go_1.detectGoRoutesFromConfig)(ctx, config));
|
|
127
|
+
findings.push(...(0, go_1.detectGoServerlessHandlersFromConfig)(ctx, config));
|
|
128
|
+
findings.push(...(0, jvm_1.detectJvmDatabaseConnectionsFromConfig)(ctx, config));
|
|
129
|
+
findings.push(...(0, jvm_1.detectJvmAuthFromConfig)(ctx, config));
|
|
130
|
+
findings.push(...(0, jvm_1.detectJvmEnvAndConfigFromConfig)(ctx, config));
|
|
131
|
+
findings.push(...(0, jvm_1.detectJvmExternalApisFromConfig)(ctx, config));
|
|
132
|
+
findings.push(...(0, jvm_1.detectJvmRoutesFromConfig)(ctx, config));
|
|
133
|
+
findings.push(...(0, jvm_1.detectJvmServerlessHandlersFromConfig)(ctx, config));
|
|
106
134
|
findings.push(...(0, typescript_1.detectTypeScriptRoutesFromConfig)(ctx, config));
|
|
107
135
|
findings.push(...(0, typescript_1.detectTypeScriptDatabaseFromConfig)(ctx, config));
|
|
108
136
|
findings.push(...(0, typescript_1.detectTypeScriptAuthFromConfig)(ctx, config));
|
|
109
137
|
findings.push(...(0, typescript_1.detectTypeScriptEnvAndConfigFromConfig)(ctx, config));
|
|
138
|
+
findings.push(...(0, typescript_1.detectTypeScriptServerlessHandlersFromConfig)(ctx, config));
|
|
139
|
+
findings.push(...(0, typescript_1.detectTypeScriptExternalApisFromConfig)(ctx, config));
|
|
110
140
|
return findings;
|
|
111
141
|
}
|
|
@@ -22,6 +22,16 @@ exports.DEFAULT_EXCLUDED_DIRS = new Set([
|
|
|
22
22
|
"coverage",
|
|
23
23
|
".vscode",
|
|
24
24
|
".idea",
|
|
25
|
+
// .NET build output. `bin` is deliberately not excluded: it is a common
|
|
26
|
+
// source directory outside .NET, and .gitignore already covers it in .NET
|
|
27
|
+
// repositories.
|
|
28
|
+
"obj",
|
|
29
|
+
// CMake out-of-source build trees.
|
|
30
|
+
"cmake-build-debug",
|
|
31
|
+
"cmake-build-release",
|
|
32
|
+
// Maven build output. Gradle's `build` and `out` are already excluded
|
|
33
|
+
// above, and its `.gradle` cache is skipped as a hidden directory.
|
|
34
|
+
"target",
|
|
25
35
|
]);
|
|
26
36
|
/**
|
|
27
37
|
* Files matching these globs are not scanned by default: they are never ingested and do not
|
|
@@ -67,6 +77,16 @@ exports.DEFAULT_EXCLUDED_FILE_GLOBS = [
|
|
|
67
77
|
"**/.env.*",
|
|
68
78
|
".env",
|
|
69
79
|
".env.*",
|
|
80
|
+
// Generated C# sources (designer files, source-generator output, assembly
|
|
81
|
+
// metadata) describe tooling rather than application structure.
|
|
82
|
+
"**/*.Designer.cs",
|
|
83
|
+
"*.Designer.cs",
|
|
84
|
+
"**/*.g.cs",
|
|
85
|
+
"*.g.cs",
|
|
86
|
+
"**/*.g.i.cs",
|
|
87
|
+
"*.g.i.cs",
|
|
88
|
+
"**/*.AssemblyInfo.cs",
|
|
89
|
+
"*.AssemblyInfo.cs",
|
|
70
90
|
];
|
|
71
91
|
function shouldSkipDirectoryName(dirName) {
|
|
72
92
|
// Hidden tooling/cache directories are noisy for structural scanning.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const lambda_init_error_1 = require("../../../src/ai-enrichment/lambda-init-error");
|
|
4
|
+
describe("lambda-init-error", () => {
|
|
5
|
+
it("detects the AWS INIT message", () => {
|
|
6
|
+
expect((0, lambda_init_error_1.isLambdaInitializingError)(new Error("ERROR: Lambda is initializing your function. It will be ready to invoke shortly."))).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
it("maps INIT errors to a user-facing message", () => {
|
|
9
|
+
expect((0, lambda_init_error_1.toUserFacingLambdaInitError)(new Error("Lambda is initializing your function.")).message).toBe(lambda_init_error_1.LAMBDA_INITIALIZING_USER_MESSAGE);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -48,4 +48,84 @@ describe("PlatformProxyProvider", () => {
|
|
|
48
48
|
expect(calls.some((c) => c.method === "POST")).toBe(true);
|
|
49
49
|
expect(calls.filter((c) => c.method === "GET").length).toBeGreaterThanOrEqual(1);
|
|
50
50
|
});
|
|
51
|
+
it("retries when a task fails because Lambda is still initializing", async () => {
|
|
52
|
+
let posts = 0;
|
|
53
|
+
global.fetch = jest.fn(async (input, init) => {
|
|
54
|
+
const url = String(input);
|
|
55
|
+
const method = init?.method ?? "GET";
|
|
56
|
+
if (url.endsWith("/api/scans/cli/ai/infer/tasks") && method === "POST") {
|
|
57
|
+
posts += 1;
|
|
58
|
+
return new Response(JSON.stringify({
|
|
59
|
+
tasks: [{ taskId: `t-${posts}`, status: "pending" }],
|
|
60
|
+
}), { status: 202 });
|
|
61
|
+
}
|
|
62
|
+
if (url.includes("taskIds=t-1") && method === "GET") {
|
|
63
|
+
return new Response(JSON.stringify({
|
|
64
|
+
tasks: [
|
|
65
|
+
{
|
|
66
|
+
taskId: "t-1",
|
|
67
|
+
status: "failed",
|
|
68
|
+
errorMessage: "ERROR: Lambda is initializing your function. It will be ready to invoke shortly.",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
}), { status: 200 });
|
|
72
|
+
}
|
|
73
|
+
if (url.includes("taskIds=t-2") && method === "GET") {
|
|
74
|
+
return new Response(JSON.stringify({
|
|
75
|
+
tasks: [
|
|
76
|
+
{
|
|
77
|
+
taskId: "t-2",
|
|
78
|
+
status: "completed",
|
|
79
|
+
proposals: [{ kind: "setProperties", candidateType: "component" }],
|
|
80
|
+
usage: { inputTokens: 1, outputTokens: 2, totalTokens: 3 },
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
}), { status: 200 });
|
|
84
|
+
}
|
|
85
|
+
return new Response("not found", { status: 404 });
|
|
86
|
+
});
|
|
87
|
+
const provider = new platform_proxy_provider_1.PlatformProxyProvider({
|
|
88
|
+
apiBaseUrl: "https://api.example.com",
|
|
89
|
+
workspaceApiKey: "dp_test",
|
|
90
|
+
jobId: "job-1",
|
|
91
|
+
pollIntervalMs: 1,
|
|
92
|
+
pollTimeoutMs: 5000,
|
|
93
|
+
lambdaInitRetryDelaysMs: [0],
|
|
94
|
+
sleep: async () => undefined,
|
|
95
|
+
});
|
|
96
|
+
const result = await provider.infer({
|
|
97
|
+
prompt: "test",
|
|
98
|
+
model: "gpt-4o-mini",
|
|
99
|
+
});
|
|
100
|
+
expect(result.proposals).toHaveLength(1);
|
|
101
|
+
expect(posts).toBe(2);
|
|
102
|
+
});
|
|
103
|
+
it("does not leak the AWS INIT message after retries are exhausted", async () => {
|
|
104
|
+
global.fetch = jest.fn(async (input, init) => {
|
|
105
|
+
const url = String(input);
|
|
106
|
+
const method = init?.method ?? "GET";
|
|
107
|
+
if (url.endsWith("/api/scans/cli/ai/infer/tasks") && method === "POST") {
|
|
108
|
+
return new Response(JSON.stringify({ tasks: [{ taskId: "t-1", status: "pending" }] }), { status: 202 });
|
|
109
|
+
}
|
|
110
|
+
return new Response(JSON.stringify({
|
|
111
|
+
tasks: [
|
|
112
|
+
{
|
|
113
|
+
taskId: "t-1",
|
|
114
|
+
status: "failed",
|
|
115
|
+
errorMessage: "ERROR: Lambda is initializing your function. It will be ready to invoke shortly.",
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
}), { status: 200 });
|
|
119
|
+
});
|
|
120
|
+
const provider = new platform_proxy_provider_1.PlatformProxyProvider({
|
|
121
|
+
apiBaseUrl: "https://api.example.com",
|
|
122
|
+
workspaceApiKey: "dp_test",
|
|
123
|
+
jobId: "job-1",
|
|
124
|
+
pollIntervalMs: 1,
|
|
125
|
+
pollTimeoutMs: 5000,
|
|
126
|
+
lambdaInitRetryDelaysMs: [0],
|
|
127
|
+
sleep: async () => undefined,
|
|
128
|
+
});
|
|
129
|
+
await expect(provider.infer({ prompt: "test", model: "gpt-4o-mini" })).rejects.toThrow("Platform AI is still starting");
|
|
130
|
+
});
|
|
51
131
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const dependency_manifests_1 = require("../../../../src/analyzers/cpp/dependency-manifests");
|
|
8
|
+
const manifest_parsers_1 = require("../../../../src/analyzers/cpp/manifest-parsers");
|
|
9
|
+
const FIXTURE_ROOT = path_1.default.join(__dirname, "..", "..", "..", "fixtures", "cpp-dependency-manifests-basic");
|
|
10
|
+
describe("C++ manifest parsers", () => {
|
|
11
|
+
it("extracts vcpkg dependencies in both string and object form", () => {
|
|
12
|
+
const content = JSON.stringify({
|
|
13
|
+
name: "app",
|
|
14
|
+
dependencies: ["libpqxx", { name: "hiredis", "version>=": "1.1.0" }],
|
|
15
|
+
});
|
|
16
|
+
expect((0, manifest_parsers_1.extractPackagesFromVcpkgJson)(content).sort()).toEqual([
|
|
17
|
+
"hiredis",
|
|
18
|
+
"libpqxx",
|
|
19
|
+
]);
|
|
20
|
+
});
|
|
21
|
+
it("returns nothing for malformed vcpkg manifests", () => {
|
|
22
|
+
expect((0, manifest_parsers_1.extractPackagesFromVcpkgJson)("{ not json")).toEqual([]);
|
|
23
|
+
});
|
|
24
|
+
it("extracts Conan requires from txt and py recipes, stripping versions", () => {
|
|
25
|
+
const txt = ["[requires]", "fmt/10.2.1", "", "[generators]", "CMakeDeps"].join("\n");
|
|
26
|
+
expect((0, manifest_parsers_1.extractPackagesFromConanfile)(txt)).toEqual(["fmt"]);
|
|
27
|
+
const py = [
|
|
28
|
+
"class AppConan(ConanFile):",
|
|
29
|
+
" def requirements(self):",
|
|
30
|
+
' self.requires("zlib/1.3")',
|
|
31
|
+
"",
|
|
32
|
+
].join("\n");
|
|
33
|
+
expect((0, manifest_parsers_1.extractPackagesFromConanfile)(py)).toEqual(["zlib"]);
|
|
34
|
+
});
|
|
35
|
+
it("extracts CMake find_package and FetchContent declarations", () => {
|
|
36
|
+
const content = [
|
|
37
|
+
"find_package(SQLite3 REQUIRED)",
|
|
38
|
+
"FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git)",
|
|
39
|
+
"",
|
|
40
|
+
].join("\n");
|
|
41
|
+
expect((0, manifest_parsers_1.extractPackagesFromCMakeLists)(content).sort()).toEqual([
|
|
42
|
+
"cpr",
|
|
43
|
+
"sqlite3",
|
|
44
|
+
]);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe("C++ dependency manifest scanning", () => {
|
|
48
|
+
it("collects packages from every manifest kind in a repository", async () => {
|
|
49
|
+
const manifests = await (0, dependency_manifests_1.parseCppDependencyManifests)(FIXTURE_ROOT);
|
|
50
|
+
const byName = new Map(manifests.map((m) => [m.manifestRelativePath, m.packages]));
|
|
51
|
+
expect(byName.get("vcpkg.json")).toEqual(expect.arrayContaining(["libpqxx", "curl", "hiredis"]));
|
|
52
|
+
expect(byName.get("conanfile.txt")).toEqual(expect.arrayContaining(["sentry-native", "aws-sdk-cpp"]));
|
|
53
|
+
expect(byName.get("CMakeLists.txt")).toEqual(expect.arrayContaining(["sqlite3"]));
|
|
54
|
+
});
|
|
55
|
+
it("maps manifest packages to third-party services and databases", async () => {
|
|
56
|
+
const findings = await (0, dependency_manifests_1.detectCppPatternsFromDependencyManifests)(FIXTURE_ROOT);
|
|
57
|
+
const serviceNames = findings
|
|
58
|
+
.filter((f) => f.pattern === "external_api_call")
|
|
59
|
+
.map((f) => f.properties.serviceName);
|
|
60
|
+
expect(serviceNames).toEqual(expect.arrayContaining(["sentry", "aws"]));
|
|
61
|
+
const databases = findings
|
|
62
|
+
.filter((f) => f.pattern === "database_connection")
|
|
63
|
+
.map((f) => f.properties.client);
|
|
64
|
+
expect(databases).toEqual(expect.arrayContaining(["libpqxx", "hiredis", "sqlite3"]));
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const parser_1 = require("../../../../src/analyzers/cpp/parser");
|
|
4
|
+
function createCppFile(content, path = "main.cpp") {
|
|
5
|
+
return {
|
|
6
|
+
path,
|
|
7
|
+
name: path,
|
|
8
|
+
content,
|
|
9
|
+
language: "cpp",
|
|
10
|
+
size: content.length,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
describe("C++ parser - parseCppTranslationUnit", () => {
|
|
14
|
+
it("indexes includes, functions, types, and calls", () => {
|
|
15
|
+
const content = [
|
|
16
|
+
"#include <curl/curl.h>",
|
|
17
|
+
'#include "handlers/users.h"',
|
|
18
|
+
"",
|
|
19
|
+
"namespace api {",
|
|
20
|
+
"",
|
|
21
|
+
"class UserService : public BaseService {",
|
|
22
|
+
"public:",
|
|
23
|
+
" void Load() {",
|
|
24
|
+
" CURL* curl = curl_easy_init();",
|
|
25
|
+
' curl_easy_setopt(curl, CURLOPT_URL, "https://api.example.com/users");',
|
|
26
|
+
" }",
|
|
27
|
+
"};",
|
|
28
|
+
"",
|
|
29
|
+
"}",
|
|
30
|
+
"",
|
|
31
|
+
].join("\n");
|
|
32
|
+
const result = (0, parser_1.parseCppTranslationUnit)(createCppFile(content));
|
|
33
|
+
expect(result.warnings).toEqual([]);
|
|
34
|
+
expect(result.includes.map((i) => i.header)).toEqual([
|
|
35
|
+
"curl/curl.h",
|
|
36
|
+
"handlers/users.h",
|
|
37
|
+
]);
|
|
38
|
+
expect(result.includes[0].isSystem).toBe(true);
|
|
39
|
+
expect(result.includes[1].isSystem).toBe(false);
|
|
40
|
+
expect(result.namespaces).toContain("api");
|
|
41
|
+
const userService = result.types.find((t) => t.name === "UserService");
|
|
42
|
+
expect(userService).toBeDefined();
|
|
43
|
+
expect(userService?.kind).toBe("class");
|
|
44
|
+
expect(userService?.baseTypes).toEqual(["BaseService"]);
|
|
45
|
+
expect(result.functions.map((fn) => fn.name)).toContain("Load");
|
|
46
|
+
const setopt = result.calls.find((c) => c.callee === "curl_easy_setopt");
|
|
47
|
+
expect(setopt).toBeDefined();
|
|
48
|
+
expect(setopt?.argumentsSnippet).toContain("https://api.example.com/users");
|
|
49
|
+
expect(setopt?.location.startLine).toBe(10);
|
|
50
|
+
});
|
|
51
|
+
it("blanks comments without destroying URLs inside string literals", () => {
|
|
52
|
+
const content = [
|
|
53
|
+
"// #include <sqlite3.h>",
|
|
54
|
+
"/* block comment",
|
|
55
|
+
" spanning lines */",
|
|
56
|
+
'#include "app.h"',
|
|
57
|
+
'const char* endpoint = "https://api.example.com/v1"; // trailing comment',
|
|
58
|
+
"",
|
|
59
|
+
].join("\n");
|
|
60
|
+
const result = (0, parser_1.parseCppTranslationUnit)(createCppFile(content));
|
|
61
|
+
expect(result.includes.map((i) => i.header)).toEqual(["app.h"]);
|
|
62
|
+
expect(result.strippedContent).toContain("https://api.example.com/v1");
|
|
63
|
+
expect(result.strippedContent).not.toContain("trailing comment");
|
|
64
|
+
// Comment blanking preserves line numbering.
|
|
65
|
+
expect(result.strippedContent.split("\n").length).toBe(content.split("\n").length);
|
|
66
|
+
});
|
|
67
|
+
it("returns a warning and an empty model for non-C++ files", () => {
|
|
68
|
+
const file = {
|
|
69
|
+
path: "app.py",
|
|
70
|
+
name: "app.py",
|
|
71
|
+
content: "import os",
|
|
72
|
+
language: "python",
|
|
73
|
+
size: 9,
|
|
74
|
+
};
|
|
75
|
+
const result = (0, parser_1.parseCppTranslationUnit)(file);
|
|
76
|
+
expect(result.includes).toEqual([]);
|
|
77
|
+
expect(result.calls).toEqual([]);
|
|
78
|
+
expect(result.warnings.length).toBeGreaterThan(0);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|