@dataparade/cli 0.0.11 → 0.0.12

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.
Files changed (48) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/analyzers/php/dependency-manifests.d.ts +10 -0
  3. package/dist/src/analyzers/php/dependency-manifests.js +117 -0
  4. package/dist/src/analyzers/php/detector.d.ts +3 -0
  5. package/dist/src/analyzers/php/detector.js +20 -0
  6. package/dist/src/analyzers/php/index.d.ts +2 -0
  7. package/dist/src/analyzers/php/index.js +11 -0
  8. package/dist/src/analyzers/php/manifest-parsers.d.ts +14 -0
  9. package/dist/src/analyzers/php/manifest-parsers.js +40 -0
  10. package/dist/src/analyzers/php/parser.d.ts +42 -0
  11. package/dist/src/analyzers/php/parser.js +297 -0
  12. package/dist/src/analyzers/php/patterns.d.ts +3 -0
  13. package/dist/src/analyzers/php/patterns.js +49 -0
  14. package/dist/src/analyzers/php/php-detection-config.d.ts +104 -0
  15. package/dist/src/analyzers/php/php-detection-config.js +192 -0
  16. package/dist/src/analyzers/registry.js +3 -0
  17. package/dist/src/analyzers/shared/strip-comments.js +3 -2
  18. package/dist/src/classifier/postprocessing.d.ts +6 -0
  19. package/dist/src/classifier/postprocessing.js +61 -6
  20. package/dist/src/config/file.js +1 -0
  21. package/dist/src/config/resolve.js +1 -0
  22. package/dist/src/core/pipeline/classifier-phase.js +3 -3
  23. package/dist/src/core/pipeline/structural-scan.js +39 -14
  24. package/dist/src/core/schema/scan-config.schema.d.ts +1 -0
  25. package/dist/src/core/schema/scan-config.schema.js +1 -0
  26. package/dist/src/core/schema/scan-result.schema.d.ts +1 -0
  27. package/dist/src/core/schema/scan-result.schema.js +1 -0
  28. package/dist/src/core/sectioning/discover-service-sections.js +3 -0
  29. package/dist/src/core/types/file.d.ts +1 -1
  30. package/dist/src/ingest/file-system.js +3 -0
  31. package/dist/src/patterns/config.d.ts +2 -0
  32. package/dist/src/patterns/config.js +31 -0
  33. package/dist/src/patterns/detectors/php.d.ts +9 -0
  34. package/dist/src/patterns/detectors/php.js +466 -0
  35. package/dist/src/patterns/engine.js +7 -0
  36. package/dist/tests/unit/analyzers/php/dependency-manifests.spec.d.ts +1 -0
  37. package/dist/tests/unit/analyzers/php/dependency-manifests.spec.js +54 -0
  38. package/dist/tests/unit/analyzers/php/parser.spec.d.ts +1 -0
  39. package/dist/tests/unit/analyzers/php/parser.spec.js +128 -0
  40. package/dist/tests/unit/analyzers/php/patterns.spec.d.ts +1 -0
  41. package/dist/tests/unit/analyzers/php/patterns.spec.js +334 -0
  42. package/dist/tests/unit/classifier/classify.spec.js +68 -0
  43. package/dist/tests/unit/ingest/php-languages.spec.d.ts +1 -0
  44. package/dist/tests/unit/ingest/php-languages.spec.js +40 -0
  45. package/package.json +1 -1
  46. package/patterns/php.md +74 -0
  47. package/patterns/php.patterns.yaml +311 -0
  48. package/patterns/third-party.patterns.yaml +10 -0
@@ -0,0 +1,104 @@
1
+ import { type PatternId } from "../../core/types/detection";
2
+ export interface PhpRouteRegex {
3
+ regex: RegExp;
4
+ methodGroup?: number;
5
+ pathGroup?: number;
6
+ defaultMethod?: string;
7
+ }
8
+ export interface PhpDbClientConfig {
9
+ id: string;
10
+ patternId: PatternId;
11
+ databaseType: string;
12
+ importNamespaces: string[];
13
+ packageNames: string[];
14
+ callNames: string[];
15
+ confidence: number;
16
+ }
17
+ export interface PhpAuthLibraryConfig {
18
+ id: string;
19
+ patternId: PatternId;
20
+ importNamespaces: string[];
21
+ packageNames: string[];
22
+ callNames: string[];
23
+ contentRegexes: RegExp[];
24
+ strategy?: string;
25
+ confidence: number;
26
+ }
27
+ export interface PhpRouteFrameworkConfig {
28
+ id: string;
29
+ patternId: PatternId;
30
+ importNamespaces: string[];
31
+ packageNames: string[];
32
+ routeRegexes: PhpRouteRegex[];
33
+ confidence: number;
34
+ }
35
+ export interface PhpServerlessHandlerConfig {
36
+ id: string;
37
+ patternId: PatternId;
38
+ importNamespaces: string[];
39
+ packageNames: string[];
40
+ callNames: string[];
41
+ confidence: number;
42
+ }
43
+ export interface PhpConfigLoader {
44
+ id: string;
45
+ importNamespaces: string[];
46
+ packageNames: string[];
47
+ callNames: string[];
48
+ }
49
+ export interface PhpHttpClientConfig {
50
+ id: string;
51
+ patternId: PatternId;
52
+ clientName: string;
53
+ importNamespaces: string[];
54
+ packageNames: string[];
55
+ callNames: string[];
56
+ callNameSuffixes: string[];
57
+ urlRegex: RegExp;
58
+ confidence: number;
59
+ /** When true, gated import/package alone emits a finding (SDK presence). */
60
+ emitOnPresence: boolean;
61
+ }
62
+ export interface PhpPatternConfig {
63
+ dbClients: PhpDbClientConfig[];
64
+ pdoDsn?: {
65
+ patternId: PatternId;
66
+ regex: RegExp;
67
+ name: string;
68
+ confidence: number;
69
+ drivers: Record<string, string>;
70
+ defaultDatabaseType: string;
71
+ };
72
+ auth: {
73
+ libraries: PhpAuthLibraryConfig[];
74
+ };
75
+ routes: {
76
+ frameworks: PhpRouteFrameworkConfig[];
77
+ };
78
+ serverless: {
79
+ handlers: PhpServerlessHandlerConfig[];
80
+ };
81
+ envConfig: {
82
+ envVariable?: {
83
+ patternId: PatternId;
84
+ regex: RegExp;
85
+ confidence: number;
86
+ };
87
+ configLoaders?: {
88
+ patternId: PatternId;
89
+ confidence: number;
90
+ loaders: PhpConfigLoader[];
91
+ };
92
+ configFile?: {
93
+ patternId: PatternId;
94
+ fileNameRegex: RegExp;
95
+ name: string;
96
+ confidence: number;
97
+ };
98
+ };
99
+ externalApis: {
100
+ httpClients: PhpHttpClientConfig[];
101
+ };
102
+ }
103
+ export declare function clearPhpPatternConfigCache(): void;
104
+ export declare function loadPhpPatternConfig(): PhpPatternConfig;
@@ -0,0 +1,192 @@
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
+ exports.clearPhpPatternConfigCache = clearPhpPatternConfigCache;
7
+ exports.loadPhpPatternConfig = loadPhpPatternConfig;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const yaml_1 = __importDefault(require("yaml"));
11
+ const detection_1 = require("../../core/types/detection");
12
+ const DEFAULT_CONFIDENCE = 0.8;
13
+ const DEFAULT_URL_REGEX = '["\'](https?:\\/\\/[^"\']+)["\']';
14
+ function validatePatternId(raw, context) {
15
+ const id = String(raw);
16
+ if (!detection_1.PATTERN_IDS.includes(id)) {
17
+ throw new Error(`Invalid patternId '${raw}' in ${context}`);
18
+ }
19
+ return id;
20
+ }
21
+ function compileRegex(pattern, context) {
22
+ try {
23
+ return new RegExp(pattern);
24
+ }
25
+ catch (err) {
26
+ const msg = err instanceof Error ? err.message : String(err);
27
+ throw new Error(`Invalid regex in ${context}: ${msg}`);
28
+ }
29
+ }
30
+ function getConfigPath() {
31
+ const parts = __dirname.split(path_1.default.sep);
32
+ const distIndex = parts.lastIndexOf("dist");
33
+ const cliRoot = distIndex !== -1
34
+ ? parts.slice(0, distIndex).join(path_1.default.sep)
35
+ : path_1.default.resolve(__dirname, "../../..");
36
+ return path_1.default.join(cliRoot, "patterns", "php.patterns.yaml");
37
+ }
38
+ function normalizeList(values) {
39
+ return (values ?? [])
40
+ .map((v) => (typeof v === "string" ? v.trim() : String(v ?? "").trim()))
41
+ .filter(Boolean);
42
+ }
43
+ /** Coerce YAML call-name entries to strings (trailing `::` can parse as maps). */
44
+ function normalizeCallNames(values) {
45
+ if (!values)
46
+ return [];
47
+ const out = [];
48
+ for (const v of values) {
49
+ if (typeof v === "string" && v.trim()) {
50
+ out.push(v.trim());
51
+ continue;
52
+ }
53
+ if (v && typeof v === "object") {
54
+ for (const key of Object.keys(v)) {
55
+ if (key.trim())
56
+ out.push(key.trim());
57
+ }
58
+ }
59
+ }
60
+ return out;
61
+ }
62
+ function normalizeRouteRegexes(raw, context) {
63
+ return (raw ?? []).map((entry, index) => ({
64
+ regex: compileRegex(entry.regex, `${context}.routeRegexes[${index}]`),
65
+ methodGroup: entry.methodGroup,
66
+ pathGroup: entry.pathGroup,
67
+ defaultMethod: entry.defaultMethod,
68
+ }));
69
+ }
70
+ function normalizeRawConfig(raw) {
71
+ const dbClients = raw.db_clients?.map((c) => ({
72
+ id: c.id,
73
+ patternId: validatePatternId(c.patternId, `php.db_clients entry '${c.id}'`),
74
+ databaseType: c.databaseType,
75
+ importNamespaces: normalizeList(c.importNamespaces),
76
+ packageNames: normalizeList(c.packageNames),
77
+ callNames: normalizeCallNames(c.callNames),
78
+ confidence: c.confidence ?? DEFAULT_CONFIDENCE,
79
+ })) ?? [];
80
+ const pdoDsnRaw = raw.pdo_dsn;
81
+ const pdoDsn = pdoDsnRaw && pdoDsnRaw.patternId && pdoDsnRaw.regex
82
+ ? {
83
+ patternId: validatePatternId(pdoDsnRaw.patternId, "php.pdo_dsn.patternId"),
84
+ regex: compileRegex(pdoDsnRaw.regex, "php.pdo_dsn.regex"),
85
+ name: pdoDsnRaw.name ?? "pdo_dsn",
86
+ confidence: pdoDsnRaw.confidence ?? DEFAULT_CONFIDENCE,
87
+ drivers: pdoDsnRaw.drivers ?? {},
88
+ defaultDatabaseType: pdoDsnRaw.defaultDatabaseType ?? "sql",
89
+ }
90
+ : undefined;
91
+ const authLibraries = raw.auth?.libraries?.map((lib) => ({
92
+ id: lib.id,
93
+ patternId: validatePatternId(lib.patternId, `php.auth.libraries['${lib.id}']`),
94
+ importNamespaces: normalizeList(lib.importNamespaces),
95
+ packageNames: normalizeList(lib.packageNames),
96
+ callNames: normalizeCallNames(lib.callNames),
97
+ contentRegexes: (lib.contentRegexes ?? []).map((p) => compileRegex(p, `php.auth.libraries['${lib.id}'].contentRegexes`)),
98
+ strategy: lib.strategy,
99
+ confidence: lib.confidence ?? DEFAULT_CONFIDENCE,
100
+ })) ?? [];
101
+ const routeFrameworks = raw.routes?.frameworks?.map((fw) => ({
102
+ id: fw.id,
103
+ patternId: validatePatternId(fw.patternId, `php.routes.frameworks['${fw.id}']`),
104
+ importNamespaces: normalizeList(fw.importNamespaces),
105
+ packageNames: normalizeList(fw.packageNames),
106
+ routeRegexes: normalizeRouteRegexes(fw.routeRegexes, `php.routes.frameworks['${fw.id}']`),
107
+ confidence: fw.confidence ?? DEFAULT_CONFIDENCE,
108
+ })) ?? [];
109
+ const serverlessHandlers = raw.serverless?.handlers?.map((handler) => ({
110
+ id: handler.id,
111
+ patternId: validatePatternId(handler.patternId, `php.serverless.handlers['${handler.id}']`),
112
+ importNamespaces: normalizeList(handler.importNamespaces),
113
+ packageNames: normalizeList(handler.packageNames),
114
+ callNames: normalizeCallNames(handler.callNames),
115
+ confidence: handler.confidence ?? DEFAULT_CONFIDENCE,
116
+ })) ?? [];
117
+ const envVarRaw = raw.env_config?.envVariable;
118
+ const envVariable = envVarRaw && envVarRaw.patternId && envVarRaw.regex
119
+ ? {
120
+ patternId: validatePatternId(envVarRaw.patternId, "php.env_config.envVariable.patternId"),
121
+ regex: compileRegex(envVarRaw.regex, "php.env_config.envVariable.regex"),
122
+ confidence: envVarRaw.confidence ?? DEFAULT_CONFIDENCE,
123
+ }
124
+ : undefined;
125
+ const configLoadersRaw = raw.env_config?.configLoaders;
126
+ const configLoaders = configLoadersRaw && configLoadersRaw.patternId
127
+ ? {
128
+ patternId: validatePatternId(configLoadersRaw.patternId, "php.env_config.configLoaders.patternId"),
129
+ confidence: configLoadersRaw.confidence ?? DEFAULT_CONFIDENCE,
130
+ loaders: (configLoadersRaw.loaders ?? []).map((loader) => ({
131
+ id: loader.id,
132
+ importNamespaces: normalizeList(loader.importNamespaces),
133
+ packageNames: normalizeList(loader.packageNames),
134
+ callNames: normalizeCallNames(loader.callNames),
135
+ })),
136
+ }
137
+ : undefined;
138
+ const configFileRaw = raw.env_config?.configFile;
139
+ const configFile = configFileRaw && configFileRaw.patternId && configFileRaw.fileNameRegex
140
+ ? {
141
+ patternId: validatePatternId(configFileRaw.patternId, "php.env_config.configFile.patternId"),
142
+ fileNameRegex: compileRegex(configFileRaw.fileNameRegex, "php.env_config.configFile.fileNameRegex"),
143
+ name: configFileRaw.name ?? "php_config",
144
+ confidence: configFileRaw.confidence ?? DEFAULT_CONFIDENCE,
145
+ }
146
+ : undefined;
147
+ const httpClients = raw.external_apis?.httpClients?.map((client) => ({
148
+ id: client.id,
149
+ patternId: validatePatternId(client.patternId, `php.external_apis.httpClients['${client.id}']`),
150
+ clientName: client.clientName,
151
+ importNamespaces: normalizeList(client.importNamespaces),
152
+ packageNames: normalizeList(client.packageNames),
153
+ callNames: normalizeCallNames(client.callNames),
154
+ callNameSuffixes: normalizeCallNames(client.callNameSuffixes),
155
+ urlRegex: compileRegex(client.urlRegex ?? DEFAULT_URL_REGEX, `php.external_apis.httpClients['${client.id}'].urlRegex`),
156
+ confidence: client.confidence ?? DEFAULT_CONFIDENCE,
157
+ emitOnPresence: client.emitOnPresence === true,
158
+ })) ?? [];
159
+ return {
160
+ dbClients,
161
+ pdoDsn,
162
+ auth: { libraries: authLibraries },
163
+ routes: { frameworks: routeFrameworks },
164
+ serverless: { handlers: serverlessHandlers },
165
+ envConfig: { envVariable, configLoaders, configFile },
166
+ externalApis: { httpClients },
167
+ };
168
+ }
169
+ let cachedConfig;
170
+ function clearPhpPatternConfigCache() {
171
+ cachedConfig = undefined;
172
+ }
173
+ function loadPhpPatternConfig() {
174
+ if (cachedConfig)
175
+ return cachedConfig;
176
+ const configPath = getConfigPath();
177
+ let rawYaml;
178
+ try {
179
+ rawYaml = fs_1.default.readFileSync(configPath, "utf8");
180
+ }
181
+ catch (err) {
182
+ const msg = err instanceof Error ? err.message : String(err);
183
+ throw new Error(`PHP pattern config is required but could not be read from '${configPath}': ${msg}`);
184
+ }
185
+ const parsed = yaml_1.default.parse(rawYaml);
186
+ if (!parsed || typeof parsed !== "object") {
187
+ throw new Error(`PHP pattern config at '${configPath}' did not parse to an object.`);
188
+ }
189
+ const normalized = normalizeRawConfig(parsed);
190
+ cachedConfig = normalized;
191
+ return normalized;
192
+ }
@@ -8,6 +8,7 @@ exports.__clearAnalyzersForTest = __clearAnalyzersForTest;
8
8
  const file_system_1 = require("../ingest/file-system");
9
9
  const cpp_1 = require("./cpp");
10
10
  const go_1 = require("./go");
11
+ const php_1 = require("./php");
11
12
  const jvm_1 = require("./jvm");
12
13
  const csharp_1 = require("./csharp");
13
14
  const python_1 = require("./python");
@@ -19,12 +20,14 @@ const typeScriptAnalyzer = (0, typescript_1.createTypeScriptAnalyzer)();
19
20
  const pythonAnalyzer = (0, python_1.createPythonAnalyzer)();
20
21
  const cppAnalyzer = (0, cpp_1.createCppAnalyzer)();
21
22
  const goAnalyzer = (0, go_1.createGoAnalyzer)();
23
+ const phpAnalyzer = (0, php_1.createPhpAnalyzer)();
22
24
  const jvmAnalyzer = (0, jvm_1.createJvmAnalyzer)();
23
25
  const cSharpAnalyzer = (0, csharp_1.createCSharpAnalyzer)();
24
26
  const terraformAnalyzer = (0, terraform_1.createTerraformAnalyzer)();
25
27
  const registry = new Map([
26
28
  ["python", pythonAnalyzer],
27
29
  ["go", goAnalyzer],
30
+ ["php", phpAnalyzer],
28
31
  // Java and Kotlin share one analyzer: same package namespace, same
29
32
  // Maven/Gradle coordinates, same Spring/Jakarta annotations, same JDBC.
30
33
  ["java", jvmAnalyzer],
@@ -125,8 +125,9 @@ function stripCommentsPreservingLayout(source, options = {}) {
125
125
  i = cursor;
126
126
  continue;
127
127
  }
128
- // Python / shell line comment.
129
- if (options.hashComments && ch === "#") {
128
+ // Python / shell / PHP `#` line comment.
129
+ // PHP 8 attributes use `#[...]`; do not treat that as a comment.
130
+ if (options.hashComments && ch === "#" && next !== "[") {
130
131
  let end = i;
131
132
  while (end < length && chars[end] !== "\n")
132
133
  end += 1;
@@ -9,4 +9,10 @@ export declare function getDatabaseCanonicalKey(component: DetectedComponent): s
9
9
  export declare function dedupeComponents(components: DetectedComponent[]): DetectedComponent[];
10
10
  export declare function mergeGlobalIdentityProviderThirdParties(components: DetectedComponent[]): DetectedComponent[];
11
11
  export declare function mergeDatabaseAssetsByType(components: DetectedComponent[]): DetectedComponent[];
12
+ /**
13
+ * Pick where in-app auth middleware should fold when compacting auth_service nodes.
14
+ * Prefer IdP third parties and HTTP API surfaces; never database/storage/config.
15
+ * Returns undefined when no safe target exists (auth_service nodes stay standalone).
16
+ */
17
+ export declare function findAuthCompactionTarget(sectionComponents: DetectedComponent[]): DetectedComponent | undefined;
12
18
  export declare function compactAuthServiceComponents(components: DetectedComponent[]): DetectedComponent[];
@@ -8,6 +8,7 @@ exports.getDatabaseCanonicalKey = getDatabaseCanonicalKey;
8
8
  exports.dedupeComponents = dedupeComponents;
9
9
  exports.mergeGlobalIdentityProviderThirdParties = mergeGlobalIdentityProviderThirdParties;
10
10
  exports.mergeDatabaseAssetsByType = mergeDatabaseAssetsByType;
11
+ exports.findAuthCompactionTarget = findAuthCompactionTarget;
11
12
  exports.compactAuthServiceComponents = compactAuthServiceComponents;
12
13
  const config_1 = require("./config");
13
14
  const naming_1 = require("./naming");
@@ -433,6 +434,65 @@ function isAuthProviderThirdParty(component) {
433
434
  const normalizedName = (component.name || "").trim().toLowerCase();
434
435
  return normalizedService.includes("auth0") || normalizedName.includes("auth0");
435
436
  }
437
+ const AUTH_MERGE_EXCLUDED_SUBTYPES = new Set([
438
+ "database",
439
+ "file_storage",
440
+ "config",
441
+ ]);
442
+ function isBadAuthMergeTarget(component) {
443
+ if (component.type !== "asset")
444
+ return true;
445
+ const subType = component.subType ?? "";
446
+ if (AUTH_MERGE_EXCLUDED_SUBTYPES.has(subType))
447
+ return true;
448
+ if (typeof component.properties?.managed_by_provider === "string")
449
+ return true;
450
+ return false;
451
+ }
452
+ function isMainApplicationAsset(component) {
453
+ return (component.type === "asset" &&
454
+ (component.properties?.isMainApplication === true ||
455
+ component.properties?.isMainApplication === "true"));
456
+ }
457
+ function httpApiAssetRank(component) {
458
+ let score = 0;
459
+ if (component.properties?.isSectionApiNode === true ||
460
+ component.properties?.isSectionApiNode === "true") {
461
+ score += 4;
462
+ }
463
+ if (component.detectedFrom.some((ref) => ref.pattern === "express_route")) {
464
+ score += 2;
465
+ }
466
+ const name = (component.name || "").trim();
467
+ if (name === "API" || name.endsWith(" API"))
468
+ score += 1;
469
+ return score;
470
+ }
471
+ /**
472
+ * Pick where in-app auth middleware should fold when compacting auth_service nodes.
473
+ * Prefer IdP third parties and HTTP API surfaces; never database/storage/config.
474
+ * Returns undefined when no safe target exists (auth_service nodes stay standalone).
475
+ */
476
+ function findAuthCompactionTarget(sectionComponents) {
477
+ const authThirdParty = sectionComponents.find(isAuthProviderThirdParty);
478
+ if (authThirdParty)
479
+ return authThirdParty;
480
+ const mainApp = sectionComponents.find(isMainApplicationAsset);
481
+ if (mainApp && !isBadAuthMergeTarget(mainApp))
482
+ return mainApp;
483
+ const apiCandidates = sectionComponents
484
+ .filter((c) => c.type === "asset" && c.subType === "api" && !isBadAuthMergeTarget(c))
485
+ .sort((a, b) => httpApiAssetRank(b) - httpApiAssetRank(a) ||
486
+ a.name.localeCompare(b.name));
487
+ if (apiCandidates[0])
488
+ return apiCandidates[0];
489
+ const serviceOrApp = sectionComponents.find((c) => c.type === "asset" &&
490
+ (c.subType === "service" || c.subType === "application") &&
491
+ !isBadAuthMergeTarget(c));
492
+ if (serviceOrApp)
493
+ return serviceOrApp;
494
+ return undefined;
495
+ }
436
496
  function mergeAuthServiceIntoTarget(authService, target) {
437
497
  const mergedProperties = {};
438
498
  mergeProperties(mergedProperties, target.properties);
@@ -485,12 +545,7 @@ function compactAuthServiceComponents(components) {
485
545
  !isTerraformScannedResourceAsset(c));
486
546
  if (authServices.length === 0)
487
547
  continue;
488
- const authThirdParty = sectionComponents.find(isAuthProviderThirdParty);
489
- const mainApp = sectionComponents.find((c) => c.type === "asset" &&
490
- (c.properties?.isMainApplication === true ||
491
- c.properties?.isMainApplication === "true"));
492
- const fallbackAsset = sectionComponents.find((c) => c.type === "asset");
493
- const mergeTarget = authThirdParty ?? mainApp ?? fallbackAsset;
548
+ const mergeTarget = findAuthCompactionTarget(sectionComponents);
494
549
  if (!mergeTarget)
495
550
  continue;
496
551
  let nextTarget = replacementById.get(mergeTarget.id) ?? mergeTarget;
@@ -18,6 +18,7 @@ const fileLanguageEnum = zod_1.z.enum([
18
18
  "cpp",
19
19
  "csharp",
20
20
  "go",
21
+ "php",
21
22
  "java",
22
23
  "kotlin",
23
24
  "terraform",
@@ -26,6 +26,7 @@ function normalizeLanguages(values) {
26
26
  "cpp",
27
27
  "csharp",
28
28
  "go",
29
+ "php",
29
30
  "java",
30
31
  "kotlin",
31
32
  "terraform",
@@ -67,12 +67,12 @@ function collapseManifestFrontendFrameworkAssets(components) {
67
67
  function runClassifierPhase(findings, sections, options) {
68
68
  const classified = (0, classify_1.classifyRawFindings)(findings);
69
69
  const dedupedComponents = (0, classify_1.dedupeComponents)(classified);
70
- const compactedAuthComponents = (0, classify_1.compactAuthServiceComponents)(dedupedComponents);
71
- const mergedDbComponents = (0, classify_1.mergeDatabaseAssetsByType)(compactedAuthComponents);
70
+ const mergedDbComponents = (0, classify_1.mergeDatabaseAssetsByType)(dedupedComponents);
72
71
  const withPerSectionApplication = (0, classify_1.injectApplicationAssetsPerSectionIfMissing)(mergedDbComponents, sections, { projectName: options.projectName });
73
72
  const withApplication = (0, classify_1.injectApplicationAssetIfMissing)(withPerSectionApplication, { projectName: options.projectName });
74
73
  const enhanced = (0, enhance_1.enhanceComponents)(withApplication);
75
74
  const mergedFrameworkHelpers = collapseManifestFrontendFrameworkAssets(enhanced);
76
75
  const withSectionApiNodes = (0, classify_1.synthesizeSectionApiNodes)(mergedFrameworkHelpers);
77
- return (0, classify_1.injectActorIfMissing)(withSectionApiNodes).filter((component) => component.confidence >= options.minimumConfidence);
76
+ const compactedAuthComponents = (0, classify_1.compactAuthServiceComponents)(withSectionApiNodes);
77
+ return (0, classify_1.injectActorIfMissing)(compactedAuthComponents).filter((component) => component.confidence >= options.minimumConfidence);
78
78
  }
@@ -14,15 +14,17 @@ const terraform_show_json_1 = require("../../analyzers/terraform/terraform-show-
14
14
  const terraform_exec_1 = require("../../analyzers/terraform/terraform-exec");
15
15
  const parser_1 = require("../../analyzers/python/parser");
16
16
  const parser_2 = require("../../analyzers/go/parser");
17
- const parser_3 = require("../../analyzers/jvm/parser");
18
- const parser_4 = require("../../analyzers/cpp/parser");
19
- const parser_5 = require("../../analyzers/csharp/parser");
17
+ const parser_3 = require("../../analyzers/php/parser");
18
+ const parser_4 = require("../../analyzers/jvm/parser");
19
+ const parser_5 = require("../../analyzers/cpp/parser");
20
+ const parser_6 = require("../../analyzers/csharp/parser");
20
21
  const dependency_manifests_1 = require("../../analyzers/python/dependency-manifests");
21
22
  const dependency_manifests_2 = require("../../analyzers/go/dependency-manifests");
22
- const dependency_manifests_3 = require("../../analyzers/jvm/dependency-manifests");
23
- const dependency_manifests_4 = require("../../analyzers/cpp/dependency-manifests");
24
- const dependency_manifests_5 = require("../../analyzers/csharp/dependency-manifests");
25
- const dependency_manifests_6 = require("../../analyzers/typescript/dependency-manifests");
23
+ const dependency_manifests_3 = require("../../analyzers/php/dependency-manifests");
24
+ const dependency_manifests_4 = require("../../analyzers/jvm/dependency-manifests");
25
+ const dependency_manifests_5 = require("../../analyzers/cpp/dependency-manifests");
26
+ const dependency_manifests_6 = require("../../analyzers/csharp/dependency-manifests");
27
+ const dependency_manifests_7 = require("../../analyzers/typescript/dependency-manifests");
26
28
  const discover_service_sections_1 = require("../sectioning/discover-service-sections");
27
29
  const classifier_phase_1 = require("./classifier-phase");
28
30
  const dataflow_phase_1 = require("./dataflow-phase");
@@ -124,10 +126,20 @@ async function runStructuralScanPhase(rootPath, config, onWarning) {
124
126
  }, warn);
125
127
  if (goStats)
126
128
  languageStats.push(goStats);
129
+ const phpStats = collectLanguageParserStats(files, "php", (file) => {
130
+ const unit = (0, parser_3.parsePhpSourceFile)(file);
131
+ return {
132
+ functionsIndexed: unit.functions.length,
133
+ callsIndexed: unit.calls.length,
134
+ warnings: unit.warnings,
135
+ };
136
+ }, warn);
137
+ if (phpStats)
138
+ languageStats.push(phpStats);
127
139
  // One parser, reported per language so the stats stay attributable.
128
140
  for (const jvmLanguage of ["java", "kotlin"]) {
129
141
  const jvmStats = collectLanguageParserStats(files, jvmLanguage, (file) => {
130
- const unit = (0, parser_3.parseJvmSourceFile)(file);
142
+ const unit = (0, parser_4.parseJvmSourceFile)(file);
131
143
  return {
132
144
  functionsIndexed: unit.methods.length,
133
145
  callsIndexed: unit.calls.length,
@@ -138,7 +150,7 @@ async function runStructuralScanPhase(rootPath, config, onWarning) {
138
150
  languageStats.push(jvmStats);
139
151
  }
140
152
  const cppStats = collectLanguageParserStats(files, "cpp", (file) => {
141
- const unit = (0, parser_4.parseCppTranslationUnit)(file);
153
+ const unit = (0, parser_5.parseCppTranslationUnit)(file);
142
154
  return {
143
155
  functionsIndexed: unit.functions.length,
144
156
  callsIndexed: unit.calls.length,
@@ -148,7 +160,7 @@ async function runStructuralScanPhase(rootPath, config, onWarning) {
148
160
  if (cppStats)
149
161
  languageStats.push(cppStats);
150
162
  const cSharpStats = collectLanguageParserStats(files, "csharp", (file) => {
151
- const unit = (0, parser_5.parseCSharpCompilationUnit)(file);
163
+ const unit = (0, parser_6.parseCSharpCompilationUnit)(file);
152
164
  return {
153
165
  functionsIndexed: unit.methods.length,
154
166
  callsIndexed: unit.calls.length,
@@ -240,13 +252,26 @@ async function runStructuralScanPhase(rootPath, config, onWarning) {
240
252
  warn(`go-manifests: ${message}`);
241
253
  }
242
254
  }
255
+ // Third-party service and dependency detection from Composer manifests.
256
+ if (!config.languages || config.languages.includes("php")) {
257
+ try {
258
+ findings.push(...(await (0, dependency_manifests_3.detectPhpPatternsFromDependencyManifests)(scanRootDir, {
259
+ onWarning: warn,
260
+ excludePaths: config.excludePaths,
261
+ })));
262
+ }
263
+ catch (err) {
264
+ const message = err instanceof Error ? err.message : "Unknown error parsing manifests.";
265
+ warn(`php-manifests: ${message}`);
266
+ }
267
+ }
243
268
  // Third-party service and dependency detection from JVM build manifests
244
269
  // (Maven / Gradle), plus Spring datasource configuration.
245
270
  if (!config.languages ||
246
271
  config.languages.includes("java") ||
247
272
  config.languages.includes("kotlin")) {
248
273
  try {
249
- findings.push(...(await (0, dependency_manifests_3.detectJvmPatternsFromDependencyManifests)(scanRootDir, {
274
+ findings.push(...(await (0, dependency_manifests_4.detectJvmPatternsFromDependencyManifests)(scanRootDir, {
250
275
  onWarning: warn,
251
276
  excludePaths: config.excludePaths,
252
277
  })));
@@ -260,7 +285,7 @@ async function runStructuralScanPhase(rootPath, config, onWarning) {
260
285
  // (vcpkg / Conan / CMake).
261
286
  if (!config.languages || config.languages.includes("cpp")) {
262
287
  try {
263
- findings.push(...(await (0, dependency_manifests_4.detectCppPatternsFromDependencyManifests)(scanRootDir, {
288
+ findings.push(...(await (0, dependency_manifests_5.detectCppPatternsFromDependencyManifests)(scanRootDir, {
264
289
  onWarning: warn,
265
290
  excludePaths: config.excludePaths,
266
291
  })));
@@ -273,7 +298,7 @@ async function runStructuralScanPhase(rootPath, config, onWarning) {
273
298
  // .NET project manifests (PackageReference) and appsettings connection strings.
274
299
  if (!config.languages || config.languages.includes("csharp")) {
275
300
  try {
276
- findings.push(...(await (0, dependency_manifests_5.detectDotnetPatternsFromManifests)(scanRootDir, {
301
+ findings.push(...(await (0, dependency_manifests_6.detectDotnetPatternsFromManifests)(scanRootDir, {
277
302
  onWarning: warn,
278
303
  excludePaths: config.excludePaths,
279
304
  })));
@@ -288,7 +313,7 @@ async function runStructuralScanPhase(rootPath, config, onWarning) {
288
313
  config.languages.some((l) => l === "typescript" || l === "javascript");
289
314
  if (wantsTsOrJs) {
290
315
  try {
291
- findings.push(...(await (0, dependency_manifests_6.detectTypeScriptPatternsFromDependencyManifests)(scanRootDir, {
316
+ findings.push(...(await (0, dependency_manifests_7.detectTypeScriptPatternsFromDependencyManifests)(scanRootDir, {
292
317
  onWarning: warn,
293
318
  excludePaths: config.excludePaths,
294
319
  })));
@@ -16,6 +16,7 @@ export declare const scanConfigurationSchema: z.ZodObject<{
16
16
  cpp: "cpp";
17
17
  csharp: "csharp";
18
18
  go: "go";
19
+ php: "php";
19
20
  java: "java";
20
21
  kotlin: "kotlin";
21
22
  terraform: "terraform";
@@ -16,6 +16,7 @@ const fileLanguageEnum = zod_1.z.enum([
16
16
  "cpp",
17
17
  "csharp",
18
18
  "go",
19
+ "php",
19
20
  "java",
20
21
  "kotlin",
21
22
  "terraform",
@@ -20,6 +20,7 @@ export declare const fileInfoSchema: z.ZodObject<{
20
20
  cpp: "cpp";
21
21
  csharp: "csharp";
22
22
  go: "go";
23
+ php: "php";
23
24
  java: "java";
24
25
  kotlin: "kotlin";
25
26
  terraform: "terraform";
@@ -14,6 +14,7 @@ const fileLanguageEnum = zod_1.z.enum([
14
14
  "cpp",
15
15
  "csharp",
16
16
  "go",
17
+ "php",
17
18
  "java",
18
19
  "kotlin",
19
20
  "terraform",
@@ -82,6 +82,8 @@ async function walkForManifests(currentDirAbs, rootDirAbs, excludePaths, accumul
82
82
  // go.mod is the canonical Go module root, so it maps exactly onto a
83
83
  // service boundary in a multi-module repository.
84
84
  const isGoModule = lower === "go.mod";
85
+ // composer.json is the Composer package root for PHP services.
86
+ const isComposerManifest = lower === "composer.json";
85
87
  // Maven and Gradle both place a build file at each module root, and on the
86
88
  // JVM a module is the deployable unit — unlike `CMakeLists.txt`, one build
87
89
  // file per directory *is* the service boundary. `settings.gradle` marks the
@@ -99,6 +101,7 @@ async function walkForManifests(currentDirAbs, rootDirAbs, excludePaths, accumul
99
101
  !isPipfile &&
100
102
  !isDotnetProject &&
101
103
  !isGoModule &&
104
+ !isComposerManifest &&
102
105
  !isJvmManifest &&
103
106
  !isCppManifest) {
104
107
  continue;
@@ -1,4 +1,4 @@
1
- export type FileLanguage = "typescript" | "javascript" | "json" | "yaml" | "env" | "python" | "cpp" | "csharp" | "go" | "java" | "kotlin" | "terraform" | "dockerfile";
1
+ export type FileLanguage = "typescript" | "javascript" | "json" | "yaml" | "env" | "python" | "cpp" | "csharp" | "go" | "php" | "java" | "kotlin" | "terraform" | "dockerfile";
2
2
  export interface FileInfo {
3
3
  path: string;
4
4
  name: string;
@@ -94,6 +94,9 @@ function getFileLanguage(filePath) {
94
94
  if (ext === ".go") {
95
95
  return "go";
96
96
  }
97
+ if (ext === ".php" || ext === ".phtml") {
98
+ return "php";
99
+ }
97
100
  if (ext === ".java") {
98
101
  return "java";
99
102
  }