@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,483 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AI_AGENT_ACTOR_NAME = exports.AI_AGENT_ACTOR_KIND = exports.AI_AGENT_ACTOR_KIND_PROPERTY = exports.AI_AGENT_ACTOR_SUBTYPE = void 0;
|
|
4
|
+
exports.pythonConsoleScriptModules = pythonConsoleScriptModules;
|
|
5
|
+
exports.detectSectionInteractionSurfaces = detectSectionInteractionSurfaces;
|
|
6
|
+
exports.isAiAgentActor = isAiAgentActor;
|
|
7
|
+
exports.applyHumanInteractionChannels = applyHumanInteractionChannels;
|
|
8
|
+
const application_hub_1 = require("./application-hub");
|
|
9
|
+
exports.AI_AGENT_ACTOR_SUBTYPE = "automated_service";
|
|
10
|
+
exports.AI_AGENT_ACTOR_KIND_PROPERTY = "actorKind";
|
|
11
|
+
exports.AI_AGENT_ACTOR_KIND = "ai_agent";
|
|
12
|
+
exports.AI_AGENT_ACTOR_NAME = "AI agent";
|
|
13
|
+
const INJECTED_DEFAULT_SOURCE_CONTEXT = "injected_default";
|
|
14
|
+
const INJECTED_CHANNEL_ACTOR_SOURCE_CONTEXT = "injected_for_interaction_channel";
|
|
15
|
+
const CHANNEL_PRIORITY_FOR_HUMAN_ACTOR_EDGES = [
|
|
16
|
+
"web_gui",
|
|
17
|
+
"mobile_app",
|
|
18
|
+
"desktop_app",
|
|
19
|
+
"api_direct",
|
|
20
|
+
"cli",
|
|
21
|
+
];
|
|
22
|
+
const PACKAGE_DEPENDENCY_CHANNELS = [
|
|
23
|
+
["cli", ["commander", "yargs", "@oclif/core", "oclif", "meow", "cac", "citty", "clipanion", "sade", "caporal"]],
|
|
24
|
+
["web_gui", ["next", "react-dom", "vue", "nuxt", "svelte", "@sveltejs/kit", "@angular/core", "solid-js", "@remix-run/react", "gatsby", "astro", "preact"]],
|
|
25
|
+
["mobile_app", ["react-native", "expo"]],
|
|
26
|
+
["desktop_app", ["electron", "@tauri-apps/api"]],
|
|
27
|
+
["api_direct", ["express", "@nestjs/core", "fastify", "koa", "hono", "@hapi/hapi", "restify"]],
|
|
28
|
+
];
|
|
29
|
+
const CHANNELS_THAT_A_LIBRARY_DEPENDENCY_DOES_NOT_PROVE = new Set([
|
|
30
|
+
"web_gui",
|
|
31
|
+
"mobile_app",
|
|
32
|
+
"desktop_app",
|
|
33
|
+
"api_direct",
|
|
34
|
+
]);
|
|
35
|
+
const CHANNELS_THAT_A_COMMAND_LINE_PACKAGE_DEPENDENCY_DOES_NOT_PROVE = new Set([
|
|
36
|
+
"web_gui",
|
|
37
|
+
"mobile_app",
|
|
38
|
+
"desktop_app",
|
|
39
|
+
]);
|
|
40
|
+
const CODE_SIGNALS = [
|
|
41
|
+
{ channel: "mcp", signal: "MCP server (TypeScript SDK)", pattern: /new\s+McpServer\s*\(|@modelcontextprotocol\/sdk\/server/ },
|
|
42
|
+
{ channel: "mcp", signal: "MCP server (FastMCP)", pattern: /\bFastMCP\s*\(/ },
|
|
43
|
+
{ channel: "mcp", signal: "MCP server (Python SDK)", pattern: /^\s*from\s+mcp\.server\b/m },
|
|
44
|
+
{ channel: "mcp", signal: "MCP server (mcp-go)", pattern: /"github\.com\/mark3labs\/mcp-go\/server"/ },
|
|
45
|
+
{ channel: "cli", signal: "click", pattern: /^\s*(?:import\s+click\b|from\s+click\s+import\b)/m, entryPointOnly: "python" },
|
|
46
|
+
{ channel: "cli", signal: "typer", pattern: /^\s*(?:import\s+typer\b|from\s+typer\s+import\b)/m, entryPointOnly: "python" },
|
|
47
|
+
{ channel: "cli", signal: "argparse", pattern: /\bargparse\.ArgumentParser\s*\(/, entryPointOnly: "python" },
|
|
48
|
+
{ channel: "cli", signal: "cobra", pattern: /"github\.com\/spf13\/cobra"/, entryPointOnly: "go" },
|
|
49
|
+
{ channel: "cli", signal: "urfave/cli", pattern: /"github\.com\/urfave\/cli(?:\/v\d+)?"/, entryPointOnly: "go" },
|
|
50
|
+
{ channel: "web_gui", signal: "Go html/template", pattern: /"html\/template"/ },
|
|
51
|
+
{ channel: "api_direct", signal: "NestJS application", pattern: /\bNestFactory\.create\s*[<(]/ },
|
|
52
|
+
{ channel: "api_direct", signal: "Express application", pattern: /\bexpress\(\s*\)/ },
|
|
53
|
+
{ channel: "api_direct", signal: "Fastify application", pattern: /\b(?:fastify|Fastify)\(\s*\{?/ },
|
|
54
|
+
{ channel: "api_direct", signal: "Hono application", pattern: /\bnew\s+Hono\s*\(/ },
|
|
55
|
+
{ channel: "api_direct", signal: "FastAPI", pattern: /^\s*from\s+fastapi\s+import\b/m },
|
|
56
|
+
{ channel: "api_direct", signal: "Flask", pattern: /^\s*from\s+flask\s+import\b/m },
|
|
57
|
+
{ channel: "api_direct", signal: "Django REST framework", pattern: /^\s*from\s+rest_framework\b/m },
|
|
58
|
+
{ channel: "api_direct", signal: "Graphene", pattern: /^\s*import\s+graphene\b/m },
|
|
59
|
+
{ channel: "api_direct", signal: "gin", pattern: /"github\.com\/gin-gonic\/gin"/ },
|
|
60
|
+
{ channel: "api_direct", signal: "chi", pattern: /"github\.com\/go-chi\/chi(?:\/v\d+)?"/ },
|
|
61
|
+
{ channel: "api_direct", signal: "echo", pattern: /"github\.com\/labstack\/echo(?:\/v\d+)?"/ },
|
|
62
|
+
{ channel: "api_direct", signal: "fiber", pattern: /"github\.com\/gofiber\/fiber(?:\/v\d+)?"/ },
|
|
63
|
+
{ channel: "api_direct", signal: "Rails API controller", pattern: /<\s*ActionController::API\b/ },
|
|
64
|
+
];
|
|
65
|
+
const GO_MAIN_PACKAGE = /^\s*package\s+main\b/m;
|
|
66
|
+
const GO_COMMAND_DIRECTORY = /(?:^|\/)cmd\//;
|
|
67
|
+
const PYTHON_PACKAGING_FILE = /(?:^|\/)(?:pyproject\.toml|setup\.cfg|setup\.py)$/;
|
|
68
|
+
const PYTHON_ENTRY_POINT_TARGET = /["']?\s*([A-Za-z_][\w.]*)\s*:\s*[A-Za-z_][\w.]*\s*["']?/g;
|
|
69
|
+
/**
|
|
70
|
+
* Module paths (`pkg/cli`) that pyproject.toml `[project.scripts]` or
|
|
71
|
+
* `[tool.poetry.scripts]`, setup.cfg `console_scripts` or setup.py `console_scripts` name.
|
|
72
|
+
*/
|
|
73
|
+
function pythonConsoleScriptModules(files) {
|
|
74
|
+
const modules = new Set();
|
|
75
|
+
for (const file of files) {
|
|
76
|
+
if (typeof file.content !== "string" || !PYTHON_PACKAGING_FILE.test(file.path))
|
|
77
|
+
continue;
|
|
78
|
+
const blocks = [];
|
|
79
|
+
if (file.path.endsWith("pyproject.toml")) {
|
|
80
|
+
for (const block of file.content.split(/^(?=\[)/m)) {
|
|
81
|
+
if (/^\[[^\]]*\bscripts\]/.test(block))
|
|
82
|
+
blocks.push(block.replace(/^\[[^\]]*\]/, ""));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const start = file.content.indexOf("console_scripts");
|
|
87
|
+
if (start === -1)
|
|
88
|
+
continue;
|
|
89
|
+
const rest = file.content.slice(start + "console_scripts".length);
|
|
90
|
+
const end = file.path.endsWith("setup.cfg") ? rest.search(/^\S/m) : rest.indexOf("]");
|
|
91
|
+
blocks.push(end === -1 ? rest : rest.slice(0, end));
|
|
92
|
+
}
|
|
93
|
+
for (const block of blocks) {
|
|
94
|
+
for (const line of block.split("\n")) {
|
|
95
|
+
const assignment = line.indexOf("=");
|
|
96
|
+
if (assignment === -1)
|
|
97
|
+
continue;
|
|
98
|
+
PYTHON_ENTRY_POINT_TARGET.lastIndex = 0;
|
|
99
|
+
const target = PYTHON_ENTRY_POINT_TARGET.exec(line.slice(assignment + 1));
|
|
100
|
+
if (target)
|
|
101
|
+
modules.add(target[1].replace(/\./g, "/"));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return modules;
|
|
106
|
+
}
|
|
107
|
+
function isPythonCommandLineEntryPoint(filePath, consoleScriptModules) {
|
|
108
|
+
if (filePath.endsWith("/__main__.py") || filePath === "__main__.py")
|
|
109
|
+
return true;
|
|
110
|
+
const modulePath = filePath.replace(/\.py$/, "").replace(/\/__init__$/, "");
|
|
111
|
+
for (const module of consoleScriptModules) {
|
|
112
|
+
if (modulePath === module || modulePath.endsWith(`/${module}`))
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
function isGoCommandLineEntryPoint(file) {
|
|
118
|
+
return GO_COMMAND_DIRECTORY.test(file.path) || GO_MAIN_PACKAGE.test(file.content);
|
|
119
|
+
}
|
|
120
|
+
const MCP_STDIO_TRANSPORT_PATTERN = /StdioServerTransport|stdio_server\s*\(|transport\s*=\s*["']stdio["']/;
|
|
121
|
+
const MCP_HTTP_TRANSPORT_PATTERN = /StreamableHTTPServerTransport|SSEServerTransport|transport\s*=\s*["'](?:sse|streamable-http|http)["']/;
|
|
122
|
+
const TEST_FILE_PATH = /(?:\.(?:test|spec)\.[cm]?[jt]sx?$|_test\.(?:go|py)$|(?:^|\/)(?:__tests__|tests?|spec|fixtures?)\/)/;
|
|
123
|
+
const EXAMPLE_OR_SAMPLE_PATH = /(?:^|\/)(?:examples?|samples?|demos?|templates?)\//;
|
|
124
|
+
const CODE_LANGUAGES_WITH_SIGNALS = new Set([
|
|
125
|
+
"typescript",
|
|
126
|
+
"javascript",
|
|
127
|
+
"python",
|
|
128
|
+
"go",
|
|
129
|
+
"ruby",
|
|
130
|
+
"java",
|
|
131
|
+
"kotlin",
|
|
132
|
+
"csharp",
|
|
133
|
+
"php",
|
|
134
|
+
"rust",
|
|
135
|
+
]);
|
|
136
|
+
const RAILS_VIEW_TEMPLATE_PATH = /(?:^|\/)app\/views\/.+\.(?:erb|haml|slim)$/;
|
|
137
|
+
function lineNumberOfFirstMatch(content, pattern) {
|
|
138
|
+
const match = pattern.exec(content);
|
|
139
|
+
if (!match)
|
|
140
|
+
return 1;
|
|
141
|
+
return content.slice(0, match.index).split("\n").length;
|
|
142
|
+
}
|
|
143
|
+
function lineNumberOfJsonKey(content, key) {
|
|
144
|
+
return lineNumberOfFirstMatch(content, new RegExp(`"${key.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&")}"\\s*:`));
|
|
145
|
+
}
|
|
146
|
+
function sectionDirectoryContainsPath(sectionDirectory, filePath) {
|
|
147
|
+
return sectionDirectory === "" || filePath === sectionDirectory || filePath.startsWith(`${sectionDirectory}/`);
|
|
148
|
+
}
|
|
149
|
+
function findOwningSection(filePath, sectionsByLongestDirectoryFirst) {
|
|
150
|
+
return sectionsByLongestDirectoryFirst.find((section) => sectionDirectoryContainsPath(section.sectionDir, filePath));
|
|
151
|
+
}
|
|
152
|
+
function addEvidence(surface, channel, evidence) {
|
|
153
|
+
const existingEvidence = surface.evidenceByChannel.get(channel) ?? [];
|
|
154
|
+
if (existingEvidence.length >= 3)
|
|
155
|
+
return;
|
|
156
|
+
existingEvidence.push(evidence);
|
|
157
|
+
surface.evidenceByChannel.set(channel, existingEvidence);
|
|
158
|
+
}
|
|
159
|
+
function readPackageManifest(file) {
|
|
160
|
+
let manifest;
|
|
161
|
+
try {
|
|
162
|
+
manifest = JSON.parse(file.content);
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
if (!manifest || typeof manifest !== "object")
|
|
168
|
+
return undefined;
|
|
169
|
+
const scripts = (manifest.scripts ?? {});
|
|
170
|
+
const declaresBinary = manifest.bin !== undefined;
|
|
171
|
+
const hasRunnableScript = ["start", "serve", "preview"].some((scriptName) => scriptName in scripts);
|
|
172
|
+
const exportsModule = ["main", "exports", "module"].some((fieldName) => fieldName in manifest);
|
|
173
|
+
const isLibraryPackage = exportsModule && !declaresBinary && !hasRunnableScript;
|
|
174
|
+
// Only runtime dependencies say what the package ships. devDependencies are build,
|
|
175
|
+
// test and script tooling.
|
|
176
|
+
const dependencyNames = new Set(Object.keys((manifest.dependencies ?? {})));
|
|
177
|
+
const evidence = [];
|
|
178
|
+
if (declaresBinary) {
|
|
179
|
+
evidence.push([
|
|
180
|
+
"cli",
|
|
181
|
+
{ signal: "package.json bin", filePath: file.path, line: lineNumberOfJsonKey(file.content, "bin") },
|
|
182
|
+
]);
|
|
183
|
+
}
|
|
184
|
+
for (const [channel, packageNames] of PACKAGE_DEPENDENCY_CHANNELS) {
|
|
185
|
+
if (isLibraryPackage && CHANNELS_THAT_A_LIBRARY_DEPENDENCY_DOES_NOT_PROVE.has(channel))
|
|
186
|
+
continue;
|
|
187
|
+
if (declaresBinary && CHANNELS_THAT_A_COMMAND_LINE_PACKAGE_DEPENDENCY_DOES_NOT_PROVE.has(channel))
|
|
188
|
+
continue;
|
|
189
|
+
// A CLI library without a `bin` entry is used by scripts, not shipped as a command.
|
|
190
|
+
if (channel === "cli" && !declaresBinary)
|
|
191
|
+
continue;
|
|
192
|
+
const dependencyName = packageNames.find((packageName) => dependencyNames.has(packageName));
|
|
193
|
+
if (!dependencyName)
|
|
194
|
+
continue;
|
|
195
|
+
evidence.push([
|
|
196
|
+
channel,
|
|
197
|
+
{
|
|
198
|
+
signal: `dependency ${dependencyName}`,
|
|
199
|
+
filePath: file.path,
|
|
200
|
+
line: lineNumberOfJsonKey(file.content, dependencyName),
|
|
201
|
+
},
|
|
202
|
+
]);
|
|
203
|
+
}
|
|
204
|
+
return { isLibraryPackage, evidence };
|
|
205
|
+
}
|
|
206
|
+
function detectSectionInteractionSurfaces(files, sections) {
|
|
207
|
+
const surfacesBySectionId = new Map();
|
|
208
|
+
const sectionsByLongestDirectoryFirst = [...sections].sort((left, right) => right.sectionDir.length - left.sectionDir.length);
|
|
209
|
+
for (const section of sections) {
|
|
210
|
+
surfacesBySectionId.set(section.id, {
|
|
211
|
+
sectionId: section.id,
|
|
212
|
+
sectionDirectory: section.sectionDir,
|
|
213
|
+
isLibraryPackage: false,
|
|
214
|
+
packageManifestCount: 0,
|
|
215
|
+
libraryPackageManifestCount: 0,
|
|
216
|
+
evidenceByChannel: new Map(),
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const consoleScriptModules = pythonConsoleScriptModules(files);
|
|
220
|
+
const sortedFiles = [...files].sort((left, right) => (left.path < right.path ? -1 : left.path > right.path ? 1 : 0));
|
|
221
|
+
for (const file of sortedFiles) {
|
|
222
|
+
const owningSection = findOwningSection(file.path, sectionsByLongestDirectoryFirst);
|
|
223
|
+
if (!owningSection)
|
|
224
|
+
continue;
|
|
225
|
+
const surface = surfacesBySectionId.get(owningSection.id);
|
|
226
|
+
if (!surface || typeof file.content !== "string")
|
|
227
|
+
continue;
|
|
228
|
+
const pathInsideSection = owningSection.sectionDir
|
|
229
|
+
? file.path.slice(owningSection.sectionDir.length + 1)
|
|
230
|
+
: file.path;
|
|
231
|
+
if (EXAMPLE_OR_SAMPLE_PATH.test(pathInsideSection) || TEST_FILE_PATH.test(pathInsideSection))
|
|
232
|
+
continue;
|
|
233
|
+
if (file.name === "package.json") {
|
|
234
|
+
const reading = readPackageManifest(file);
|
|
235
|
+
if (reading) {
|
|
236
|
+
surface.packageManifestCount += 1;
|
|
237
|
+
if (reading.isLibraryPackage)
|
|
238
|
+
surface.libraryPackageManifestCount += 1;
|
|
239
|
+
surface.isLibraryPackage = surface.libraryPackageManifestCount === surface.packageManifestCount;
|
|
240
|
+
for (const [channel, evidence] of reading.evidence)
|
|
241
|
+
addEvidence(surface, channel, evidence);
|
|
242
|
+
}
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (RAILS_VIEW_TEMPLATE_PATH.test(file.path)) {
|
|
246
|
+
addEvidence(surface, "web_gui", { signal: "Rails view template", filePath: file.path, line: 1 });
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (!CODE_LANGUAGES_WITH_SIGNALS.has(file.language))
|
|
250
|
+
continue;
|
|
251
|
+
for (const codeSignal of CODE_SIGNALS) {
|
|
252
|
+
if (!codeSignal.pattern.test(file.content))
|
|
253
|
+
continue;
|
|
254
|
+
if (codeSignal.entryPointOnly === "python" && !isPythonCommandLineEntryPoint(file.path, consoleScriptModules))
|
|
255
|
+
continue;
|
|
256
|
+
if (codeSignal.entryPointOnly === "go" && !isGoCommandLineEntryPoint(file))
|
|
257
|
+
continue;
|
|
258
|
+
addEvidence(surface, codeSignal.channel, {
|
|
259
|
+
signal: codeSignal.signal,
|
|
260
|
+
filePath: file.path,
|
|
261
|
+
line: lineNumberOfFirstMatch(file.content, codeSignal.pattern),
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
if (surface.evidenceByChannel.has("mcp") && surface.mcpServerTransport === undefined) {
|
|
265
|
+
if (MCP_STDIO_TRANSPORT_PATTERN.test(file.content))
|
|
266
|
+
surface.mcpServerTransport = "stdio";
|
|
267
|
+
else if (MCP_HTTP_TRANSPORT_PATTERN.test(file.content))
|
|
268
|
+
surface.mcpServerTransport = "http";
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return surfacesBySectionId;
|
|
272
|
+
}
|
|
273
|
+
function mergeSurfacesUnderSectionDirectory(surfacesBySectionId, sectionId) {
|
|
274
|
+
const nestedSurfaces = [...surfacesBySectionId.values()].filter((surface) => surface.sectionDirectory.startsWith(`${sectionId}/`) &&
|
|
275
|
+
!EXAMPLE_OR_SAMPLE_PATH.test(`${surface.sectionDirectory.slice(sectionId.length + 1)}/`) &&
|
|
276
|
+
!TEST_FILE_PATH.test(`${surface.sectionDirectory.slice(sectionId.length + 1)}/`));
|
|
277
|
+
if (nestedSurfaces.length === 0)
|
|
278
|
+
return undefined;
|
|
279
|
+
const merged = {
|
|
280
|
+
sectionId,
|
|
281
|
+
sectionDirectory: sectionId,
|
|
282
|
+
isLibraryPackage: nestedSurfaces.every((surface) => surface.isLibraryPackage),
|
|
283
|
+
packageManifestCount: 0,
|
|
284
|
+
libraryPackageManifestCount: 0,
|
|
285
|
+
evidenceByChannel: new Map(),
|
|
286
|
+
};
|
|
287
|
+
for (const nestedSurface of nestedSurfaces) {
|
|
288
|
+
merged.packageManifestCount += nestedSurface.packageManifestCount;
|
|
289
|
+
merged.libraryPackageManifestCount += nestedSurface.libraryPackageManifestCount;
|
|
290
|
+
for (const [channel, evidenceList] of nestedSurface.evidenceByChannel) {
|
|
291
|
+
for (const evidence of evidenceList)
|
|
292
|
+
addEvidence(merged, channel, evidence);
|
|
293
|
+
}
|
|
294
|
+
merged.mcpServerTransport ??= nestedSurface.mcpServerTransport;
|
|
295
|
+
}
|
|
296
|
+
return merged;
|
|
297
|
+
}
|
|
298
|
+
function surfaceForSectionId(surfacesBySectionId, sectionId) {
|
|
299
|
+
if (!sectionId)
|
|
300
|
+
return undefined;
|
|
301
|
+
const exactSurface = surfacesBySectionId.get(sectionId);
|
|
302
|
+
if (exactSurface && exactSurface.evidenceByChannel.size > 0)
|
|
303
|
+
return exactSurface;
|
|
304
|
+
return mergeSurfacesUnderSectionDirectory(surfacesBySectionId, sectionId) ?? exactSurface;
|
|
305
|
+
}
|
|
306
|
+
function sectionIdOfComponent(component) {
|
|
307
|
+
const sectionId = component?.properties?.section_id;
|
|
308
|
+
return typeof sectionId === "string" ? sectionId.trim() : "";
|
|
309
|
+
}
|
|
310
|
+
function isAiAgentActor(component) {
|
|
311
|
+
return component?.type === "actor" && component.properties?.[exports.AI_AGENT_ACTOR_KIND_PROPERTY] === exports.AI_AGENT_ACTOR_KIND;
|
|
312
|
+
}
|
|
313
|
+
function isHumanActor(component) {
|
|
314
|
+
return (component?.type === "actor" &&
|
|
315
|
+
!isAiAgentActor(component) &&
|
|
316
|
+
component.subType !== "automated_service" &&
|
|
317
|
+
component.subType !== "service_account");
|
|
318
|
+
}
|
|
319
|
+
function chooseChannelForHumanActorEdge(surface) {
|
|
320
|
+
if (!surface)
|
|
321
|
+
return undefined;
|
|
322
|
+
return CHANNEL_PRIORITY_FOR_HUMAN_ACTOR_EDGES.find((channel) => surface.evidenceByChannel.has(channel));
|
|
323
|
+
}
|
|
324
|
+
function surfaceHasAnyChannel(surface) {
|
|
325
|
+
return surface.evidenceByChannel.size > 0;
|
|
326
|
+
}
|
|
327
|
+
function firstEvidenceAsSourceLocation(evidence) {
|
|
328
|
+
const first = evidence[0];
|
|
329
|
+
return first ? { filePath: first.filePath, startLine: first.line, endLine: first.line } : undefined;
|
|
330
|
+
}
|
|
331
|
+
function isSyntheticActorEdgeIntoLibraryPackage(flow, componentsById, surfacesBySectionId) {
|
|
332
|
+
const sourceComponent = componentsById.get(flow.sourceComponentId);
|
|
333
|
+
if (!isHumanActor(sourceComponent))
|
|
334
|
+
return false;
|
|
335
|
+
if (sourceComponent?.properties?.sourceContext !== INJECTED_DEFAULT_SOURCE_CONTEXT)
|
|
336
|
+
return false;
|
|
337
|
+
if (flow.sourceLocation || (flow.sourceLocations?.length ?? 0) > 0)
|
|
338
|
+
return false;
|
|
339
|
+
const surface = surfaceForSectionId(surfacesBySectionId, sectionIdOfComponent(componentsById.get(flow.targetComponentId)));
|
|
340
|
+
return surface !== undefined && surface.isLibraryPackage && !surfaceHasAnyChannel(surface);
|
|
341
|
+
}
|
|
342
|
+
function componentIdsTouchedByFlows(flows) {
|
|
343
|
+
return new Set(flows.flatMap((flow) => [flow.sourceComponentId, flow.targetComponentId]));
|
|
344
|
+
}
|
|
345
|
+
function nextNumericSuffix(existingIds, prefix) {
|
|
346
|
+
let highest = 0;
|
|
347
|
+
for (const id of existingIds) {
|
|
348
|
+
if (!id.startsWith(prefix))
|
|
349
|
+
continue;
|
|
350
|
+
const parsed = Number.parseInt(id.slice(prefix.length), 10);
|
|
351
|
+
if (!Number.isNaN(parsed))
|
|
352
|
+
highest = Math.max(highest, parsed);
|
|
353
|
+
}
|
|
354
|
+
return highest + 1;
|
|
355
|
+
}
|
|
356
|
+
function applyHumanInteractionChannels(input) {
|
|
357
|
+
const surfacesBySectionId = detectSectionInteractionSurfaces(input.files, input.sections);
|
|
358
|
+
let components = [...input.components];
|
|
359
|
+
const componentsById = new Map(components.map((component) => [component.id, component]));
|
|
360
|
+
let flows = input.flows.filter((flow) => !isSyntheticActorEdgeIntoLibraryPackage(flow, componentsById, surfacesBySectionId));
|
|
361
|
+
const componentIdsWithFlowsBeforeDropping = componentIdsTouchedByFlows(input.flows);
|
|
362
|
+
const componentIdsWithFlowsAfterDropping = componentIdsTouchedByFlows(flows);
|
|
363
|
+
components = components.filter((component) => !(isHumanActor(component) &&
|
|
364
|
+
component.properties?.sourceContext === INJECTED_DEFAULT_SOURCE_CONTEXT &&
|
|
365
|
+
componentIdsWithFlowsBeforeDropping.has(component.id) &&
|
|
366
|
+
!componentIdsWithFlowsAfterDropping.has(component.id)));
|
|
367
|
+
for (const flow of flows) {
|
|
368
|
+
if (!isHumanActor(componentsById.get(flow.sourceComponentId)))
|
|
369
|
+
continue;
|
|
370
|
+
const targetComponent = componentsById.get(flow.targetComponentId);
|
|
371
|
+
if (targetComponent?.type !== "asset")
|
|
372
|
+
continue;
|
|
373
|
+
const surface = surfaceForSectionId(surfacesBySectionId, sectionIdOfComponent(targetComponent));
|
|
374
|
+
const channel = chooseChannelForHumanActorEdge(surface);
|
|
375
|
+
if (!channel || !surface)
|
|
376
|
+
continue;
|
|
377
|
+
flow.channel = channel;
|
|
378
|
+
flow.channelEvidence = surface.evidenceByChannel.get(channel);
|
|
379
|
+
}
|
|
380
|
+
let nextFlowSuffix = nextNumericSuffix(flows.map((flow) => flow.id), "flow_channel_");
|
|
381
|
+
let nextComponentSuffix = nextNumericSuffix(components.map((component) => component.id), "cmp_channel_");
|
|
382
|
+
const additionalFlows = [];
|
|
383
|
+
const additionalComponents = [];
|
|
384
|
+
const primaryHumanActor = () => {
|
|
385
|
+
const existing = components.find((component) => isHumanActor(component) && component.subType === "customer") ??
|
|
386
|
+
components.find((component) => isHumanActor(component)) ??
|
|
387
|
+
additionalComponents.find((component) => isHumanActor(component));
|
|
388
|
+
if (existing)
|
|
389
|
+
return existing;
|
|
390
|
+
const created = {
|
|
391
|
+
id: `cmp_channel_${nextComponentSuffix++}`,
|
|
392
|
+
name: "User",
|
|
393
|
+
type: "actor",
|
|
394
|
+
subType: "customer",
|
|
395
|
+
confidence: 0.5,
|
|
396
|
+
detectedFrom: [],
|
|
397
|
+
sourceLocations: [],
|
|
398
|
+
properties: { sourceContext: INJECTED_CHANNEL_ACTOR_SOURCE_CONTEXT, section_id: "root", section_role: "root" },
|
|
399
|
+
};
|
|
400
|
+
additionalComponents.push(created);
|
|
401
|
+
return created;
|
|
402
|
+
};
|
|
403
|
+
const findComponentIncludingAdditional = (componentId) => componentsById.get(componentId) ?? additionalComponents.find((component) => component.id === componentId);
|
|
404
|
+
const sortedSurfaces = [...surfacesBySectionId.values()].sort((left, right) => left.sectionId < right.sectionId ? -1 : left.sectionId > right.sectionId ? 1 : 0);
|
|
405
|
+
const sectionAlreadyHasHumanCommandLineEdge = (sectionId) => [...flows, ...additionalFlows].some((flow) => flow.channel === "cli" &&
|
|
406
|
+
isHumanActor(findComponentIncludingAdditional(flow.sourceComponentId)) &&
|
|
407
|
+
sectionIdOfComponent(findComponentIncludingAdditional(flow.targetComponentId)) === sectionId);
|
|
408
|
+
for (const surface of sortedSurfaces) {
|
|
409
|
+
const cliEvidence = surface.evidenceByChannel.get("cli");
|
|
410
|
+
if (!cliEvidence)
|
|
411
|
+
continue;
|
|
412
|
+
const hub = (0, application_hub_1.findApplicationHubForFlows)(components, surface.sectionId);
|
|
413
|
+
if (!hub || sectionIdOfComponent(hub) !== surface.sectionId)
|
|
414
|
+
continue;
|
|
415
|
+
if (sectionAlreadyHasHumanCommandLineEdge(surface.sectionId))
|
|
416
|
+
continue;
|
|
417
|
+
additionalFlows.push({
|
|
418
|
+
id: `flow_channel_${nextFlowSuffix++}`,
|
|
419
|
+
sourceComponentId: primaryHumanActor().id,
|
|
420
|
+
targetComponentId: hub.id,
|
|
421
|
+
type: "api_call",
|
|
422
|
+
confidence: 0.7,
|
|
423
|
+
sourceLocation: firstEvidenceAsSourceLocation(cliEvidence),
|
|
424
|
+
relationship: "interacts",
|
|
425
|
+
channel: "cli",
|
|
426
|
+
channelEvidence: cliEvidence,
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
for (const surface of sortedSurfaces) {
|
|
430
|
+
const mcpEvidence = surface.evidenceByChannel.get("mcp");
|
|
431
|
+
if (!mcpEvidence)
|
|
432
|
+
continue;
|
|
433
|
+
const hub = (0, application_hub_1.findApplicationHubForFlows)(components, surface.sectionId);
|
|
434
|
+
if (!hub)
|
|
435
|
+
continue;
|
|
436
|
+
const aiAgent = {
|
|
437
|
+
id: `cmp_channel_${nextComponentSuffix++}`,
|
|
438
|
+
name: exports.AI_AGENT_ACTOR_NAME,
|
|
439
|
+
type: "actor",
|
|
440
|
+
subType: exports.AI_AGENT_ACTOR_SUBTYPE,
|
|
441
|
+
description: "An AI agent that calls this MCP server on a person's behalf",
|
|
442
|
+
confidence: 0.7,
|
|
443
|
+
detectedFrom: [],
|
|
444
|
+
sourceLocations: mcpEvidence.map((evidence) => ({
|
|
445
|
+
filePath: evidence.filePath,
|
|
446
|
+
startLine: evidence.line,
|
|
447
|
+
endLine: evidence.line,
|
|
448
|
+
})),
|
|
449
|
+
properties: {
|
|
450
|
+
[exports.AI_AGENT_ACTOR_KIND_PROPERTY]: exports.AI_AGENT_ACTOR_KIND,
|
|
451
|
+
sourceContext: INJECTED_CHANNEL_ACTOR_SOURCE_CONTEXT,
|
|
452
|
+
section_id: sectionIdOfComponent(hub),
|
|
453
|
+
section_role: hub.properties?.section_role ?? "service",
|
|
454
|
+
},
|
|
455
|
+
};
|
|
456
|
+
additionalComponents.push(aiAgent);
|
|
457
|
+
const person = primaryHumanActor();
|
|
458
|
+
additionalFlows.push({
|
|
459
|
+
id: `flow_channel_${nextFlowSuffix++}`,
|
|
460
|
+
sourceComponentId: person.id,
|
|
461
|
+
targetComponentId: aiAgent.id,
|
|
462
|
+
type: "api_call",
|
|
463
|
+
confidence: 0.6,
|
|
464
|
+
relationship: "interacts",
|
|
465
|
+
});
|
|
466
|
+
additionalFlows.push({
|
|
467
|
+
id: `flow_channel_${nextFlowSuffix++}`,
|
|
468
|
+
sourceComponentId: aiAgent.id,
|
|
469
|
+
targetComponentId: hub.id,
|
|
470
|
+
type: "api_call",
|
|
471
|
+
confidence: 0.7,
|
|
472
|
+
sourceLocation: firstEvidenceAsSourceLocation(mcpEvidence),
|
|
473
|
+
relationship: "interacts",
|
|
474
|
+
channel: "mcp",
|
|
475
|
+
channelEvidence: mcpEvidence,
|
|
476
|
+
protocol: "mcp",
|
|
477
|
+
...(surface.mcpServerTransport ? { transport: surface.mcpServerTransport } : {}),
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
flows = [...flows, ...additionalFlows];
|
|
481
|
+
components = [...components, ...additionalComponents];
|
|
482
|
+
return { components, flows };
|
|
483
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { DetectedComponent } from "../core/types/component";
|
|
2
2
|
import type { DetectedDataFlow } from "../core/types/data-flow";
|
|
3
3
|
import type { FileInfo } from "../core/types/file";
|
|
4
|
+
export declare function isCommentLine(line: string): boolean;
|
|
5
|
+
/** Data categories that a line of code (`span`) and the code around it name. */
|
|
6
|
+
export declare function collectDataCategories(span: string, contextSpan: string): string[];
|
|
4
7
|
type EnclosingScope = {
|
|
5
8
|
startLine: number;
|
|
6
9
|
endLine: number;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCommentLine = isCommentLine;
|
|
4
|
+
exports.collectDataCategories = collectDataCategories;
|
|
3
5
|
exports.enclosingScopeFinder = enclosingScopeFinder;
|
|
4
6
|
exports.detectIntraComponentLineage = detectIntraComponentLineage;
|
|
5
7
|
const pii_signal_rules_1 = require("../pii-signals/pii-signal-rules");
|
|
@@ -113,12 +115,6 @@ function isAuthUserLookupSpan(span, contextSpan) {
|
|
|
113
115
|
return (/directus_users/i.test(text) &&
|
|
114
116
|
/\.from\(|whereRaw|\.select\(/i.test(span));
|
|
115
117
|
}
|
|
116
|
-
function normalizeFlowDataCategory(category) {
|
|
117
|
-
if (category === "email") {
|
|
118
|
-
return "email_address";
|
|
119
|
-
}
|
|
120
|
-
return category;
|
|
121
|
-
}
|
|
122
118
|
function isPasswordVerificationSpan(span) {
|
|
123
119
|
return /argon2\.verify|bcrypt\.compare|wp_check_password|check_password/i.test(span);
|
|
124
120
|
}
|
|
@@ -135,15 +131,16 @@ function shouldInferCategoriesFromSpanOnly(span, contextSpan) {
|
|
|
135
131
|
return (shouldCollectCategoriesFromSpanOnly(span, contextSpan) ||
|
|
136
132
|
/argon2\.verify|bcrypt\.compare/i.test(span));
|
|
137
133
|
}
|
|
134
|
+
/** Data categories that a line of code (`span`) and the code around it name. */
|
|
138
135
|
function collectDataCategories(span, contextSpan) {
|
|
139
136
|
if (isAuthEmitterFilterSpan(span, contextSpan)) {
|
|
140
137
|
const text = `${span}\n${contextSpan}`;
|
|
141
138
|
const categories = new Set();
|
|
142
139
|
if (/password/i.test(text)) {
|
|
143
|
-
categories.add("
|
|
140
|
+
categories.add("pd:Password");
|
|
144
141
|
}
|
|
145
142
|
if (/\bemail\b/i.test(text)) {
|
|
146
|
-
categories.add("
|
|
143
|
+
categories.add("pd:EmailAddress");
|
|
147
144
|
}
|
|
148
145
|
return [...categories].sort((left, right) => left.localeCompare(right));
|
|
149
146
|
}
|
|
@@ -153,7 +150,7 @@ function collectDataCategories(span, contextSpan) {
|
|
|
153
150
|
if (!spanOnlyCategories && !shouldSkipPiiRuleCategoryHarvest(span)) {
|
|
154
151
|
for (const rule of (0, pii_signal_rules_1.loadPiiSignalRules)()) {
|
|
155
152
|
if (rule.patterns.some((pattern) => pattern.test(span))) {
|
|
156
|
-
categories.add(
|
|
153
|
+
categories.add(rule.id);
|
|
157
154
|
}
|
|
158
155
|
}
|
|
159
156
|
}
|
|
@@ -161,25 +158,23 @@ function collectDataCategories(span, contextSpan) {
|
|
|
161
158
|
categories.add(category);
|
|
162
159
|
}
|
|
163
160
|
if (/PasswordField|PasswordFieldValue|PlainPassword|GenerateFromPassword/i.test(span)) {
|
|
164
|
-
categories.add("
|
|
161
|
+
categories.add("pd:Password");
|
|
165
162
|
}
|
|
166
163
|
if (/EmailField|\.Email\s*\(/i.test(span)) {
|
|
167
|
-
categories.add("
|
|
164
|
+
categories.add("pd:EmailAddress");
|
|
168
165
|
}
|
|
169
166
|
if (/TokenKey|tokenKey/i.test(span)) {
|
|
170
|
-
categories.add("
|
|
167
|
+
categories.add("dpx:AccessToken");
|
|
171
168
|
}
|
|
172
169
|
if (categories.size === 0) {
|
|
173
170
|
if (/PasswordField|PasswordFieldValue|GenerateFromPassword/i.test(contextSpan)) {
|
|
174
|
-
categories.add("
|
|
171
|
+
categories.add("pd:Password");
|
|
175
172
|
}
|
|
176
173
|
if (/EmailField|\.Email\s*\(/i.test(contextSpan)) {
|
|
177
|
-
categories.add("
|
|
174
|
+
categories.add("pd:EmailAddress");
|
|
178
175
|
}
|
|
179
176
|
}
|
|
180
|
-
return [...categories]
|
|
181
|
-
.map(normalizeFlowDataCategory)
|
|
182
|
-
.sort((left, right) => left.localeCompare(right));
|
|
177
|
+
return [...categories].sort((left, right) => left.localeCompare(right));
|
|
183
178
|
}
|
|
184
179
|
function intraComponentFlowType(span, contextSpan) {
|
|
185
180
|
const text = `${span}\n${contextSpan}`;
|
|
@@ -77,7 +77,10 @@ function appendTerraformDataFlows(components, startIndex) {
|
|
|
77
77
|
seen.add(key);
|
|
78
78
|
flowIndex += 1;
|
|
79
79
|
const finding = syntheticTerraformFinding(source);
|
|
80
|
-
flows.push(
|
|
80
|
+
flows.push({
|
|
81
|
+
...(0, flow_builder_1.buildFlow)(source.id, dest.id, flowType, finding, flowIndex, source, dest),
|
|
82
|
+
relationship: "provisions",
|
|
83
|
+
});
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
return { flows, nextIndex: flowIndex };
|
|
@@ -165,6 +168,7 @@ function appendTerraformBareProviderAttachmentFlows(input) {
|
|
|
165
168
|
confidence: 0.72,
|
|
166
169
|
sourceLocation: loc,
|
|
167
170
|
description: `${prov.name} terraform provider attachment (${String(c.properties?.terraform_address ?? "")})`,
|
|
171
|
+
relationship: "provisions",
|
|
168
172
|
});
|
|
169
173
|
}
|
|
170
174
|
}
|
|
@@ -25,5 +25,9 @@ export declare function hasCrossBoundaryEvidence(span: string, contextSpan: stri
|
|
|
25
25
|
export declare function hasIntraComponentTransformationEvidence(span: string, contextSpan: string): boolean;
|
|
26
26
|
export declare function hasStrongTransformationOnSpan(span: string, contextSpan?: string): boolean;
|
|
27
27
|
export declare function inferFlowTypeFromSpan(span: string, contextSpan: string): DataFlowType;
|
|
28
|
-
|
|
28
|
+
/** Personal-data types (taxonomy concept CURIEs) that a span names, by pattern (DATAP-947). */
|
|
29
|
+
export declare const DATA_CATEGORY_PATTERNS: Array<{
|
|
30
|
+
category: string;
|
|
31
|
+
patterns: RegExp[];
|
|
32
|
+
}>;
|
|
29
33
|
export declare function inferDataCategoriesFromSpan(span: string, contextSpan: string): string[];
|