@dataparade/cli 0.0.35 → 0.1.1
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 -0
- package/dist/package.json +4 -4
- package/dist/src/ai-enrichment/pii-signal-rules.d.ts +5 -0
- package/dist/src/ai-enrichment/pii-signal-rules.js +2 -3
- package/dist/src/ai-enrichment/provider-prompt.js +1 -0
- package/dist/src/ai-enrichment/providers/provider-contract.js +2 -44
- package/dist/src/ai-enrichment/third-party-data-flow.js +5 -4
- package/dist/src/cli.js +9 -3
- package/dist/src/discoveries/contract/ocsf-discovery-record.d.ts +4 -1
- package/dist/src/discoveries/contract/ocsf-discovery-record.js +1 -1
- package/dist/src/discoveries/contract/ontology-pins.d.ts +6 -4
- package/dist/src/discoveries/contract/ontology-pins.js +7 -5
- package/dist/src/facts/build-facts.d.ts +2 -0
- package/dist/src/facts/build-facts.js +18 -0
- package/dist/src/facts/layout.d.ts +4 -0
- package/dist/src/facts/layout.js +5 -1
- package/dist/src/facts/scan-stamps.d.ts +7 -0
- package/dist/src/facts/scan-stamps.js +30 -0
- package/dist/src/facts/schema.d.ts +178 -0
- package/dist/src/facts/schema.js +37 -1
- package/dist/src/kb/data-category-catalog.generated.d.ts +34 -0
- package/dist/src/kb/data-category-catalog.generated.js +962 -0
- package/dist/src/kb/kb-store.js +4 -1
- package/dist/src/kb/migrate.js +4 -2
- package/dist/src/kb/slot-shapes.d.ts +3 -2
- package/dist/src/kb/slot-shapes.js +13 -8
- package/dist/src/kb/taxonomy.d.ts +12 -6
- package/dist/src/kb/taxonomy.js +13 -18
- package/dist/src/output/scan-output-excludes.js +2 -0
- package/dist/src/output/write-scan-knowledge.d.ts +5 -1
- package/dist/src/output/write-scan-knowledge.js +21 -0
- package/dist/src/threat-model/build-threat-model.d.ts +3 -0
- package/dist/src/threat-model/build-threat-model.js +71 -0
- package/dist/src/threat-model/carry-forward-person-set-statuses.d.ts +8 -0
- package/dist/src/threat-model/carry-forward-person-set-statuses.js +87 -0
- package/dist/src/threat-model/io.d.ts +19 -0
- package/dist/src/threat-model/io.js +63 -0
- package/dist/src/threat-model/schema.d.ts +214 -0
- package/dist/src/threat-model/schema.js +75 -0
- package/dist/src/ui/scan-progress-renderer.d.ts +8 -1
- package/dist/src/ui/scan-progress-renderer.js +20 -1
- package/dist/src/upload/collect-scan-sidecars.d.ts +2 -1
- package/dist/src/upload/collect-scan-sidecars.js +3 -1
- package/dist/tests/cli/cli.spec.js +10 -1
- package/dist/tests/helpers/facts-fixture.js +16 -16
- package/dist/tests/schema/scan-result.schema.spec.js +1 -1
- package/dist/tests/unit/ai-enrichment/provider-contract.spec.js +1 -1
- package/dist/tests/unit/ai-enrichment/third-party-data-flow.spec.js +5 -5
- package/dist/tests/unit/core/graph-mapping.spec.js +4 -3
- package/dist/tests/unit/discoveries/write-ocsf-discoveries-long-ids.spec.js +3 -3
- package/dist/tests/unit/export/export-ocsf.spec.js +4 -4
- package/dist/tests/unit/facts/apply-answers.spec.js +20 -20
- package/dist/tests/unit/facts/build-facts.spec.js +143 -45
- package/dist/tests/unit/facts/identity.spec.js +13 -0
- package/dist/tests/unit/facts/scan-stamps.spec.js +32 -0
- package/dist/tests/unit/facts/slug.spec.js +2 -0
- package/dist/tests/unit/kb/answer-fingerprint.spec.js +9 -9
- package/dist/tests/unit/kb/data-category-catalog.spec.d.ts +1 -0
- package/dist/tests/unit/kb/data-category-catalog.spec.js +65 -0
- package/dist/tests/unit/kb/kb-interview-loop.spec.js +8 -7
- package/dist/tests/unit/kb/migrate.spec.js +2 -2
- package/dist/tests/unit/output/scan-output-excludes.spec.js +1 -1
- package/dist/tests/unit/threat-model/build-threat-model.spec.d.ts +1 -0
- package/dist/tests/unit/threat-model/build-threat-model.spec.js +189 -0
- package/dist/tests/unit/threat-model/carry-forward-person-set-statuses.spec.d.ts +1 -0
- package/dist/tests/unit/threat-model/carry-forward-person-set-statuses.spec.js +163 -0
- package/dist/tests/unit/threat-model/io.spec.d.ts +1 -0
- package/dist/tests/unit/threat-model/io.spec.js +103 -0
- package/dist/tests/unit/threat-model/schema.spec.d.ts +1 -0
- package/dist/tests/unit/threat-model/schema.spec.js +42 -0
- package/dist/tests/unit/ui/scan-progress-renderer.spec.js +58 -0
- package/dist/tests/unit/upload/collect-scan-sidecars.spec.js +8 -5
- package/dist/vendor/scanner/dist/src/analyze/code-navigator.d.ts +1 -1
- package/dist/vendor/scanner/dist/src/analyze/code-navigator.js +4 -0
- package/dist/vendor/scanner/dist/src/analyze/column-catalog.d.ts +1 -1
- package/dist/vendor/scanner/dist/src/analyze/column-catalog.js +2 -2
- package/dist/vendor/scanner/dist/src/analyze/concept-profile.d.ts +2 -2
- package/dist/vendor/scanner/dist/src/analyze/concept-profile.js +5 -3
- package/dist/vendor/scanner/dist/src/core/pipeline/build-scan-personal-data-layers.js +1 -1
- package/dist/vendor/scanner/dist/src/core/pipeline/deterministic-scan.js +43 -0
- package/dist/vendor/scanner/dist/src/core/pipeline/graph-mapping.js +23 -2
- package/dist/vendor/scanner/dist/src/core/pipeline/mixed-app-terraform-scan.js +1 -0
- package/dist/vendor/scanner/dist/src/core/pipeline/orchestrator-result.d.ts +2 -2
- package/dist/vendor/scanner/dist/src/core/pipeline/terraform-minimal-services.js +1 -0
- package/dist/vendor/scanner/dist/src/core/schema/scan-result.schema.d.ts +160 -2
- package/dist/vendor/scanner/dist/src/core/schema/scan-result.schema.js +24 -0
- package/dist/vendor/scanner/dist/src/core/types/data-flow.d.ts +48 -0
- package/dist/vendor/scanner/dist/src/core/types/data-flow.js +53 -0
- package/dist/vendor/scanner/dist/src/data-flow/detect.js +1 -0
- package/dist/vendor/scanner/dist/src/data-flow/ensure-hub-linked-assets.js +1 -0
- package/dist/vendor/scanner/dist/src/data-flow/ensure-manifest-declared-flows.js +1 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-authentication.d.ts +30 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-authentication.js +277 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-builder.js +6 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-controls.d.ts +24 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-controls.js +238 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-data-categories.d.ts +22 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-data-categories.js +69 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-interaction-description.d.ts +13 -0
- package/dist/vendor/scanner/dist/src/data-flow/flow-interaction-description.js +263 -0
- package/dist/vendor/scanner/dist/src/data-flow/hub-link-policy.d.ts +2 -1
- package/dist/vendor/scanner/dist/src/data-flow/hub-link-policy.js +3 -0
- package/dist/vendor/scanner/dist/src/data-flow/human-interaction-channels.d.ts +37 -0
- package/dist/vendor/scanner/dist/src/data-flow/human-interaction-channels.js +483 -0
- package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.d.ts +3 -0
- package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.js +12 -17
- package/dist/vendor/scanner/dist/src/data-flow/terraform-flows.js +5 -1
- package/dist/vendor/scanner/dist/src/data-flow/transformation-patterns.d.ts +5 -1
- package/dist/vendor/scanner/dist/src/data-flow/transformation-patterns.js +17 -37
- package/dist/vendor/scanner/dist/src/eval/canonical/concept-map.d.ts +36 -5
- package/dist/vendor/scanner/dist/src/eval/canonical/concept-map.js +53 -60
- package/dist/vendor/scanner/dist/src/eval/canonical/graph/endpoints.js +2 -9
- package/dist/vendor/scanner/dist/src/eval/canonical/scanner/personal-data.js +10 -7
- package/dist/vendor/scanner/dist/src/graph/build-dataparade-graph.js +3 -1
- package/dist/vendor/scanner/dist/src/index.d.ts +6 -0
- package/dist/vendor/scanner/dist/src/index.js +16 -1
- package/dist/vendor/scanner/dist/src/patterns/engine.js +1 -0
- package/dist/vendor/scanner/dist/src/pii-signals/match-pii-signals.d.ts +1 -1
- package/dist/vendor/scanner/dist/src/pii-signals/match-pii-signals.js +2 -2
- package/dist/vendor/scanner/dist/src/pii-signals/occurrence-group.d.ts +3 -3
- package/dist/vendor/scanner/dist/src/pii-signals/occurrence-group.js +12 -11
- package/dist/vendor/scanner/dist/src/pii-signals/personal-data-taxonomy.d.ts +44 -0
- package/dist/vendor/scanner/dist/src/pii-signals/personal-data-taxonomy.js +167 -0
- package/dist/vendor/scanner/dist/src/pii-signals/pii-signal-aliases.js +43 -43
- package/dist/vendor/scanner/dist/src/pii-signals/pii-signal-rules.d.ts +12 -1
- package/dist/vendor/scanner/dist/src/pii-signals/pii-signal-rules.js +28 -7
- package/dist/vendor/scanner/dist/src/pii-signals/signal-token.js +1 -1
- package/dist/vendor/scanner/dist/src/threats/stride.d.ts +98 -0
- package/dist/vendor/scanner/dist/src/threats/stride.js +179 -0
- package/dist/vendor/scanner/package.json +2 -2
- package/dist/vendor/scanner/patterns/concept-profiles.yaml +2 -2
- package/dist/vendor/scanner/patterns/flow-authentication.rules.yaml +75 -0
- package/dist/vendor/scanner/patterns/flow-controls.rules.yaml +68 -0
- package/dist/vendor/scanner/patterns/personal-data-taxonomy.yaml +155 -0
- package/dist/vendor/scanner/patterns/pii-signals.rules.yaml +38 -49
- package/dist/vendor/scanner/patterns/stride.rules.yaml +86 -0
- package/package.json +4 -4
- package/dist/vendor/scanner/dist/src/eval/canonical/concept-map.validate.d.ts +0 -17
- package/dist/vendor/scanner/dist/src/eval/canonical/concept-map.validate.js +0 -108
- package/dist/vendor/scanner/patterns/personal-data-concept-map.yaml +0 -76
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observed data categories on flows between two components (DATAP-856).
|
|
3
|
+
*
|
|
4
|
+
* Intra-component lineage names the categories of the code at its evidence line. A flow
|
|
5
|
+
* between two components gets them the same way, from the code that sends the data: for
|
|
6
|
+
* each evidence location, the request window around the call (see flow-authentication.ts).
|
|
7
|
+
* When the location is an SDK import, the calls are the lines that use what the import
|
|
8
|
+
* binds, and each of their request windows is read. Comments and Python docstrings are not
|
|
9
|
+
* read.
|
|
10
|
+
*
|
|
11
|
+
* An empty list means no category was seen. It does not mean the flow carries no data.
|
|
12
|
+
*/
|
|
13
|
+
import type { DetectedDataFlow } from "../core/types/data-flow";
|
|
14
|
+
import type { FileInfo } from "../core/types/file";
|
|
15
|
+
import { type FlowAuthenticationRules } from "./flow-authentication";
|
|
16
|
+
/** Observed data categories for one flow, or undefined when the flow is not checked. */
|
|
17
|
+
export declare function flowDataCategories(flow: DetectedDataFlow, linesByPath: ReadonlyMap<string, string[]>, windowRules?: FlowAuthenticationRules): string[] | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Sets `dataCategories` on each flow between two components. Intra-component flows keep
|
|
20
|
+
* the categories lineage gave them. Mutates the flows.
|
|
21
|
+
*/
|
|
22
|
+
export declare function annotateFlowDataCategories(flows: DetectedDataFlow[], files: FileInfo[]): void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flowDataCategories = flowDataCategories;
|
|
4
|
+
exports.annotateFlowDataCategories = annotateFlowDataCategories;
|
|
5
|
+
const flow_authentication_1 = require("./flow-authentication");
|
|
6
|
+
const flow_controls_1 = require("./flow-controls");
|
|
7
|
+
const intra_component_lineage_1 = require("./intra-component-lineage");
|
|
8
|
+
/** Line indexes (0-based) of the code that sends data at one evidence location. */
|
|
9
|
+
function sendingLines(lines, location, windowRules) {
|
|
10
|
+
const read = new Set();
|
|
11
|
+
const index = location.startLine - 1;
|
|
12
|
+
if (index < 0 || index >= lines.length)
|
|
13
|
+
return read;
|
|
14
|
+
if (!flow_authentication_1.IMPORT_LINE.test(lines[index])) {
|
|
15
|
+
for (const i of (0, flow_authentication_1.requestWindow)(lines, index, windowRules))
|
|
16
|
+
read.add(i);
|
|
17
|
+
return read;
|
|
18
|
+
}
|
|
19
|
+
const uses = (0, flow_controls_1.importedNames)(lines[index]).map((n) => new RegExp(`\\b${n.replace(/\$/g, "\\$")}\\b`));
|
|
20
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
21
|
+
if (i === index || flow_authentication_1.IMPORT_LINE.test(lines[i]) || !uses.some((u) => u.test(lines[i])))
|
|
22
|
+
continue;
|
|
23
|
+
for (const j of (0, flow_authentication_1.requestWindow)(lines, i, windowRules))
|
|
24
|
+
read.add(j);
|
|
25
|
+
}
|
|
26
|
+
return read;
|
|
27
|
+
}
|
|
28
|
+
/** Observed data categories for one flow, or undefined when the flow is not checked. */
|
|
29
|
+
function flowDataCategories(flow, linesByPath, windowRules = (0, flow_authentication_1.loadFlowAuthenticationRules)()) {
|
|
30
|
+
if (flow.sourceComponentId === flow.targetComponentId)
|
|
31
|
+
return undefined;
|
|
32
|
+
const locations = (0, flow_authentication_1.locationsOf)(flow);
|
|
33
|
+
if (locations.length === 0)
|
|
34
|
+
return undefined;
|
|
35
|
+
const categories = new Set();
|
|
36
|
+
for (const location of locations) {
|
|
37
|
+
const lines = linesByPath.get(location.filePath);
|
|
38
|
+
if (!lines)
|
|
39
|
+
continue;
|
|
40
|
+
const docstring = location.filePath.endsWith(".py") ? (0, flow_controls_1.docstringLines)(lines) : undefined;
|
|
41
|
+
for (const i of sendingLines(lines, location, windowRules)) {
|
|
42
|
+
const line = lines[i];
|
|
43
|
+
if ((0, intra_component_lineage_1.isCommentLine)(line) || docstring?.[i])
|
|
44
|
+
continue;
|
|
45
|
+
for (const category of (0, intra_component_lineage_1.collectDataCategories)(line, ""))
|
|
46
|
+
categories.add(category);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return [...categories].sort((a, b) => a.localeCompare(b));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Sets `dataCategories` on each flow between two components. Intra-component flows keep
|
|
53
|
+
* the categories lineage gave them. Mutates the flows.
|
|
54
|
+
*/
|
|
55
|
+
function annotateFlowDataCategories(flows, files) {
|
|
56
|
+
if (flows.length === 0)
|
|
57
|
+
return;
|
|
58
|
+
const windowRules = (0, flow_authentication_1.loadFlowAuthenticationRules)();
|
|
59
|
+
const linesByPath = new Map();
|
|
60
|
+
for (const file of files) {
|
|
61
|
+
if (typeof file.content === "string")
|
|
62
|
+
linesByPath.set(file.path, file.content.split(/\r?\n/));
|
|
63
|
+
}
|
|
64
|
+
for (const flow of flows) {
|
|
65
|
+
const categories = flowDataCategories(flow, linesByPath, windowRules);
|
|
66
|
+
if (categories)
|
|
67
|
+
flow.dataCategories = categories;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DetectedComponent } from "../core/types/component";
|
|
2
|
+
import type { DataFlowType, DetectedDataFlow, FlowProtocol, FlowRelationship, FlowTransport } from "../core/types/data-flow";
|
|
3
|
+
import type { RawFinding } from "../core/types/detection";
|
|
4
|
+
export interface FlowInteractionDescription {
|
|
5
|
+
relationship?: FlowRelationship;
|
|
6
|
+
protocol?: FlowProtocol;
|
|
7
|
+
transport?: FlowTransport;
|
|
8
|
+
client?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function protocolForDatabaseEngineName(databaseEngineName: string | undefined): FlowProtocol | undefined;
|
|
11
|
+
export declare function describeFlowFromFinding(finding: RawFinding, flowType: DataFlowType, sourceComponent: DetectedComponent, targetComponent: DetectedComponent): FlowInteractionDescription;
|
|
12
|
+
export declare function completeFlowInteractionDescriptions(flows: DetectedDataFlow[], components: DetectedComponent[]): void;
|
|
13
|
+
export declare function flowInteractionLabel(flow: DetectedDataFlow): string;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.protocolForDatabaseEngineName = protocolForDatabaseEngineName;
|
|
4
|
+
exports.describeFlowFromFinding = describeFlowFromFinding;
|
|
5
|
+
exports.completeFlowInteractionDescriptions = completeFlowInteractionDescriptions;
|
|
6
|
+
exports.flowInteractionLabel = flowInteractionLabel;
|
|
7
|
+
const HTTP_CLIENT_LIBRARY_NAMES = new Set([
|
|
8
|
+
"fetch",
|
|
9
|
+
"axios",
|
|
10
|
+
"got",
|
|
11
|
+
"superagent",
|
|
12
|
+
"node-fetch",
|
|
13
|
+
"undici",
|
|
14
|
+
"ky",
|
|
15
|
+
"requests",
|
|
16
|
+
"httpx",
|
|
17
|
+
"aiohttp",
|
|
18
|
+
"urllib",
|
|
19
|
+
"urllib3",
|
|
20
|
+
"net/http",
|
|
21
|
+
"resty",
|
|
22
|
+
"httpclient",
|
|
23
|
+
"okhttp",
|
|
24
|
+
"resttemplate",
|
|
25
|
+
"webclient",
|
|
26
|
+
"guzzle",
|
|
27
|
+
"faraday",
|
|
28
|
+
"httparty",
|
|
29
|
+
"curl",
|
|
30
|
+
]);
|
|
31
|
+
const GRAPHQL_URL_PATTERN = /\bgraphql\b|\/graphql\b/i;
|
|
32
|
+
const PROTOCOL_BY_FINDING_TRANSPORT_PROPERTY = {
|
|
33
|
+
mcp_http: "mcp",
|
|
34
|
+
mcp_stdio: "mcp",
|
|
35
|
+
otlp: "otlp",
|
|
36
|
+
grpc: "grpc",
|
|
37
|
+
};
|
|
38
|
+
const TRANSPORT_BY_FINDING_TRANSPORT_PROPERTY = {
|
|
39
|
+
mcp_stdio: "stdio",
|
|
40
|
+
};
|
|
41
|
+
const PROTOCOL_BY_DATABASE_ENGINE_NAME = [
|
|
42
|
+
[/postgres|pg\b|mysql|mariadb|sqlite|mssql|sql ?server|oracle|cockroach|aurora|^sql$|jdbc|sequelize|typeorm|prisma|knex|activerecord|django/i, "sql"],
|
|
43
|
+
[/mongo/i, "mongodb_wire"],
|
|
44
|
+
[/redis|valkey|elasticache/i, "redis"],
|
|
45
|
+
[/kafka|msk/i, "kafka"],
|
|
46
|
+
[/rabbit|amqp/i, "amqp"],
|
|
47
|
+
[/mqtt/i, "mqtt"],
|
|
48
|
+
];
|
|
49
|
+
function readStringProperty(properties, propertyName) {
|
|
50
|
+
const value = properties?.[propertyName];
|
|
51
|
+
if (typeof value !== "string")
|
|
52
|
+
return undefined;
|
|
53
|
+
const trimmed = value.trim();
|
|
54
|
+
return trimmed ? trimmed : undefined;
|
|
55
|
+
}
|
|
56
|
+
function transportFromUrlScheme(url) {
|
|
57
|
+
if (!url)
|
|
58
|
+
return undefined;
|
|
59
|
+
const lowerCaseUrl = url.trim().toLowerCase();
|
|
60
|
+
if (lowerCaseUrl.startsWith("https://"))
|
|
61
|
+
return "https";
|
|
62
|
+
if (lowerCaseUrl.startsWith("wss://") || lowerCaseUrl.startsWith("ws://"))
|
|
63
|
+
return "websocket";
|
|
64
|
+
if (lowerCaseUrl.startsWith("http://"))
|
|
65
|
+
return "http";
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
function protocolForDatabaseEngineName(databaseEngineName) {
|
|
69
|
+
if (!databaseEngineName)
|
|
70
|
+
return undefined;
|
|
71
|
+
for (const [engineNamePattern, protocol] of PROTOCOL_BY_DATABASE_ENGINE_NAME) {
|
|
72
|
+
if (engineNamePattern.test(databaseEngineName))
|
|
73
|
+
return protocol;
|
|
74
|
+
}
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
function isHttpClientLibraryName(clientName) {
|
|
78
|
+
return clientName !== undefined && HTTP_CLIENT_LIBRARY_NAMES.has(clientName.toLowerCase());
|
|
79
|
+
}
|
|
80
|
+
function describeOutboundCallFinding(finding) {
|
|
81
|
+
const properties = finding.properties;
|
|
82
|
+
const url = readStringProperty(properties, "url");
|
|
83
|
+
const findingTransportProperty = readStringProperty(properties, "transport");
|
|
84
|
+
const httpClientLibrary = readStringProperty(properties, "httpClientLibrary");
|
|
85
|
+
const clientProperty = readStringProperty(properties, "client");
|
|
86
|
+
// The SDK package the call imports. `package_name` is the scanned section's own package,
|
|
87
|
+
// so it never names the client.
|
|
88
|
+
const sdkPackage = readStringProperty(properties, "sdkPackage");
|
|
89
|
+
const serviceName = readStringProperty(properties, "serviceName");
|
|
90
|
+
const description = { relationship: "invokes" };
|
|
91
|
+
const protocolFromTransportProperty = findingTransportProperty
|
|
92
|
+
? PROTOCOL_BY_FINDING_TRANSPORT_PROPERTY[findingTransportProperty]
|
|
93
|
+
: undefined;
|
|
94
|
+
const callsThroughHttpClientLibrary = httpClientLibrary !== undefined || isHttpClientLibraryName(clientProperty);
|
|
95
|
+
if (protocolFromTransportProperty) {
|
|
96
|
+
description.protocol = protocolFromTransportProperty;
|
|
97
|
+
}
|
|
98
|
+
else if (url && GRAPHQL_URL_PATTERN.test(url)) {
|
|
99
|
+
description.protocol = "graphql";
|
|
100
|
+
}
|
|
101
|
+
else if (!callsThroughHttpClientLibrary && serviceName) {
|
|
102
|
+
description.protocol = "vendor_sdk";
|
|
103
|
+
}
|
|
104
|
+
description.transport =
|
|
105
|
+
(findingTransportProperty
|
|
106
|
+
? TRANSPORT_BY_FINDING_TRANSPORT_PROPERTY[findingTransportProperty]
|
|
107
|
+
: undefined) ?? transportFromUrlScheme(url);
|
|
108
|
+
description.client = callsThroughHttpClientLibrary
|
|
109
|
+
? (httpClientLibrary ?? clientProperty)
|
|
110
|
+
: (sdkPackage ?? clientProperty ?? serviceName);
|
|
111
|
+
return description;
|
|
112
|
+
}
|
|
113
|
+
function describeDatabaseConnectionFinding(finding, targetComponent) {
|
|
114
|
+
const databaseEngineName = readStringProperty(finding.properties, "databaseType") ??
|
|
115
|
+
readStringProperty(targetComponent?.properties, "databaseType") ??
|
|
116
|
+
readStringProperty(targetComponent?.properties, "database_engine");
|
|
117
|
+
return {
|
|
118
|
+
relationship: "queries",
|
|
119
|
+
protocol: protocolForDatabaseEngineName(databaseEngineName),
|
|
120
|
+
client: readStringProperty(finding.properties, "client"),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function isInternalFetchFinding(finding) {
|
|
124
|
+
return finding.pattern === "express_route" && finding.name.startsWith("INTERNAL_FETCH ");
|
|
125
|
+
}
|
|
126
|
+
function describeFlowFromFinding(finding, flowType, sourceComponent, targetComponent) {
|
|
127
|
+
if (sourceComponent.type === "actor")
|
|
128
|
+
return { relationship: "interacts" };
|
|
129
|
+
if (finding.pattern === "database_connection") {
|
|
130
|
+
return describeDatabaseConnectionFinding(finding, targetComponent);
|
|
131
|
+
}
|
|
132
|
+
if (finding.pattern === "external_api_call")
|
|
133
|
+
return describeOutboundCallFinding(finding);
|
|
134
|
+
if (finding.pattern === "auth_middleware")
|
|
135
|
+
return { relationship: "authenticates_via" };
|
|
136
|
+
if (isInternalFetchFinding(finding)) {
|
|
137
|
+
const url = readStringProperty(finding.properties, "url");
|
|
138
|
+
// A path alone does not say REST, so only GraphQL is named (DATAP-937).
|
|
139
|
+
return {
|
|
140
|
+
relationship: "invokes",
|
|
141
|
+
protocol: url && GRAPHQL_URL_PATTERN.test(url) ? "graphql" : "unknown",
|
|
142
|
+
transport: transportFromUrlScheme(url),
|
|
143
|
+
client: "fetch",
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (finding.pattern === "express_route")
|
|
147
|
+
return { relationship: "exposes" };
|
|
148
|
+
return { relationship: relationshipForFlowTypeWithEvidence(flowType) };
|
|
149
|
+
}
|
|
150
|
+
function relationshipForFlowTypeWithEvidence(flowType) {
|
|
151
|
+
if (flowType === "database_query")
|
|
152
|
+
return "queries";
|
|
153
|
+
if (flowType === "message_queue")
|
|
154
|
+
return "publishes";
|
|
155
|
+
if (flowType === "data_transfer")
|
|
156
|
+
return "uses_in_process";
|
|
157
|
+
return "invokes";
|
|
158
|
+
}
|
|
159
|
+
function flowHasCodeEvidence(flow) {
|
|
160
|
+
return flow.sourceLocation !== undefined || (flow.sourceLocations?.length ?? 0) > 0;
|
|
161
|
+
}
|
|
162
|
+
function inferRelationshipForFlowWithoutOne(flow, componentsById) {
|
|
163
|
+
const sourceComponent = componentsById.get(flow.sourceComponentId);
|
|
164
|
+
if (sourceComponent?.type === "actor")
|
|
165
|
+
return "interacts";
|
|
166
|
+
if (flow.type !== "api_call")
|
|
167
|
+
return relationshipForFlowTypeWithEvidence(flow.type);
|
|
168
|
+
return flowHasCodeEvidence(flow) ? "invokes" : "depends_on";
|
|
169
|
+
}
|
|
170
|
+
function completeFlowInteractionDescriptions(flows, components) {
|
|
171
|
+
const componentsById = new Map(components.map((component) => [component.id, component]));
|
|
172
|
+
for (const flow of flows) {
|
|
173
|
+
const sourceComponent = componentsById.get(flow.sourceComponentId);
|
|
174
|
+
if (sourceComponent?.type === "actor") {
|
|
175
|
+
flow.relationship = "interacts";
|
|
176
|
+
}
|
|
177
|
+
else if (!flow.relationship) {
|
|
178
|
+
flow.relationship = inferRelationshipForFlowWithoutOne(flow, componentsById);
|
|
179
|
+
}
|
|
180
|
+
if (!flow.protocol && flow.relationship === "queries") {
|
|
181
|
+
const targetComponent = componentsById.get(flow.targetComponentId);
|
|
182
|
+
const protocol = protocolForDatabaseEngineName(readStringProperty(targetComponent?.properties, "databaseType") ??
|
|
183
|
+
readStringProperty(targetComponent?.properties, "database_engine"));
|
|
184
|
+
if (protocol)
|
|
185
|
+
flow.protocol = protocol;
|
|
186
|
+
}
|
|
187
|
+
if (!flow.transport && flow.relationship === "uses_in_process") {
|
|
188
|
+
flow.transport = "in_process";
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const PROTOCOL_DISPLAY_NAMES = {
|
|
193
|
+
rest: "REST",
|
|
194
|
+
graphql: "GraphQL",
|
|
195
|
+
grpc: "gRPC",
|
|
196
|
+
soap: "SOAP",
|
|
197
|
+
json_rpc: "JSON-RPC",
|
|
198
|
+
mcp: "MCP",
|
|
199
|
+
sql: "SQL",
|
|
200
|
+
mongodb_wire: "MongoDB",
|
|
201
|
+
redis: "Redis",
|
|
202
|
+
kafka: "Kafka",
|
|
203
|
+
amqp: "AMQP",
|
|
204
|
+
mqtt: "MQTT",
|
|
205
|
+
smtp: "SMTP",
|
|
206
|
+
oauth_oidc: "OAuth/OIDC",
|
|
207
|
+
otlp: "OTLP",
|
|
208
|
+
vendor_sdk: "Vendor SDK",
|
|
209
|
+
unknown: "",
|
|
210
|
+
};
|
|
211
|
+
const TRANSPORT_DISPLAY_NAMES = {
|
|
212
|
+
https: "HTTPS",
|
|
213
|
+
http: "HTTP",
|
|
214
|
+
websocket: "WebSocket",
|
|
215
|
+
http2: "HTTP/2",
|
|
216
|
+
tcp_tls: "TLS",
|
|
217
|
+
tcp: "TCP",
|
|
218
|
+
stdio: "stdio",
|
|
219
|
+
in_process: "",
|
|
220
|
+
unknown: "",
|
|
221
|
+
};
|
|
222
|
+
const RELATIONSHIP_DISPLAY_NAMES_FOR_STRUCTURAL_EDGES = {
|
|
223
|
+
uses_in_process: "uses",
|
|
224
|
+
exposes: "exposes",
|
|
225
|
+
authenticates_via: "authenticates via",
|
|
226
|
+
depends_on: "depends on",
|
|
227
|
+
provisions: "provisions",
|
|
228
|
+
};
|
|
229
|
+
const CHANNEL_DISPLAY_NAMES = {
|
|
230
|
+
web_gui: "Web GUI",
|
|
231
|
+
mobile_app: "Mobile app",
|
|
232
|
+
desktop_app: "Desktop app",
|
|
233
|
+
cli: "CLI",
|
|
234
|
+
mcp: "MCP",
|
|
235
|
+
api_direct: "Direct API",
|
|
236
|
+
email: "Email",
|
|
237
|
+
};
|
|
238
|
+
function joinProtocolAndTransport(protocolName, transportName) {
|
|
239
|
+
if (protocolName && transportName)
|
|
240
|
+
return `${protocolName} · ${transportName}`;
|
|
241
|
+
return protocolName || transportName;
|
|
242
|
+
}
|
|
243
|
+
function flowInteractionLabel(flow) {
|
|
244
|
+
const structuralRelationshipName = flow.relationship
|
|
245
|
+
? RELATIONSHIP_DISPLAY_NAMES_FOR_STRUCTURAL_EDGES[flow.relationship]
|
|
246
|
+
: undefined;
|
|
247
|
+
if (structuralRelationshipName)
|
|
248
|
+
return structuralRelationshipName;
|
|
249
|
+
if (flow.relationship === "interacts") {
|
|
250
|
+
return (flow.channel && CHANNEL_DISPLAY_NAMES[flow.channel]) || "interacts";
|
|
251
|
+
}
|
|
252
|
+
const transportName = flow.transport ? TRANSPORT_DISPLAY_NAMES[flow.transport] : "";
|
|
253
|
+
const protocolName = flow.protocol ? PROTOCOL_DISPLAY_NAMES[flow.protocol] : "";
|
|
254
|
+
const protocolAndTransport = joinProtocolAndTransport(protocolName, transportName);
|
|
255
|
+
if (protocolAndTransport && protocolName)
|
|
256
|
+
return protocolAndTransport;
|
|
257
|
+
if (isHttpClientLibraryName(flow.client)) {
|
|
258
|
+
return flow.transport === "https" ? "HTTPS request" : "HTTP request";
|
|
259
|
+
}
|
|
260
|
+
if (protocolAndTransport)
|
|
261
|
+
return protocolAndTransport;
|
|
262
|
+
return flow.type.replace(/_/g, " ");
|
|
263
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DetectedComponent } from "../core/types/component";
|
|
2
|
-
import type { DataFlowType } from "../core/types/data-flow";
|
|
2
|
+
import type { DataFlowType, FlowRelationship } from "../core/types/data-flow";
|
|
3
3
|
import type { DetectedDataFlow } from "../core/types/data-flow";
|
|
4
4
|
export type HubLinkRuleId = "auth_service" | "section_api" | "unlinked_asset";
|
|
5
5
|
export interface HubLinkRule {
|
|
@@ -10,6 +10,7 @@ export interface HubLinkRule {
|
|
|
10
10
|
enrichmentNotes: string;
|
|
11
11
|
description: string;
|
|
12
12
|
flowType?: DataFlowType;
|
|
13
|
+
relationship: FlowRelationship;
|
|
13
14
|
}
|
|
14
15
|
export declare function getSectionId(component: DetectedComponent): string;
|
|
15
16
|
export declare function isMainApplication(component: DetectedComponent): boolean;
|
|
@@ -45,6 +45,7 @@ exports.DEFAULT_HUB_LINK_RULES = [
|
|
|
45
45
|
confidence: 0.75,
|
|
46
46
|
enrichmentNotes: "auth_service_hub_link",
|
|
47
47
|
description: "Application hub to auth service",
|
|
48
|
+
relationship: "authenticates_via",
|
|
48
49
|
},
|
|
49
50
|
{
|
|
50
51
|
id: "section_api",
|
|
@@ -54,6 +55,7 @@ exports.DEFAULT_HUB_LINK_RULES = [
|
|
|
54
55
|
confidence: 0.75,
|
|
55
56
|
enrichmentNotes: "section_api_hub_link",
|
|
56
57
|
description: "Section main to API surface",
|
|
58
|
+
relationship: "exposes",
|
|
57
59
|
},
|
|
58
60
|
{
|
|
59
61
|
id: "unlinked_asset",
|
|
@@ -61,5 +63,6 @@ exports.DEFAULT_HUB_LINK_RULES = [
|
|
|
61
63
|
confidence: 0.55,
|
|
62
64
|
enrichmentNotes: "unlinked_asset_hub_link",
|
|
63
65
|
description: "Application hub to unlinked asset",
|
|
66
|
+
relationship: "uses_in_process",
|
|
64
67
|
},
|
|
65
68
|
];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DetectedComponent } from "../core/types/component";
|
|
2
|
+
import type { DetectedDataFlow, FlowTransport, HumanInteractionChannel, HumanInteractionChannelEvidence } from "../core/types/data-flow";
|
|
3
|
+
import type { FileInfo } from "../core/types/file";
|
|
4
|
+
import type { ServiceSection } from "../core/sectioning/discover-service-sections";
|
|
5
|
+
export declare const AI_AGENT_ACTOR_SUBTYPE = "automated_service";
|
|
6
|
+
export declare const AI_AGENT_ACTOR_KIND_PROPERTY = "actorKind";
|
|
7
|
+
export declare const AI_AGENT_ACTOR_KIND = "ai_agent";
|
|
8
|
+
export declare const AI_AGENT_ACTOR_NAME = "AI agent";
|
|
9
|
+
type DetectedChannel = Exclude<HumanInteractionChannel, "unknown" | "email">;
|
|
10
|
+
export interface SectionInteractionSurface {
|
|
11
|
+
sectionId: string;
|
|
12
|
+
sectionDirectory: string;
|
|
13
|
+
isLibraryPackage: boolean;
|
|
14
|
+
packageManifestCount: number;
|
|
15
|
+
libraryPackageManifestCount: number;
|
|
16
|
+
evidenceByChannel: Map<DetectedChannel, HumanInteractionChannelEvidence[]>;
|
|
17
|
+
mcpServerTransport?: FlowTransport;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Module paths (`pkg/cli`) that pyproject.toml `[project.scripts]` or
|
|
21
|
+
* `[tool.poetry.scripts]`, setup.cfg `console_scripts` or setup.py `console_scripts` name.
|
|
22
|
+
*/
|
|
23
|
+
export declare function pythonConsoleScriptModules(files: FileInfo[]): Set<string>;
|
|
24
|
+
export declare function detectSectionInteractionSurfaces(files: FileInfo[], sections: ServiceSection[]): Map<string, SectionInteractionSurface>;
|
|
25
|
+
export declare function isAiAgentActor(component: DetectedComponent | undefined): boolean;
|
|
26
|
+
export interface HumanInteractionChannelInput {
|
|
27
|
+
components: DetectedComponent[];
|
|
28
|
+
flows: DetectedDataFlow[];
|
|
29
|
+
files: FileInfo[];
|
|
30
|
+
sections: ServiceSection[];
|
|
31
|
+
}
|
|
32
|
+
export interface HumanInteractionChannelResult {
|
|
33
|
+
components: DetectedComponent[];
|
|
34
|
+
flows: DetectedDataFlow[];
|
|
35
|
+
}
|
|
36
|
+
export declare function applyHumanInteractionChannels(input: HumanInteractionChannelInput): HumanInteractionChannelResult;
|
|
37
|
+
export {};
|