@dataparade/cli 0.0.9 → 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 +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 +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
|
@@ -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 {};
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
function fixturePath(name) {
|
|
12
|
+
return path_1.default.join(__dirname, "..", "..", "fixtures", name);
|
|
13
|
+
}
|
|
14
|
+
function write(filePath, content) {
|
|
15
|
+
fs_1.default.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
|
|
16
|
+
fs_1.default.writeFileSync(filePath, content, "utf8");
|
|
17
|
+
}
|
|
18
|
+
describe("structural scan - JVM repositories", () => {
|
|
19
|
+
it("produces components, flows, and parser stats for a Spring service", async () => {
|
|
20
|
+
const config = (0, orchestrator_1.createDefaultScanConfiguration)({ enableAiInference: false });
|
|
21
|
+
const { scanResult, files, findings } = await (0, orchestrator_1.scan)(fixturePath("java-basic"), config);
|
|
22
|
+
expect(files.some((file) => file.language === "java")).toBe(true);
|
|
23
|
+
const routeNames = findings
|
|
24
|
+
.filter((f) => f.pattern === "express_route")
|
|
25
|
+
.map((f) => f.name);
|
|
26
|
+
expect(routeNames).toEqual(expect.arrayContaining([
|
|
27
|
+
"GET /api/customers/{id}",
|
|
28
|
+
"POST /api/customers",
|
|
29
|
+
"DELETE /api/customers/{id}",
|
|
30
|
+
]));
|
|
31
|
+
const patterns = new Set(findings.map((f) => f.pattern));
|
|
32
|
+
expect(patterns.has("database_connection")).toBe(true);
|
|
33
|
+
expect(patterns.has("external_api_call")).toBe(true);
|
|
34
|
+
expect(patterns.has("auth_middleware")).toBe(true);
|
|
35
|
+
expect(patterns.has("env_variable")).toBe(true);
|
|
36
|
+
expect(scanResult.components.length).toBeGreaterThan(0);
|
|
37
|
+
const stats = (scanResult.languageStats ?? []).find((stat) => stat.language === "java");
|
|
38
|
+
expect(stats).toBeDefined();
|
|
39
|
+
expect(stats?.filesParsed).toBe(3);
|
|
40
|
+
expect(stats?.warnings).toEqual([]);
|
|
41
|
+
const serviceNames = scanResult.components
|
|
42
|
+
.filter((c) => c.type === "third_party")
|
|
43
|
+
.map((c) => c.properties?.serviceName);
|
|
44
|
+
expect(serviceNames).toContain("stripe");
|
|
45
|
+
// The JDBC URL should surface postgres, not a generic SQL node.
|
|
46
|
+
const postgres = findings.filter((f) => f.pattern === "database_connection" &&
|
|
47
|
+
f.properties.databaseType === "postgres");
|
|
48
|
+
expect(postgres.length).toBeGreaterThan(0);
|
|
49
|
+
});
|
|
50
|
+
it("scans a Kotlin service through the same analyzer", async () => {
|
|
51
|
+
const config = (0, orchestrator_1.createDefaultScanConfiguration)({ enableAiInference: false });
|
|
52
|
+
const { scanResult, files, findings } = await (0, orchestrator_1.scan)(fixturePath("kotlin-basic"), config);
|
|
53
|
+
expect(files.some((file) => file.language === "kotlin")).toBe(true);
|
|
54
|
+
const routeNames = findings
|
|
55
|
+
.filter((f) => f.pattern === "express_route")
|
|
56
|
+
.map((f) => f.name);
|
|
57
|
+
expect(routeNames).toEqual(expect.arrayContaining(["GET /health", "POST /api/invoices"]));
|
|
58
|
+
const databases = findings.filter((f) => f.pattern === "database_connection");
|
|
59
|
+
expect(databases.map((f) => f.name)).toContain("exposed");
|
|
60
|
+
const stats = (scanResult.languageStats ?? []).find((stat) => stat.language === "kotlin");
|
|
61
|
+
expect(stats?.filesParsed).toBe(1);
|
|
62
|
+
expect(stats?.warnings).toEqual([]);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe("section discovery - JVM build files", () => {
|
|
66
|
+
let root;
|
|
67
|
+
beforeAll(() => {
|
|
68
|
+
root = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "dp-jvm-sections-"));
|
|
69
|
+
write(path_1.default.join(root, "services", "billing", "pom.xml"), "<project><groupId>com.acme</groupId><artifactId>billing</artifactId></project>");
|
|
70
|
+
write(path_1.default.join(root, "services", "billing", "src", "main", "java", "App.java"), "package com.acme.billing;\n\npublic class App {}\n");
|
|
71
|
+
write(path_1.default.join(root, "services", "ledger", "build.gradle.kts"), 'dependencies {\n implementation("org.postgresql:postgresql:42.7.1")\n}\n');
|
|
72
|
+
write(path_1.default.join(root, "services", "ledger", "src", "main", "kotlin", "App.kt"), "package com.acme.ledger\n\nfun main() {}\n");
|
|
73
|
+
// A settings file marks the root of a multi-project build, not a module.
|
|
74
|
+
write(path_1.default.join(root, "settings.gradle.kts"), 'rootProject.name = "acme"\n');
|
|
75
|
+
});
|
|
76
|
+
afterAll(() => {
|
|
77
|
+
fs_1.default.rmSync(root, { recursive: true, force: true });
|
|
78
|
+
});
|
|
79
|
+
it("treats pom.xml and build.gradle.kts as service boundaries", async () => {
|
|
80
|
+
const { sections } = await (0, discover_service_sections_1.discoverServiceSections)(root);
|
|
81
|
+
const serviceDirs = sections
|
|
82
|
+
.filter((section) => section.role === "service")
|
|
83
|
+
.map((section) => section.sectionDir)
|
|
84
|
+
.sort();
|
|
85
|
+
expect(serviceDirs).toEqual(["services/billing", "services/ledger"]);
|
|
86
|
+
});
|
|
87
|
+
it("does not promote settings.gradle.kts to a service section", async () => {
|
|
88
|
+
const { sections } = await (0, discover_service_sections_1.discoverServiceSections)(root);
|
|
89
|
+
const rootSection = sections.find((section) => section.sectionDir === "");
|
|
90
|
+
// A settings file marks a multi-project build, not a deployable module,
|
|
91
|
+
// so the repository root stays the root section.
|
|
92
|
+
expect(rootSection?.role).toBe("root");
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
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 promises_1 = __importDefault(require("fs/promises"));
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const file_system_1 = require("../../../src/ingest/file-system");
|
|
10
|
+
describe("ingest/file-system - C++ and C# language mapping", () => {
|
|
11
|
+
let root;
|
|
12
|
+
beforeAll(async () => {
|
|
13
|
+
root = await promises_1.default.mkdtemp(path_1.default.join(os_1.default.tmpdir(), "dp-ingest-cpp-dotnet-"));
|
|
14
|
+
const files = {
|
|
15
|
+
"main.cpp": "int main() { return 0; }",
|
|
16
|
+
"helper.cc": "void helper() {}",
|
|
17
|
+
"service.cxx": "void service() {}",
|
|
18
|
+
"types.hpp": "struct T {};",
|
|
19
|
+
"legacy.h": "void legacy();",
|
|
20
|
+
"Program.cs": "class Program {}",
|
|
21
|
+
"View.cshtml": "@page",
|
|
22
|
+
"Component.razor": "<div></div>",
|
|
23
|
+
"notes.md": "# notes",
|
|
24
|
+
};
|
|
25
|
+
for (const [name, content] of Object.entries(files)) {
|
|
26
|
+
await promises_1.default.writeFile(path_1.default.join(root, name), content, "utf8");
|
|
27
|
+
}
|
|
28
|
+
// Generated C# sources and .NET build output are excluded by default.
|
|
29
|
+
await promises_1.default.writeFile(path_1.default.join(root, "Resources.Designer.cs"), "class Resources {}", "utf8");
|
|
30
|
+
await promises_1.default.mkdir(path_1.default.join(root, "obj"), { recursive: true });
|
|
31
|
+
await promises_1.default.writeFile(path_1.default.join(root, "obj", "Generated.cs"), "class Generated {}", "utf8");
|
|
32
|
+
});
|
|
33
|
+
afterAll(async () => {
|
|
34
|
+
await promises_1.default.rm(root, { recursive: true, force: true });
|
|
35
|
+
});
|
|
36
|
+
it("maps C++ and C# extensions to their languages", async () => {
|
|
37
|
+
const files = await (0, file_system_1.ingestFileSystem)(root);
|
|
38
|
+
const byPath = new Map(files.map((file) => [file.path, file.language]));
|
|
39
|
+
expect(byPath.get("main.cpp")).toBe("cpp");
|
|
40
|
+
expect(byPath.get("helper.cc")).toBe("cpp");
|
|
41
|
+
expect(byPath.get("service.cxx")).toBe("cpp");
|
|
42
|
+
expect(byPath.get("types.hpp")).toBe("cpp");
|
|
43
|
+
expect(byPath.get("legacy.h")).toBe("cpp");
|
|
44
|
+
expect(byPath.get("Program.cs")).toBe("csharp");
|
|
45
|
+
expect(byPath.get("View.cshtml")).toBe("csharp");
|
|
46
|
+
expect(byPath.get("Component.razor")).toBe("csharp");
|
|
47
|
+
// Unsupported file types are still skipped.
|
|
48
|
+
expect(byPath.has("notes.md")).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
it("skips generated C# sources and .NET build output", async () => {
|
|
51
|
+
const files = await (0, file_system_1.ingestFileSystem)(root);
|
|
52
|
+
const paths = files.map((file) => file.path);
|
|
53
|
+
expect(paths).not.toContain("Resources.Designer.cs");
|
|
54
|
+
expect(paths.some((p) => p.startsWith("obj/"))).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|