@dataparade/cli 0.0.30 → 0.0.32
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/dist/package.json +3 -3
- package/dist/src/ai-enrichment/fallbacks.js +12 -1
- package/dist/src/cli.js +3 -0
- package/dist/src/core/pipeline/omit-internal-implementation.js +13 -6
- package/dist/src/output/git-context.d.ts +17 -0
- package/dist/src/output/git-context.js +104 -0
- package/dist/tests/unit/ai-enrichment/fallbacks.spec.js +30 -0
- package/dist/tests/unit/core/omit-internal-implementation.spec.js +21 -0
- package/dist/tests/unit/output/git-context.spec.d.ts +1 -0
- package/dist/tests/unit/output/git-context.spec.js +79 -0
- package/dist/vendor/scanner/dist/src/analyzers/python/python-detection-config.d.ts +11 -0
- package/dist/vendor/scanner/dist/src/analyzers/python/python-detection-config.js +2 -0
- package/dist/vendor/scanner/dist/src/analyzers/registry.d.ts +2 -0
- package/dist/vendor/scanner/dist/src/analyzers/registry.js +3 -2
- package/dist/vendor/scanner/dist/src/analyzers/typescript/typescript-detection-config.d.ts +17 -0
- package/dist/vendor/scanner/dist/src/analyzers/typescript/typescript-detection-config.js +11 -0
- package/dist/vendor/scanner/dist/src/classifier/component-factory.js +33 -3
- package/dist/vendor/scanner/dist/src/classifier/enhance.js +14 -0
- package/dist/vendor/scanner/dist/src/classifier/external-url-third-party.d.ts +8 -0
- package/dist/vendor/scanner/dist/src/classifier/external-url-third-party.js +43 -2
- package/dist/vendor/scanner/dist/src/classifier/postprocessing.js +4 -1
- package/dist/vendor/scanner/dist/src/config/third-party-detection-config.d.ts +41 -0
- package/dist/vendor/scanner/dist/src/config/third-party-detection-config.js +65 -1
- package/dist/vendor/scanner/dist/src/core/pipeline/diagram-layout/constants.d.ts +2 -0
- package/dist/vendor/scanner/dist/src/core/pipeline/diagram-layout/constants.js +3 -1
- package/dist/vendor/scanner/dist/src/core/pipeline/diagram-layout/section-packing.d.ts +9 -0
- package/dist/vendor/scanner/dist/src/core/pipeline/diagram-layout/section-packing.js +40 -0
- package/dist/vendor/scanner/dist/src/core/pipeline/graph-mapping.js +2 -0
- package/dist/vendor/scanner/dist/src/core/pipeline/structural-scan.js +2 -0
- package/dist/vendor/scanner/dist/src/eval/canonical/scanner/components.d.ts +5 -0
- package/dist/vendor/scanner/dist/src/eval/canonical/scanner/components.js +10 -2
- package/dist/vendor/scanner/dist/src/eval/canonical/scanner/data-flows.js +4 -4
- package/dist/vendor/scanner/dist/src/patterns/config.js +7 -1
- package/dist/vendor/scanner/dist/src/patterns/detectors/git-remote-owner.d.ts +14 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/git-remote-owner.js +108 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/python-outbound-http.d.ts +93 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/python-outbound-http.js +1206 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/python-source.d.ts +180 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/python-source.js +1022 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/python.d.ts +6 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/python.js +49 -1
- package/dist/vendor/scanner/dist/src/patterns/detectors/repo-declared-domains.d.ts +2 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/repo-declared-domains.js +80 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/source-module-index.d.ts +23 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/source-module-index.js +145 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/typescript-outbound-http.d.ts +30 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/typescript-outbound-http.js +575 -0
- package/dist/vendor/scanner/dist/src/patterns/detectors/typescript.js +12 -0
- package/dist/vendor/scanner/dist/src/patterns/engine.js +6 -1
- package/dist/vendor/scanner/patterns/classifier/third-party.classifier.yaml +188 -0
- package/dist/vendor/scanner/patterns/python.patterns.yaml +10 -0
- package/dist/vendor/scanner/patterns/third-party.patterns.yaml +246 -0
- package/dist/vendor/scanner/patterns/typescript.patterns.yaml +21 -0
- package/package.json +3 -3
|
@@ -8,11 +8,14 @@ exports.isOrganizationOwnedExternalApiFinding = isOrganizationOwnedExternalApiFi
|
|
|
8
8
|
exports.isReservedPlaceholderHost = isReservedPlaceholderHost;
|
|
9
9
|
exports.shouldIgnoreExternalHttpUrl = shouldIgnoreExternalHttpUrl;
|
|
10
10
|
exports.deriveServiceKeyFromHostname = deriveServiceKeyFromHostname;
|
|
11
|
+
exports.registrableDomainOf = registrableDomainOf;
|
|
12
|
+
exports.vendorNameFromHostname = vendorNameFromHostname;
|
|
11
13
|
exports.urlHostMatchKeys = urlHostMatchKeys;
|
|
12
14
|
exports.defaultServiceNameFromLiteralPublicUrl = defaultServiceNameFromLiteralPublicUrl;
|
|
13
15
|
exports.inferThirdPartyFromLiteralHttpUrl = inferThirdPartyFromLiteralHttpUrl;
|
|
14
16
|
const config_1 = require("./config");
|
|
15
17
|
const organization_domains_scan_scope_1 = require("./organization-domains-scan-scope");
|
|
18
|
+
const third_party_detection_config_1 = require("../config/third-party-detection-config");
|
|
16
19
|
/**
|
|
17
20
|
* Structural heuristics (not a vendor list): URLs that are obviously templated or
|
|
18
21
|
* env-driven should not be treated as static third-party endpoints.
|
|
@@ -197,6 +200,38 @@ function deriveServiceKeyFromHostname(host) {
|
|
|
197
200
|
}
|
|
198
201
|
return `${parts[parts.length - 2]}.${parts[parts.length - 1]}`;
|
|
199
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Second-level public suffixes (`co.uk`): the registrable domain then has three labels.
|
|
205
|
+
* A short list of the common ones; anything else is treated as a one-label suffix.
|
|
206
|
+
*/
|
|
207
|
+
const TWO_LABEL_PUBLIC_SUFFIXES = new Set([
|
|
208
|
+
"co.uk", "org.uk", "ac.uk", "gov.uk", "me.uk", "ltd.uk",
|
|
209
|
+
"com.au", "net.au", "org.au", "edu.au", "gov.au",
|
|
210
|
+
"co.nz", "org.nz", "co.jp", "ne.jp", "or.jp", "co.kr", "co.in", "co.za", "co.id", "co.il",
|
|
211
|
+
"com.br", "com.mx", "com.ar", "com.sg", "com.hk", "com.tw", "com.cn", "com.tr", "com.my", "com.ph",
|
|
212
|
+
]);
|
|
213
|
+
/** Registrable domain of a host (`www.shop.example.co.uk` -> `example.co.uk`). */
|
|
214
|
+
function registrableDomainOf(host) {
|
|
215
|
+
const parts = host.replace(/^www\./, "").toLowerCase().split(".").filter(Boolean);
|
|
216
|
+
if (parts.length < 2)
|
|
217
|
+
return parts.join(".");
|
|
218
|
+
const lastTwo = parts.slice(-2).join(".");
|
|
219
|
+
const labels = parts.length >= 3 && TWO_LABEL_PUBLIC_SUFFIXES.has(lastTwo) ? 3 : 2;
|
|
220
|
+
return parts.slice(-labels).join(".");
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Vendor key for a host the catalog does not know: the registrable domain without its
|
|
224
|
+
* public suffix (`api.dramaboxdb.com` -> `dramaboxdb`, `shop.example.co.uk` -> `example`),
|
|
225
|
+
* so components are named after a vendor, not a domain (DATAP-818).
|
|
226
|
+
*/
|
|
227
|
+
function vendorNameFromHostname(host) {
|
|
228
|
+
const parts = host.replace(/^www\./, "").toLowerCase().split(".").filter(Boolean);
|
|
229
|
+
if (parts.length < 2)
|
|
230
|
+
return parts[0] ?? host.toLowerCase();
|
|
231
|
+
const lastTwo = parts.slice(-2).join(".");
|
|
232
|
+
const suffixLabels = parts.length >= 3 && TWO_LABEL_PUBLIC_SUFFIXES.has(lastTwo) ? 2 : 1;
|
|
233
|
+
return parts[parts.length - 1 - suffixLabels] ?? lastTwo;
|
|
234
|
+
}
|
|
200
235
|
/**
|
|
201
236
|
* Hostname + registrable domain keys from an absolute http(s) URL (for matching
|
|
202
237
|
* external_api_call findings to third_party nodes by endpoint.
|
|
@@ -236,7 +271,10 @@ function defaultServiceNameFromLiteralPublicUrl(url, options) {
|
|
|
236
271
|
if (hostname == null || !hostname) {
|
|
237
272
|
return undefined;
|
|
238
273
|
}
|
|
239
|
-
|
|
274
|
+
// A shared hosting host (`*.run.app`) is someone's own service, not a vendor.
|
|
275
|
+
if ((0, third_party_detection_config_1.platformOfHost)(hostname))
|
|
276
|
+
return undefined;
|
|
277
|
+
return vendorNameFromHostname(hostname);
|
|
240
278
|
}
|
|
241
279
|
catch {
|
|
242
280
|
return undefined;
|
|
@@ -294,7 +332,10 @@ function inferThirdPartyFromLiteralHttpUrl(finding, options) {
|
|
|
294
332
|
if (isLocalOrPrivateHost(hostname) || isReservedPlaceholderHost(hostname)) {
|
|
295
333
|
return undefined;
|
|
296
334
|
}
|
|
297
|
-
|
|
335
|
+
if ((0, third_party_detection_config_1.platformOfHost)(hostname)) {
|
|
336
|
+
return undefined;
|
|
337
|
+
}
|
|
338
|
+
const serviceName = vendorNameFromHostname(hostname);
|
|
298
339
|
if (!serviceName) {
|
|
299
340
|
return undefined;
|
|
300
341
|
}
|
|
@@ -135,7 +135,10 @@ function buildComponentDedupeKey(component, nameNormalization) {
|
|
|
135
135
|
const serviceName = component.properties.serviceName;
|
|
136
136
|
if (typeof serviceName === "string" && serviceName.trim()) {
|
|
137
137
|
const key = serviceName.trim().toLowerCase();
|
|
138
|
-
|
|
138
|
+
// Endpoints of one service routed to another subtype stay separate (DATAP-818).
|
|
139
|
+
const routed = component.properties.thirdPartySubType;
|
|
140
|
+
const subtypeKey = typeof routed === "string" && routed.trim() ? `:${component.subType ?? routed}` : "";
|
|
141
|
+
return `third_party:${sectionId}:${key}${subtypeKey}`;
|
|
139
142
|
}
|
|
140
143
|
const normalized = (0, naming_1.normalizeComponentName)(component.name, nameNormalization);
|
|
141
144
|
const keyName = normalized || component.name.trim().toLowerCase() || "<unknown>";
|
|
@@ -17,9 +17,50 @@ export interface ThirdPartyServiceConfig {
|
|
|
17
17
|
confidence: number;
|
|
18
18
|
urlHostPatterns: string[];
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* One rule for a host shared by several products (DATAP-818). `path` is tested against the
|
|
22
|
+
* URL path (no query); `hint` against the calling code's names (file path, class, function,
|
|
23
|
+
* URL expression). The first rule whose tests all pass names the service.
|
|
24
|
+
*/
|
|
25
|
+
export interface ThirdPartyUrlRouteRule {
|
|
26
|
+
path?: RegExp;
|
|
27
|
+
hint?: RegExp;
|
|
28
|
+
serviceName: string;
|
|
29
|
+
/** Overrides the catalog subtype for this route (e.g. Instagram messaging vs publishing). */
|
|
30
|
+
subType?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ThirdPartyUrlRoute {
|
|
33
|
+
host: string;
|
|
34
|
+
rules: ThirdPartyUrlRouteRule[];
|
|
35
|
+
}
|
|
36
|
+
/** LLM gateway model prefix (`groq/llama-3.1-8b`) naming the provider (DATAP-818). */
|
|
37
|
+
export interface LlmModelPrefix {
|
|
38
|
+
prefix: string;
|
|
39
|
+
serviceName: string;
|
|
40
|
+
}
|
|
20
41
|
export interface ThirdPartyDetectionConfig {
|
|
21
42
|
httpClients: ThirdPartyHttpClientConfig[];
|
|
22
43
|
services: ThirdPartyServiceConfig[];
|
|
44
|
+
urlRoutes: ThirdPartyUrlRoute[];
|
|
45
|
+
/** Rules for URLs whose host is only known at runtime (`https://{shop}/api/mcp`): path and hint required. */
|
|
46
|
+
urlPathRoutes: ThirdPartyUrlRouteRule[];
|
|
47
|
+
llmModelPrefixes: LlmModelPrefix[];
|
|
48
|
+
/** `googleapiclient.discovery.build("<api>", ...)` API name -> service (DATAP-818). */
|
|
49
|
+
googleApiServices: Map<string, string>;
|
|
50
|
+
/** Shared hosting suffixes (`*.run.app`): own services, never vendors (DATAP-818). */
|
|
51
|
+
platformHosts: Array<{
|
|
52
|
+
pattern: RegExp;
|
|
53
|
+
platform: string;
|
|
54
|
+
name: string;
|
|
55
|
+
}>;
|
|
23
56
|
}
|
|
24
57
|
export declare function clearThirdPartyDetectionConfigCache(): void;
|
|
25
58
|
export declare function loadThirdPartyDetectionConfig(): ThirdPartyDetectionConfig;
|
|
59
|
+
/** Platform of a host on a shared hosting suffix (`gcp/cloud_run`), or undefined. */
|
|
60
|
+
export declare function platformOfHost(host: string): string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Display name for a service on a shared hosting platform: the first host label without
|
|
63
|
+
* project numbers, deploy hashes or region codes, plus the platform
|
|
64
|
+
* (`mom-skipify-328574824807.us-central1.run.app` -> "mom-skipify (Cloud Run)").
|
|
65
|
+
*/
|
|
66
|
+
export declare function platformServiceDisplayName(host: string): string | undefined;
|
|
@@ -10,6 +10,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.clearThirdPartyDetectionConfigCache = clearThirdPartyDetectionConfigCache;
|
|
12
12
|
exports.loadThirdPartyDetectionConfig = loadThirdPartyDetectionConfig;
|
|
13
|
+
exports.platformOfHost = platformOfHost;
|
|
14
|
+
exports.platformServiceDisplayName = platformServiceDisplayName;
|
|
13
15
|
const fs_1 = __importDefault(require("fs"));
|
|
14
16
|
const path_1 = __importDefault(require("path"));
|
|
15
17
|
const yaml_1 = __importDefault(require("yaml"));
|
|
@@ -92,6 +94,68 @@ function loadThirdPartyDetectionConfig() {
|
|
|
92
94
|
});
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
|
-
|
|
97
|
+
const urlRoutes = [];
|
|
98
|
+
if (Array.isArray(parsed.url_routes)) {
|
|
99
|
+
for (const route of parsed.url_routes) {
|
|
100
|
+
if (!route?.host || !Array.isArray(route.rules)) {
|
|
101
|
+
throw new Error(`third-party-detection.url_routes entries need host and rules (${configPath}).`);
|
|
102
|
+
}
|
|
103
|
+
urlRoutes.push({
|
|
104
|
+
host: route.host.toLowerCase(),
|
|
105
|
+
rules: route.rules.map((rule) => {
|
|
106
|
+
if (!rule.serviceName) {
|
|
107
|
+
throw new Error(`third-party-detection.url_routes['${route.host}'] rule is missing serviceName.`);
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
serviceName: rule.serviceName,
|
|
111
|
+
...(rule.path ? { path: new RegExp(rule.path, "i") } : {}),
|
|
112
|
+
...(rule.hint ? { hint: new RegExp(rule.hint, "i") } : {}),
|
|
113
|
+
...(rule.subType ? { subType: rule.subType } : {}),
|
|
114
|
+
};
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const urlPathRoutes = (parsed.url_path_routes ?? []).map((rule) => {
|
|
120
|
+
if (!rule.serviceName || !rule.path || !rule.hint) {
|
|
121
|
+
throw new Error("third-party-detection.url_path_routes rules need path, hint and serviceName.");
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
serviceName: rule.serviceName,
|
|
125
|
+
path: new RegExp(rule.path, "i"),
|
|
126
|
+
hint: new RegExp(rule.hint, "i"),
|
|
127
|
+
...(rule.subType ? { subType: rule.subType } : {}),
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
const llmModelPrefixes = Object.entries(parsed.llm_model_prefixes ?? {}).map(([prefix, serviceName]) => ({ prefix: prefix.toLowerCase().replace(/\/$/, ""), serviceName: String(serviceName) }));
|
|
131
|
+
const googleApiServices = new Map(Object.entries(parsed.google_api_services ?? {}).map(([api, serviceName]) => [api.toLowerCase(), String(serviceName)]));
|
|
132
|
+
const platformHosts = (parsed.platform_hosts ?? []).map((entry) => ({
|
|
133
|
+
pattern: compileRegex(entry.pattern),
|
|
134
|
+
platform: String(entry.platform),
|
|
135
|
+
name: String(entry.name ?? entry.platform),
|
|
136
|
+
}));
|
|
137
|
+
cached = { httpClients, services, urlRoutes, urlPathRoutes, llmModelPrefixes, googleApiServices, platformHosts };
|
|
96
138
|
return cached;
|
|
97
139
|
}
|
|
140
|
+
/** Platform of a host on a shared hosting suffix (`gcp/cloud_run`), or undefined. */
|
|
141
|
+
function platformOfHost(host) {
|
|
142
|
+
const h = host.toLowerCase();
|
|
143
|
+
return loadThirdPartyDetectionConfig().platformHosts.find((entry) => entry.pattern.test(h))?.platform;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Display name for a service on a shared hosting platform: the first host label without
|
|
147
|
+
* project numbers, deploy hashes or region codes, plus the platform
|
|
148
|
+
* (`mom-skipify-328574824807.us-central1.run.app` -> "mom-skipify (Cloud Run)").
|
|
149
|
+
*/
|
|
150
|
+
function platformServiceDisplayName(host) {
|
|
151
|
+
const h = host.toLowerCase();
|
|
152
|
+
const entry = loadThirdPartyDetectionConfig().platformHosts.find((e) => e.pattern.test(h));
|
|
153
|
+
if (!entry)
|
|
154
|
+
return undefined;
|
|
155
|
+
let label = h.split(".")[0] ?? h;
|
|
156
|
+
label = label
|
|
157
|
+
.replace(/-[a-z0-9]{8,12}-[a-z]{2}$/, "") // Cloud Run `service-<hash>-<region code>`
|
|
158
|
+
.replace(/-\d{6,}$/, "") // project number
|
|
159
|
+
.replace(/-[a-f0-9]{8,}$/, ""); // deploy hash
|
|
160
|
+
return `${label || h} (${entry.name})`;
|
|
161
|
+
}
|
|
@@ -9,3 +9,5 @@ export declare const MANAGED_NODE_Y_STEP = 200;
|
|
|
9
9
|
export declare const TERRAFORM_LANE_X_STEP = 400;
|
|
10
10
|
/** Horizontal space per section (TF lanes + optional managed column beside provider). */
|
|
11
11
|
export declare const SECTION_BLOCK_WIDTH: number;
|
|
12
|
+
/** Space between the last column of one section and the first column of the next (one empty lane). */
|
|
13
|
+
export declare const SECTION_GAP_X: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SECTION_BLOCK_WIDTH = exports.TERRAFORM_LANE_X_STEP = exports.MANAGED_NODE_Y_STEP = exports.MANAGED_NODE_Y_BASE_OFFSET = exports.MANAGED_NODE_X_OFFSET = exports.NODES_PER_ROW = exports.NODE_VERTICAL_SPACING = exports.NODE_HORIZONTAL_SPACING = void 0;
|
|
3
|
+
exports.SECTION_GAP_X = exports.SECTION_BLOCK_WIDTH = exports.TERRAFORM_LANE_X_STEP = exports.MANAGED_NODE_Y_STEP = exports.MANAGED_NODE_Y_BASE_OFFSET = exports.MANAGED_NODE_X_OFFSET = exports.NODES_PER_ROW = exports.NODE_VERTICAL_SPACING = exports.NODE_HORIZONTAL_SPACING = void 0;
|
|
4
4
|
exports.NODE_HORIZONTAL_SPACING = 350;
|
|
5
5
|
exports.NODE_VERTICAL_SPACING = 200;
|
|
6
6
|
exports.NODES_PER_ROW = 4;
|
|
@@ -12,3 +12,5 @@ exports.MANAGED_NODE_Y_STEP = exports.NODE_VERTICAL_SPACING;
|
|
|
12
12
|
exports.TERRAFORM_LANE_X_STEP = 400;
|
|
13
13
|
/** Horizontal space per section (TF lanes + optional managed column beside provider). */
|
|
14
14
|
exports.SECTION_BLOCK_WIDTH = Math.max(exports.NODES_PER_ROW * exports.NODE_HORIZONTAL_SPACING, 5 * exports.TERRAFORM_LANE_X_STEP + exports.MANAGED_NODE_X_OFFSET + 120);
|
|
15
|
+
/** Space between the last column of one section and the first column of the next (one empty lane). */
|
|
16
|
+
exports.SECTION_GAP_X = 2 * exports.TERRAFORM_LANE_X_STEP;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DiagramNodeSchema } from "../../schema";
|
|
2
|
+
import type { ComponentByIdMap } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Section layouts start each section at a fixed `SECTION_BLOCK_WIDTH` offset,
|
|
5
|
+
* which leaves wide empty bands after sparse sections. Shift every section left
|
|
6
|
+
* so it starts `SECTION_GAP_X` after the previous one actually ends; the shape
|
|
7
|
+
* inside each section is unchanged.
|
|
8
|
+
*/
|
|
9
|
+
export declare function packSectionsHorizontally(nodes: DiagramNodeSchema[], componentsById: ComponentByIdMap, sectionIds: string[]): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packSectionsHorizontally = packSectionsHorizontally;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const section_helpers_1 = require("./section-helpers");
|
|
6
|
+
/**
|
|
7
|
+
* Section layouts start each section at a fixed `SECTION_BLOCK_WIDTH` offset,
|
|
8
|
+
* which leaves wide empty bands after sparse sections. Shift every section left
|
|
9
|
+
* so it starts `SECTION_GAP_X` after the previous one actually ends; the shape
|
|
10
|
+
* inside each section is unchanged.
|
|
11
|
+
*/
|
|
12
|
+
function packSectionsHorizontally(nodes, componentsById, sectionIds) {
|
|
13
|
+
const nodesBySection = new Map();
|
|
14
|
+
for (const node of nodes) {
|
|
15
|
+
const component = componentsById.get(node.id);
|
|
16
|
+
if (!component)
|
|
17
|
+
continue;
|
|
18
|
+
const sectionId = (0, section_helpers_1.getSectionIdFromComponent)(component);
|
|
19
|
+
const list = nodesBySection.get(sectionId) ?? [];
|
|
20
|
+
list.push(node);
|
|
21
|
+
nodesBySection.set(sectionId, list);
|
|
22
|
+
}
|
|
23
|
+
let nextX = null;
|
|
24
|
+
for (const sectionId of sectionIds) {
|
|
25
|
+
const sectionNodes = nodesBySection.get(sectionId);
|
|
26
|
+
if (!sectionNodes?.length)
|
|
27
|
+
continue;
|
|
28
|
+
const xs = sectionNodes.map((node) => node.position.x);
|
|
29
|
+
const minX = Math.min(...xs);
|
|
30
|
+
const maxX = Math.max(...xs);
|
|
31
|
+
// Only ever pull sections left, so packing can't push them into each other.
|
|
32
|
+
const shift = nextX === null ? 0 : Math.min(0, nextX - minX);
|
|
33
|
+
if (shift < 0) {
|
|
34
|
+
for (const node of sectionNodes) {
|
|
35
|
+
node.position = { x: node.position.x + shift, y: node.position.y };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
nextX = maxX + shift + constants_1.SECTION_GAP_X;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -10,6 +10,7 @@ const edge_handles_1 = require("./diagram-layout/edge-handles");
|
|
|
10
10
|
const managed_provider_layout_1 = require("./diagram-layout/managed-provider-layout");
|
|
11
11
|
const minimal_terraform_layout_1 = require("./diagram-layout/minimal-terraform-layout");
|
|
12
12
|
const section_helpers_1 = require("./diagram-layout/section-helpers");
|
|
13
|
+
const section_packing_1 = require("./diagram-layout/section-packing");
|
|
13
14
|
const terraform_lane_layout_1 = require("./diagram-layout/terraform-lane-layout");
|
|
14
15
|
const terraform_minimal_services_1 = require("./terraform-minimal-services");
|
|
15
16
|
const infer_data_flow_protocol_1 = require("./infer-data-flow-protocol");
|
|
@@ -341,6 +342,7 @@ function buildDiagramGraphFromScanResult(scanResult) {
|
|
|
341
342
|
(0, terraform_lane_layout_1.applyTerraformLaneLayout)(nodes, componentsById, sectionIds);
|
|
342
343
|
(0, app_section_layout_1.applyAppSectionStackLayout)(nodes, componentsById, sectionIds);
|
|
343
344
|
(0, managed_provider_layout_1.repositionManagedProviderNodes)(nodes, componentsById);
|
|
345
|
+
(0, section_packing_1.packSectionsHorizontally)(nodes, componentsById, sectionIds);
|
|
344
346
|
}
|
|
345
347
|
for (const flow of scanResult.dataFlows) {
|
|
346
348
|
const edge = mapDataFlowToEdge(flow, componentsById);
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.runStructuralScanPhase = runStructuralScanPhase;
|
|
7
7
|
exports.runStructuralScan = runStructuralScan;
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const git_remote_owner_1 = require("../../patterns/detectors/git-remote-owner");
|
|
9
10
|
const scan_result_schema_1 = require("../schema/scan-result.schema");
|
|
10
11
|
const file_system_1 = require("../../ingest/file-system");
|
|
11
12
|
const registry_1 = require("../../analyzers/registry");
|
|
@@ -184,6 +185,7 @@ async function runStructuralScanPhase(rootPath, config, onWarning) {
|
|
|
184
185
|
terraformModuleManifest,
|
|
185
186
|
terraformScanRootPath: scanRootDir,
|
|
186
187
|
organizationDomains: config.organizationDomains,
|
|
188
|
+
gitRemoteOwner: (0, git_remote_owner_1.readGitRemoteOwner)(scanRootDir),
|
|
187
189
|
});
|
|
188
190
|
}
|
|
189
191
|
finally {
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { DetectedComponent } from "../../../core/types/component";
|
|
2
2
|
import type { CanonicalScannerFinding } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Gold vendor keys are snake_case (`facebook_messenger`); scanner display names and the
|
|
5
|
+
* vendor property are title case with spaces (`Facebook Messenger`).
|
|
6
|
+
*/
|
|
7
|
+
export declare function thirdPartyVendorKey(value: string): string;
|
|
3
8
|
export declare function componentScannerIdentityKey(component: DetectedComponent): string;
|
|
4
9
|
export declare function adaptDetectedComponent(component: DetectedComponent, adapterMapVersion?: string): CanonicalScannerFinding;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.thirdPartyVendorKey = thirdPartyVendorKey;
|
|
3
4
|
exports.componentScannerIdentityKey = componentScannerIdentityKey;
|
|
4
5
|
exports.adaptDetectedComponent = adaptDetectedComponent;
|
|
5
6
|
const record_factory_1 = require("../record-factory");
|
|
6
7
|
const manifest_1 = require("./manifest");
|
|
8
|
+
/**
|
|
9
|
+
* Gold vendor keys are snake_case (`facebook_messenger`); scanner display names and the
|
|
10
|
+
* vendor property are title case with spaces (`Facebook Messenger`).
|
|
11
|
+
*/
|
|
12
|
+
function thirdPartyVendorKey(value) {
|
|
13
|
+
return value.trim().toLowerCase().replace(/\s+/g, "_");
|
|
14
|
+
}
|
|
7
15
|
function componentScannerIdentityKey(component) {
|
|
8
16
|
const nameKey = component.name.toLowerCase();
|
|
9
17
|
const subtype = component.subType?.trim().toLowerCase();
|
|
10
18
|
if (component.type === "third_party") {
|
|
11
|
-
return `${component.type}:${nameKey}`;
|
|
19
|
+
return `${component.type}:${thirdPartyVendorKey(nameKey)}`;
|
|
12
20
|
}
|
|
13
21
|
if (component.type === "asset" || component.type === "actor") {
|
|
14
22
|
if (subtype) {
|
|
@@ -44,7 +52,7 @@ function resolveOptionalVendor(component) {
|
|
|
44
52
|
if (typeof vendor !== "string" || vendor.trim().length === 0) {
|
|
45
53
|
return undefined;
|
|
46
54
|
}
|
|
47
|
-
return vendor
|
|
55
|
+
return thirdPartyVendorKey(vendor);
|
|
48
56
|
}
|
|
49
57
|
function adaptDetectedComponent(component, adapterMapVersion = (0, manifest_1.resolveScannerAdapterMapVersion)()) {
|
|
50
58
|
const identityKey = componentScannerIdentityKey(component);
|
|
@@ -14,7 +14,7 @@ function flowComponentIdentityKey(component) {
|
|
|
14
14
|
}
|
|
15
15
|
const vendor = component.properties?.vendor;
|
|
16
16
|
if (typeof vendor === "string" && vendor.trim()) {
|
|
17
|
-
return `${component.type}:${
|
|
17
|
+
return `${component.type}:${(0, components_1.thirdPartyVendorKey)(vendor)}`;
|
|
18
18
|
}
|
|
19
19
|
return (0, components_1.componentScannerIdentityKey)(component);
|
|
20
20
|
}
|
|
@@ -105,7 +105,7 @@ function resolveFlowEndpointVendor(flow, component) {
|
|
|
105
105
|
}
|
|
106
106
|
const vendor = component?.properties?.vendor;
|
|
107
107
|
if (typeof vendor === "string" && vendor.trim()) {
|
|
108
|
-
return
|
|
108
|
+
return (0, components_1.thirdPartyVendorKey)(vendor);
|
|
109
109
|
}
|
|
110
110
|
return undefined;
|
|
111
111
|
}
|
|
@@ -164,9 +164,9 @@ function endpointKeyForFlowComponent(component, fallback) {
|
|
|
164
164
|
}
|
|
165
165
|
const vendor = component.properties?.vendor;
|
|
166
166
|
if (typeof vendor === "string" && vendor.trim()) {
|
|
167
|
-
return
|
|
167
|
+
return (0, components_1.thirdPartyVendorKey)(vendor);
|
|
168
168
|
}
|
|
169
|
-
return component.name
|
|
169
|
+
return (0, components_1.thirdPartyVendorKey)(component.name) || fallback;
|
|
170
170
|
}
|
|
171
171
|
const subType = component.subType?.trim();
|
|
172
172
|
if (subType) {
|
|
@@ -247,7 +247,13 @@ function validateUnifiedPatternConfig(unified) {
|
|
|
247
247
|
throw new Error(`Unified pattern config validation failed: classifier.pattern_defaults is missing ${missingInClassifier.join(", ")}.`);
|
|
248
248
|
}
|
|
249
249
|
// Ensure third-party service catalog alignment (serviceName label).
|
|
250
|
-
const patternServiceNames =
|
|
250
|
+
const patternServiceNames = [
|
|
251
|
+
...unified.thirdParty.services.map((s) => s.serviceName),
|
|
252
|
+
...unified.thirdParty.urlRoutes.flatMap((route) => route.rules.map((rule) => rule.serviceName)),
|
|
253
|
+
...unified.thirdParty.urlPathRoutes.map((rule) => rule.serviceName),
|
|
254
|
+
...unified.thirdParty.llmModelPrefixes.map((entry) => entry.serviceName),
|
|
255
|
+
...unified.thirdParty.googleApiServices.values(),
|
|
256
|
+
].map((name) => name.toLowerCase());
|
|
251
257
|
const classifierServiceNames = unified.classifier.thirdParties.map((s) => s.serviceName.toLowerCase());
|
|
252
258
|
const missingThirdPartyServices = patternServiceNames.filter((svc) => !classifierServiceNames.includes(svc));
|
|
253
259
|
if (missingThirdPartyServices.length > 0) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The owner (user or organization) of the scanned repository's `origin` remote, read from
|
|
3
|
+
* the git config (DATAP-818). It is one more conservative first-party signal: a host whose
|
|
4
|
+
* registrable-domain label matches the owner name is the organization's own service.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readGitRemoteOwner(startDir: string): string | undefined;
|
|
7
|
+
/** `git@github.com:Acme/repo.git`, `https://github.com/Acme/repo` -> `Acme`. */
|
|
8
|
+
export declare function ownerFromRemoteUrl(url: string): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Comparable organization name: lowercase, alphanumerics only, common suffixes removed
|
|
11
|
+
* (`Acme-Widgets-AI` -> `acmewidgets`). A suffix is removed only when at least three
|
|
12
|
+
* characters remain.
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeOrganizationName(name: string): string;
|
|
@@ -0,0 +1,108 @@
|
|
|
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.readGitRemoteOwner = readGitRemoteOwner;
|
|
7
|
+
exports.ownerFromRemoteUrl = ownerFromRemoteUrl;
|
|
8
|
+
exports.normalizeOrganizationName = normalizeOrganizationName;
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
/**
|
|
12
|
+
* The owner (user or organization) of the scanned repository's `origin` remote, read from
|
|
13
|
+
* the git config (DATAP-818). It is one more conservative first-party signal: a host whose
|
|
14
|
+
* registrable-domain label matches the owner name is the organization's own service.
|
|
15
|
+
*/
|
|
16
|
+
function readGitRemoteOwner(startDir) {
|
|
17
|
+
const config = findGitConfig(startDir);
|
|
18
|
+
if (!config)
|
|
19
|
+
return undefined;
|
|
20
|
+
let text;
|
|
21
|
+
try {
|
|
22
|
+
text = fs_1.default.readFileSync(config, "utf8");
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const url = originUrl(text);
|
|
28
|
+
return url ? ownerFromRemoteUrl(url) : undefined;
|
|
29
|
+
}
|
|
30
|
+
/** Path of the git config for `startDir` or its nearest ancestor (worktrees included). */
|
|
31
|
+
function findGitConfig(startDir) {
|
|
32
|
+
let dir = path_1.default.resolve(startDir);
|
|
33
|
+
for (;;) {
|
|
34
|
+
const dotGit = path_1.default.join(dir, ".git");
|
|
35
|
+
try {
|
|
36
|
+
const st = fs_1.default.statSync(dotGit);
|
|
37
|
+
if (st.isDirectory())
|
|
38
|
+
return path_1.default.join(dotGit, "config");
|
|
39
|
+
if (st.isFile()) {
|
|
40
|
+
// Worktree or submodule: `gitdir: <path>`; the shared config is in the common dir.
|
|
41
|
+
const gitdir = /^gitdir:\s*(.+)$/m.exec(fs_1.default.readFileSync(dotGit, "utf8"))?.[1]?.trim();
|
|
42
|
+
if (!gitdir)
|
|
43
|
+
return undefined;
|
|
44
|
+
const resolved = path_1.default.resolve(dir, gitdir);
|
|
45
|
+
const commondirFile = path_1.default.join(resolved, "commondir");
|
|
46
|
+
const common = fs_1.default.existsSync(commondirFile)
|
|
47
|
+
? path_1.default.resolve(resolved, fs_1.default.readFileSync(commondirFile, "utf8").trim())
|
|
48
|
+
: resolved;
|
|
49
|
+
return path_1.default.join(common, "config");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// No .git here: keep walking up.
|
|
54
|
+
}
|
|
55
|
+
const parent = path_1.default.dirname(dir);
|
|
56
|
+
if (parent === dir)
|
|
57
|
+
return undefined;
|
|
58
|
+
dir = parent;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function originUrl(config) {
|
|
62
|
+
let inOrigin = false;
|
|
63
|
+
for (const raw of config.split(/\r?\n/)) {
|
|
64
|
+
const line = raw.trim();
|
|
65
|
+
if (line.startsWith("[")) {
|
|
66
|
+
inOrigin = /^\[remote\s+"origin"\]$/.test(line);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (!inOrigin)
|
|
70
|
+
continue;
|
|
71
|
+
const m = /^url\s*=\s*(.+)$/.exec(line);
|
|
72
|
+
if (m)
|
|
73
|
+
return m[1].trim();
|
|
74
|
+
}
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
/** `git@github.com:Acme/repo.git`, `https://github.com/Acme/repo` -> `Acme`. */
|
|
78
|
+
function ownerFromRemoteUrl(url) {
|
|
79
|
+
const scp = /^[^@/\s]+@[^:/\s]+:([^/\s]+)\/[^/\s]+$/.exec(url);
|
|
80
|
+
if (scp)
|
|
81
|
+
return scp[1];
|
|
82
|
+
try {
|
|
83
|
+
const parts = new URL(url).pathname.split("/").filter(Boolean);
|
|
84
|
+
return parts.length >= 2 ? parts[parts.length - 2] : undefined;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const ORG_SUFFIXES = ["labs", "inc", "app", "ai", "hq", "io"];
|
|
91
|
+
/**
|
|
92
|
+
* Comparable organization name: lowercase, alphanumerics only, common suffixes removed
|
|
93
|
+
* (`Acme-Widgets-AI` -> `acmewidgets`). A suffix is removed only when at least three
|
|
94
|
+
* characters remain.
|
|
95
|
+
*/
|
|
96
|
+
function normalizeOrganizationName(name) {
|
|
97
|
+
let key = name.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
98
|
+
for (let changed = true; changed;) {
|
|
99
|
+
changed = false;
|
|
100
|
+
for (const suffix of ORG_SUFFIXES) {
|
|
101
|
+
if (key.endsWith(suffix) && key.length - suffix.length >= 3) {
|
|
102
|
+
key = key.slice(0, -suffix.length);
|
|
103
|
+
changed = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return key;
|
|
108
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Python outbound HTTP destinations (DATAP-818).
|
|
3
|
+
*
|
|
4
|
+
* Finds request calls made with a raw HTTP library (httpx, requests, aiohttp), with an
|
|
5
|
+
* OpenAI-compatible client pointed at another provider, with an MCP-over-HTTP client, with
|
|
6
|
+
* Phoenix tracing, or through an unresolved `(method, url)` helper, and resolves the URL the
|
|
7
|
+
* call reaches in the same file. A known host names the third party; an unknown host gives an
|
|
8
|
+
* outbound-HTTP finding with no vendor. The HTTP library is never the destination.
|
|
9
|
+
*/
|
|
10
|
+
import type { RawFinding } from "../../core/types/detection";
|
|
11
|
+
import type { UnifiedPatternConfig } from "../config";
|
|
12
|
+
/** Finding name for an outbound HTTP call whose destination host is not known. */
|
|
13
|
+
export declare const OUTBOUND_HTTP_UNKNOWN_FINDING_NAME = "outbound_http_call";
|
|
14
|
+
interface Site {
|
|
15
|
+
startLine: number;
|
|
16
|
+
endLine: number;
|
|
17
|
+
}
|
|
18
|
+
export interface RawHttpLibrary {
|
|
19
|
+
/** Library name (`httpx`); never reported as a destination. */
|
|
20
|
+
name: string;
|
|
21
|
+
importModules: string[];
|
|
22
|
+
constructors: string[];
|
|
23
|
+
patternId: RawFinding["pattern"];
|
|
24
|
+
confidence: number;
|
|
25
|
+
}
|
|
26
|
+
export interface Destination {
|
|
27
|
+
serviceName: string;
|
|
28
|
+
subType?: string;
|
|
29
|
+
url: string;
|
|
30
|
+
sites: Site[];
|
|
31
|
+
/**
|
|
32
|
+
* Set when the host is a service of its own rather than a vendor: one of the
|
|
33
|
+
* organization's hosts (`firstParty`) or a host on a shared hosting platform
|
|
34
|
+
* (`platform`, e.g. gcp/cloud_run). The call is kept as an API asset for that remote
|
|
35
|
+
* service, never a third party, so cross-repo flows are not lost (DATAP-818).
|
|
36
|
+
*/
|
|
37
|
+
remote?: RemoteService;
|
|
38
|
+
}
|
|
39
|
+
export interface RemoteService {
|
|
40
|
+
host: string;
|
|
41
|
+
firstParty?: true;
|
|
42
|
+
platform?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare class DestinationRouter {
|
|
45
|
+
private readonly hostPatterns;
|
|
46
|
+
private readonly routes;
|
|
47
|
+
private readonly pathRoutes;
|
|
48
|
+
private readonly modelPrefixes;
|
|
49
|
+
private readonly catalogSubTypes;
|
|
50
|
+
private readonly libraryNames;
|
|
51
|
+
constructor(config: UnifiedPatternConfig, libraryNames: string[]);
|
|
52
|
+
/**
|
|
53
|
+
* Service for a URL. `fallback` allows the registrable host (`acme.io`) for public hosts
|
|
54
|
+
* the catalog does not know. Returns "unknown" for local, placeholder and dynamic hosts,
|
|
55
|
+
* and `{ remote }` for a service of its own: the organization's domains (including the
|
|
56
|
+
* ones the repository declares) or a shared hosting platform host.
|
|
57
|
+
*/
|
|
58
|
+
route(url: string, hint: string, fallback: boolean): {
|
|
59
|
+
serviceName: string;
|
|
60
|
+
subType?: string;
|
|
61
|
+
} | "unknown" | {
|
|
62
|
+
remote: RemoteService;
|
|
63
|
+
};
|
|
64
|
+
/** Provider of an LLM gateway model id (`groq/llama-3.1-8b-instant` -> groq). */
|
|
65
|
+
routeModel(model: string): {
|
|
66
|
+
serviceName: string;
|
|
67
|
+
subType?: string;
|
|
68
|
+
} | "unknown";
|
|
69
|
+
isLibrary(name: string): boolean;
|
|
70
|
+
private named;
|
|
71
|
+
}
|
|
72
|
+
export interface PythonOutboundHttpInput {
|
|
73
|
+
filePath: string;
|
|
74
|
+
content: string;
|
|
75
|
+
libraries: RawHttpLibrary[];
|
|
76
|
+
config: UnifiedPatternConfig;
|
|
77
|
+
}
|
|
78
|
+
export interface PythonOutboundHttpResult {
|
|
79
|
+
findings: RawFinding[];
|
|
80
|
+
/**
|
|
81
|
+
* Lines of outbound request calls, HTTP client constructors and the header dicts passed
|
|
82
|
+
* to them: an `Authorization` header there is a credential sent to an API.
|
|
83
|
+
*/
|
|
84
|
+
outgoingRequestLines: number[];
|
|
85
|
+
/** True when the file builds OpenAI clients and every one points at a non-OpenAI host. */
|
|
86
|
+
openAiClientsRedirected: boolean;
|
|
87
|
+
}
|
|
88
|
+
export declare function detectPythonOutboundHttp(input: PythonOutboundHttpInput): PythonOutboundHttpResult;
|
|
89
|
+
/** Properties of a finding for a remote service of its own (see `Destination.remote`). */
|
|
90
|
+
export declare function remoteServiceProperties(remote: RemoteService, url: string, extra: Record<string, unknown>): Record<string, unknown>;
|
|
91
|
+
/** Finding name for a remote service of its own: the platform display name, else the host. */
|
|
92
|
+
export declare function remoteServiceName(remote: RemoteService): string;
|
|
93
|
+
export {};
|