@dataparade/cli 0.0.25 → 0.0.28
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/LICENSE +202 -674
- package/NOTICE +5 -0
- package/README.md +54 -14
- package/dist/package.json +9 -8
- package/dist/src/ai-enrichment/providers/platform-proxy-provider.js +0 -1
- package/dist/src/cli.js +37 -37
- package/dist/src/discoveries/contract/ocsf-discovery-record.d.ts +1 -1
- package/dist/src/discoveries/load-ocsf-discoveries.d.ts +0 -8
- package/dist/src/discoveries/load-ocsf-discoveries.js +0 -31
- package/dist/src/discoveries/write-ocsf-discoveries.d.ts +0 -8
- package/dist/src/discoveries/write-ocsf-discoveries.js +0 -38
- package/dist/src/evals/run-model-matrix.js +0 -1
- package/dist/src/export/export-ocsf.d.ts +18 -0
- package/dist/src/export/export-ocsf.js +104 -0
- package/dist/src/export/register-export-commands.d.ts +2 -0
- package/dist/src/export/register-export-commands.js +30 -0
- package/dist/src/facts/apply-answers.d.ts +29 -0
- package/dist/src/facts/apply-answers.js +202 -0
- package/dist/src/facts/build-facts.d.ts +24 -0
- package/dist/src/facts/build-facts.js +198 -0
- package/dist/src/facts/io.d.ts +17 -0
- package/dist/src/facts/io.js +67 -0
- package/dist/src/facts/layout.d.ts +29 -0
- package/dist/src/facts/layout.js +38 -0
- package/dist/src/facts/schema.d.ts +265 -0
- package/dist/src/facts/schema.js +122 -0
- package/dist/src/facts/slug.d.ts +7 -0
- package/dist/src/facts/slug.js +47 -0
- package/dist/src/kb/brief.d.ts +1 -2
- package/dist/src/kb/brief.js +2 -4
- package/dist/src/kb/interview-record.d.ts +18 -0
- package/dist/src/kb/interview-record.js +70 -0
- package/dist/src/kb/kb-store.d.ts +24 -18
- package/dist/src/kb/kb-store.js +89 -28
- package/dist/src/kb/land.d.ts +32 -12
- package/dist/src/kb/land.js +97 -90
- package/dist/src/kb/migrate.d.ts +23 -0
- package/dist/src/kb/migrate.js +91 -0
- package/dist/src/kb/project-diagram.js +4 -4
- package/dist/src/kb/register-kb-commands.js +71 -20
- package/dist/src/observability/scan-sentry.js +0 -1
- package/dist/src/output/scan-output-excludes.d.ts +1 -1
- package/dist/src/output/scan-output-excludes.js +14 -5
- package/dist/src/output/write-scan-knowledge.d.ts +33 -0
- package/dist/src/output/write-scan-knowledge.js +115 -0
- package/dist/src/platform-api/estimate-scan-footprint.d.ts +31 -0
- package/dist/src/platform-api/estimate-scan-footprint.js +75 -2
- package/dist/src/ui/scan-progress-renderer.d.ts +2 -0
- package/dist/src/ui/scan-progress-renderer.js +10 -0
- package/dist/src/ui/teaching-lines.js +18 -6
- package/dist/src/upload/collect-scan-sidecars.d.ts +2 -27
- package/dist/src/upload/collect-scan-sidecars.js +25 -121
- package/dist/src/upload/run-upload.js +0 -3
- package/dist/tests/cli/cli.spec.js +30 -13
- package/dist/tests/helpers/facts-fixture.d.ts +9 -0
- package/dist/tests/helpers/facts-fixture.js +72 -0
- package/dist/tests/unit/export/export-ocsf.spec.js +72 -0
- package/dist/tests/unit/facts/apply-answers.spec.js +128 -0
- package/dist/tests/unit/facts/build-facts.spec.d.ts +1 -0
- package/dist/tests/unit/facts/build-facts.spec.js +161 -0
- package/dist/tests/unit/facts/slug.spec.d.ts +1 -0
- package/dist/tests/unit/facts/slug.spec.js +30 -0
- package/dist/tests/unit/kb/kb-interview-loop.spec.js +83 -35
- package/dist/tests/unit/kb/migrate.spec.d.ts +1 -0
- package/dist/tests/unit/kb/migrate.spec.js +108 -0
- package/dist/tests/unit/output/graphify-cache-dir.spec.d.ts +1 -0
- package/dist/tests/unit/output/graphify-cache-dir.spec.js +20 -0
- package/dist/tests/unit/output/scan-output-excludes.spec.js +4 -2
- package/dist/tests/unit/platform-api/estimate-scan-footprint.spec.js +77 -0
- package/dist/tests/unit/platform-api/upload-client.spec.js +2 -2
- package/dist/tests/unit/ui/teaching-lines.spec.js +16 -0
- package/dist/tests/unit/upload/collect-scan-sidecars.spec.js +46 -46
- package/dist/tests/unit/upload/pack-scan-upload.spec.js +6 -6
- package/dist/vendor/scanner/LICENSE +202 -674
- package/dist/vendor/scanner/NOTICE +4 -0
- package/dist/vendor/scanner/dist/src/classifier/component-factory.js +6 -14
- package/dist/vendor/scanner/dist/src/classifier/external-url-third-party.d.ts +1 -0
- package/dist/vendor/scanner/dist/src/classifier/external-url-third-party.js +32 -1
- package/dist/vendor/scanner/dist/src/classifier/naming.d.ts +5 -0
- package/dist/vendor/scanner/dist/src/classifier/naming.js +8 -4
- package/dist/vendor/scanner/dist/src/core/pipeline/build-scan-personal-data-layers.js +26 -14
- package/dist/vendor/scanner/dist/src/core/pipeline/enrich-personal-data-layers.js +3 -1
- package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.d.ts +18 -0
- package/dist/vendor/scanner/dist/src/data-flow/intra-component-lineage.js +125 -66
- package/dist/vendor/scanner/dist/src/index.d.ts +2 -0
- package/dist/vendor/scanner/dist/src/index.js +7 -2
- package/dist/vendor/scanner/dist/src/ingest/file-system.d.ts +5 -0
- package/dist/vendor/scanner/dist/src/ingest/file-system.js +5 -0
- package/dist/vendor/scanner/dist/src/ingest/gitignore.d.ts +17 -0
- package/dist/vendor/scanner/dist/src/ingest/gitignore.js +47 -9
- package/dist/vendor/scanner/dist/src/ingest/schema-files.d.ts +10 -2
- package/dist/vendor/scanner/dist/src/ingest/schema-files.js +24 -7
- package/dist/vendor/scanner/dist/src/patterns/frontend-frameworks.d.ts +3 -0
- package/dist/vendor/scanner/dist/src/patterns/frontend-frameworks.js +45 -0
- package/dist/vendor/scanner/dist/src/patterns/scan-exclusions.js +7 -0
- package/dist/vendor/scanner/package.json +1 -1
- package/dist/vendor/scanner/patterns/classifier/third-party.classifier.yaml +8 -0
- package/dist/vendor/scanner/patterns/third-party.patterns.yaml +9 -0
- package/package.json +9 -8
- package/dist/src/discoveries/project-collected-diagram.d.ts +0 -7
- package/dist/src/discoveries/project-collected-diagram.js +0 -182
- package/dist/src/discoveries/project-ocsf-to-discoveries-document.d.ts +0 -16
- package/dist/src/discoveries/project-ocsf-to-discoveries-document.js +0 -269
- package/dist/src/discoveries/scan-result-to-discovery-input.d.ts +0 -13
- package/dist/src/discoveries/scan-result-to-discovery-input.js +0 -60
- package/dist/src/output/write-knowledge-graph.d.ts +0 -20
- package/dist/src/output/write-knowledge-graph.js +0 -53
- package/dist/src/output/write-scan-discoveries.d.ts +0 -17
- package/dist/src/output/write-scan-discoveries.js +0 -61
- package/dist/tests/unit/discoveries/project-collected-diagram.spec.js +0 -97
- package/dist/tests/unit/discoveries/rescan-replaces-scan-records.spec.js +0 -89
- /package/dist/tests/unit/{discoveries/project-collected-diagram.spec.d.ts → export/export-ocsf.spec.d.ts} +0 -0
- /package/dist/tests/unit/{discoveries/rescan-replaces-scan-records.spec.d.ts → facts/apply-answers.spec.d.ts} +0 -0
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeOccurrenceId = normalizeOccurrenceId;
|
|
4
|
-
exports.projectOcsfToDiscoveriesDocument = projectOcsfToDiscoveriesDocument;
|
|
5
|
-
const discoveries_document_schema_1 = require("./contract/discoveries-document.schema");
|
|
6
|
-
const load_ocsf_discoveries_1 = require("./load-ocsf-discoveries");
|
|
7
|
-
const scan_entity_uri_1 = require("./scan-entity-uri");
|
|
8
|
-
const SYSTEM_ASSERTS_URI = "dp:a0/system";
|
|
9
|
-
function parseScanEntityId(asserts) {
|
|
10
|
-
return (0, scan_entity_uri_1.parseScanEntityAsserts)(asserts)?.entityId ?? null;
|
|
11
|
-
}
|
|
12
|
-
/** Discoveries written before the mention -> occurrence rename (ontology < 0.4.0). */
|
|
13
|
-
const LEGACY_OCCURRENCE_PREFIX = "mention:";
|
|
14
|
-
/** `mention:email:a.ts:3` -> `occurrence:email:a.ts:3`; other ids unchanged. */
|
|
15
|
-
function normalizeOccurrenceId(entityId) {
|
|
16
|
-
return entityId.startsWith(LEGACY_OCCURRENCE_PREFIX)
|
|
17
|
-
? `occurrence:${entityId.slice(LEGACY_OCCURRENCE_PREFIX.length)}`
|
|
18
|
-
: entityId;
|
|
19
|
-
}
|
|
20
|
-
/** A projected id (`<scanPath>::<entityId>` or a bare entity id) with a legacy `mention:` entity renamed. */
|
|
21
|
-
function normalizeProjectedOccurrenceId(projectedId) {
|
|
22
|
-
const at = projectedId.lastIndexOf("::");
|
|
23
|
-
return at === -1
|
|
24
|
-
? normalizeOccurrenceId(projectedId)
|
|
25
|
-
: `${projectedId.slice(0, at + 2)}${normalizeOccurrenceId(projectedId.slice(at + 2))}`;
|
|
26
|
-
}
|
|
27
|
-
function entityKind(entityId) {
|
|
28
|
-
if (entityId.startsWith("occurrence:") || entityId.startsWith(LEGACY_OCCURRENCE_PREFIX)) {
|
|
29
|
-
return "occurrence";
|
|
30
|
-
}
|
|
31
|
-
if (entityId.startsWith("data_item:")) {
|
|
32
|
-
return "data_item";
|
|
33
|
-
}
|
|
34
|
-
if (entityId.startsWith("cmp_")) {
|
|
35
|
-
return "component";
|
|
36
|
-
}
|
|
37
|
-
if (entityId.startsWith("flow_")) {
|
|
38
|
-
return "flow";
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
function parseJsonArray(raw) {
|
|
43
|
-
if (!raw) {
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
const parsed = JSON.parse(raw);
|
|
48
|
-
if (Array.isArray(parsed)) {
|
|
49
|
-
return parsed.map(String);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return [];
|
|
54
|
-
}
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
function parseCategoriesValue(raw) {
|
|
58
|
-
const values = parseJsonArray(raw);
|
|
59
|
-
return values.length > 0 ? values : undefined;
|
|
60
|
-
}
|
|
61
|
-
function parseSourceLocations(raw) {
|
|
62
|
-
if (!raw) {
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
const parsed = JSON.parse(raw);
|
|
67
|
-
if (Array.isArray(parsed)) {
|
|
68
|
-
return parsed;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
return [];
|
|
73
|
-
}
|
|
74
|
-
return [];
|
|
75
|
-
}
|
|
76
|
-
function parseNumber(raw, fallback = 0) {
|
|
77
|
-
if (raw === undefined) {
|
|
78
|
-
return fallback;
|
|
79
|
-
}
|
|
80
|
-
const value = Number(raw);
|
|
81
|
-
return Number.isFinite(value) ? value : fallback;
|
|
82
|
-
}
|
|
83
|
-
function assertsForProjectedId(scanUris, projectedId) {
|
|
84
|
-
for (const uri of scanUris) {
|
|
85
|
-
const parsed = (0, scan_entity_uri_1.parseScanEntityAsserts)(uri);
|
|
86
|
-
if (parsed && (0, scan_entity_uri_1.projectedEntityId)(parsed.scanPath, parsed.entityId) === projectedId) {
|
|
87
|
-
return uri;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
throw new Error(`Missing scan entity URI for ${projectedId}`);
|
|
91
|
-
}
|
|
92
|
-
function scanEntityUrisFromRecords(records) {
|
|
93
|
-
const uris = new Set();
|
|
94
|
-
for (const record of records) {
|
|
95
|
-
if (record.dataparade.source !== "scan") {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
const asserts = record.dataparade.asserts;
|
|
99
|
-
if ((0, scan_entity_uri_1.parseScanEntityAsserts)(asserts)) {
|
|
100
|
-
uris.add(asserts);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return uris;
|
|
104
|
-
}
|
|
105
|
-
function projectOcsfToDiscoveriesDocument(input) {
|
|
106
|
-
const scanUris = scanEntityUrisFromRecords(input.records);
|
|
107
|
-
const slotIndex = (0, load_ocsf_discoveries_1.indexDiscoverySlots)(input.records);
|
|
108
|
-
const componentIds = [];
|
|
109
|
-
const flowIds = [];
|
|
110
|
-
const occurrenceIds = [];
|
|
111
|
-
const dataItemIds = [];
|
|
112
|
-
for (const uri of scanUris) {
|
|
113
|
-
const parsed = (0, scan_entity_uri_1.parseScanEntityAsserts)(uri);
|
|
114
|
-
if (!parsed) {
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
const entityId = (0, scan_entity_uri_1.projectedEntityId)(parsed.scanPath, parsed.entityId);
|
|
118
|
-
const kind = entityKind(parsed.entityId);
|
|
119
|
-
switch (kind) {
|
|
120
|
-
case "component":
|
|
121
|
-
componentIds.push(entityId);
|
|
122
|
-
break;
|
|
123
|
-
case "flow":
|
|
124
|
-
flowIds.push(entityId);
|
|
125
|
-
break;
|
|
126
|
-
case "occurrence":
|
|
127
|
-
occurrenceIds.push(entityId);
|
|
128
|
-
break;
|
|
129
|
-
case "data_item":
|
|
130
|
-
dataItemIds.push(entityId);
|
|
131
|
-
break;
|
|
132
|
-
default:
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
componentIds.sort((left, right) => left.localeCompare(right, undefined, { numeric: true }));
|
|
137
|
-
flowIds.sort((left, right) => left.localeCompare(right, undefined, { numeric: true }));
|
|
138
|
-
occurrenceIds.sort((left, right) => left.localeCompare(right, undefined, { numeric: true }));
|
|
139
|
-
dataItemIds.sort((left, right) => left.localeCompare(right, undefined, { numeric: true }));
|
|
140
|
-
const components = componentIds.map((id) => {
|
|
141
|
-
const asserts = assertsForProjectedId(scanUris, id);
|
|
142
|
-
const parsed = (0, scan_entity_uri_1.parseScanEntityAsserts)(asserts);
|
|
143
|
-
const scanPath = parsed?.scanPath ?? "";
|
|
144
|
-
const actorKind = (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "actor_kind");
|
|
145
|
-
const dataItemIdsForComponent = parseJsonArray((0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "data_item_ids")).map((dataItemId) => (0, scan_entity_uri_1.projectedEntityId)(scanPath, dataItemId));
|
|
146
|
-
return {
|
|
147
|
-
id,
|
|
148
|
-
...(scanPath ? { scanPath } : {}),
|
|
149
|
-
name: (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "name") ?? id,
|
|
150
|
-
type: (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "type") ?? "asset",
|
|
151
|
-
subType: (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "sub_type") ?? "",
|
|
152
|
-
confidence: parseNumber((0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "confidence")),
|
|
153
|
-
sourceLocations: parseSourceLocations((0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "source_locations")),
|
|
154
|
-
dataItemIds: dataItemIdsForComponent,
|
|
155
|
-
...(actorKind ? { actor_kind: actorKind } : {}),
|
|
156
|
-
};
|
|
157
|
-
});
|
|
158
|
-
const dataFlows = flowIds.map((id) => {
|
|
159
|
-
const asserts = assertsForProjectedId(scanUris, id);
|
|
160
|
-
const scanPath = (0, scan_entity_uri_1.parseScanEntityAsserts)(asserts)?.scanPath ?? "";
|
|
161
|
-
const categoriesRaw = (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "data_categories");
|
|
162
|
-
const purpose = (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "purpose");
|
|
163
|
-
const dataCategories = parseCategoriesValue(categoriesRaw);
|
|
164
|
-
const targetScope = (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "target_scope");
|
|
165
|
-
const sourceComponentId = (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "source_component");
|
|
166
|
-
const targetComponentId = (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "target_component");
|
|
167
|
-
if (!sourceComponentId) {
|
|
168
|
-
throw new Error(`Flow ${id} missing source_component in scan OCSF`);
|
|
169
|
-
}
|
|
170
|
-
if (!targetComponentId) {
|
|
171
|
-
throw new Error(`Flow ${id} missing target_component in scan OCSF`);
|
|
172
|
-
}
|
|
173
|
-
return {
|
|
174
|
-
id,
|
|
175
|
-
...(scanPath ? { scanPath } : {}),
|
|
176
|
-
sourceComponentId: (0, scan_entity_uri_1.projectedEntityId)(scanPath, sourceComponentId),
|
|
177
|
-
targetComponentId: (0, scan_entity_uri_1.projectedEntityId)(scanPath, targetComponentId),
|
|
178
|
-
type: (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "type") ?? "data_transfer",
|
|
179
|
-
confidence: parseNumber((0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "confidence")),
|
|
180
|
-
...(targetScope ? { targetScope } : {}),
|
|
181
|
-
...(dataCategories && dataCategories.length > 0 ? { data_categories: dataCategories } : {}),
|
|
182
|
-
...(purpose ? { purpose } : {}),
|
|
183
|
-
};
|
|
184
|
-
});
|
|
185
|
-
const occurrences = occurrenceIds.map((id) => {
|
|
186
|
-
const asserts = assertsForProjectedId(scanUris, id);
|
|
187
|
-
const scanPath = (0, scan_entity_uri_1.parseScanEntityAsserts)(asserts)?.scanPath ?? "";
|
|
188
|
-
const code = (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "code");
|
|
189
|
-
return {
|
|
190
|
-
id: normalizeProjectedOccurrenceId(id),
|
|
191
|
-
...(scanPath ? { scanPath } : {}),
|
|
192
|
-
filePath: (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "file_path") ??
|
|
193
|
-
(() => {
|
|
194
|
-
throw new Error(`Occurrence ${id} missing file_path in scan OCSF`);
|
|
195
|
-
})(),
|
|
196
|
-
startLine: parseNumber((0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "start_line")),
|
|
197
|
-
endLine: parseNumber((0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "end_line")),
|
|
198
|
-
...(code !== undefined ? { code } : {}),
|
|
199
|
-
};
|
|
200
|
-
});
|
|
201
|
-
const dataItems = dataItemIds.map((id) => {
|
|
202
|
-
const asserts = assertsForProjectedId(scanUris, id);
|
|
203
|
-
const scanPath = (0, scan_entity_uri_1.parseScanEntityAsserts)(asserts)?.scanPath ?? "";
|
|
204
|
-
const projectOccurrence = (occurrenceId) => (0, scan_entity_uri_1.projectedEntityId)(scanPath, normalizeOccurrenceId(occurrenceId));
|
|
205
|
-
const occurrenceIdsFromSlot = parseJsonArray((0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "occurrence_ids") ??
|
|
206
|
-
(0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "mention_ids")).map(projectOccurrence);
|
|
207
|
-
const singleOccurrenceId = (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "occurrence") ?? (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, asserts, "mention");
|
|
208
|
-
const legacyOccurrenceId = singleOccurrenceId ? projectOccurrence(singleOccurrenceId) : undefined;
|
|
209
|
-
const occurrenceIds = occurrenceIdsFromSlot.length > 0
|
|
210
|
-
? occurrenceIdsFromSlot
|
|
211
|
-
: legacyOccurrenceId
|
|
212
|
-
? [legacyOccurrenceId]
|
|
213
|
-
: (() => {
|
|
214
|
-
throw new Error(`Data item ${id} missing occurrence_ids in scan OCSF`);
|
|
215
|
-
})();
|
|
216
|
-
return {
|
|
217
|
-
id,
|
|
218
|
-
...(scanPath ? { scanPath } : {}),
|
|
219
|
-
occurrenceIds,
|
|
220
|
-
};
|
|
221
|
-
});
|
|
222
|
-
const inScope = (0, load_ocsf_discoveries_1.discoveryValue)(slotIndex, SYSTEM_ASSERTS_URI, "in_scope");
|
|
223
|
-
const document = {
|
|
224
|
-
components,
|
|
225
|
-
dataFlows,
|
|
226
|
-
dataItems,
|
|
227
|
-
occurrences,
|
|
228
|
-
...(inScope ? { system: { in_scope: inScope } } : {}),
|
|
229
|
-
};
|
|
230
|
-
for (const record of input.records) {
|
|
231
|
-
if (record.dataparade.source !== "interview") {
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
const asserts = record.dataparade.asserts;
|
|
235
|
-
if (asserts === SYSTEM_ASSERTS_URI) {
|
|
236
|
-
const slot = record.dataparade.asserted_slot;
|
|
237
|
-
if (slot && slot !== "in_scope") {
|
|
238
|
-
throw new Error(`Interview system overlay ${record.metadata.uid} only allows in_scope; got ${slot}`);
|
|
239
|
-
}
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
if (!(0, scan_entity_uri_1.parseScanEntityAsserts)(asserts)) {
|
|
243
|
-
throw new Error(`Interview record ${record.metadata.uid} asserts unsupported URI ${asserts}`);
|
|
244
|
-
}
|
|
245
|
-
if (!record.dataparade.asserted_slot) {
|
|
246
|
-
throw new Error(`Interview record ${record.metadata.uid} must not assert scan entity existence`);
|
|
247
|
-
}
|
|
248
|
-
if (!scanUris.has(asserts)) {
|
|
249
|
-
if (input.orphanInterviewRecords === "skip") {
|
|
250
|
-
input.onOrphanInterviewRecord?.(record);
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
throw new Error(`Interview record ${record.metadata.uid} must not create ${asserts}`);
|
|
254
|
-
}
|
|
255
|
-
const entityId = parseScanEntityId(asserts);
|
|
256
|
-
const kind = entityId ? entityKind(entityId) : null;
|
|
257
|
-
const slot = record.dataparade.asserted_slot;
|
|
258
|
-
const allowed = (kind === "component" && slot === "actor_kind") ||
|
|
259
|
-
(kind === "flow" && (slot === "data_categories" || slot === "purpose"));
|
|
260
|
-
if (!allowed) {
|
|
261
|
-
throw new Error(`Interview overlay ${record.metadata.uid} slot '${slot}' is not allowed on ${asserts}`);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
const validation = (0, discoveries_document_schema_1.validateA0DiscoveriesDocument)(document);
|
|
265
|
-
if (!validation.ok) {
|
|
266
|
-
throw new Error(`Invalid A0 discoveries document: ${validation.errors.join("; ")}`);
|
|
267
|
-
}
|
|
268
|
-
return validation.value;
|
|
269
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { OrchestratorScanResult } from "../core/pipeline/orchestrator-result";
|
|
2
|
-
import type { ScanResult } from "../core/types/result";
|
|
3
|
-
import type { ScanDiscoveryInput } from "./scan-discovery-input";
|
|
4
|
-
export interface DiscoverySeedLike {
|
|
5
|
-
components: ScanDiscoveryInput["components"];
|
|
6
|
-
dataFlows: Array<ScanDiscoveryInput["dataFlows"][number] & {
|
|
7
|
-
sourceLocation?: ScanDiscoveryInput["components"][number]["sourceLocations"][number];
|
|
8
|
-
sourceLocations?: ScanDiscoveryInput["components"][number]["sourceLocations"];
|
|
9
|
-
}>;
|
|
10
|
-
}
|
|
11
|
-
export declare function discoverySeedToDiscoveryInput(seed: DiscoverySeedLike): ScanDiscoveryInput;
|
|
12
|
-
export declare function scanResultToDiscoveryInput(scanResult: ScanResult, personalData?: Pick<OrchestratorScanResult, "occurrences" | "dataItems">): ScanDiscoveryInput;
|
|
13
|
-
export declare function orchestratorScanResultToDiscoveryInput(result: OrchestratorScanResult): ScanDiscoveryInput;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.discoverySeedToDiscoveryInput = discoverySeedToDiscoveryInput;
|
|
4
|
-
exports.scanResultToDiscoveryInput = scanResultToDiscoveryInput;
|
|
5
|
-
exports.orchestratorScanResultToDiscoveryInput = orchestratorScanResultToDiscoveryInput;
|
|
6
|
-
function discoverySeedToDiscoveryInput(seed) {
|
|
7
|
-
return {
|
|
8
|
-
components: seed.components,
|
|
9
|
-
dataFlows: seed.dataFlows.map(({ sourceLocation: _sourceLocation, sourceLocations: _sourceLocations, ...flow }) => flow),
|
|
10
|
-
occurrences: [],
|
|
11
|
-
dataItems: [],
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function scanResultToDiscoveryInput(scanResult, personalData = {
|
|
15
|
-
occurrences: [],
|
|
16
|
-
dataItems: [],
|
|
17
|
-
}) {
|
|
18
|
-
return {
|
|
19
|
-
components: scanResult.components.map((component) => ({
|
|
20
|
-
id: component.id,
|
|
21
|
-
name: component.name,
|
|
22
|
-
type: component.type,
|
|
23
|
-
subType: component.subType ?? "",
|
|
24
|
-
confidence: component.confidence,
|
|
25
|
-
sourceLocations: component.sourceLocations.map((location) => ({
|
|
26
|
-
filePath: location.filePath,
|
|
27
|
-
startLine: location.startLine,
|
|
28
|
-
endLine: location.endLine,
|
|
29
|
-
...(location.code !== undefined ? { code: location.code } : {}),
|
|
30
|
-
})),
|
|
31
|
-
})),
|
|
32
|
-
dataFlows: scanResult.dataFlows.map((flow) => ({
|
|
33
|
-
id: flow.id,
|
|
34
|
-
sourceComponentId: flow.sourceComponentId,
|
|
35
|
-
targetComponentId: flow.targetComponentId,
|
|
36
|
-
type: flow.type,
|
|
37
|
-
confidence: flow.confidence,
|
|
38
|
-
...(flow.targetScope !== undefined ? { targetScope: flow.targetScope } : {}),
|
|
39
|
-
})),
|
|
40
|
-
occurrences: personalData.occurrences.map((occurrence) => ({
|
|
41
|
-
id: occurrence.id,
|
|
42
|
-
filePath: occurrence.filePath,
|
|
43
|
-
startLine: occurrence.startLine,
|
|
44
|
-
endLine: occurrence.endLine,
|
|
45
|
-
labels: [...occurrence.labels],
|
|
46
|
-
...(occurrence.code !== undefined ? { code: occurrence.code } : {}),
|
|
47
|
-
})),
|
|
48
|
-
dataItems: personalData.dataItems.map((dataItem) => ({
|
|
49
|
-
id: dataItem.id,
|
|
50
|
-
occurrenceIds: [...dataItem.occurrenceIds],
|
|
51
|
-
labels: [...dataItem.labels],
|
|
52
|
-
})),
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function orchestratorScanResultToDiscoveryInput(result) {
|
|
56
|
-
return scanResultToDiscoveryInput(result.scanResult, {
|
|
57
|
-
occurrences: result.occurrences ?? [],
|
|
58
|
-
dataItems: result.dataItems ?? [],
|
|
59
|
-
});
|
|
60
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Knowledge graph next to dataflow.json (scanner KDATAP-a528cd, KDATAP-d3e0bc).
|
|
3
|
-
*
|
|
4
|
-
* graphify maps the code structure (graphify-out/graph.json); the scanner adds
|
|
5
|
-
* DataParade's privacy and security layer in the same NetworkX node-link format
|
|
6
|
-
* (dataparade-graph.json), with edges that point at graphify's nodes. Loaded
|
|
7
|
-
* together, they are one connected graph from data flows down to the functions and
|
|
8
|
-
* lines that handle each data item. graphify is optional: without it, only
|
|
9
|
-
* dataparade-graph.json is written. Problems here are warnings; they never fail the
|
|
10
|
-
* scan or block dataflow.json.
|
|
11
|
-
*/
|
|
12
|
-
import { type OrchestratorScanResult } from '../../vendor/scanner/dist/src/index.js';
|
|
13
|
-
import { type DataflowHierarchy } from './c4-hierarchy';
|
|
14
|
-
/**
|
|
15
|
-
* C4 hierarchy for `dataflow.json` metadata, from the knowledge graph built in
|
|
16
|
-
* memory (it does not need graphify or the file on disk). Never throws: on any
|
|
17
|
-
* problem it warns and returns undefined, and the scan continues without it.
|
|
18
|
-
*/
|
|
19
|
-
export declare function buildScanHierarchy(result: OrchestratorScanResult, graphNodeIds: Iterable<string>): Promise<DataflowHierarchy | undefined>;
|
|
20
|
-
export declare function writeScanKnowledgeGraph(result: OrchestratorScanResult, scanRoot: string, outDir: string): Promise<void>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildScanHierarchy = buildScanHierarchy;
|
|
4
|
-
exports.writeScanKnowledgeGraph = writeScanKnowledgeGraph;
|
|
5
|
-
/**
|
|
6
|
-
* Knowledge graph next to dataflow.json (scanner KDATAP-a528cd, KDATAP-d3e0bc).
|
|
7
|
-
*
|
|
8
|
-
* graphify maps the code structure (graphify-out/graph.json); the scanner adds
|
|
9
|
-
* DataParade's privacy and security layer in the same NetworkX node-link format
|
|
10
|
-
* (dataparade-graph.json), with edges that point at graphify's nodes. Loaded
|
|
11
|
-
* together, they are one connected graph from data flows down to the functions and
|
|
12
|
-
* lines that handle each data item. graphify is optional: without it, only
|
|
13
|
-
* dataparade-graph.json is written. Problems here are warnings; they never fail the
|
|
14
|
-
* scan or block dataflow.json.
|
|
15
|
-
*/
|
|
16
|
-
const scanner_1 = require("../../vendor/scanner/dist/src/index.js");
|
|
17
|
-
const c4_hierarchy_1 = require("./c4-hierarchy");
|
|
18
|
-
/**
|
|
19
|
-
* C4 hierarchy for `dataflow.json` metadata, from the knowledge graph built in
|
|
20
|
-
* memory (it does not need graphify or the file on disk). Never throws: on any
|
|
21
|
-
* problem it warns and returns undefined, and the scan continues without it.
|
|
22
|
-
*/
|
|
23
|
-
async function buildScanHierarchy(result, graphNodeIds) {
|
|
24
|
-
try {
|
|
25
|
-
const knowledgeGraph = await (0, scanner_1.buildDataParadeGraph)(result);
|
|
26
|
-
return (0, c4_hierarchy_1.buildDataflowHierarchy)(knowledgeGraph, graphNodeIds);
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
// eslint-disable-next-line no-console
|
|
30
|
-
console.warn(`[scan] warning: C4 hierarchy not computed: ${error instanceof Error ? error.message : String(error)}`);
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async function writeScanKnowledgeGraph(result, scanRoot, outDir) {
|
|
35
|
-
try {
|
|
36
|
-
const structure = await (0, scanner_1.runGraphify)(scanRoot, { outDir });
|
|
37
|
-
for (const warning of structure.warnings) {
|
|
38
|
-
// eslint-disable-next-line no-console
|
|
39
|
-
console.warn(`[scan] ${warning}`);
|
|
40
|
-
}
|
|
41
|
-
const written = await (0, scanner_1.writeKnowledgeGraph)(structure.info ? { ...result, structureGraph: structure.info } : result, outDir);
|
|
42
|
-
if (written.structureGraph) {
|
|
43
|
-
// eslint-disable-next-line no-console
|
|
44
|
-
console.log(`[scan] code-structure graph (graphify ${structure.info?.version}) written to ${written.structureGraph}`);
|
|
45
|
-
}
|
|
46
|
-
// eslint-disable-next-line no-console
|
|
47
|
-
console.log(`[scan] knowledge graph written to ${written.dataparadeGraph}`);
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
// eslint-disable-next-line no-console
|
|
51
|
-
console.warn(`[scan] warning: knowledge graph not written: ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { OrchestratorScanResult } from "../core/pipeline/orchestrator-result";
|
|
2
|
-
export declare const SCAN_OCSF_DISCOVERIES_DIRNAME = "ocsf-discoveries";
|
|
3
|
-
export declare const SCAN_DATAPARADE_JSON_BASENAME = "dataparade.json";
|
|
4
|
-
export declare const SCAN_COLLECTED_DIAGRAM_JSON_BASENAME = "discoveries-diagram.json";
|
|
5
|
-
export declare const SCAN_COLLECTED_DIAGRAM_D2_BASENAME = "discoveries-diagram.d2";
|
|
6
|
-
export interface ScanDiscoveriesOutputPaths {
|
|
7
|
-
ocsfDiscoveriesDir: string;
|
|
8
|
-
dataparadeJsonPath: string;
|
|
9
|
-
collectedDiagramJsonPath: string;
|
|
10
|
-
collectedDiagramD2Path: string;
|
|
11
|
-
}
|
|
12
|
-
export declare function resolveScanDiscoveriesOutputPaths(dataflowOutputPath: string): ScanDiscoveriesOutputPaths;
|
|
13
|
-
export interface WriteScanDiscoveriesOptions {
|
|
14
|
-
assertedAt?: string;
|
|
15
|
-
scanRootDir: string;
|
|
16
|
-
}
|
|
17
|
-
export declare function writeScanDiscoveriesArtifacts(scanResult: OrchestratorScanResult, dataflowOutputPath: string, options: WriteScanDiscoveriesOptions): ScanDiscoveriesOutputPaths;
|
|
@@ -1,61 +0,0 @@
|
|
|
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.SCAN_COLLECTED_DIAGRAM_D2_BASENAME = exports.SCAN_COLLECTED_DIAGRAM_JSON_BASENAME = exports.SCAN_DATAPARADE_JSON_BASENAME = exports.SCAN_OCSF_DISCOVERIES_DIRNAME = void 0;
|
|
7
|
-
exports.resolveScanDiscoveriesOutputPaths = resolveScanDiscoveriesOutputPaths;
|
|
8
|
-
exports.writeScanDiscoveriesArtifacts = writeScanDiscoveriesArtifacts;
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const load_ocsf_discoveries_1 = require("../discoveries/load-ocsf-discoveries");
|
|
12
|
-
const project_collected_diagram_1 = require("../discoveries/project-collected-diagram");
|
|
13
|
-
const project_ocsf_to_discoveries_document_1 = require("../discoveries/project-ocsf-to-discoveries-document");
|
|
14
|
-
const scan_result_to_discovery_input_1 = require("../discoveries/scan-result-to-discovery-input");
|
|
15
|
-
const scan_discovery_to_ocsf_1 = require("../discoveries/scan-discovery-to-ocsf");
|
|
16
|
-
const write_ocsf_discoveries_1 = require("../discoveries/write-ocsf-discoveries");
|
|
17
|
-
exports.SCAN_OCSF_DISCOVERIES_DIRNAME = "ocsf-discoveries";
|
|
18
|
-
exports.SCAN_DATAPARADE_JSON_BASENAME = "dataparade.json";
|
|
19
|
-
exports.SCAN_COLLECTED_DIAGRAM_JSON_BASENAME = "discoveries-diagram.json";
|
|
20
|
-
exports.SCAN_COLLECTED_DIAGRAM_D2_BASENAME = "discoveries-diagram.d2";
|
|
21
|
-
function resolveScanDiscoveriesOutputPaths(dataflowOutputPath) {
|
|
22
|
-
const outputDir = path_1.default.dirname(path_1.default.resolve(dataflowOutputPath));
|
|
23
|
-
return {
|
|
24
|
-
ocsfDiscoveriesDir: path_1.default.join(outputDir, exports.SCAN_OCSF_DISCOVERIES_DIRNAME),
|
|
25
|
-
dataparadeJsonPath: path_1.default.join(outputDir, exports.SCAN_DATAPARADE_JSON_BASENAME),
|
|
26
|
-
collectedDiagramJsonPath: path_1.default.join(outputDir, exports.SCAN_COLLECTED_DIAGRAM_JSON_BASENAME),
|
|
27
|
-
collectedDiagramD2Path: path_1.default.join(outputDir, exports.SCAN_COLLECTED_DIAGRAM_D2_BASENAME),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Every discovery record in the output directory. A scan that found nothing (an empty or
|
|
32
|
-
* unsupported repository) writes no records, and that is an empty inventory, not an error.
|
|
33
|
-
*/
|
|
34
|
-
function loadScanRecords(directory) {
|
|
35
|
-
try {
|
|
36
|
-
return (0, load_ocsf_discoveries_1.loadOcsfDiscoveriesFromDir)(directory).records;
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
if (error instanceof load_ocsf_discoveries_1.OcsfDiscoveryLoadError && ["EMPTY_DIRECTORY", "MISSING_DIRECTORY"].includes(error.code)) {
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function writeScanDiscoveriesArtifacts(scanResult, dataflowOutputPath, options) {
|
|
46
|
-
const assertedAt = options.assertedAt ?? new Date().toISOString();
|
|
47
|
-
const discoveryInput = {
|
|
48
|
-
...(0, scan_result_to_discovery_input_1.orchestratorScanResultToDiscoveryInput)(scanResult),
|
|
49
|
-
scanPath: options.scanRootDir,
|
|
50
|
-
};
|
|
51
|
-
const scanRecords = (0, scan_discovery_to_ocsf_1.landScanDiscoveryToOcsfRecords)(discoveryInput, { assertedAt });
|
|
52
|
-
const paths = resolveScanDiscoveriesOutputPaths(dataflowOutputPath);
|
|
53
|
-
(0, write_ocsf_discoveries_1.removeScanRecordsForScanPath)(paths.ocsfDiscoveriesDir, options.scanRootDir);
|
|
54
|
-
(0, write_ocsf_discoveries_1.writeOcsfDiscoveryRecordsToDir)(scanRecords, paths.ocsfDiscoveriesDir);
|
|
55
|
-
const document = (0, project_ocsf_to_discoveries_document_1.projectOcsfToDiscoveriesDocument)({ records: loadScanRecords(paths.ocsfDiscoveriesDir) });
|
|
56
|
-
fs_1.default.writeFileSync(paths.dataparadeJsonPath, `${JSON.stringify(document, null, 2)}\n`, "utf8");
|
|
57
|
-
const collected = (0, project_collected_diagram_1.projectCollectedDiscoveriesDiagram)(document);
|
|
58
|
-
fs_1.default.writeFileSync(paths.collectedDiagramJsonPath, `${JSON.stringify(collected.graph, null, 2)}\n`, "utf8");
|
|
59
|
-
fs_1.default.writeFileSync(paths.collectedDiagramD2Path, collected.d2, "utf8");
|
|
60
|
-
return paths;
|
|
61
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const project_collected_diagram_1 = require("../../../src/discoveries/project-collected-diagram");
|
|
4
|
-
const document = {
|
|
5
|
-
components: [
|
|
6
|
-
{
|
|
7
|
-
id: "/repo-a::cmp_1",
|
|
8
|
-
scanPath: "/repo-a",
|
|
9
|
-
name: "api",
|
|
10
|
-
type: "asset",
|
|
11
|
-
subType: "service",
|
|
12
|
-
confidence: 0.9,
|
|
13
|
-
sourceLocations: [],
|
|
14
|
-
dataItemIds: ["/repo-a::data_item:email"],
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
id: "/repo-a::cmp_2",
|
|
18
|
-
scanPath: "/repo-a",
|
|
19
|
-
name: "db",
|
|
20
|
-
type: "asset",
|
|
21
|
-
subType: "database",
|
|
22
|
-
confidence: 0.8,
|
|
23
|
-
sourceLocations: [],
|
|
24
|
-
dataItemIds: [],
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
dataFlows: [
|
|
28
|
-
{
|
|
29
|
-
id: "/repo-a::flow_1",
|
|
30
|
-
scanPath: "/repo-a",
|
|
31
|
-
sourceComponentId: "/repo-a::cmp_1",
|
|
32
|
-
targetComponentId: "/repo-a::cmp_2",
|
|
33
|
-
type: "data_transfer",
|
|
34
|
-
confidence: 0.7,
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
dataItems: [
|
|
38
|
-
{
|
|
39
|
-
id: "/repo-a::data_item:email",
|
|
40
|
-
scanPath: "/repo-a",
|
|
41
|
-
occurrenceIds: ["/repo-a::occurrence:email:src/a.ts:3"],
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
id: "/repo-b::data_item:email",
|
|
45
|
-
scanPath: "/repo-b",
|
|
46
|
-
occurrenceIds: ["/repo-b::occurrence:email:src/a.ts:3"],
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
occurrences: [
|
|
50
|
-
{
|
|
51
|
-
id: "/repo-a::occurrence:email:src/a.ts:3",
|
|
52
|
-
scanPath: "/repo-a",
|
|
53
|
-
filePath: "src/a.ts",
|
|
54
|
-
startLine: 3,
|
|
55
|
-
endLine: 3,
|
|
56
|
-
code: "email",
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
id: "/repo-b::occurrence:email:src/a.ts:3",
|
|
60
|
-
scanPath: "/repo-b",
|
|
61
|
-
filePath: "src/a.ts",
|
|
62
|
-
startLine: 3,
|
|
63
|
-
endLine: 3,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
};
|
|
67
|
-
describe("projectCollectedDiscoveriesDiagram", () => {
|
|
68
|
-
const diagram = (0, project_collected_diagram_1.projectCollectedDiscoveriesDiagram)(document);
|
|
69
|
-
it("draws the components and the flow that exist, and does not invent a system box", () => {
|
|
70
|
-
expect(diagram.graph.nodes.map((node) => node.id).sort()).toEqual([
|
|
71
|
-
"/repo-a::cmp_1",
|
|
72
|
-
"/repo-a::cmp_2",
|
|
73
|
-
"/repo-b::data_item:email",
|
|
74
|
-
]);
|
|
75
|
-
expect(diagram.graph.nodes.some((node) => node.type === "system")).toBe(false);
|
|
76
|
-
expect(diagram.graph.edges).toEqual([
|
|
77
|
-
expect.objectContaining({
|
|
78
|
-
id: "/repo-a::flow_1",
|
|
79
|
-
source: "/repo-a::cmp_1",
|
|
80
|
-
target: "/repo-a::cmp_2",
|
|
81
|
-
}),
|
|
82
|
-
]);
|
|
83
|
-
expect(diagram.graph.edges[0]?.data?.label).toBe("data_transfer");
|
|
84
|
-
expect(JSON.stringify(diagram.graph)).not.toContain("?");
|
|
85
|
-
});
|
|
86
|
-
it("keeps occurrences on the data item and does not draw them as nodes", () => {
|
|
87
|
-
const api = diagram.graph.nodes.find((node) => node.id === "/repo-a::cmp_1");
|
|
88
|
-
const collected = api?.data.collected;
|
|
89
|
-
expect(collected.dataItems[0]?.occurrences).toEqual([
|
|
90
|
-
expect.objectContaining({ filePath: "src/a.ts", startLine: 3 }),
|
|
91
|
-
]);
|
|
92
|
-
expect(diagram.graph.nodes.some((node) => String(node.id).includes("occurrence:"))).toBe(false);
|
|
93
|
-
const loose = diagram.graph.nodes.find((node) => node.id === "/repo-b::data_item:email");
|
|
94
|
-
expect(loose?.type).toBe("data_item");
|
|
95
|
-
expect(loose?.data.label).toBe("data_item:email (repo-b)");
|
|
96
|
-
});
|
|
97
|
-
});
|