@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
|
@@ -286,4 +286,173 @@ describe("Python analyzer patterns - DP-P0-CLI-703", () => {
|
|
|
286
286
|
f.properties.serviceName === expectedServiceName);
|
|
287
287
|
expect(serviceFinding).toBeDefined();
|
|
288
288
|
});
|
|
289
|
+
it("detects AWS Lambda handlers as lambda_handler findings", () => {
|
|
290
|
+
const content = [
|
|
291
|
+
"import boto3",
|
|
292
|
+
"",
|
|
293
|
+
"def lambda_handler(event, context):",
|
|
294
|
+
" return {'statusCode': 200}",
|
|
295
|
+
"",
|
|
296
|
+
].join("\n");
|
|
297
|
+
const file = makePythonFile(content, "handler.py");
|
|
298
|
+
const findings = (0, detector_1.detectPythonPatterns)(file);
|
|
299
|
+
const handlers = findings.filter((f) => f.pattern === "lambda_handler");
|
|
300
|
+
expect(handlers.length).toBeGreaterThan(0);
|
|
301
|
+
expect(handlers[0].properties.framework).toBe("aws_lambda");
|
|
302
|
+
expect(handlers[0].properties.handler).toBe("lambda_handler");
|
|
303
|
+
expect(handlers[0].properties.handlerType).toBe("serverless_handler");
|
|
304
|
+
});
|
|
305
|
+
it("detects GCP Cloud Functions handlers as lambda_handler findings", () => {
|
|
306
|
+
const content = [
|
|
307
|
+
"import functions_framework",
|
|
308
|
+
"",
|
|
309
|
+
"@functions_framework.http",
|
|
310
|
+
"def hello_http(request):",
|
|
311
|
+
' return "Hello"',
|
|
312
|
+
"",
|
|
313
|
+
].join("\n");
|
|
314
|
+
const file = makePythonFile(content, "main.py");
|
|
315
|
+
const findings = (0, detector_1.detectPythonPatterns)(file);
|
|
316
|
+
const handlers = findings.filter((f) => f.pattern === "lambda_handler");
|
|
317
|
+
expect(handlers.length).toBeGreaterThan(0);
|
|
318
|
+
expect(handlers[0].properties.framework).toBe("gcp_functions");
|
|
319
|
+
expect(handlers[0].properties.handler).toBe("hello_http");
|
|
320
|
+
expect(handlers[0].properties.handlerType).toBe("serverless_handler");
|
|
321
|
+
});
|
|
322
|
+
it("detects gRPC client channels as external_api_call findings", () => {
|
|
323
|
+
const content = [
|
|
324
|
+
"import grpc",
|
|
325
|
+
"",
|
|
326
|
+
'channel = grpc.insecure_channel("localhost:50051")',
|
|
327
|
+
"",
|
|
328
|
+
].join("\n");
|
|
329
|
+
const file = makePythonFile(content, "grpc_client.py");
|
|
330
|
+
const findings = (0, detector_1.detectPythonPatterns)(file);
|
|
331
|
+
const apiFindings = findings.filter((f) => f.pattern === "external_api_call");
|
|
332
|
+
expect(apiFindings.length).toBeGreaterThan(0);
|
|
333
|
+
expect(apiFindings.some((f) => f.properties.serviceName === "grpc")).toBe(true);
|
|
334
|
+
});
|
|
335
|
+
it("detects OAuth2 libraries as auth_middleware findings", () => {
|
|
336
|
+
const content = [
|
|
337
|
+
"from authlib.integrations.flask_client import OAuth",
|
|
338
|
+
"",
|
|
339
|
+
"oauth = OAuth()",
|
|
340
|
+
"",
|
|
341
|
+
].join("\n");
|
|
342
|
+
const file = makePythonFile(content, "oauth_app.py");
|
|
343
|
+
const findings = (0, detector_1.detectPythonPatterns)(file);
|
|
344
|
+
const authFindings = findings.filter((f) => f.pattern === "auth_middleware");
|
|
345
|
+
expect(authFindings.length).toBeGreaterThan(0);
|
|
346
|
+
expect(authFindings.some((f) => f.properties.strategy === "oauth2")).toBe(true);
|
|
347
|
+
});
|
|
348
|
+
it("detects gRPC routes as express_route findings", () => {
|
|
349
|
+
const content = [
|
|
350
|
+
"import grpc",
|
|
351
|
+
"",
|
|
352
|
+
"def serve():",
|
|
353
|
+
" server = grpc.server(None)",
|
|
354
|
+
' server.add_insecure_port("0.0.0.0:50051")',
|
|
355
|
+
"",
|
|
356
|
+
].join("\n");
|
|
357
|
+
const file = makePythonFile(content, "grpc_server.py");
|
|
358
|
+
const findings = (0, detector_1.detectPythonPatterns)(file);
|
|
359
|
+
const routes = findings.filter((f) => f.pattern === "express_route");
|
|
360
|
+
expect(routes.length).toBeGreaterThan(0);
|
|
361
|
+
expect(routes[0].properties.framework).toBe("grpc");
|
|
362
|
+
expect(routes[0].properties.handlerType).toBe("grpc_service");
|
|
363
|
+
});
|
|
364
|
+
it("detects Bearer authorization headers as auth_middleware findings", () => {
|
|
365
|
+
const content = [
|
|
366
|
+
'headers = {"Authorization": "Bearer secret-token"}',
|
|
367
|
+
"",
|
|
368
|
+
].join("\n");
|
|
369
|
+
const file = makePythonFile(content, "auth_headers.py");
|
|
370
|
+
const findings = (0, detector_1.detectPythonPatterns)(file);
|
|
371
|
+
const authFindings = findings.filter((f) => f.pattern === "auth_middleware");
|
|
372
|
+
expect(authFindings.length).toBeGreaterThan(0);
|
|
373
|
+
expect(authFindings.some((f) => f.properties.strategy === "bearer_token")).toBe(true);
|
|
374
|
+
});
|
|
375
|
+
it("detects pymysql as database_connection with databaseType mysql", () => {
|
|
376
|
+
const content = [
|
|
377
|
+
"import pymysql",
|
|
378
|
+
"",
|
|
379
|
+
"conn = pymysql.connect(host='localhost', user='root', db='mydb')",
|
|
380
|
+
"",
|
|
381
|
+
].join("\n");
|
|
382
|
+
const file = makePythonFile(content, "db_mysql.py");
|
|
383
|
+
const findings = (0, detector_1.detectPythonPatterns)(file);
|
|
384
|
+
const dbFindings = findings.filter((f) => f.pattern === "database_connection");
|
|
385
|
+
expect(dbFindings.length).toBeGreaterThan(0);
|
|
386
|
+
expect(dbFindings.some((f) => f.properties.databaseType === "mysql")).toBe(true);
|
|
387
|
+
expect(dbFindings.some((f) => f.properties.client === "pymysql")).toBe(true);
|
|
388
|
+
});
|
|
389
|
+
it("detects pymongo/motor as database_connection with databaseType mongodb", () => {
|
|
390
|
+
const content = [
|
|
391
|
+
"from motor.motor_asyncio import AsyncIOMotorClient",
|
|
392
|
+
"",
|
|
393
|
+
"client = AsyncIOMotorClient('mongodb://localhost:27017')",
|
|
394
|
+
"",
|
|
395
|
+
].join("\n");
|
|
396
|
+
const file = makePythonFile(content, "db_motor.py");
|
|
397
|
+
const findings = (0, detector_1.detectPythonPatterns)(file);
|
|
398
|
+
const dbFindings = findings.filter((f) => f.pattern === "database_connection");
|
|
399
|
+
expect(dbFindings.length).toBeGreaterThan(0);
|
|
400
|
+
expect(dbFindings.some((f) => f.properties.databaseType === "mongodb")).toBe(true);
|
|
401
|
+
});
|
|
402
|
+
it("detects redis-py as database_connection with databaseType redis", () => {
|
|
403
|
+
const content = [
|
|
404
|
+
"import redis",
|
|
405
|
+
"",
|
|
406
|
+
"r = redis.Redis(host='localhost', port=6379)",
|
|
407
|
+
"",
|
|
408
|
+
].join("\n");
|
|
409
|
+
const file = makePythonFile(content, "db_redis.py");
|
|
410
|
+
const findings = (0, detector_1.detectPythonPatterns)(file);
|
|
411
|
+
const dbFindings = findings.filter((f) => f.pattern === "database_connection");
|
|
412
|
+
expect(dbFindings.length).toBeGreaterThan(0);
|
|
413
|
+
expect(dbFindings.some((f) => f.properties.databaseType === "redis")).toBe(true);
|
|
414
|
+
});
|
|
415
|
+
it("detects asyncpg as database_connection with databaseType postgres", () => {
|
|
416
|
+
const content = [
|
|
417
|
+
"import asyncpg",
|
|
418
|
+
"",
|
|
419
|
+
"conn = await asyncpg.connect('postgresql://localhost/mydb')",
|
|
420
|
+
"",
|
|
421
|
+
].join("\n");
|
|
422
|
+
const file = makePythonFile(content, "db_asyncpg.py");
|
|
423
|
+
const findings = (0, detector_1.detectPythonPatterns)(file);
|
|
424
|
+
const dbFindings = findings.filter((f) => f.pattern === "database_connection");
|
|
425
|
+
expect(dbFindings.length).toBeGreaterThan(0);
|
|
426
|
+
expect(dbFindings.some((f) => f.properties.databaseType === "postgres")).toBe(true);
|
|
427
|
+
expect(dbFindings.some((f) => f.properties.client === "asyncpg")).toBe(true);
|
|
428
|
+
});
|
|
429
|
+
it("detects elasticsearch-py as database_connection with databaseType elasticsearch", () => {
|
|
430
|
+
const content = [
|
|
431
|
+
"from elasticsearch import Elasticsearch",
|
|
432
|
+
"",
|
|
433
|
+
"es = Elasticsearch(['http://localhost:9200'])",
|
|
434
|
+
"",
|
|
435
|
+
].join("\n");
|
|
436
|
+
const file = makePythonFile(content, "db_elastic.py");
|
|
437
|
+
const findings = (0, detector_1.detectPythonPatterns)(file);
|
|
438
|
+
const dbFindings = findings.filter((f) => f.pattern === "database_connection");
|
|
439
|
+
expect(dbFindings.length).toBeGreaterThan(0);
|
|
440
|
+
expect(dbFindings.some((f) => f.properties.databaseType === "elasticsearch")).toBe(true);
|
|
441
|
+
});
|
|
442
|
+
it("does not match routes commented out in Python sources", () => {
|
|
443
|
+
const content = [
|
|
444
|
+
"from fastapi import FastAPI",
|
|
445
|
+
"",
|
|
446
|
+
"app = FastAPI()",
|
|
447
|
+
"",
|
|
448
|
+
"# @app.get('/hidden')",
|
|
449
|
+
"async def hidden():",
|
|
450
|
+
" return {}",
|
|
451
|
+
"",
|
|
452
|
+
].join("\n");
|
|
453
|
+
const file = makePythonFile(content, "commented_routes.py");
|
|
454
|
+
const findings = (0, detector_1.detectPythonPatterns)(file);
|
|
455
|
+
const routes = findings.filter((f) => f.pattern === "express_route");
|
|
456
|
+
expect(routes).toHaveLength(0);
|
|
457
|
+
});
|
|
289
458
|
});
|
|
@@ -222,4 +222,192 @@ describe("analyzers/typescript/detector - DP-P0-CLI-104", () => {
|
|
|
222
222
|
expect(configFindings.length).toBeGreaterThan(0);
|
|
223
223
|
patternConfig.loadTypeScriptPatternConfig.mockRestore();
|
|
224
224
|
});
|
|
225
|
+
it("detects AWS Lambda handlers as lambda_handler findings", () => {
|
|
226
|
+
const file = makeFile(`
|
|
227
|
+
import type { APIGatewayProxyHandler } from "aws-lambda";
|
|
228
|
+
|
|
229
|
+
export const handler: APIGatewayProxyHandler = async () => ({
|
|
230
|
+
statusCode: 200,
|
|
231
|
+
body: "ok",
|
|
232
|
+
});
|
|
233
|
+
`);
|
|
234
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
235
|
+
const handlers = findings.filter((f) => f.pattern === "lambda_handler");
|
|
236
|
+
expect(handlers.length).toBeGreaterThan(0);
|
|
237
|
+
expect(handlers[0].properties.framework).toBe("aws_lambda");
|
|
238
|
+
expect(handlers[0].properties.handlerType).toBe("serverless_handler");
|
|
239
|
+
});
|
|
240
|
+
it("detects GCP Cloud Functions handlers as lambda_handler findings", () => {
|
|
241
|
+
const file = makeFile(`
|
|
242
|
+
import * as functions from "@google-cloud/functions-framework";
|
|
243
|
+
|
|
244
|
+
functions.http("helloHttp", (req, res) => {
|
|
245
|
+
res.send("ok");
|
|
246
|
+
});
|
|
247
|
+
`);
|
|
248
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
249
|
+
const handlers = findings.filter((f) => f.pattern === "lambda_handler");
|
|
250
|
+
expect(handlers.length).toBeGreaterThan(0);
|
|
251
|
+
expect(handlers[0].properties.framework).toBe("gcp_functions");
|
|
252
|
+
expect(handlers[0].properties.handlerType).toBe("serverless_handler");
|
|
253
|
+
});
|
|
254
|
+
it("detects gRPC client dial as external_api_call findings", () => {
|
|
255
|
+
const file = makeFile(`
|
|
256
|
+
import * as grpc from "@grpc/grpc-js";
|
|
257
|
+
|
|
258
|
+
const client = new GreeterClient(
|
|
259
|
+
"localhost:50051",
|
|
260
|
+
grpc.credentials.createInsecure(),
|
|
261
|
+
);
|
|
262
|
+
`);
|
|
263
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
264
|
+
const apiFindings = findings.filter((f) => f.pattern === "external_api_call");
|
|
265
|
+
expect(apiFindings.length).toBeGreaterThan(0);
|
|
266
|
+
expect(apiFindings.some((f) => f.properties.client === "grpc")).toBe(true);
|
|
267
|
+
});
|
|
268
|
+
it("detects OAuth2 libraries as auth_middleware findings", () => {
|
|
269
|
+
const file = makeFile(`
|
|
270
|
+
import { OAuth2Client } from "google-auth-library";
|
|
271
|
+
|
|
272
|
+
const client = new OAuth2Client();
|
|
273
|
+
`);
|
|
274
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
275
|
+
const authFindings = findings.filter((f) => f.pattern === "auth_middleware");
|
|
276
|
+
expect(authFindings.length).toBeGreaterThan(0);
|
|
277
|
+
expect(authFindings.some((f) => f.properties.strategy === "oauth2")).toBe(true);
|
|
278
|
+
});
|
|
279
|
+
it("detects dotenv.config as config_file findings", () => {
|
|
280
|
+
const file = makeFile(`
|
|
281
|
+
import dotenv from "dotenv";
|
|
282
|
+
dotenv.config();
|
|
283
|
+
`);
|
|
284
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
285
|
+
const configFindings = findings.filter((f) => f.pattern === "config_file" && f.name === "dotenv_config");
|
|
286
|
+
expect(configFindings.length).toBeGreaterThan(0);
|
|
287
|
+
});
|
|
288
|
+
it("still detects Express routes after a template literal that contains //", () => {
|
|
289
|
+
const file = makeFile(`
|
|
290
|
+
import express from "express";
|
|
291
|
+
const app = express();
|
|
292
|
+
const docs = \`See http://example.com/guide\`;
|
|
293
|
+
app.get("/users", (_req, res) => res.send("ok"));
|
|
294
|
+
`);
|
|
295
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
296
|
+
const routes = findings.filter((f) => f.pattern === "express_route");
|
|
297
|
+
expect(routes.length).toBeGreaterThan(0);
|
|
298
|
+
expect(routes[0].name).toContain("/users");
|
|
299
|
+
});
|
|
300
|
+
it("detects gRPC service registration as express_route findings", () => {
|
|
301
|
+
const file = makeFile(`
|
|
302
|
+
import * as grpc from "@grpc/grpc-js";
|
|
303
|
+
|
|
304
|
+
const server = new grpc.Server();
|
|
305
|
+
server.addService(serviceDefinition, implementation);
|
|
306
|
+
`);
|
|
307
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
308
|
+
const routes = findings.filter((f) => f.pattern === "express_route");
|
|
309
|
+
expect(routes.length).toBeGreaterThan(0);
|
|
310
|
+
expect(routes.some((f) => f.properties.framework === "grpc")).toBe(true);
|
|
311
|
+
});
|
|
312
|
+
it("detects Bearer authorization headers as auth_middleware findings", () => {
|
|
313
|
+
const file = makeFile(`
|
|
314
|
+
const headers = { Authorization: "Bearer token-value" };
|
|
315
|
+
`);
|
|
316
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
317
|
+
const authFindings = findings.filter((f) => f.pattern === "auth_middleware");
|
|
318
|
+
expect(authFindings.length).toBeGreaterThan(0);
|
|
319
|
+
expect(authFindings.some((f) => f.properties.strategy === "bearer_token")).toBe(true);
|
|
320
|
+
});
|
|
321
|
+
it("detects jsonwebtoken import with strategy jwt", () => {
|
|
322
|
+
const file = makeFile(`
|
|
323
|
+
import jwt from "jsonwebtoken";
|
|
324
|
+
const token = jwt.sign({ userId: 1 }, process.env.JWT_SECRET);
|
|
325
|
+
`);
|
|
326
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
327
|
+
const authFindings = findings.filter((f) => f.pattern === "auth_middleware");
|
|
328
|
+
expect(authFindings.length).toBeGreaterThan(0);
|
|
329
|
+
expect(authFindings.some((f) => f.properties.strategy === "jwt")).toBe(true);
|
|
330
|
+
});
|
|
331
|
+
it("detects better-sqlite3 as database_connection with databaseType sqlite", () => {
|
|
332
|
+
const file = makeFile(`
|
|
333
|
+
import Database from "better-sqlite3";
|
|
334
|
+
const db = new Database("app.db");
|
|
335
|
+
`);
|
|
336
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
337
|
+
const dbFindings = findings.filter((f) => f.pattern === "database_connection");
|
|
338
|
+
expect(dbFindings.length).toBeGreaterThan(0);
|
|
339
|
+
expect(dbFindings.some((f) => f.properties.databaseType === "sqlite")).toBe(true);
|
|
340
|
+
});
|
|
341
|
+
it("detects cassandra-driver as database_connection with databaseType cassandra", () => {
|
|
342
|
+
const file = makeFile(`
|
|
343
|
+
import { Client } from "cassandra-driver";
|
|
344
|
+
const client = new Client({ contactPoints: ["localhost"] });
|
|
345
|
+
`);
|
|
346
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
347
|
+
const dbFindings = findings.filter((f) => f.pattern === "database_connection");
|
|
348
|
+
expect(dbFindings.length).toBeGreaterThan(0);
|
|
349
|
+
expect(dbFindings.some((f) => f.properties.databaseType === "cassandra")).toBe(true);
|
|
350
|
+
});
|
|
351
|
+
it("detects mssql as database_connection with databaseType mssql", () => {
|
|
352
|
+
const file = makeFile(`
|
|
353
|
+
import sql from "mssql";
|
|
354
|
+
await sql.connect(config);
|
|
355
|
+
`);
|
|
356
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
357
|
+
const dbFindings = findings.filter((f) => f.pattern === "database_connection");
|
|
358
|
+
expect(dbFindings.length).toBeGreaterThan(0);
|
|
359
|
+
expect(dbFindings.some((f) => f.properties.databaseType === "mssql")).toBe(true);
|
|
360
|
+
});
|
|
361
|
+
it("detects @aws-sdk/client-dynamodb as database_connection with databaseType dynamodb", () => {
|
|
362
|
+
const file = makeFile(`
|
|
363
|
+
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
|
|
364
|
+
const client = new DynamoDBClient({ region: "us-east-1" });
|
|
365
|
+
`);
|
|
366
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
367
|
+
const dbFindings = findings.filter((f) => f.pattern === "database_connection");
|
|
368
|
+
expect(dbFindings.length).toBeGreaterThan(0);
|
|
369
|
+
expect(dbFindings.some((f) => f.properties.databaseType === "dynamodb")).toBe(true);
|
|
370
|
+
});
|
|
371
|
+
it("detects axios as external_api_call findings", () => {
|
|
372
|
+
const file = makeFile(`
|
|
373
|
+
import axios from "axios";
|
|
374
|
+
const res = await axios.get("https://api.example.com/users");
|
|
375
|
+
`);
|
|
376
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
377
|
+
const apiFindings = findings.filter((f) => f.pattern === "external_api_call");
|
|
378
|
+
expect(apiFindings.length).toBeGreaterThan(0);
|
|
379
|
+
expect(apiFindings.some((f) => f.properties.client === "axios")).toBe(true);
|
|
380
|
+
});
|
|
381
|
+
it("detects node-fetch as external_api_call findings", () => {
|
|
382
|
+
const file = makeFile(`
|
|
383
|
+
import fetch from "node-fetch";
|
|
384
|
+
const res = await fetch("https://api.example.com/data");
|
|
385
|
+
`);
|
|
386
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
387
|
+
const apiFindings = findings.filter((f) => f.pattern === "external_api_call");
|
|
388
|
+
expect(apiFindings.length).toBeGreaterThan(0);
|
|
389
|
+
expect(apiFindings.some((f) => f.properties.client === "fetch")).toBe(true);
|
|
390
|
+
});
|
|
391
|
+
it("detects important env variable keys from the importantKeys list", () => {
|
|
392
|
+
const file = makeFile(`
|
|
393
|
+
const secret = process.env.JWT_SECRET;
|
|
394
|
+
const key = process.env.STRIPE_SECRET_KEY;
|
|
395
|
+
`);
|
|
396
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
397
|
+
const envFindings = findings.filter((f) => f.pattern === "env_variable");
|
|
398
|
+
expect(envFindings.length).toBeGreaterThanOrEqual(2);
|
|
399
|
+
const keys = envFindings.map((f) => f.properties.key);
|
|
400
|
+
expect(keys).toContain("JWT_SECRET");
|
|
401
|
+
expect(keys).toContain("STRIPE_SECRET_KEY");
|
|
402
|
+
});
|
|
403
|
+
it("does not match Express routes inside line comments", () => {
|
|
404
|
+
const file = makeFile(`
|
|
405
|
+
import express from "express";
|
|
406
|
+
const app = express();
|
|
407
|
+
// app.get("/hidden", (_req, res) => res.send("nope"));
|
|
408
|
+
`);
|
|
409
|
+
const findings = (0, detector_1.detectPatterns)(file);
|
|
410
|
+
const routes = findings.filter((f) => f.pattern === "express_route");
|
|
411
|
+
expect(routes).toHaveLength(0);
|
|
412
|
+
});
|
|
225
413
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
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 orchestrator_1 = require("../../../src/core/pipeline/orchestrator");
|
|
8
|
+
function fixturePath(name) {
|
|
9
|
+
return path_1.default.join(__dirname, "..", "..", "fixtures", name);
|
|
10
|
+
}
|
|
11
|
+
describe("structural scan - C++ and .NET repositories", () => {
|
|
12
|
+
it("produces components, flows, and parser stats for a C++ service", async () => {
|
|
13
|
+
const config = (0, orchestrator_1.createDefaultScanConfiguration)({ enableAiInference: false });
|
|
14
|
+
const { scanResult, files, findings } = await (0, orchestrator_1.scan)(fixturePath("cpp-basic"), config);
|
|
15
|
+
expect(files.some((file) => file.language === "cpp")).toBe(true);
|
|
16
|
+
const patterns = new Set(findings.map((f) => f.pattern));
|
|
17
|
+
expect(patterns.has("express_route")).toBe(true);
|
|
18
|
+
expect(patterns.has("database_connection")).toBe(true);
|
|
19
|
+
expect(patterns.has("external_api_call")).toBe(true);
|
|
20
|
+
expect(patterns.has("env_variable")).toBe(true);
|
|
21
|
+
expect(scanResult.components.length).toBeGreaterThan(0);
|
|
22
|
+
expect(scanResult.dataFlows.length).toBeGreaterThan(0);
|
|
23
|
+
const stats = (scanResult.languageStats ?? []).find((stat) => stat.language === "cpp");
|
|
24
|
+
expect(stats).toBeDefined();
|
|
25
|
+
expect(stats?.filesParsed).toBeGreaterThan(0);
|
|
26
|
+
expect(stats?.warnings).toEqual([]);
|
|
27
|
+
const serviceNames = scanResult.components
|
|
28
|
+
.filter((c) => c.type === "third_party")
|
|
29
|
+
.map((c) => c.properties?.serviceName);
|
|
30
|
+
expect(serviceNames).toContain("stripe");
|
|
31
|
+
});
|
|
32
|
+
it("produces components, flows, and parser stats for a .NET service", async () => {
|
|
33
|
+
const config = (0, orchestrator_1.createDefaultScanConfiguration)({ enableAiInference: false });
|
|
34
|
+
const { scanResult, files, findings } = await (0, orchestrator_1.scan)(fixturePath("csharp-basic"), config);
|
|
35
|
+
expect(files.some((file) => file.language === "csharp")).toBe(true);
|
|
36
|
+
const routeNames = findings
|
|
37
|
+
.filter((f) => f.pattern === "express_route")
|
|
38
|
+
.map((f) => f.name);
|
|
39
|
+
expect(routeNames).toEqual(expect.arrayContaining([
|
|
40
|
+
"GET api/Customers/{id}",
|
|
41
|
+
"POST api/Customers",
|
|
42
|
+
"GET /health",
|
|
43
|
+
]));
|
|
44
|
+
const patterns = new Set(findings.map((f) => f.pattern));
|
|
45
|
+
expect(patterns.has("database_connection")).toBe(true);
|
|
46
|
+
expect(patterns.has("auth_middleware")).toBe(true);
|
|
47
|
+
expect(patterns.has("env_variable")).toBe(true);
|
|
48
|
+
expect(scanResult.components.length).toBeGreaterThan(0);
|
|
49
|
+
expect(scanResult.dataFlows.length).toBeGreaterThan(0);
|
|
50
|
+
const stats = (scanResult.languageStats ?? []).find((stat) => stat.language === "csharp");
|
|
51
|
+
expect(stats).toBeDefined();
|
|
52
|
+
expect(stats?.filesParsed).toBe(3);
|
|
53
|
+
expect(stats?.warnings).toEqual([]);
|
|
54
|
+
const serviceNames = scanResult.components
|
|
55
|
+
.filter((c) => c.type === "third_party")
|
|
56
|
+
.map((c) => c.properties?.serviceName);
|
|
57
|
+
expect(serviceNames).toContain("stripe");
|
|
58
|
+
});
|
|
59
|
+
it("honours the language filter for C++ and C#", async () => {
|
|
60
|
+
const config = (0, orchestrator_1.createDefaultScanConfiguration)({ enableAiInference: false });
|
|
61
|
+
const { files } = await (0, orchestrator_1.scan)(fixturePath("csharp-basic"), {
|
|
62
|
+
...config,
|
|
63
|
+
languages: ["cpp"],
|
|
64
|
+
});
|
|
65
|
+
expect(files.every((file) => file.language === "cpp")).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
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 fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const discover_service_sections_1 = require("../../../src/core/sectioning/discover-service-sections");
|
|
10
|
+
function write(filePath, content) {
|
|
11
|
+
fs_1.default.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
|
|
12
|
+
fs_1.default.writeFileSync(filePath, content, "utf8");
|
|
13
|
+
}
|
|
14
|
+
describe("service sections - C++ and .NET manifests", () => {
|
|
15
|
+
it("registers a section per .NET project file", async () => {
|
|
16
|
+
const root = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "dp-dotnet-sections-"));
|
|
17
|
+
try {
|
|
18
|
+
write(path_1.default.join(root, "src", "Billing.Api", "Billing.Api.csproj"), '<Project Sdk="Microsoft.NET.Sdk.Web"></Project>');
|
|
19
|
+
write(path_1.default.join(root, "src", "Billing.Worker", "Billing.Worker.csproj"), '<Project Sdk="Microsoft.NET.Sdk.Worker"></Project>');
|
|
20
|
+
const { sections } = await (0, discover_service_sections_1.discoverServiceSections)(root);
|
|
21
|
+
const serviceDirs = sections
|
|
22
|
+
.filter((section) => section.role === "service")
|
|
23
|
+
.map((section) => section.sectionDir)
|
|
24
|
+
.sort();
|
|
25
|
+
expect(serviceDirs).toEqual(["src/Billing.Api", "src/Billing.Worker"]);
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
fs_1.default.rmSync(root, { recursive: true, force: true });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
it("registers a section for C++ package manifests but not for nested CMakeLists", async () => {
|
|
32
|
+
const root = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "dp-cpp-sections-"));
|
|
33
|
+
try {
|
|
34
|
+
write(path_1.default.join(root, "services", "gateway", "vcpkg.json"), JSON.stringify({ name: "gateway", dependencies: ["curl"] }));
|
|
35
|
+
write(path_1.default.join(root, "services", "gateway", "src", "CMakeLists.txt"), "add_library(gateway_core core.cpp)");
|
|
36
|
+
const { sections } = await (0, discover_service_sections_1.discoverServiceSections)(root);
|
|
37
|
+
const serviceDirs = sections
|
|
38
|
+
.filter((section) => section.role === "service")
|
|
39
|
+
.map((section) => section.sectionDir);
|
|
40
|
+
expect(serviceDirs).toEqual(["services/gateway"]);
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
fs_1.default.rmSync(root, { recursive: true, force: true });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
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 fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const orchestrator_1 = require("../../../src/core/pipeline/orchestrator");
|
|
10
|
+
const discover_service_sections_1 = require("../../../src/core/sectioning/discover-service-sections");
|
|
11
|
+
const file_system_1 = require("../../../src/ingest/file-system");
|
|
12
|
+
function fixturePath(name) {
|
|
13
|
+
return path_1.default.join(__dirname, "..", "..", "fixtures", name);
|
|
14
|
+
}
|
|
15
|
+
function write(filePath, content) {
|
|
16
|
+
fs_1.default.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
|
|
17
|
+
fs_1.default.writeFileSync(filePath, content, "utf8");
|
|
18
|
+
}
|
|
19
|
+
describe("structural scan - Go repositories", () => {
|
|
20
|
+
it("produces components, flows, and parser stats for a Go service", async () => {
|
|
21
|
+
const config = (0, orchestrator_1.createDefaultScanConfiguration)({ enableAiInference: false });
|
|
22
|
+
const { scanResult, files, findings } = await (0, orchestrator_1.scan)(fixturePath("go-basic"), config);
|
|
23
|
+
expect(files.some((file) => file.language === "go")).toBe(true);
|
|
24
|
+
const routeNames = findings
|
|
25
|
+
.filter((f) => f.pattern === "express_route")
|
|
26
|
+
.map((f) => f.name);
|
|
27
|
+
expect(routeNames).toEqual(expect.arrayContaining(["GET /customers", "POST /charges"]));
|
|
28
|
+
const patterns = new Set(findings.map((f) => f.pattern));
|
|
29
|
+
expect(patterns.has("database_connection")).toBe(true);
|
|
30
|
+
expect(patterns.has("external_api_call")).toBe(true);
|
|
31
|
+
expect(patterns.has("auth_middleware")).toBe(true);
|
|
32
|
+
expect(patterns.has("env_variable")).toBe(true);
|
|
33
|
+
expect(scanResult.components.length).toBeGreaterThan(0);
|
|
34
|
+
expect(scanResult.dataFlows.length).toBeGreaterThan(0);
|
|
35
|
+
const stats = (scanResult.languageStats ?? []).find((stat) => stat.language === "go");
|
|
36
|
+
expect(stats).toBeDefined();
|
|
37
|
+
expect(stats?.filesParsed).toBe(2);
|
|
38
|
+
expect(stats?.warnings).toEqual([]);
|
|
39
|
+
const serviceNames = scanResult.components
|
|
40
|
+
.filter((c) => c.type === "third_party")
|
|
41
|
+
.map((c) => c.properties?.serviceName);
|
|
42
|
+
expect(serviceNames).toContain("stripe");
|
|
43
|
+
// sql.Open("postgres", ...) should surface as postgres, not generic SQL.
|
|
44
|
+
const postgres = findings.filter((f) => f.pattern === "database_connection" &&
|
|
45
|
+
f.properties.databaseType === "postgres");
|
|
46
|
+
expect(postgres.length).toBeGreaterThan(0);
|
|
47
|
+
});
|
|
48
|
+
it("honours the language filter for Go", async () => {
|
|
49
|
+
const config = (0, orchestrator_1.createDefaultScanConfiguration)({ enableAiInference: false });
|
|
50
|
+
const { files } = await (0, orchestrator_1.scan)(fixturePath("go-basic"), {
|
|
51
|
+
...config,
|
|
52
|
+
languages: ["python"],
|
|
53
|
+
});
|
|
54
|
+
expect(files.every((file) => file.language === "python")).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
it("maps .go files to the go language on ingest", async () => {
|
|
57
|
+
const files = await (0, file_system_1.ingestFileSystem)(fixturePath("go-basic"));
|
|
58
|
+
const byPath = new Map(files.map((file) => [file.path, file.language]));
|
|
59
|
+
expect(byPath.get("main.go")).toBe("go");
|
|
60
|
+
expect(byPath.get("handlers.go")).toBe("go");
|
|
61
|
+
});
|
|
62
|
+
it("registers a section per Go module in a multi-module repository", async () => {
|
|
63
|
+
const root = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "dp-go-sections-"));
|
|
64
|
+
try {
|
|
65
|
+
write(path_1.default.join(root, "services", "api", "go.mod"), "module github.com/acme/api\n\ngo 1.22\n");
|
|
66
|
+
write(path_1.default.join(root, "services", "worker", "go.mod"), "module github.com/acme/worker\n\ngo 1.22\n");
|
|
67
|
+
const { sections } = await (0, discover_service_sections_1.discoverServiceSections)(root);
|
|
68
|
+
const serviceDirs = sections
|
|
69
|
+
.filter((section) => section.role === "service")
|
|
70
|
+
.map((section) => section.sectionDir)
|
|
71
|
+
.sort();
|
|
72
|
+
expect(serviceDirs).toEqual(["services/api", "services/worker"]);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
fs_1.default.rmSync(root, { recursive: true, force: true });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -98,6 +98,19 @@ describe("core/pipeline/graph-mapping - DP-P0-CLI-402", () => {
|
|
|
98
98
|
expect(nodeData.description).toBe("Main application service");
|
|
99
99
|
expect(nodeData.componentType).toBe("asset");
|
|
100
100
|
expect(nodeData.componentSubType).toBe("service");
|
|
101
|
+
expect(nodeData.scanConfidence).toBe(0.99);
|
|
102
|
+
expect(nodeData.sourceLocations).toEqual([
|
|
103
|
+
{
|
|
104
|
+
filePath: "src/app.ts",
|
|
105
|
+
startLine: 10,
|
|
106
|
+
endLine: 20,
|
|
107
|
+
},
|
|
108
|
+
]);
|
|
109
|
+
expect(nodeData.detectedFrom).toEqual([
|
|
110
|
+
{
|
|
111
|
+
pattern: "express_route",
|
|
112
|
+
},
|
|
113
|
+
]);
|
|
101
114
|
expect(nodeData.technologyStack).toEqual(["node", "express"]);
|
|
102
115
|
expect(nodeData.cloudProvider).toBe("AWS");
|
|
103
116
|
const edge = graph.edges[0];
|
|
@@ -122,6 +135,68 @@ describe("core/pipeline/graph-mapping - DP-P0-CLI-402", () => {
|
|
|
122
135
|
expect(properties.targetScope).toBe("local");
|
|
123
136
|
expect(properties.targetScopeConfidence).toBe("high");
|
|
124
137
|
expect(properties.targetScopeReason).toBe("same-section-id");
|
|
138
|
+
expect(properties.sourceLocation).toEqual({
|
|
139
|
+
filePath: "src/app.ts",
|
|
140
|
+
startLine: 30,
|
|
141
|
+
endLine: 40,
|
|
142
|
+
});
|
|
143
|
+
expect(properties.confidence).toBe(0.9);
|
|
144
|
+
});
|
|
145
|
+
it("strips SourceLocation.code and copies scanConfidence onto node data", () => {
|
|
146
|
+
const scanResult = {
|
|
147
|
+
components: [
|
|
148
|
+
{
|
|
149
|
+
id: "component-1",
|
|
150
|
+
name: "DB",
|
|
151
|
+
type: "asset",
|
|
152
|
+
subType: "database",
|
|
153
|
+
confidence: 0.87,
|
|
154
|
+
detectedFrom: [
|
|
155
|
+
{
|
|
156
|
+
pattern: "orm_save",
|
|
157
|
+
sourceLocation: {
|
|
158
|
+
filePath: "src/db/users.ts",
|
|
159
|
+
startLine: 88,
|
|
160
|
+
endLine: 88,
|
|
161
|
+
code: "await db.insert(users)",
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
sourceLocations: [
|
|
166
|
+
{
|
|
167
|
+
filePath: "src/db/users.ts",
|
|
168
|
+
startLine: 88,
|
|
169
|
+
endLine: 88,
|
|
170
|
+
code: "await db.insert(users)",
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
properties: {},
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
dataFlows: [],
|
|
177
|
+
filesScanned: 1,
|
|
178
|
+
filesSkipped: 0,
|
|
179
|
+
totalLines: 10,
|
|
180
|
+
scanDurationMs: 1,
|
|
181
|
+
warnings: [],
|
|
182
|
+
errors: [],
|
|
183
|
+
};
|
|
184
|
+
const graph = (0, graph_mapping_1.buildDiagramGraphFromScanResult)(scanResult);
|
|
185
|
+
const nodeData = graph.nodes[0].data;
|
|
186
|
+
expect(nodeData.scanConfidence).toBe(0.87);
|
|
187
|
+
expect(nodeData.sourceLocations).toEqual([
|
|
188
|
+
{ filePath: "src/db/users.ts", startLine: 88, endLine: 88 },
|
|
189
|
+
]);
|
|
190
|
+
expect(nodeData.detectedFrom).toEqual([
|
|
191
|
+
{
|
|
192
|
+
pattern: "orm_save",
|
|
193
|
+
sourceLocation: {
|
|
194
|
+
filePath: "src/db/users.ts",
|
|
195
|
+
startLine: 88,
|
|
196
|
+
endLine: 88,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
]);
|
|
125
200
|
});
|
|
126
201
|
it("sets engineering.protocol to graphql when flow endpoint is a GraphQL URL", () => {
|
|
127
202
|
const scanResult = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|