@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
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildThirdPartyHeuristicProposal = buildThirdPartyHeuristicProposal;
|
|
4
4
|
exports.verifyThirdPartyProposal = verifyThirdPartyProposal;
|
|
5
|
-
const
|
|
6
|
-
aws
|
|
7
|
-
stripe
|
|
8
|
-
sentry
|
|
9
|
-
auth0
|
|
10
|
-
twilio
|
|
11
|
-
slack
|
|
12
|
-
github
|
|
13
|
-
google
|
|
14
|
-
azure
|
|
15
|
-
|
|
5
|
+
const KNOWN_VENDORS = new Set([
|
|
6
|
+
'aws',
|
|
7
|
+
'stripe',
|
|
8
|
+
'sentry',
|
|
9
|
+
'auth0',
|
|
10
|
+
'twilio',
|
|
11
|
+
'slack',
|
|
12
|
+
'github',
|
|
13
|
+
'google',
|
|
14
|
+
'azure',
|
|
15
|
+
]);
|
|
16
16
|
function isSparse(value) {
|
|
17
17
|
if (value === null || value === undefined)
|
|
18
18
|
return true;
|
|
19
|
-
if (typeof value ===
|
|
19
|
+
if (typeof value === 'string')
|
|
20
20
|
return value.trim().length === 0;
|
|
21
21
|
if (Array.isArray(value))
|
|
22
22
|
return value.length === 0;
|
|
@@ -24,10 +24,10 @@ function isSparse(value) {
|
|
|
24
24
|
}
|
|
25
25
|
function toBand(score) {
|
|
26
26
|
if (score >= 0.85)
|
|
27
|
-
return
|
|
27
|
+
return 'high';
|
|
28
28
|
if (score >= 0.65)
|
|
29
|
-
return
|
|
30
|
-
return
|
|
29
|
+
return 'medium';
|
|
30
|
+
return 'low';
|
|
31
31
|
}
|
|
32
32
|
function firstLineMatch(file, pattern) {
|
|
33
33
|
const lines = file.content.split(/\r?\n/);
|
|
@@ -42,7 +42,7 @@ function firstLineMatch(file, pattern) {
|
|
|
42
42
|
function componentSeedPaths(component) {
|
|
43
43
|
const seed = new Set();
|
|
44
44
|
const sectionId = component.properties.section_id;
|
|
45
|
-
if (typeof sectionId ===
|
|
45
|
+
if (typeof sectionId === 'string' && sectionId.trim()) {
|
|
46
46
|
seed.add(sectionId.trim());
|
|
47
47
|
}
|
|
48
48
|
for (const loc of component.sourceLocations ?? []) {
|
|
@@ -82,7 +82,7 @@ function extractEndpoints(files) {
|
|
|
82
82
|
function parseDependencies(files) {
|
|
83
83
|
const out = new Set();
|
|
84
84
|
for (const file of files) {
|
|
85
|
-
if (!file.path.endsWith(
|
|
85
|
+
if (!file.path.endsWith('package.json'))
|
|
86
86
|
continue;
|
|
87
87
|
try {
|
|
88
88
|
const parsed = JSON.parse(file.content);
|
|
@@ -104,18 +104,18 @@ function inferVendor(component, evidence) {
|
|
|
104
104
|
if (fromName)
|
|
105
105
|
candidates.add(fromName.toLowerCase());
|
|
106
106
|
const fromClient = component.properties.client;
|
|
107
|
-
if (typeof fromClient ===
|
|
107
|
+
if (typeof fromClient === 'string' && fromClient.trim()) {
|
|
108
108
|
candidates.add(fromClient.trim().toLowerCase());
|
|
109
109
|
}
|
|
110
110
|
for (const dep of evidence.dependencyNames) {
|
|
111
|
-
const normalized = dep.replace(/^@/,
|
|
111
|
+
const normalized = dep.replace(/^@/, '').split('/')[0]?.trim();
|
|
112
112
|
if (normalized)
|
|
113
113
|
candidates.add(normalized.toLowerCase());
|
|
114
114
|
}
|
|
115
115
|
for (const endpoint of evidence.endpoints) {
|
|
116
116
|
try {
|
|
117
|
-
const host = new URL(endpoint.url).hostname.replace(/^api\./,
|
|
118
|
-
const base = host.split(
|
|
117
|
+
const host = new URL(endpoint.url).hostname.replace(/^api\./, '');
|
|
118
|
+
const base = host.split('.')[0]?.toLowerCase();
|
|
119
119
|
if (base)
|
|
120
120
|
candidates.add(base);
|
|
121
121
|
refs.push({
|
|
@@ -131,7 +131,7 @@ function inferVendor(component, evidence) {
|
|
|
131
131
|
}
|
|
132
132
|
const ranked = [...candidates]
|
|
133
133
|
.map((raw) => {
|
|
134
|
-
if (
|
|
134
|
+
if (KNOWN_VENDORS.has(raw))
|
|
135
135
|
return { raw, score: 0.92 };
|
|
136
136
|
if (raw.length >= 3)
|
|
137
137
|
return { raw, score: 0.78 };
|
|
@@ -141,25 +141,29 @@ function inferVendor(component, evidence) {
|
|
|
141
141
|
const winner = ranked[0];
|
|
142
142
|
if (!winner)
|
|
143
143
|
return { score: 0, refs: [] };
|
|
144
|
-
const depEvidence = evidence.files.find((f) => f.path.endsWith(
|
|
144
|
+
const depEvidence = evidence.files.find((f) => f.path.endsWith('package.json'));
|
|
145
145
|
if (depEvidence) {
|
|
146
146
|
refs.push({
|
|
147
147
|
filePath: depEvidence.path,
|
|
148
148
|
startLine: 1,
|
|
149
149
|
endLine: 1,
|
|
150
|
-
reason:
|
|
150
|
+
reason: 'dependency manifest contributes vendor inference',
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
-
return {
|
|
153
|
+
return {
|
|
154
|
+
vendor: winner.raw[0].toUpperCase() + winner.raw.slice(1),
|
|
155
|
+
score: winner.score,
|
|
156
|
+
refs,
|
|
157
|
+
};
|
|
154
158
|
}
|
|
155
159
|
function inferAuthHints(files) {
|
|
156
160
|
const hints = new Set();
|
|
157
161
|
const patterns = [
|
|
158
|
-
{ id:
|
|
159
|
-
{ id:
|
|
160
|
-
{ id:
|
|
161
|
-
{ id:
|
|
162
|
-
{ id:
|
|
162
|
+
{ id: 'oauth2', re: /\boauth2?\b/i },
|
|
163
|
+
{ id: 'jwt', re: /\bjwt\b/i },
|
|
164
|
+
{ id: 'api_key', re: /\bapi[_-]?key\b/i },
|
|
165
|
+
{ id: 'bearer_token', re: /\bbearer\b/i },
|
|
166
|
+
{ id: 'basic_auth', re: /\bbasic auth\b/i },
|
|
163
167
|
];
|
|
164
168
|
for (const file of files) {
|
|
165
169
|
for (const pattern of patterns) {
|
|
@@ -175,13 +179,13 @@ function inferImportHints(files) {
|
|
|
175
179
|
const lines = file.content.split(/\r?\n/);
|
|
176
180
|
for (const line of lines) {
|
|
177
181
|
if (/\b(import|require)\b/.test(line))
|
|
178
|
-
hints.add(
|
|
182
|
+
hints.add('sdk');
|
|
179
183
|
if (/\bfetch\(|\baxios\b|\bhttp[s]?:\/\//i.test(line))
|
|
180
|
-
hints.add(
|
|
184
|
+
hints.add('api');
|
|
181
185
|
if (/\bgraphql\b|\/graphql\b/i.test(line))
|
|
182
|
-
hints.add(
|
|
186
|
+
hints.add('graphql');
|
|
183
187
|
if (/\bwebhook\b/i.test(line))
|
|
184
|
-
hints.add(
|
|
188
|
+
hints.add('webhook');
|
|
185
189
|
}
|
|
186
190
|
}
|
|
187
191
|
return hints;
|
|
@@ -217,7 +221,7 @@ function buildThirdPartyHeuristicProposal(input) {
|
|
|
217
221
|
allEvidence.push(...vendorResult.refs);
|
|
218
222
|
scores.push(vendorResult.score);
|
|
219
223
|
}
|
|
220
|
-
const vendorLower = typeof setProperties.vendor ===
|
|
224
|
+
const vendorLower = typeof setProperties.vendor === 'string'
|
|
221
225
|
? String(setProperties.vendor).toLowerCase()
|
|
222
226
|
: undefined;
|
|
223
227
|
if (vendorLower && isSparse(bundle.component.properties.serviceName)) {
|
|
@@ -232,12 +236,12 @@ function buildThirdPartyHeuristicProposal(input) {
|
|
|
232
236
|
}
|
|
233
237
|
if (isSparse(bundle.component.properties.integration_method)) {
|
|
234
238
|
const methods = [];
|
|
235
|
-
if (bundle.importHints.has(
|
|
236
|
-
methods.push(
|
|
237
|
-
if (bundle.importHints.has(
|
|
238
|
-
methods.push(
|
|
239
|
-
if (bundle.importHints.has(
|
|
240
|
-
methods.push(
|
|
239
|
+
if (bundle.importHints.has('api'))
|
|
240
|
+
methods.push('api');
|
|
241
|
+
if (bundle.importHints.has('sdk'))
|
|
242
|
+
methods.push('sdk');
|
|
243
|
+
if (bundle.importHints.has('webhook'))
|
|
244
|
+
methods.push('webhook');
|
|
241
245
|
if (methods.length > 0) {
|
|
242
246
|
setProperties.integration_method = [...new Set(methods)];
|
|
243
247
|
const file = bundle.files[0];
|
|
@@ -248,9 +252,9 @@ function buildThirdPartyHeuristicProposal(input) {
|
|
|
248
252
|
filePath: file.path,
|
|
249
253
|
startLine: match.line,
|
|
250
254
|
endLine: match.line,
|
|
251
|
-
reason:
|
|
255
|
+
reason: 'integration style inferred from imports/call sites',
|
|
252
256
|
},
|
|
253
|
-
],
|
|
257
|
+
], 'integration_method').integration_method;
|
|
254
258
|
allEvidence.push(...(propertyEvidence.integration_method ?? []));
|
|
255
259
|
}
|
|
256
260
|
scores.push(0.82);
|
|
@@ -258,12 +262,12 @@ function buildThirdPartyHeuristicProposal(input) {
|
|
|
258
262
|
}
|
|
259
263
|
if (isSparse(bundle.component.properties.api_type)) {
|
|
260
264
|
let apiType;
|
|
261
|
-
if (bundle.importHints.has(
|
|
262
|
-
apiType =
|
|
263
|
-
else if (bundle.importHints.has(
|
|
264
|
-
apiType =
|
|
265
|
-
else if (bundle.endpoints.length > 0 || bundle.importHints.has(
|
|
266
|
-
apiType =
|
|
265
|
+
if (bundle.importHints.has('graphql'))
|
|
266
|
+
apiType = 'graphql';
|
|
267
|
+
else if (bundle.importHints.has('webhook'))
|
|
268
|
+
apiType = 'webhook';
|
|
269
|
+
else if (bundle.endpoints.length > 0 || bundle.importHints.has('api'))
|
|
270
|
+
apiType = 'rest';
|
|
267
271
|
if (apiType) {
|
|
268
272
|
setProperties.api_type = apiType;
|
|
269
273
|
const hit = bundle.endpoints[0];
|
|
@@ -278,21 +282,21 @@ function buildThirdPartyHeuristicProposal(input) {
|
|
|
278
282
|
];
|
|
279
283
|
allEvidence.push(...propertyEvidence.api_type);
|
|
280
284
|
}
|
|
281
|
-
scores.push(apiType ===
|
|
285
|
+
scores.push(apiType === 'graphql' ? 0.86 : 0.8);
|
|
282
286
|
}
|
|
283
287
|
}
|
|
284
288
|
if (isSparse(bundle.component.properties.authentication_method)) {
|
|
285
289
|
let method;
|
|
286
|
-
if (bundle.authHints.has(
|
|
287
|
-
method =
|
|
288
|
-
else if (bundle.authHints.has(
|
|
289
|
-
method =
|
|
290
|
-
else if (bundle.authHints.has(
|
|
291
|
-
method =
|
|
292
|
-
else if (bundle.authHints.has(
|
|
293
|
-
method =
|
|
294
|
-
else if (bundle.authHints.has(
|
|
295
|
-
method =
|
|
290
|
+
if (bundle.authHints.has('oauth2'))
|
|
291
|
+
method = 'oauth2';
|
|
292
|
+
else if (bundle.authHints.has('api_key'))
|
|
293
|
+
method = 'api_key';
|
|
294
|
+
else if (bundle.authHints.has('bearer_token'))
|
|
295
|
+
method = 'bearer_token';
|
|
296
|
+
else if (bundle.authHints.has('jwt'))
|
|
297
|
+
method = 'jwt';
|
|
298
|
+
else if (bundle.authHints.has('basic_auth'))
|
|
299
|
+
method = 'basic_auth';
|
|
296
300
|
if (method) {
|
|
297
301
|
setProperties.authentication_method = method;
|
|
298
302
|
const matchFile = bundle.files.find((file) => /\boauth2?\b|\bapi[_-]?key\b|\bbearer\b|\bjwt\b|\bbasic auth\b/i.test(file.content));
|
|
@@ -304,7 +308,7 @@ function buildThirdPartyHeuristicProposal(input) {
|
|
|
304
308
|
filePath: matchFile.path,
|
|
305
309
|
startLine: match.line,
|
|
306
310
|
endLine: match.line,
|
|
307
|
-
reason:
|
|
311
|
+
reason: 'auth token/header pattern detected',
|
|
308
312
|
},
|
|
309
313
|
];
|
|
310
314
|
allEvidence.push(...propertyEvidence.authentication_method);
|
|
@@ -313,7 +317,8 @@ function buildThirdPartyHeuristicProposal(input) {
|
|
|
313
317
|
scores.push(0.78);
|
|
314
318
|
}
|
|
315
319
|
}
|
|
316
|
-
if (bundle.endpoints.length > 0 &&
|
|
320
|
+
if (bundle.endpoints.length > 0 &&
|
|
321
|
+
isSparse(bundle.component.properties.api_endpoint)) {
|
|
317
322
|
const endpoint = bundle.endpoints[0];
|
|
318
323
|
setProperties.api_endpoint = endpoint.url;
|
|
319
324
|
propertyEvidence.api_endpoint = [
|
|
@@ -321,14 +326,15 @@ function buildThirdPartyHeuristicProposal(input) {
|
|
|
321
326
|
filePath: endpoint.filePath,
|
|
322
327
|
startLine: endpoint.line,
|
|
323
328
|
endLine: endpoint.line,
|
|
324
|
-
reason:
|
|
329
|
+
reason: 'external endpoint found in section code',
|
|
325
330
|
},
|
|
326
331
|
];
|
|
327
332
|
allEvidence.push(...propertyEvidence.api_endpoint);
|
|
328
333
|
scores.push(0.84);
|
|
329
334
|
}
|
|
330
|
-
if (bundle.endpoints.length > 0 &&
|
|
331
|
-
|
|
335
|
+
if (bundle.endpoints.length > 0 &&
|
|
336
|
+
isSparse(bundle.component.properties.https_enforced)) {
|
|
337
|
+
const httpsOnly = bundle.endpoints.every((item) => item.url.startsWith('https://'));
|
|
332
338
|
setProperties.https_enforced = httpsOnly;
|
|
333
339
|
const endpoint = bundle.endpoints[0];
|
|
334
340
|
propertyEvidence.https_enforced = [
|
|
@@ -336,39 +342,34 @@ function buildThirdPartyHeuristicProposal(input) {
|
|
|
336
342
|
filePath: endpoint.filePath,
|
|
337
343
|
startLine: endpoint.line,
|
|
338
344
|
endLine: endpoint.line,
|
|
339
|
-
reason: httpsOnly
|
|
345
|
+
reason: httpsOnly
|
|
346
|
+
? 'all discovered endpoints are HTTPS'
|
|
347
|
+
: 'non-HTTPS endpoint found',
|
|
340
348
|
},
|
|
341
349
|
];
|
|
342
350
|
allEvidence.push(...propertyEvidence.https_enforced);
|
|
343
351
|
scores.push(httpsOnly ? 0.9 : 0.7);
|
|
344
352
|
}
|
|
345
|
-
if (
|
|
346
|
-
|
|
347
|
-
if (docs) {
|
|
348
|
-
setProperties.documentation_url = docs;
|
|
349
|
-
propertyEvidence.documentation_url = propertyEvidence.vendor ?? [];
|
|
350
|
-
scores.push(0.86);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
if (bundle.dependencyNames.length > 0 && isSparse(bundle.component.properties.sdk_available)) {
|
|
353
|
+
if (bundle.dependencyNames.length > 0 &&
|
|
354
|
+
isSparse(bundle.component.properties.sdk_available)) {
|
|
354
355
|
setProperties.sdk_available = true;
|
|
355
|
-
const depFile = bundle.files.find((file) => file.path.endsWith(
|
|
356
|
+
const depFile = bundle.files.find((file) => file.path.endsWith('package.json'));
|
|
356
357
|
if (depFile) {
|
|
357
358
|
propertyEvidence.sdk_available = [
|
|
358
359
|
{
|
|
359
360
|
filePath: depFile.path,
|
|
360
361
|
startLine: 1,
|
|
361
362
|
endLine: 1,
|
|
362
|
-
reason:
|
|
363
|
+
reason: 'dependency manifest indicates SDK/library usage',
|
|
363
364
|
},
|
|
364
365
|
];
|
|
365
366
|
allEvidence.push(...propertyEvidence.sdk_available);
|
|
366
367
|
}
|
|
367
368
|
scores.push(0.83);
|
|
368
369
|
}
|
|
369
|
-
if ((bundle.importHints.has(
|
|
370
|
+
if ((bundle.importHints.has('api') || bundle.importHints.has('sdk')) &&
|
|
370
371
|
isSparse(bundle.component.properties.integration_status)) {
|
|
371
|
-
setProperties.integration_status =
|
|
372
|
+
setProperties.integration_status = 'active';
|
|
372
373
|
const file = bundle.files[0];
|
|
373
374
|
if (file) {
|
|
374
375
|
propertyEvidence.integration_status = [
|
|
@@ -376,21 +377,23 @@ function buildThirdPartyHeuristicProposal(input) {
|
|
|
376
377
|
filePath: file.path,
|
|
377
378
|
startLine: 1,
|
|
378
379
|
endLine: 1,
|
|
379
|
-
reason:
|
|
380
|
+
reason: 'client calls/imports indicate active integration',
|
|
380
381
|
},
|
|
381
382
|
];
|
|
382
383
|
allEvidence.push(...propertyEvidence.integration_status);
|
|
383
384
|
}
|
|
384
385
|
scores.push(0.8);
|
|
385
386
|
}
|
|
386
|
-
const normalizedSetProperties =
|
|
387
|
+
const normalizedSetProperties = Object.fromEntries(Object.entries(setProperties).filter(([key]) => (propertyEvidence[key]?.length ?? 0) > 0));
|
|
387
388
|
if (Object.keys(normalizedSetProperties).length === 0)
|
|
388
389
|
return undefined;
|
|
389
|
-
const confidenceScore = scores.length > 0
|
|
390
|
+
const confidenceScore = scores.length > 0
|
|
391
|
+
? Math.max(0.65, Math.min(0.96, scores.reduce((a, b) => a + b, 0) / scores.length))
|
|
392
|
+
: 0.65;
|
|
390
393
|
return {
|
|
391
|
-
kind:
|
|
394
|
+
kind: 'component_patch',
|
|
392
395
|
targetComponentId: bundle.component.id,
|
|
393
|
-
candidateType:
|
|
396
|
+
candidateType: 'third_party',
|
|
394
397
|
setProperties: normalizedSetProperties,
|
|
395
398
|
propertyEvidence,
|
|
396
399
|
confidence: {
|
|
@@ -398,9 +401,9 @@ function buildThirdPartyHeuristicProposal(input) {
|
|
|
398
401
|
band: toBand(confidenceScore),
|
|
399
402
|
},
|
|
400
403
|
evidence: allEvidence.slice(0, 16),
|
|
401
|
-
provider:
|
|
402
|
-
model:
|
|
403
|
-
agent:
|
|
404
|
+
provider: 'mock',
|
|
405
|
+
model: 'third_party_evidence_v1',
|
|
406
|
+
agent: 'tpAgent',
|
|
404
407
|
};
|
|
405
408
|
}
|
|
406
409
|
function verifyPropertyEvidence(patch) {
|
|
@@ -414,13 +417,13 @@ function verifyPropertyEvidence(patch) {
|
|
|
414
417
|
return true;
|
|
415
418
|
}
|
|
416
419
|
function verifyThirdPartyProposal(proposal) {
|
|
417
|
-
if (proposal.kind !==
|
|
418
|
-
return { ok: false, reason:
|
|
419
|
-
if (proposal.candidateType !==
|
|
420
|
-
return { ok: false, reason:
|
|
420
|
+
if (proposal.kind !== 'component_patch')
|
|
421
|
+
return { ok: false, reason: 'not_component_patch' };
|
|
422
|
+
if (proposal.candidateType !== 'third_party')
|
|
423
|
+
return { ok: false, reason: 'not_third_party_candidate' };
|
|
421
424
|
if (proposal.evidence.length === 0)
|
|
422
|
-
return { ok: false, reason:
|
|
425
|
+
return { ok: false, reason: 'missing_evidence' };
|
|
423
426
|
if (!verifyPropertyEvidence(proposal))
|
|
424
|
-
return { ok: false, reason:
|
|
427
|
+
return { ok: false, reason: 'missing_property_evidence' };
|
|
425
428
|
return { ok: true };
|
|
426
429
|
}
|
package/dist/src/cli.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './config/load-cli-env';
|
|
2
2
|
export declare function run(argv?: string[]): Promise<void>;
|