@dataparade/cli 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +2 -2
- package/dist/src/ai-enrichment/candidate-selector.d.ts +4 -4
- package/dist/src/ai-enrichment/candidate-selector.js +37 -32
- package/dist/src/ai-enrichment/fallbacks.js +130 -3
- package/dist/src/ai-enrichment/merge-rules.d.ts +3 -3
- package/dist/src/ai-enrichment/merge-rules.js +118 -40
- package/dist/src/ai-enrichment/prompts/provider-enrichment-prompts.d.ts +2 -2
- package/dist/src/ai-enrichment/prompts/provider-enrichment-prompts.js +3 -3
- package/dist/src/ai-enrichment/property-priority.d.ts +5 -0
- package/dist/src/ai-enrichment/property-priority.js +23 -0
- package/dist/src/ai-enrichment/provider-prompt.d.ts +5 -5
- package/dist/src/ai-enrichment/provider-prompt.js +24 -19
- package/dist/src/ai-enrichment/red-flags.d.ts +46 -0
- package/dist/src/ai-enrichment/red-flags.js +365 -0
- package/dist/src/ai-enrichment/third-party-evidence.d.ts +3 -3
- package/dist/src/ai-enrichment/third-party-evidence.js +96 -93
- package/dist/src/cli.d.ts +1 -1
- package/dist/src/cli.js +236 -143
- package/dist/src/core/pipeline/orchestrator-result.d.ts +9 -1
- package/dist/src/core/pipeline/orchestrator.d.ts +2 -2
- package/dist/src/core/pipeline/scan-pipeline.d.ts +2 -2
- package/dist/src/core/pipeline/scan-pipeline.js +46 -34
- package/dist/src/core/schema/dataflow-wrapper.schema.d.ts +33 -1
- package/dist/src/core/schema/dataflow-wrapper.schema.js +19 -3
- package/dist/src/output/json.d.ts +18 -3
- package/dist/src/output/json.js +14 -5
- package/dist/src/platform-api/cli-scan-failure-report.d.ts +9 -0
- package/dist/src/platform-api/cli-scan-failure-report.js +23 -0
- package/dist/tests/schema/dataflow-wrapper.schema.spec.js +142 -21
- package/dist/tests/unit/ai-enrichment/candidate-selector.spec.js +80 -49
- package/dist/tests/unit/ai-enrichment/fallbacks.spec.js +78 -0
- package/dist/tests/unit/ai-enrichment/merge-rules.spec.js +510 -264
- package/dist/tests/unit/ai-enrichment/provider-prompt.spec.js +80 -77
- package/dist/tests/unit/ai-enrichment/red-flags.spec.js +227 -0
- package/dist/tests/unit/ai-enrichment/third-party-evidence.spec.js +38 -34
- package/dist/tests/unit/cli/scan-command-e2e-backend-lambda-orphan.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-command-e2e-backend-lambda-orphan.spec.js +60 -0
- package/dist/tests/unit/cli/scan-command-e2e-occupied-section-hubs.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-command-e2e-occupied-section-hubs.spec.js +58 -0
- package/dist/tests/unit/cli/scan-command-e2e-ruby-basic.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-command-e2e-ruby-basic.spec.js +46 -0
- package/dist/tests/unit/cli/scan-quota-flow.spec.js +57 -45
- package/dist/tests/unit/platform-api/cli-scan-failure-report.spec.d.ts +1 -0
- package/dist/tests/unit/platform-api/cli-scan-failure-report.spec.js +25 -0
- package/package.json +2 -2
- package/dist/tests/fixtures/e2e-ts-sample/db-client-import.d.ts +0 -2
- package/dist/tests/fixtures/e2e-ts-sample/db-client-import.js +0 -8
- package/dist/tests/fixtures/e2e-ts-sample/db.d.ts +0 -3
- package/dist/tests/fixtures/e2e-ts-sample/db.js +0 -7
- package/dist/tests/fixtures/e2e-ts-sample/external-api.d.ts +0 -1
- package/dist/tests/fixtures/e2e-ts-sample/external-api.js +0 -18
- package/dist/tests/fixtures/e2e-ts-sample/pg-client.d.ts +0 -3
- package/dist/tests/fixtures/e2e-ts-sample/pg-client.js +0 -7
- package/dist/tests/fixtures/e2e-ts-sample/server.d.ts +0 -14
- package/dist/tests/fixtures/e2e-ts-sample/server.js +0 -4
- package/dist/tests/fixtures/e2e-ts-sentry-route-env/server.js +0 -24
- package/dist/tests/fixtures/ingest-basic/src/index.d.ts +0 -1
- package/dist/tests/fixtures/ingest-basic/src/index.js +0 -6
- package/dist/tests/fixtures/mixed-language-basic/api.d.ts +0 -2
- package/dist/tests/fixtures/mixed-language-basic/api.js +0 -12
- package/dist/tests/fixtures/monorepo-app-plus-terraform/packages/app/app/route.d.ts +0 -1
- package/dist/tests/fixtures/monorepo-app-plus-terraform/packages/app/app/route.js +0 -6
- package/dist/tests/fixtures/monorepo-front-back-sections/backend/app/route.d.ts +0 -1
- package/dist/tests/fixtures/monorepo-front-back-sections/backend/app/route.js +0 -6
- package/dist/tests/fixtures/monorepo-front-back-sections/frontend/app/route.d.ts +0 -1
- package/dist/tests/fixtures/monorepo-front-back-sections/frontend/app/route.js +0 -7
- package/dist/tests/fixtures/typescript-basic/app/route.d.ts +0 -1
- package/dist/tests/fixtures/typescript-basic/app/route.js +0 -7
- package/dist/tests/fixtures/typescript-basic/db-client-import.d.ts +0 -2
- package/dist/tests/fixtures/typescript-basic/db-client-import.js +0 -8
- package/dist/tests/fixtures/typescript-basic/db.d.ts +0 -3
- package/dist/tests/fixtures/typescript-basic/db.js +0 -7
- package/dist/tests/fixtures/typescript-basic/external-api.d.ts +0 -1
- package/dist/tests/fixtures/typescript-basic/external-api.js +0 -18
- package/dist/tests/fixtures/typescript-basic/pg-client.d.ts +0 -3
- package/dist/tests/fixtures/typescript-basic/pg-client.js +0 -7
- package/dist/tests/fixtures/typescript-basic/server.d.ts +0 -14
- package/dist/tests/fixtures/typescript-basic/server.js +0 -4
- package/dist/tests/fixtures/typescript-dependency-manifests-basic/src/index.d.ts +0 -0
- package/dist/tests/fixtures/typescript-dependency-manifests-basic/src/index.js +0 -2
- /package/dist/tests/{fixtures/e2e-ts-sentry-route-env/server.d.ts → unit/ai-enrichment/red-flags.spec.d.ts} +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const dataflow_wrapper_schema_1 = require("../../src/core/schema/dataflow-wrapper.schema");
|
|
4
|
-
describe(
|
|
5
|
-
it(
|
|
4
|
+
describe('dataflowWrapperSchema', () => {
|
|
5
|
+
it('accepts a valid dataflow.json wrapper', () => {
|
|
6
6
|
const input = {
|
|
7
|
-
schemaVersion:
|
|
7
|
+
schemaVersion: '1.0',
|
|
8
8
|
graph: {
|
|
9
9
|
nodes: [
|
|
10
10
|
{
|
|
11
|
-
id:
|
|
12
|
-
type:
|
|
11
|
+
id: 'n1',
|
|
12
|
+
type: 'asset',
|
|
13
13
|
position: { x: 0, y: 0 },
|
|
14
|
-
data: { label:
|
|
14
|
+
data: { label: 'Node 1', privacy: {} },
|
|
15
15
|
},
|
|
16
16
|
],
|
|
17
17
|
edges: [],
|
|
@@ -27,19 +27,19 @@ describe("dataflowWrapperSchema", () => {
|
|
|
27
27
|
const result = (0, dataflow_wrapper_schema_1.validateDataflowJson)(input);
|
|
28
28
|
expect(result.ok).toBe(true);
|
|
29
29
|
if (result.ok) {
|
|
30
|
-
expect(result.value.graph.nodes[0].id).toBe(
|
|
30
|
+
expect(result.value.graph.nodes[0].id).toBe('n1');
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
it(
|
|
33
|
+
it('accepts metadata.terraform when shape matches CLI output', () => {
|
|
34
34
|
const input = {
|
|
35
|
-
schemaVersion:
|
|
35
|
+
schemaVersion: '1.0',
|
|
36
36
|
graph: {
|
|
37
37
|
nodes: [
|
|
38
38
|
{
|
|
39
|
-
id:
|
|
40
|
-
type:
|
|
39
|
+
id: 'n1',
|
|
40
|
+
type: 'asset',
|
|
41
41
|
position: { x: 0, y: 0 },
|
|
42
|
-
data: { label:
|
|
42
|
+
data: { label: 'Node 1', privacy: {} },
|
|
43
43
|
},
|
|
44
44
|
],
|
|
45
45
|
edges: [],
|
|
@@ -47,9 +47,9 @@ describe("dataflowWrapperSchema", () => {
|
|
|
47
47
|
metadata: {
|
|
48
48
|
componentsCount: 1,
|
|
49
49
|
terraform: {
|
|
50
|
-
mode:
|
|
50
|
+
mode: 'json_overlay',
|
|
51
51
|
staticTfFiles: 2,
|
|
52
|
-
jsonInputPath:
|
|
52
|
+
jsonInputPath: '/tmp/plan.json',
|
|
53
53
|
jsonFindingsMerged: 1,
|
|
54
54
|
},
|
|
55
55
|
},
|
|
@@ -57,27 +57,27 @@ describe("dataflowWrapperSchema", () => {
|
|
|
57
57
|
const result = (0, dataflow_wrapper_schema_1.validateDataflowJson)(input);
|
|
58
58
|
expect(result.ok).toBe(true);
|
|
59
59
|
});
|
|
60
|
-
it(
|
|
60
|
+
it('rejects wrappers missing schemaVersion or graph', () => {
|
|
61
61
|
const input = {
|
|
62
62
|
graph: {},
|
|
63
63
|
};
|
|
64
64
|
const result = (0, dataflow_wrapper_schema_1.validateDataflowJson)(input);
|
|
65
65
|
expect(result.ok).toBe(false);
|
|
66
66
|
if (!result.ok) {
|
|
67
|
-
const message = result.errors.join(
|
|
67
|
+
const message = result.errors.join(' | ');
|
|
68
68
|
expect(message).toMatch(/schemaVersion/);
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
|
-
it(
|
|
71
|
+
it('rejects invalid graph structures', () => {
|
|
72
72
|
const input = {
|
|
73
|
-
schemaVersion:
|
|
73
|
+
schemaVersion: '1.0',
|
|
74
74
|
graph: {
|
|
75
75
|
nodes: [
|
|
76
76
|
{
|
|
77
|
-
id:
|
|
78
|
-
type:
|
|
77
|
+
id: '',
|
|
78
|
+
type: 'asset',
|
|
79
79
|
position: { x: 0, y: 0 },
|
|
80
|
-
data: { label:
|
|
80
|
+
data: { label: 'Invalid Node', privacy: {} },
|
|
81
81
|
},
|
|
82
82
|
],
|
|
83
83
|
edges: [],
|
|
@@ -86,4 +86,125 @@ describe("dataflowWrapperSchema", () => {
|
|
|
86
86
|
const result = dataflow_wrapper_schema_1.dataflowWrapperSchema.safeParse(input);
|
|
87
87
|
expect(result.success).toBe(false);
|
|
88
88
|
});
|
|
89
|
+
it('accepts metadata.gitContext for evidence linking', () => {
|
|
90
|
+
const input = {
|
|
91
|
+
schemaVersion: '1.0',
|
|
92
|
+
graph: {
|
|
93
|
+
nodes: [
|
|
94
|
+
{
|
|
95
|
+
id: 'n1',
|
|
96
|
+
type: 'asset',
|
|
97
|
+
position: { x: 0, y: 0 },
|
|
98
|
+
data: { label: 'Node 1', privacy: {} },
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
edges: [],
|
|
102
|
+
},
|
|
103
|
+
metadata: {
|
|
104
|
+
componentsCount: 1,
|
|
105
|
+
gitContext: {
|
|
106
|
+
provider: 'github',
|
|
107
|
+
repository: 'dataparade-io/dataparade',
|
|
108
|
+
commitSha: 'abc1234567890abc1234567890abc1234567890a',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
const result = (0, dataflow_wrapper_schema_1.validateDataflowJson)(input);
|
|
113
|
+
expect(result.ok).toBe(true);
|
|
114
|
+
if (result.ok) {
|
|
115
|
+
expect(result.value.metadata?.gitContext).toEqual({
|
|
116
|
+
provider: 'github',
|
|
117
|
+
repository: 'dataparade-io/dataparade',
|
|
118
|
+
commitSha: 'abc1234567890abc1234567890abc1234567890a',
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
it('accepts metadata.gitContext with baseUrl for self-hosted GitLab', () => {
|
|
123
|
+
const input = {
|
|
124
|
+
schemaVersion: '1.0',
|
|
125
|
+
graph: {
|
|
126
|
+
nodes: [],
|
|
127
|
+
edges: [],
|
|
128
|
+
},
|
|
129
|
+
metadata: {
|
|
130
|
+
gitContext: {
|
|
131
|
+
provider: 'gitlab',
|
|
132
|
+
repository: 'internal/project',
|
|
133
|
+
commitSha: 'def1234567890def1234567890def1234567890d',
|
|
134
|
+
baseUrl: 'https://gitlab.mycompany.com',
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
const result = (0, dataflow_wrapper_schema_1.validateDataflowJson)(input);
|
|
139
|
+
expect(result.ok).toBe(true);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
describe('gitContextSchema', () => {
|
|
143
|
+
it('accepts valid GitHub context', () => {
|
|
144
|
+
const result = dataflow_wrapper_schema_1.gitContextSchema.safeParse({
|
|
145
|
+
provider: 'github',
|
|
146
|
+
repository: 'owner/repo',
|
|
147
|
+
commitSha: 'abc1234567890abc1234567890abc1234567890a',
|
|
148
|
+
});
|
|
149
|
+
expect(result.success).toBe(true);
|
|
150
|
+
});
|
|
151
|
+
it('accepts valid GitLab context', () => {
|
|
152
|
+
const result = dataflow_wrapper_schema_1.gitContextSchema.safeParse({
|
|
153
|
+
provider: 'gitlab',
|
|
154
|
+
repository: 'group/project',
|
|
155
|
+
commitSha: 'def1234567890def1234567890def1234567890d',
|
|
156
|
+
});
|
|
157
|
+
expect(result.success).toBe(true);
|
|
158
|
+
});
|
|
159
|
+
it('accepts baseUrl for self-hosted instances', () => {
|
|
160
|
+
const result = dataflow_wrapper_schema_1.gitContextSchema.safeParse({
|
|
161
|
+
provider: 'gitlab',
|
|
162
|
+
repository: 'internal/project',
|
|
163
|
+
commitSha: '1234567890123456789012345678901234567890',
|
|
164
|
+
baseUrl: 'https://gitlab.mycompany.com',
|
|
165
|
+
});
|
|
166
|
+
expect(result.success).toBe(true);
|
|
167
|
+
if (result.success) {
|
|
168
|
+
expect(result.data.baseUrl).toBe('https://gitlab.mycompany.com');
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
it('rejects invalid provider', () => {
|
|
172
|
+
const result = dataflow_wrapper_schema_1.gitContextSchema.safeParse({
|
|
173
|
+
provider: 'bitbucket',
|
|
174
|
+
repository: 'owner/repo',
|
|
175
|
+
commitSha: 'abc1234567890abc1234567890abc1234567890a',
|
|
176
|
+
});
|
|
177
|
+
expect(result.success).toBe(false);
|
|
178
|
+
});
|
|
179
|
+
it('rejects empty repository', () => {
|
|
180
|
+
const result = dataflow_wrapper_schema_1.gitContextSchema.safeParse({
|
|
181
|
+
provider: 'github',
|
|
182
|
+
repository: '',
|
|
183
|
+
commitSha: 'abc1234567890abc1234567890abc1234567890a',
|
|
184
|
+
});
|
|
185
|
+
expect(result.success).toBe(false);
|
|
186
|
+
});
|
|
187
|
+
it('rejects invalid commitSha (not 40 hex chars)', () => {
|
|
188
|
+
const shortSha = dataflow_wrapper_schema_1.gitContextSchema.safeParse({
|
|
189
|
+
provider: 'github',
|
|
190
|
+
repository: 'owner/repo',
|
|
191
|
+
commitSha: 'abc123',
|
|
192
|
+
});
|
|
193
|
+
expect(shortSha.success).toBe(false);
|
|
194
|
+
const invalidChars = dataflow_wrapper_schema_1.gitContextSchema.safeParse({
|
|
195
|
+
provider: 'github',
|
|
196
|
+
repository: 'owner/repo',
|
|
197
|
+
commitSha: 'xyz1234567890xyz1234567890xyz1234567890z',
|
|
198
|
+
});
|
|
199
|
+
expect(invalidChars.success).toBe(false);
|
|
200
|
+
});
|
|
201
|
+
it('rejects invalid baseUrl', () => {
|
|
202
|
+
const result = dataflow_wrapper_schema_1.gitContextSchema.safeParse({
|
|
203
|
+
provider: 'gitlab',
|
|
204
|
+
repository: 'internal/project',
|
|
205
|
+
commitSha: '1234567890123456789012345678901234567890',
|
|
206
|
+
baseUrl: 'not-a-url',
|
|
207
|
+
});
|
|
208
|
+
expect(result.success).toBe(false);
|
|
209
|
+
});
|
|
89
210
|
});
|
|
@@ -1,106 +1,137 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const candidate_selector_1 = require("../../../src/ai-enrichment/candidate-selector");
|
|
4
|
-
describe(
|
|
5
|
-
it(
|
|
4
|
+
describe('ai-enrichment candidate selector', () => {
|
|
5
|
+
it('selects third-party, sparse property, flow direction, and missing interaction candidates', () => {
|
|
6
6
|
const sections = [
|
|
7
7
|
{
|
|
8
|
-
id:
|
|
9
|
-
label:
|
|
10
|
-
role:
|
|
11
|
-
sectionDir:
|
|
12
|
-
manifestPaths: [
|
|
8
|
+
id: 'frontend',
|
|
9
|
+
label: 'frontend',
|
|
10
|
+
role: 'service',
|
|
11
|
+
sectionDir: 'frontend',
|
|
12
|
+
manifestPaths: ['frontend/package.json'],
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
id:
|
|
16
|
-
label:
|
|
17
|
-
role:
|
|
18
|
-
sectionDir:
|
|
19
|
-
manifestPaths: [
|
|
15
|
+
id: 'backend',
|
|
16
|
+
label: 'backend',
|
|
17
|
+
role: 'service',
|
|
18
|
+
sectionDir: 'backend',
|
|
19
|
+
manifestPaths: ['backend/package.json'],
|
|
20
20
|
},
|
|
21
21
|
];
|
|
22
22
|
const components = [
|
|
23
23
|
{
|
|
24
|
-
id:
|
|
25
|
-
name:
|
|
26
|
-
type:
|
|
24
|
+
id: 'tp_1',
|
|
25
|
+
name: 'Stripe',
|
|
26
|
+
type: 'third_party',
|
|
27
27
|
confidence: 0.9,
|
|
28
28
|
detectedFrom: [],
|
|
29
29
|
sourceLocations: [],
|
|
30
|
-
properties: { section_id:
|
|
30
|
+
properties: { section_id: 'backend', dpa_signed: null },
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
id:
|
|
34
|
-
name:
|
|
35
|
-
type:
|
|
33
|
+
id: 'app_1',
|
|
34
|
+
name: 'Backend',
|
|
35
|
+
type: 'asset',
|
|
36
36
|
confidence: 0.95,
|
|
37
37
|
detectedFrom: [],
|
|
38
38
|
sourceLocations: [],
|
|
39
|
-
properties: { section_id:
|
|
39
|
+
properties: { section_id: 'backend', encryption_at_rest: null },
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
|
-
id:
|
|
43
|
-
name:
|
|
44
|
-
type:
|
|
42
|
+
id: 'actor_1',
|
|
43
|
+
name: 'Customer',
|
|
44
|
+
type: 'actor',
|
|
45
45
|
confidence: 0.7,
|
|
46
46
|
detectedFrom: [],
|
|
47
47
|
sourceLocations: [],
|
|
48
|
-
properties: { section_id:
|
|
48
|
+
properties: { section_id: 'frontend' },
|
|
49
49
|
},
|
|
50
50
|
];
|
|
51
51
|
const flows = [
|
|
52
52
|
{
|
|
53
|
-
id:
|
|
54
|
-
sourceComponentId:
|
|
55
|
-
targetComponentId:
|
|
56
|
-
type:
|
|
53
|
+
id: 'flow_1',
|
|
54
|
+
sourceComponentId: 'app_1',
|
|
55
|
+
targetComponentId: 'actor_1',
|
|
56
|
+
type: 'api_call',
|
|
57
57
|
confidence: 0.6,
|
|
58
58
|
},
|
|
59
59
|
];
|
|
60
|
-
const candidates = (0, candidate_selector_1.selectInferenceCandidates)({
|
|
60
|
+
const candidates = (0, candidate_selector_1.selectInferenceCandidates)({
|
|
61
|
+
components,
|
|
62
|
+
dataFlows: flows,
|
|
63
|
+
sections,
|
|
64
|
+
});
|
|
61
65
|
const candidateTypes = candidates.map((candidate) => candidate.candidateType);
|
|
62
|
-
expect(candidateTypes).toContain(
|
|
63
|
-
expect(candidateTypes).toContain(
|
|
64
|
-
expect(candidateTypes).toContain(
|
|
65
|
-
expect(candidateTypes).toContain(
|
|
66
|
+
expect(candidateTypes).toContain('third_party');
|
|
67
|
+
expect(candidateTypes).toContain('node_property');
|
|
68
|
+
expect(candidateTypes).toContain('flow_direction');
|
|
69
|
+
expect(candidateTypes).toContain('missing_interaction');
|
|
66
70
|
});
|
|
67
|
-
it(
|
|
71
|
+
it('third_party_only returns one third_party candidate per third-party and skips assets', () => {
|
|
68
72
|
const components = [
|
|
69
73
|
{
|
|
70
|
-
id:
|
|
71
|
-
name:
|
|
72
|
-
type:
|
|
74
|
+
id: 'tp_a',
|
|
75
|
+
name: 'Stripe',
|
|
76
|
+
type: 'third_party',
|
|
73
77
|
confidence: 0.9,
|
|
74
78
|
detectedFrom: [],
|
|
75
79
|
sourceLocations: [],
|
|
76
|
-
properties: { section_id:
|
|
80
|
+
properties: { section_id: 'backend', subType: 'payments' },
|
|
77
81
|
},
|
|
78
82
|
{
|
|
79
|
-
id:
|
|
80
|
-
name:
|
|
81
|
-
type:
|
|
83
|
+
id: 'tp_b',
|
|
84
|
+
name: 'Sentry',
|
|
85
|
+
type: 'third_party',
|
|
82
86
|
confidence: 0.85,
|
|
83
87
|
detectedFrom: [],
|
|
84
88
|
sourceLocations: [],
|
|
85
|
-
properties: { section_id:
|
|
89
|
+
properties: { section_id: 'backend' },
|
|
86
90
|
},
|
|
87
91
|
{
|
|
88
|
-
id:
|
|
89
|
-
name:
|
|
90
|
-
type:
|
|
92
|
+
id: 'app_1',
|
|
93
|
+
name: 'API',
|
|
94
|
+
type: 'asset',
|
|
91
95
|
confidence: 0.95,
|
|
92
96
|
detectedFrom: [],
|
|
93
97
|
sourceLocations: [],
|
|
94
|
-
properties: { section_id:
|
|
98
|
+
properties: { section_id: 'backend', encryption_at_rest: null },
|
|
95
99
|
},
|
|
96
100
|
];
|
|
97
101
|
const candidates = (0, candidate_selector_1.selectInferenceCandidates)({
|
|
98
102
|
components,
|
|
99
103
|
dataFlows: [],
|
|
100
|
-
inferenceScope:
|
|
104
|
+
inferenceScope: 'third_party_only',
|
|
101
105
|
});
|
|
102
106
|
expect(candidates).toHaveLength(2);
|
|
103
|
-
expect(candidates.every((c) => c.candidateType ===
|
|
104
|
-
expect(new Set(candidates.map((c) => c.componentId))).toEqual(new Set([
|
|
107
|
+
expect(candidates.every((c) => c.candidateType === 'third_party')).toBe(true);
|
|
108
|
+
expect(new Set(candidates.map((c) => c.componentId))).toEqual(new Set(['tp_a', 'tp_b']));
|
|
109
|
+
});
|
|
110
|
+
it('puts Tier 1 property keys first in bounded missingFields', () => {
|
|
111
|
+
const properties = Object.fromEntries(Array.from({ length: 40 }, (_, index) => [
|
|
112
|
+
`z_field_${String(index).padStart(2, '0')}`,
|
|
113
|
+
null,
|
|
114
|
+
]));
|
|
115
|
+
properties.encrypt_at_rest = null;
|
|
116
|
+
properties.authentication_method = null;
|
|
117
|
+
const candidates = (0, candidate_selector_1.selectInferenceCandidates)({
|
|
118
|
+
components: [
|
|
119
|
+
{
|
|
120
|
+
id: 'asset_1',
|
|
121
|
+
name: 'API',
|
|
122
|
+
type: 'asset',
|
|
123
|
+
confidence: 0.9,
|
|
124
|
+
detectedFrom: [],
|
|
125
|
+
sourceLocations: [],
|
|
126
|
+
properties,
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
dataFlows: [],
|
|
130
|
+
});
|
|
131
|
+
const propertyCandidate = candidates.find((candidate) => candidate.candidateType === 'node_property');
|
|
132
|
+
expect(propertyCandidate?.missingFields.slice(0, 2)).toEqual([
|
|
133
|
+
'authentication_method',
|
|
134
|
+
'encrypt_at_rest',
|
|
135
|
+
]);
|
|
105
136
|
});
|
|
106
137
|
});
|
|
@@ -1301,4 +1301,82 @@ describe("ai-enrichment deterministic fallbacks", () => {
|
|
|
1301
1301
|
(f.targetComponentId === "section_api" || f.targetComponentId === "db_pg"));
|
|
1302
1302
|
expect(badFallbacks).toHaveLength(0);
|
|
1303
1303
|
});
|
|
1304
|
+
it("injects a section hub and edges for third_party-only sections (cli-shaped)", () => {
|
|
1305
|
+
const components = [
|
|
1306
|
+
{
|
|
1307
|
+
id: "tp_openai",
|
|
1308
|
+
name: "Openai",
|
|
1309
|
+
type: "third_party",
|
|
1310
|
+
subType: "saas_service",
|
|
1311
|
+
confidence: 0.9,
|
|
1312
|
+
detectedFrom: [],
|
|
1313
|
+
sourceLocations: [],
|
|
1314
|
+
properties: {
|
|
1315
|
+
section_id: "cli",
|
|
1316
|
+
section_label: "cli",
|
|
1317
|
+
section_role: "service",
|
|
1318
|
+
},
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
id: "tp_sentry",
|
|
1322
|
+
name: "Sentry",
|
|
1323
|
+
type: "third_party",
|
|
1324
|
+
subType: "saas_service",
|
|
1325
|
+
confidence: 0.9,
|
|
1326
|
+
detectedFrom: [],
|
|
1327
|
+
sourceLocations: [],
|
|
1328
|
+
properties: {
|
|
1329
|
+
section_id: "cli",
|
|
1330
|
+
section_label: "cli",
|
|
1331
|
+
section_role: "service",
|
|
1332
|
+
},
|
|
1333
|
+
},
|
|
1334
|
+
];
|
|
1335
|
+
const result = (0, fallbacks_1.applyDeterministicInferenceFallbacks)(components, []);
|
|
1336
|
+
const hub = result.components.find((c) => c.type === "asset" &&
|
|
1337
|
+
c.properties?.section_id === "cli" &&
|
|
1338
|
+
(c.properties?.isMainApplication === true ||
|
|
1339
|
+
c.properties?.isMainApplication === "true"));
|
|
1340
|
+
expect(hub).toBeDefined();
|
|
1341
|
+
expect(hub?.name).toBe("cli");
|
|
1342
|
+
expect(result.dataFlows.filter((f) => f.sourceComponentId === hub?.id &&
|
|
1343
|
+
(f.targetComponentId === "tp_openai" ||
|
|
1344
|
+
f.targetComponentId === "tp_sentry"))).toHaveLength(2);
|
|
1345
|
+
});
|
|
1346
|
+
it("promotes an existing section asset to main hub instead of duplicating", () => {
|
|
1347
|
+
const components = [
|
|
1348
|
+
{
|
|
1349
|
+
id: "asset_scripts",
|
|
1350
|
+
name: "Scripts Service",
|
|
1351
|
+
type: "asset",
|
|
1352
|
+
subType: "service",
|
|
1353
|
+
confidence: 1,
|
|
1354
|
+
detectedFrom: [],
|
|
1355
|
+
sourceLocations: [],
|
|
1356
|
+
properties: {
|
|
1357
|
+
section_id: "scripts",
|
|
1358
|
+
section_label: "scripts",
|
|
1359
|
+
},
|
|
1360
|
+
},
|
|
1361
|
+
{
|
|
1362
|
+
id: "tp_stripe",
|
|
1363
|
+
name: "Stripe",
|
|
1364
|
+
type: "third_party",
|
|
1365
|
+
confidence: 1,
|
|
1366
|
+
detectedFrom: [],
|
|
1367
|
+
sourceLocations: [],
|
|
1368
|
+
properties: { section_id: "scripts", section_label: "scripts" },
|
|
1369
|
+
},
|
|
1370
|
+
];
|
|
1371
|
+
const result = (0, fallbacks_1.applyDeterministicInferenceFallbacks)(components, []);
|
|
1372
|
+
const hubs = result.components.filter((c) => c.type === "asset" &&
|
|
1373
|
+
c.properties?.section_id === "scripts" &&
|
|
1374
|
+
(c.properties?.isMainApplication === true ||
|
|
1375
|
+
c.properties?.isMainApplication === "true"));
|
|
1376
|
+
expect(hubs).toHaveLength(1);
|
|
1377
|
+
expect(hubs[0]?.id).toBe("asset_scripts");
|
|
1378
|
+
expect(hubs[0]?.name).toBe("scripts");
|
|
1379
|
+
expect(result.dataFlows.some((f) => f.sourceComponentId === "asset_scripts" &&
|
|
1380
|
+
f.targetComponentId === "tp_stripe")).toBe(true);
|
|
1381
|
+
});
|
|
1304
1382
|
});
|