@dataparade/cli 0.0.26 → 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/README.md +52 -12
- package/dist/package.json +7 -7
- 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/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/patterns/classifier/third-party.classifier.yaml +8 -0
- package/dist/vendor/scanner/patterns/third-party.patterns.yaml +9 -0
- package/package.json +7 -7
- 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
|
@@ -3,18 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.entityIdFromAsserts = entityIdFromAsserts;
|
|
7
|
-
exports.isOccurrenceOrDataItemFact = isOccurrenceOrDataItemFact;
|
|
8
|
-
exports.collectScanSidecars = collectScanSidecars;
|
|
9
6
|
exports.collectScanUploadFiles = collectScanUploadFiles;
|
|
10
7
|
const fs_1 = __importDefault(require("fs"));
|
|
11
8
|
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const
|
|
13
|
-
const ENTITY_MARKER = '/entity/';
|
|
14
|
-
const LEGACY_PREFIX = 'dp:scan/entity/';
|
|
9
|
+
const layout_1 = require("../facts/layout");
|
|
15
10
|
function readTextIfPresent(filePath) {
|
|
16
|
-
if (!fs_1.default.existsSync(filePath))
|
|
17
|
-
return undefined;
|
|
18
11
|
try {
|
|
19
12
|
return fs_1.default.readFileSync(filePath, 'utf8');
|
|
20
13
|
}
|
|
@@ -22,132 +15,43 @@ function readTextIfPresent(filePath) {
|
|
|
22
15
|
return undefined;
|
|
23
16
|
}
|
|
24
17
|
}
|
|
25
|
-
function
|
|
26
|
-
const text = readTextIfPresent(filePath);
|
|
27
|
-
if (text === undefined)
|
|
28
|
-
return undefined;
|
|
18
|
+
function isJsonObject(text) {
|
|
29
19
|
try {
|
|
30
|
-
|
|
20
|
+
const parsed = JSON.parse(text);
|
|
21
|
+
return Boolean(parsed) && typeof parsed === 'object' && !Array.isArray(parsed);
|
|
31
22
|
}
|
|
32
23
|
catch {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function asObject(value) {
|
|
37
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
return value;
|
|
41
|
-
}
|
|
42
|
-
function entityIdFromAsserts(asserts) {
|
|
43
|
-
if (asserts.startsWith(PATH_PREFIX)) {
|
|
44
|
-
const rest = asserts.slice(PATH_PREFIX.length);
|
|
45
|
-
const markerAt = rest.indexOf(ENTITY_MARKER);
|
|
46
|
-
if (markerAt === -1)
|
|
47
|
-
return null;
|
|
48
|
-
const entityId = rest.slice(markerAt + ENTITY_MARKER.length);
|
|
49
|
-
return entityId || null;
|
|
50
|
-
}
|
|
51
|
-
if (asserts.startsWith(LEGACY_PREFIX)) {
|
|
52
|
-
const entityId = asserts.slice(LEGACY_PREFIX.length);
|
|
53
|
-
return entityId || null;
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
/** True for an occurrence or data-item Fact, including its slot records. */
|
|
58
|
-
function isOccurrenceOrDataItemFact(record) {
|
|
59
|
-
if (!record || typeof record !== 'object')
|
|
60
|
-
return false;
|
|
61
|
-
const asserts = record.dataparade
|
|
62
|
-
?.asserts;
|
|
63
|
-
if (typeof asserts !== 'string')
|
|
64
24
|
return false;
|
|
65
|
-
const entityId = entityIdFromAsserts(asserts);
|
|
66
|
-
if (!entityId)
|
|
67
|
-
return false;
|
|
68
|
-
return (entityId.startsWith('occurrence:') || entityId.startsWith('data_item:'));
|
|
69
|
-
}
|
|
70
|
-
function readOccurrenceAndDataItemFacts(discoveriesDir) {
|
|
71
|
-
if (!fs_1.default.existsSync(discoveriesDir))
|
|
72
|
-
return undefined;
|
|
73
|
-
const facts = [];
|
|
74
|
-
const names = fs_1.default
|
|
75
|
-
.readdirSync(discoveriesDir)
|
|
76
|
-
.filter((name) => name.endsWith('.json'));
|
|
77
|
-
names.sort((left, right) => left.localeCompare(right));
|
|
78
|
-
for (const name of names) {
|
|
79
|
-
const parsed = readJsonIfPresent(path_1.default.join(discoveriesDir, name));
|
|
80
|
-
if (isOccurrenceOrDataItemFact(parsed)) {
|
|
81
|
-
facts.push(parsed);
|
|
82
|
-
}
|
|
83
25
|
}
|
|
84
|
-
return facts;
|
|
85
26
|
}
|
|
86
27
|
/**
|
|
87
|
-
*
|
|
88
|
-
* graphify
|
|
89
|
-
*/
|
|
90
|
-
function collectScanSidecars(dataflowFilePath) {
|
|
91
|
-
const outputDir = path_1.default.dirname(path_1.default.resolve(dataflowFilePath));
|
|
92
|
-
const sidecars = {};
|
|
93
|
-
const graphifyGraph = asObject(readJsonIfPresent(path_1.default.join(outputDir, 'graphify-out', 'graph.json')));
|
|
94
|
-
if (graphifyGraph !== undefined) {
|
|
95
|
-
sidecars.graphifyGraph = graphifyGraph;
|
|
96
|
-
}
|
|
97
|
-
const dataparadeGraph = asObject(readJsonIfPresent(path_1.default.join(outputDir, 'dataparade-graph.json')));
|
|
98
|
-
if (dataparadeGraph !== undefined) {
|
|
99
|
-
sidecars.dataparadeGraph = dataparadeGraph;
|
|
100
|
-
}
|
|
101
|
-
const facts = readOccurrenceAndDataItemFacts(path_1.default.join(outputDir, 'ocsf-discoveries'));
|
|
102
|
-
if (facts !== undefined) {
|
|
103
|
-
sidecars.facts = facts;
|
|
104
|
-
}
|
|
105
|
-
return sidecars;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Raw scan files to upload beside dataflow.json.
|
|
109
|
-
* graphify-out/graph.json is included only when that file exists.
|
|
110
|
-
* Only occurrence and data-item Facts are included.
|
|
28
|
+
* The scan files to upload after dataflow.json: facts.json, every data-items/*.json,
|
|
29
|
+
* graphify.json, and answers.json. A file that is missing or is not a JSON object is left out.
|
|
111
30
|
*/
|
|
112
31
|
function collectScanUploadFiles(dataflowFilePath) {
|
|
113
|
-
const
|
|
32
|
+
const layout = (0, layout_1.layoutForDir)(path_1.default.dirname(path_1.default.resolve(dataflowFilePath)));
|
|
114
33
|
const files = [];
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const dataparadeGraph = readTextIfPresent(path_1.default.join(outputDir, 'dataparade-graph.json'));
|
|
120
|
-
if (dataparadeGraph !== undefined && asObject(parseJson(dataparadeGraph))) {
|
|
121
|
-
files.push({
|
|
122
|
-
relativePath: 'dataparade-graph.json',
|
|
123
|
-
content: dataparadeGraph,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
const discoveriesDir = path_1.default.join(outputDir, 'ocsf-discoveries');
|
|
127
|
-
if (fs_1.default.existsSync(discoveriesDir)) {
|
|
128
|
-
const names = fs_1.default
|
|
129
|
-
.readdirSync(discoveriesDir)
|
|
130
|
-
.filter((name) => name.endsWith('.json'));
|
|
131
|
-
names.sort((left, right) => left.localeCompare(right));
|
|
132
|
-
for (const name of names) {
|
|
133
|
-
const content = readTextIfPresent(path_1.default.join(discoveriesDir, name));
|
|
134
|
-
if (content === undefined)
|
|
135
|
-
continue;
|
|
136
|
-
if (!isOccurrenceOrDataItemFact(parseJson(content)))
|
|
137
|
-
continue;
|
|
138
|
-
files.push({
|
|
139
|
-
relativePath: `ocsf-discoveries/${name}`,
|
|
140
|
-
content,
|
|
141
|
-
});
|
|
34
|
+
const add = (relativePath, absolutePath) => {
|
|
35
|
+
const content = readTextIfPresent(absolutePath);
|
|
36
|
+
if (content !== undefined && isJsonObject(content)) {
|
|
37
|
+
files.push({ relativePath, content });
|
|
142
38
|
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
function parseJson(text) {
|
|
39
|
+
};
|
|
40
|
+
add(layout_1.FACTS_BASENAME, layout.factsPath);
|
|
41
|
+
let names = [];
|
|
147
42
|
try {
|
|
148
|
-
|
|
43
|
+
names = fs_1.default
|
|
44
|
+
.readdirSync(layout.dataItemsDir)
|
|
45
|
+
.filter((name) => name.endsWith('.json'));
|
|
149
46
|
}
|
|
150
47
|
catch {
|
|
151
|
-
|
|
48
|
+
names = [];
|
|
152
49
|
}
|
|
50
|
+
names.sort((left, right) => left.localeCompare(right));
|
|
51
|
+
for (const name of names) {
|
|
52
|
+
add(`${layout_1.DATA_ITEMS_DIRNAME}/${name}`, path_1.default.join(layout.dataItemsDir, name));
|
|
53
|
+
}
|
|
54
|
+
add(layout_1.GRAPHIFY_BASENAME, layout.graphifyPath);
|
|
55
|
+
add(layout_1.ANSWERS_BASENAME, layout.answersPath);
|
|
56
|
+
return files;
|
|
153
57
|
}
|
|
@@ -25,7 +25,6 @@ async function runDataflowUpload(input) {
|
|
|
25
25
|
});
|
|
26
26
|
const previewUrl = (0, build_preview_url_1.buildImportPreviewUrl)(result.draftId, sessionId);
|
|
27
27
|
if (!input.quiet) {
|
|
28
|
-
// eslint-disable-next-line no-console
|
|
29
28
|
console.log(`${prefix} Preview ready: ${previewUrl}`);
|
|
30
29
|
}
|
|
31
30
|
if (sessionId) {
|
|
@@ -57,9 +56,7 @@ async function runDataflowUpload(input) {
|
|
|
57
56
|
? ' and any platform AI tokens used during the scan.'
|
|
58
57
|
: '.');
|
|
59
58
|
if (!input.quiet) {
|
|
60
|
-
// eslint-disable-next-line no-console
|
|
61
59
|
console.log(`${prefix} Preview ready: ${previewUrl}`);
|
|
62
|
-
// eslint-disable-next-line no-console
|
|
63
60
|
console.log(`${prefix} ${notice}`);
|
|
64
61
|
}
|
|
65
62
|
if (sessionId) {
|
|
@@ -9,19 +9,19 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const cliDistPath = path_1.default.join(__dirname, '../../dist/bin/cli.js');
|
|
10
10
|
const cliCwd = path_1.default.join(__dirname, '../../');
|
|
11
11
|
const scanFixturePath = path_1.default.join(cliCwd, 'tests/fixtures/typescript-basic');
|
|
12
|
-
/** Scan outputs the CLI writes
|
|
12
|
+
/** Scan outputs the CLI writes in the working directory (default `.dataparade/`, plus `-o` files in the tests). */
|
|
13
13
|
const SCAN_OUTPUTS = [
|
|
14
|
+
'.dataparade',
|
|
15
|
+
'.cli-test-out',
|
|
14
16
|
'dataflow.json',
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'graphify-out',
|
|
17
|
+
'facts.json',
|
|
18
|
+
'data-items',
|
|
19
|
+
'graphify.json',
|
|
20
|
+
'scan-fixture-summary.json',
|
|
21
|
+
'scan-teaching-progress.json',
|
|
21
22
|
];
|
|
22
23
|
describe('CLI', () => {
|
|
23
|
-
//
|
|
24
|
-
// from a clean working directory.
|
|
24
|
+
// Each scan test starts from a clean working directory.
|
|
25
25
|
beforeEach(() => {
|
|
26
26
|
for (const name of SCAN_OUTPUTS)
|
|
27
27
|
(0, fs_1.rmSync)(path_1.default.join(cliCwd, name), { recursive: true, force: true });
|
|
@@ -47,7 +47,7 @@ describe('CLI', () => {
|
|
|
47
47
|
cwd: cliCwd,
|
|
48
48
|
});
|
|
49
49
|
expect(result.status).toBe(0);
|
|
50
|
-
const outputPath = path_1.default.join(cliCwd, 'dataflow.json');
|
|
50
|
+
const outputPath = path_1.default.join(cliCwd, '.dataparade', 'dataflow.json');
|
|
51
51
|
const exists = (0, fs_1.existsSync)(outputPath);
|
|
52
52
|
expect(exists).toBe(true);
|
|
53
53
|
const contents = (0, fs_1.readFileSync)(outputPath, 'utf8').trim();
|
|
@@ -56,6 +56,23 @@ describe('CLI', () => {
|
|
|
56
56
|
expect(dataflow.graph).toBeDefined();
|
|
57
57
|
expect(Array.isArray(dataflow.graph.nodes)).toBe(true);
|
|
58
58
|
expect(Array.isArray(dataflow.graph.edges)).toBe(true);
|
|
59
|
+
// The default folder holds Facts, one file per data item, and nothing from older versions.
|
|
60
|
+
const outputDir = path_1.default.join(cliCwd, '.dataparade');
|
|
61
|
+
const names = (0, fs_1.readdirSync)(outputDir).sort();
|
|
62
|
+
expect(names).toEqual(expect.arrayContaining(['dataflow.json', 'facts.json']));
|
|
63
|
+
for (const legacy of [
|
|
64
|
+
'dataparade.json',
|
|
65
|
+
'dataparade-graph.json',
|
|
66
|
+
'ocsf-discoveries',
|
|
67
|
+
'discoveries-diagram.json',
|
|
68
|
+
'graphify-out',
|
|
69
|
+
]) {
|
|
70
|
+
expect(names).not.toContain(legacy);
|
|
71
|
+
}
|
|
72
|
+
const facts = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(outputDir, 'facts.json'), 'utf8'));
|
|
73
|
+
expect(facts.schemaVersion).toBe(1);
|
|
74
|
+
expect(facts.components.length).toBeGreaterThan(0);
|
|
75
|
+
expect(JSON.stringify(facts)).not.toContain(cliCwd);
|
|
59
76
|
});
|
|
60
77
|
it('scan fixture produces a dataflow.json wrapper with at least one node', () => {
|
|
61
78
|
const result = (0, child_process_1.spawnSync)('node', [
|
|
@@ -69,14 +86,14 @@ describe('CLI', () => {
|
|
|
69
86
|
cwd: cliCwd,
|
|
70
87
|
});
|
|
71
88
|
expect(result.status).toBe(0);
|
|
72
|
-
const outputPath = path_1.default.join(cliCwd, 'dataflow.json');
|
|
89
|
+
const outputPath = path_1.default.join(cliCwd, '.dataparade', 'dataflow.json');
|
|
73
90
|
const contents = (0, fs_1.readFileSync)(outputPath, 'utf8').trim();
|
|
74
91
|
const dataflow = JSON.parse(contents);
|
|
75
92
|
expect(Array.isArray(dataflow.graph.nodes)).toBe(true);
|
|
76
93
|
expect(dataflow.graph.nodes.length).toBeGreaterThan(0);
|
|
77
94
|
});
|
|
78
95
|
it('scan fixture --output writes a dataflow.json wrapper to the given file and prints a short message', () => {
|
|
79
|
-
const outputFile = 'scan-fixture-summary.json';
|
|
96
|
+
const outputFile = '.cli-test-out/scan-fixture-summary.json';
|
|
80
97
|
const result = (0, child_process_1.spawnSync)('node', [
|
|
81
98
|
cliDistPath,
|
|
82
99
|
'scan',
|
|
@@ -98,7 +115,7 @@ describe('CLI', () => {
|
|
|
98
115
|
});
|
|
99
116
|
it('scan mixed-language fixture prints teaching lines before dataflow.json written', () => {
|
|
100
117
|
const teachingFixture = path_1.default.join(cliCwd, 'tests/fixtures/mixed-language-basic');
|
|
101
|
-
const outputFile = 'scan-teaching-progress.json';
|
|
118
|
+
const outputFile = '.cli-test-out/scan-teaching-progress.json';
|
|
102
119
|
const result = (0, child_process_1.spawnSync)('node', [
|
|
103
120
|
cliDistPath,
|
|
104
121
|
'scan',
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type OutputLayout } from "../../src/facts/layout";
|
|
2
|
+
import type { DataItemFile, FactsFile } from "../../src/facts/schema";
|
|
3
|
+
/** A small scan: an API, Sendgrid, a customer, two flows, and an email data item with two groups. */
|
|
4
|
+
export declare function sampleFacts(): {
|
|
5
|
+
facts: FactsFile;
|
|
6
|
+
files: DataItemFile[];
|
|
7
|
+
};
|
|
8
|
+
/** A knowledge base folder holding sampleFacts(). */
|
|
9
|
+
export declare function makeKbDir(): OutputLayout;
|
|
@@ -0,0 +1,72 @@
|
|
|
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.sampleFacts = sampleFacts;
|
|
7
|
+
exports.makeKbDir = makeKbDir;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const io_1 = require("../../src/facts/io");
|
|
12
|
+
const layout_1 = require("../../src/facts/layout");
|
|
13
|
+
/** A small scan: an API, Sendgrid, a customer, two flows, and an email data item with two groups. */
|
|
14
|
+
function sampleFacts() {
|
|
15
|
+
const groups = [
|
|
16
|
+
{ id: "group:email:customer", label: "customer", basis: "column", occurrenceCount: 2, handledBy: ["cmp_api"] },
|
|
17
|
+
{ id: "group:email:staff", label: "staff", basis: "name", occurrenceCount: 1, handledBy: ["cmp_api", "cmp_mail"] },
|
|
18
|
+
];
|
|
19
|
+
const emailFile = {
|
|
20
|
+
schemaVersion: 1,
|
|
21
|
+
id: "data_item:email",
|
|
22
|
+
name: "email",
|
|
23
|
+
labels: ["contact"],
|
|
24
|
+
groups,
|
|
25
|
+
occurrences: [
|
|
26
|
+
{ id: "occurrence:email:src/a.ts:3", groupId: "group:email:customer", filePath: "src/a.ts", startLine: 3, endLine: 3, code: "email", labels: ["contact"], codeRefs: [] },
|
|
27
|
+
{ id: "occurrence:email:src/b.ts:9", groupId: "group:email:customer", filePath: "src/b.ts", startLine: 9, endLine: 9, labels: ["contact"], codeRefs: [] },
|
|
28
|
+
{ id: "occurrence:email:src/c.ts:1", groupId: "group:email:staff", filePath: "src/c.ts", startLine: 1, endLine: 1, labels: [], codeRefs: [] },
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
const phoneFile = {
|
|
32
|
+
schemaVersion: 1,
|
|
33
|
+
id: "data_item:phone",
|
|
34
|
+
name: "phone",
|
|
35
|
+
labels: [],
|
|
36
|
+
groups: [{ id: "group:phone:customer", label: "customer", occurrenceCount: 1, handledBy: ["cmp_api"] }],
|
|
37
|
+
occurrences: [
|
|
38
|
+
{ id: "occurrence:phone:src/a.ts:7", groupId: "group:phone:customer", filePath: "src/a.ts", startLine: 7, endLine: 7, labels: [], codeRefs: [] },
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
const facts = {
|
|
42
|
+
schemaVersion: 1,
|
|
43
|
+
scan: { projectName: "demo", scannedAt: "2026-10-09T00:00:00.000Z", cliVersion: "0.0.27", scannerVersion: "abc123" },
|
|
44
|
+
components: [
|
|
45
|
+
{ id: "cmp_api", name: "backend", type: "asset", subType: "service", confidence: 0.9, sourceLocations: [{ filePath: "backend/src/main.ts", startLine: 1, endLine: 1 }], codeRefs: [] },
|
|
46
|
+
{ id: "cmp_mail", name: "Sendgrid", type: "third_party", subType: "email", confidence: 0.9, sourceLocations: [], codeRefs: [] },
|
|
47
|
+
{ id: "cmp_user", name: "Customer", type: "actor", subType: "", confidence: 0.8, sourceLocations: [], codeRefs: [] },
|
|
48
|
+
],
|
|
49
|
+
dataFlows: [
|
|
50
|
+
{ id: "flow_mail", sourceComponentId: "cmp_api", targetComponentId: "cmp_mail", type: "api_call", confidence: 0.9, sourceLocations: [], codeRefs: [] },
|
|
51
|
+
{ id: "flow_login", sourceComponentId: "cmp_user", targetComponentId: "cmp_api", type: "api_call", confidence: 0.9, sourceLocations: [], codeRefs: [] },
|
|
52
|
+
],
|
|
53
|
+
dataItems: [
|
|
54
|
+
{ id: "data_item:email", name: "email", labels: ["contact"], occurrenceCount: 3, file: "data-items/email.json", groups },
|
|
55
|
+
{ id: "data_item:phone", name: "phone", labels: [], occurrenceCount: 1, file: "data-items/phone.json", groups: phoneFile.groups },
|
|
56
|
+
],
|
|
57
|
+
relations: [
|
|
58
|
+
{ type: "sends", source: "cmp_api", target: "flow_mail", confidence: "EXTRACTED", basis: null },
|
|
59
|
+
{ type: "delivers_to", source: "flow_mail", target: "cmp_mail", confidence: "EXTRACTED", basis: null },
|
|
60
|
+
{ type: "handled_by", source: "group:email:staff", target: "cmp_mail", confidence: "INFERRED", basis: "same_file" },
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
return { facts, files: [emailFile, phoneFile] };
|
|
64
|
+
}
|
|
65
|
+
/** A knowledge base folder holding sampleFacts(). */
|
|
66
|
+
function makeKbDir() {
|
|
67
|
+
const layout = (0, layout_1.layoutForDir)(fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "dp-kb-")));
|
|
68
|
+
const { facts, files } = sampleFacts();
|
|
69
|
+
(0, io_1.writeFactsOutput)(layout, facts, new Map(files.map((file) => [`data-items/${file.name}.json`, file])));
|
|
70
|
+
fs_1.default.writeFileSync(layout.dataflowPath, JSON.stringify({ schemaVersion: "1.0", graph: { nodes: [], edges: [] }, metadata: { projectName: "demo" } }));
|
|
71
|
+
return layout;
|
|
72
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const load_ocsf_discoveries_1 = require("../../../src/discoveries/load-ocsf-discoveries");
|
|
10
|
+
const export_ocsf_1 = require("../../../src/export/export-ocsf");
|
|
11
|
+
const brief_1 = require("../../../src/kb/brief");
|
|
12
|
+
const land_1 = require("../../../src/kb/land");
|
|
13
|
+
const facts_fixture_1 = require("../../helpers/facts-fixture");
|
|
14
|
+
describe("export ocsf", () => {
|
|
15
|
+
let paths;
|
|
16
|
+
let out;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
paths = (0, facts_fixture_1.makeKbDir)();
|
|
19
|
+
out = path_1.default.join(fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "dp-export-")), "ocsf");
|
|
20
|
+
});
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
fs_1.default.rmSync(paths.dir, { recursive: true, force: true });
|
|
23
|
+
fs_1.default.rmSync(path_1.default.dirname(out), { recursive: true, force: true });
|
|
24
|
+
});
|
|
25
|
+
const slot = (records, name) => records.filter((r) => r.dataparade.asserted_slot === name).map((r) => r.dataparade.asserted_value);
|
|
26
|
+
it("writes valid OCSF records for the Facts, with no absolute paths", () => {
|
|
27
|
+
const result = (0, export_ocsf_1.exportOcsf)(paths, out);
|
|
28
|
+
expect(result.interviewRecords).toBe(0);
|
|
29
|
+
expect(result.records).toBe(result.scanRecords);
|
|
30
|
+
const { records } = (0, load_ocsf_discoveries_1.loadOcsfDiscoveriesFromDir)(out);
|
|
31
|
+
expect(records).toHaveLength(result.records);
|
|
32
|
+
expect(slot(records, "name").sort()).toEqual(["Customer", "Sendgrid", "backend"]);
|
|
33
|
+
expect(records.some((r) => r.dataparade.asserts === "dp:scan/entity/occurrence:email:src/a.ts:3")).toBe(true);
|
|
34
|
+
expect(records.some((r) => r.dataparade.asserts === "dp:scan/entity/data_item:email")).toBe(true);
|
|
35
|
+
expect(JSON.stringify(records)).not.toContain("/Users/");
|
|
36
|
+
});
|
|
37
|
+
it("exports the applied state: overrides in, removed Facts out", () => {
|
|
38
|
+
(0, land_1.landReviewAnswer)(paths, { target: "cmp_mail", action: "set", property: "name", value: "SendGrid Inc", reviewer: "dev@example.com" });
|
|
39
|
+
(0, land_1.landReviewAnswer)(paths, { target: "data_item:phone", action: "remove", reviewer: "dev@example.com" });
|
|
40
|
+
(0, export_ocsf_1.exportOcsf)(paths, out);
|
|
41
|
+
const { records } = (0, load_ocsf_discoveries_1.loadOcsfDiscoveriesFromDir)(out);
|
|
42
|
+
expect(slot(records, "name")).toContain("SendGrid Inc");
|
|
43
|
+
expect(slot(records, "name")).not.toContain("Sendgrid");
|
|
44
|
+
const asserted = records.map((r) => r.dataparade.asserts);
|
|
45
|
+
expect(asserted.some((a) => a.includes("phone"))).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
it("exports interview answers as interview records that supersede the earlier answer", () => {
|
|
48
|
+
fs_1.default.mkdirSync(paths.evidenceDir, { recursive: true });
|
|
49
|
+
fs_1.default.writeFileSync(path_1.default.join(paths.dir, "evidence/s.md"), "Q/A");
|
|
50
|
+
const { sha } = (0, brief_1.writeKbBrief)(paths);
|
|
51
|
+
const land = (value, now) => (0, land_1.landInterviewAnswer)(paths, { briefSha: sha, target: "flow_mail", slot: "purpose", value, reviewer: "dev@example.com", evidence: "evidence/s.md", skillSha: "f".repeat(40), now });
|
|
52
|
+
land("marketing", new Date("2026-10-10T10:00:00.000Z"));
|
|
53
|
+
land("service_provision", new Date("2026-10-10T11:00:00.000Z"));
|
|
54
|
+
const result = (0, export_ocsf_1.exportOcsf)(paths, out);
|
|
55
|
+
expect(result.interviewRecords).toBe(2);
|
|
56
|
+
const interview = (0, load_ocsf_discoveries_1.loadOcsfDiscoveriesFromDir)(out).records.filter((r) => r.dataparade.source === "interview");
|
|
57
|
+
expect(interview.map((r) => r.dataparade.asserted_value).sort()).toEqual(["marketing", "service_provision"]);
|
|
58
|
+
const second = interview.find((r) => r.dataparade.asserted_value === "service_provision");
|
|
59
|
+
expect(second?.dataparade).toMatchObject({ asserts: "dp:scan/entity/flow_mail", reviewer: "dev@example.com", brief_sha: sha, raw_evidence_ref: "evidence/s.md" });
|
|
60
|
+
expect(second?.dataparade.supersedes).toBe(interview.find((r) => r.dataparade.asserted_value === "marketing")?.metadata.uid);
|
|
61
|
+
});
|
|
62
|
+
it("replaces an earlier export and refuses a folder that holds other files", () => {
|
|
63
|
+
(0, export_ocsf_1.exportOcsf)(paths, out);
|
|
64
|
+
expect(() => (0, export_ocsf_1.exportOcsf)(paths, out)).not.toThrow();
|
|
65
|
+
fs_1.default.writeFileSync(path_1.default.join(out, "notes.txt"), "mine");
|
|
66
|
+
expect(() => (0, export_ocsf_1.exportOcsf)(paths, out)).toThrow(/not OCSF records/);
|
|
67
|
+
expect(fs_1.default.existsSync(path_1.default.join(out, "notes.txt"))).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
it("refuses to export into the knowledge base folder", () => {
|
|
70
|
+
expect(() => (0, export_ocsf_1.exportOcsf)(paths, paths.dir)).toThrow(/separate folder/);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const apply_answers_1 = require("../../../src/facts/apply-answers");
|
|
4
|
+
const facts_fixture_1 = require("../../helpers/facts-fixture");
|
|
5
|
+
let counter = 0;
|
|
6
|
+
function answer(partial) {
|
|
7
|
+
counter += 1;
|
|
8
|
+
return {
|
|
9
|
+
id: `ans_${counter}`,
|
|
10
|
+
by: "dev@example.com",
|
|
11
|
+
at: `2026-10-10T00:00:${String(counter).padStart(2, "0")}.000Z`,
|
|
12
|
+
source: "review",
|
|
13
|
+
...partial,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
describe("applyAnswers", () => {
|
|
17
|
+
const { facts, files } = (0, facts_fixture_1.sampleFacts)();
|
|
18
|
+
it("returns the scan unchanged when there are no answers, and does not change its inputs", () => {
|
|
19
|
+
const before = JSON.stringify({ facts, files });
|
|
20
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, []);
|
|
21
|
+
expect(state.facts).toEqual(facts);
|
|
22
|
+
expect(state.dataItemFiles).toEqual(files);
|
|
23
|
+
expect(JSON.stringify({ facts, files })).toBe(before);
|
|
24
|
+
expect(state.facts).not.toBe(facts);
|
|
25
|
+
});
|
|
26
|
+
describe("set", () => {
|
|
27
|
+
it("overrides one property of a component and leaves the rest", () => {
|
|
28
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [answer({ factId: "cmp_mail", action: "set", property: "name", value: "SendGrid Inc" })]);
|
|
29
|
+
const mail = state.facts.components.find((c) => c.id === "cmp_mail");
|
|
30
|
+
expect(mail).toMatchObject({ name: "SendGrid Inc", type: "third_party", subType: "email" });
|
|
31
|
+
expect(state.applied).toHaveLength(1);
|
|
32
|
+
});
|
|
33
|
+
it("lets the latest answer for a property win, by time and not by position in the file", () => {
|
|
34
|
+
const late = answer({ factId: "flow_mail", action: "set", property: "purpose", value: "marketing", at: "2026-11-01T00:00:00.000Z" });
|
|
35
|
+
const early = answer({ factId: "flow_mail", action: "set", property: "purpose", value: "security", at: "2026-10-01T00:00:00.000Z" });
|
|
36
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [late, early]);
|
|
37
|
+
expect(state.facts.dataFlows.find((f) => f.id === "flow_mail").purpose).toBe("marketing");
|
|
38
|
+
});
|
|
39
|
+
it("adds a property the scan did not have", () => {
|
|
40
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [answer({ factId: "cmp_user", action: "set", property: "actor_kind", value: "persona" })]);
|
|
41
|
+
expect(state.facts.components.find((c) => c.id === "cmp_user").actor_kind).toBe("persona");
|
|
42
|
+
});
|
|
43
|
+
it("sets a data item in facts.json and in its file, and a group in both", () => {
|
|
44
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [
|
|
45
|
+
answer({ factId: "data_item:email", action: "set", property: "labels", value: ["contact", "pii"] }),
|
|
46
|
+
answer({ factId: "group:email:staff", action: "set", property: "label", value: "employees" }),
|
|
47
|
+
]);
|
|
48
|
+
expect(state.facts.dataItems[0].labels).toEqual(["contact", "pii"]);
|
|
49
|
+
expect(state.dataItemFiles[0].labels).toEqual(["contact", "pii"]);
|
|
50
|
+
expect(state.facts.dataItems[0].groups.find((g) => g.id === "group:email:staff")?.label).toBe("employees");
|
|
51
|
+
expect(state.dataItemFiles[0].groups.find((g) => g.id === "group:email:staff")?.label).toBe("employees");
|
|
52
|
+
});
|
|
53
|
+
it("sets a property of an occurrence", () => {
|
|
54
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [answer({ factId: "occurrence:email:src/a.ts:3", action: "set", property: "labels", value: ["verified"] })]);
|
|
55
|
+
expect(state.dataItemFiles[0].occurrences[0].labels).toEqual(["verified"]);
|
|
56
|
+
});
|
|
57
|
+
it("keeps answers about the system apart from Facts", () => {
|
|
58
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [answer({ factId: "dp:a0/system", action: "set", property: "in_scope", value: "The web app" })]);
|
|
59
|
+
expect(state.system).toEqual({ in_scope: "The web app" });
|
|
60
|
+
expect(state.facts).toEqual(facts);
|
|
61
|
+
});
|
|
62
|
+
it.each(["id", "file", "codeRefs", "groups", "occurrences"])("refuses to change %s", (property) => {
|
|
63
|
+
const a = answer({ factId: "cmp_api", action: "set", property, value: "x" });
|
|
64
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [a]);
|
|
65
|
+
expect(state.ignored).toEqual([a]);
|
|
66
|
+
expect(state.facts).toEqual(facts);
|
|
67
|
+
});
|
|
68
|
+
it("ignores a set without a property", () => {
|
|
69
|
+
const a = answer({ factId: "cmp_api", action: "set", value: "x" });
|
|
70
|
+
expect((0, apply_answers_1.applyAnswers)(facts, files, [a]).ignored).toEqual([a]);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe("remove", () => {
|
|
74
|
+
it("drops a flow and the relations that mention it", () => {
|
|
75
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [answer({ factId: "flow_mail", action: "remove" })]);
|
|
76
|
+
expect(state.facts.dataFlows.map((f) => f.id)).toEqual(["flow_login"]);
|
|
77
|
+
expect(state.facts.relations.map((r) => r.type)).toEqual(["handled_by"]);
|
|
78
|
+
});
|
|
79
|
+
it("drops a component with its flows and every handledBy reference to it", () => {
|
|
80
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [answer({ factId: "cmp_mail", action: "remove" })]);
|
|
81
|
+
expect(state.facts.components.map((c) => c.id)).toEqual(["cmp_api", "cmp_user"]);
|
|
82
|
+
expect(state.facts.dataFlows.map((f) => f.id)).toEqual(["flow_login"]);
|
|
83
|
+
const staff = state.facts.dataItems[0].groups.find((g) => g.id === "group:email:staff");
|
|
84
|
+
expect(staff?.handledBy).toEqual(["cmp_api"]);
|
|
85
|
+
expect(state.dataItemFiles[0].groups.find((g) => g.id === "group:email:staff")?.handledBy).toEqual(["cmp_api"]);
|
|
86
|
+
expect(state.facts.relations).toEqual([]);
|
|
87
|
+
});
|
|
88
|
+
it("drops a data item with its occurrences, its file and its entry in facts.json", () => {
|
|
89
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [answer({ factId: "data_item:email", action: "remove" })]);
|
|
90
|
+
expect(state.facts.dataItems.map((i) => i.id)).toEqual(["data_item:phone"]);
|
|
91
|
+
expect(state.dataItemFiles.map((f) => f.id)).toEqual(["data_item:phone"]);
|
|
92
|
+
expect(state.facts.relations.some((r) => r.source.startsWith("group:email"))).toBe(false);
|
|
93
|
+
});
|
|
94
|
+
it("drops a group with its occurrences and fixes the counts", () => {
|
|
95
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [answer({ factId: "group:email:customer", action: "remove" })]);
|
|
96
|
+
expect(state.dataItemFiles[0].occurrences.map((o) => o.id)).toEqual(["occurrence:email:src/c.ts:1"]);
|
|
97
|
+
expect(state.facts.dataItems[0].occurrenceCount).toBe(1);
|
|
98
|
+
expect(state.facts.dataItems[0].groups.map((g) => g.id)).toEqual(["group:email:staff"]);
|
|
99
|
+
});
|
|
100
|
+
it("drops one occurrence and fixes the counts", () => {
|
|
101
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [answer({ factId: "occurrence:email:src/a.ts:3", action: "remove" })]);
|
|
102
|
+
expect(state.dataItemFiles[0].occurrences).toHaveLength(2);
|
|
103
|
+
expect(state.facts.dataItems[0].occurrenceCount).toBe(2);
|
|
104
|
+
expect(state.facts.dataItems[0].groups.find((g) => g.id === "group:email:customer")?.occurrenceCount).toBe(1);
|
|
105
|
+
expect(state.dataItemFiles[0].groups.find((g) => g.id === "group:email:customer")?.occurrenceCount).toBe(1);
|
|
106
|
+
});
|
|
107
|
+
it("is final: a later set about a removed Fact is ignored, also through its parent", () => {
|
|
108
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [
|
|
109
|
+
answer({ factId: "data_item:phone", action: "remove" }),
|
|
110
|
+
answer({ factId: "data_item:phone", action: "set", property: "labels", value: ["x"] }),
|
|
111
|
+
answer({ factId: "occurrence:phone:src/a.ts:7", action: "set", property: "labels", value: ["x"] }),
|
|
112
|
+
]);
|
|
113
|
+
expect(state.ignored).toHaveLength(2);
|
|
114
|
+
expect(state.applied).toHaveLength(1);
|
|
115
|
+
});
|
|
116
|
+
it("cannot remove the system", () => {
|
|
117
|
+
const a = answer({ factId: "dp:a0/system", action: "remove" });
|
|
118
|
+
expect((0, apply_answers_1.applyAnswers)(facts, files, [a]).ignored).toEqual([a]);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
it("returns an answer about a Fact the scan does not have as an orphan, and applies the rest", () => {
|
|
122
|
+
const gone = answer({ factId: "flow_old", action: "set", property: "purpose", value: "security" });
|
|
123
|
+
const kept = answer({ factId: "cmp_api", action: "set", property: "name", value: "API" });
|
|
124
|
+
const state = (0, apply_answers_1.applyAnswers)(facts, files, [gone, kept]);
|
|
125
|
+
expect(state.orphans).toEqual([gone]);
|
|
126
|
+
expect(state.applied).toEqual([kept]);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|