@trustify-da/trustify-da-javascript-client 0.3.0-ea.63ae5c2 → 0.3.0-ea.7144952
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 +119 -4
- package/dist/package.json +10 -2
- package/dist/src/analysis.d.ts +16 -6
- package/dist/src/analysis.js +69 -66
- package/dist/src/batch_opts.d.ts +24 -0
- package/dist/src/batch_opts.js +35 -0
- package/dist/src/cli.js +192 -8
- package/dist/src/cyclone_dx_sbom.d.ts +3 -1
- package/dist/src/cyclone_dx_sbom.js +18 -5
- package/dist/src/index.d.ts +64 -1
- package/dist/src/index.js +267 -4
- package/dist/src/license/index.d.ts +28 -0
- package/dist/src/license/index.js +100 -0
- package/dist/src/license/license_utils.d.ts +40 -0
- package/dist/src/license/license_utils.js +134 -0
- package/dist/src/license/licenses_api.d.ts +34 -0
- package/dist/src/license/licenses_api.js +98 -0
- package/dist/src/license/project_license.d.ts +20 -0
- package/dist/src/license/project_license.js +62 -0
- package/dist/src/provider.d.ts +15 -3
- package/dist/src/provider.js +23 -5
- package/dist/src/providers/base_javascript.d.ts +19 -7
- package/dist/src/providers/base_javascript.js +48 -14
- package/dist/src/providers/golang_gomodules.d.ts +8 -1
- package/dist/src/providers/golang_gomodules.js +13 -4
- package/dist/src/providers/java_gradle.d.ts +6 -0
- package/dist/src/providers/java_gradle.js +12 -2
- package/dist/src/providers/java_maven.d.ts +8 -1
- package/dist/src/providers/java_maven.js +32 -4
- package/dist/src/providers/javascript_pnpm.d.ts +1 -1
- package/dist/src/providers/javascript_pnpm.js +2 -2
- package/dist/src/providers/python_pip.d.ts +7 -0
- package/dist/src/providers/python_pip.js +13 -3
- package/dist/src/providers/requirements_parser.js +5 -8
- package/dist/src/providers/rust_cargo.d.ts +52 -0
- package/dist/src/providers/rust_cargo.js +614 -0
- package/dist/src/providers/tree-sitter-requirements.wasm +0 -0
- package/dist/src/sbom.d.ts +3 -1
- package/dist/src/sbom.js +3 -2
- package/dist/src/tools.d.ts +18 -0
- package/dist/src/tools.js +55 -0
- package/dist/src/workspace.d.ts +61 -0
- package/dist/src/workspace.js +256 -0
- package/package.json +11 -3
package/dist/src/cli.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import * as path from "path";
|
|
3
3
|
import yargs from 'yargs';
|
|
4
4
|
import { hideBin } from 'yargs/helpers';
|
|
5
|
-
import
|
|
5
|
+
import { getProjectLicense, getLicenseDetails } from './license/index.js';
|
|
6
|
+
import client, { selectTrustifyDABackend } from './index.js';
|
|
6
7
|
// command for component analysis take manifest type and content
|
|
7
8
|
const component = {
|
|
8
9
|
command: 'component </path/to/manifest>',
|
|
@@ -11,10 +12,18 @@ const component = {
|
|
|
11
12
|
desc: 'manifest path for analyzing',
|
|
12
13
|
type: 'string',
|
|
13
14
|
normalize: true,
|
|
15
|
+
}).options({
|
|
16
|
+
workspaceDir: {
|
|
17
|
+
alias: 'w',
|
|
18
|
+
desc: 'Workspace root directory (for monorepos; lock file is expected here)',
|
|
19
|
+
type: 'string',
|
|
20
|
+
normalize: true,
|
|
21
|
+
}
|
|
14
22
|
}),
|
|
15
23
|
handler: async (args) => {
|
|
16
24
|
let manifestName = args['/path/to/manifest'];
|
|
17
|
-
|
|
25
|
+
const opts = args.workspaceDir ? { TRUSTIFY_DA_WORKSPACE_DIR: args.workspaceDir } : {};
|
|
26
|
+
let res = await client.componentAnalysis(manifestName, opts);
|
|
18
27
|
console.log(JSON.stringify(res, null, 2));
|
|
19
28
|
}
|
|
20
29
|
};
|
|
@@ -22,9 +31,8 @@ const validateToken = {
|
|
|
22
31
|
command: 'validate-token <token-provider> [--token-value thevalue]',
|
|
23
32
|
desc: 'Validates input token if authentic and authorized',
|
|
24
33
|
builder: yargs => yargs.positional('token-provider', {
|
|
25
|
-
desc: 'the token provider',
|
|
26
|
-
type: 'string'
|
|
27
|
-
choices: ['snyk', 'oss-index'],
|
|
34
|
+
desc: 'the token provider name',
|
|
35
|
+
type: 'string'
|
|
28
36
|
}).options({
|
|
29
37
|
tokenValue: {
|
|
30
38
|
alias: 'value',
|
|
@@ -37,7 +45,7 @@ const validateToken = {
|
|
|
37
45
|
let opts = {};
|
|
38
46
|
if (args['tokenValue'] !== undefined && args['tokenValue'].trim() !== "") {
|
|
39
47
|
let tokenValue = args['tokenValue'].trim();
|
|
40
|
-
opts[`
|
|
48
|
+
opts[`TRUSTIFY_DA_PROVIDER_${tokenProvider}_TOKEN`] = tokenValue;
|
|
41
49
|
}
|
|
42
50
|
let res = await client.validateToken(opts);
|
|
43
51
|
console.log(res);
|
|
@@ -117,15 +125,22 @@ const stack = {
|
|
|
117
125
|
desc: 'For JSON report, get only the \'summary\'',
|
|
118
126
|
type: 'boolean',
|
|
119
127
|
conflicts: 'html'
|
|
128
|
+
},
|
|
129
|
+
workspaceDir: {
|
|
130
|
+
alias: 'w',
|
|
131
|
+
desc: 'Workspace root directory (for monorepos; lock file is expected here)',
|
|
132
|
+
type: 'string',
|
|
133
|
+
normalize: true,
|
|
120
134
|
}
|
|
121
135
|
}),
|
|
122
136
|
handler: async (args) => {
|
|
123
137
|
let manifest = args['/path/to/manifest'];
|
|
124
138
|
let html = args['html'];
|
|
125
139
|
let summary = args['summary'];
|
|
140
|
+
const opts = args.workspaceDir ? { TRUSTIFY_DA_WORKSPACE_DIR: args.workspaceDir } : {};
|
|
126
141
|
let theProvidersSummary = new Map();
|
|
127
142
|
let theProvidersObject = {};
|
|
128
|
-
let res = await client.stackAnalysis(manifest, html);
|
|
143
|
+
let res = await client.stackAnalysis(manifest, html, opts);
|
|
129
144
|
if (summary) {
|
|
130
145
|
for (let provider in res.providers) {
|
|
131
146
|
if (res.providers[provider].sources !== undefined) {
|
|
@@ -143,13 +158,182 @@ const stack = {
|
|
|
143
158
|
console.log(html ? res : JSON.stringify(!html && summary ? theProvidersObject : res, null, 2));
|
|
144
159
|
}
|
|
145
160
|
};
|
|
161
|
+
// command for batch stack analysis (workspace)
|
|
162
|
+
const stackBatch = {
|
|
163
|
+
command: 'stack-batch </path/to/workspace-root> [--html|--summary] [--concurrency <n>] [--ignore <pattern>...] [--metadata] [--fail-fast]',
|
|
164
|
+
desc: 'produce stack report for all packages/crates in a workspace (Cargo or JS/TS)',
|
|
165
|
+
builder: yargs => yargs.positional('/path/to/workspace-root', {
|
|
166
|
+
desc: 'workspace root directory (containing Cargo.toml+Cargo.lock or package.json+lock file)',
|
|
167
|
+
type: 'string',
|
|
168
|
+
normalize: true,
|
|
169
|
+
}).options({
|
|
170
|
+
html: {
|
|
171
|
+
alias: 'r',
|
|
172
|
+
desc: 'Get the report as HTML instead of JSON',
|
|
173
|
+
type: 'boolean',
|
|
174
|
+
conflicts: 'summary'
|
|
175
|
+
},
|
|
176
|
+
summary: {
|
|
177
|
+
alias: 's',
|
|
178
|
+
desc: 'For JSON report, get only the \'summary\' per package',
|
|
179
|
+
type: 'boolean',
|
|
180
|
+
conflicts: 'html'
|
|
181
|
+
},
|
|
182
|
+
concurrency: {
|
|
183
|
+
alias: 'c',
|
|
184
|
+
desc: 'Max parallel SBOM generations (default: 10, env: TRUSTIFY_DA_BATCH_CONCURRENCY)',
|
|
185
|
+
type: 'number',
|
|
186
|
+
},
|
|
187
|
+
ignore: {
|
|
188
|
+
alias: 'i',
|
|
189
|
+
desc: 'Extra glob patterns excluded from workspace discovery (merged with defaults). Repeat flag per pattern. Env: TRUSTIFY_DA_WORKSPACE_DISCOVERY_IGNORE (comma-separated)',
|
|
190
|
+
type: 'string',
|
|
191
|
+
array: true,
|
|
192
|
+
},
|
|
193
|
+
metadata: {
|
|
194
|
+
alias: 'm',
|
|
195
|
+
desc: 'Return { analysis, metadata } with per-manifest errors (env: TRUSTIFY_DA_BATCH_METADATA=true)',
|
|
196
|
+
type: 'boolean',
|
|
197
|
+
default: false,
|
|
198
|
+
},
|
|
199
|
+
failFast: {
|
|
200
|
+
desc: 'Stop on first invalid package.json or SBOM error (env: TRUSTIFY_DA_CONTINUE_ON_ERROR=false)',
|
|
201
|
+
type: 'boolean',
|
|
202
|
+
default: false,
|
|
203
|
+
}
|
|
204
|
+
}),
|
|
205
|
+
handler: async (args) => {
|
|
206
|
+
const workspaceRoot = args['/path/to/workspace-root'];
|
|
207
|
+
const html = args['html'];
|
|
208
|
+
const summary = args['summary'];
|
|
209
|
+
const opts = {};
|
|
210
|
+
if (args.concurrency != null) {
|
|
211
|
+
opts.batchConcurrency = args.concurrency;
|
|
212
|
+
}
|
|
213
|
+
const extraIgnores = Array.isArray(args.ignore) ? args.ignore.filter(p => p != null && String(p).trim()) : [];
|
|
214
|
+
if (extraIgnores.length > 0) {
|
|
215
|
+
opts.workspaceDiscoveryIgnore = extraIgnores;
|
|
216
|
+
}
|
|
217
|
+
if (args.metadata) {
|
|
218
|
+
opts.batchMetadata = true;
|
|
219
|
+
}
|
|
220
|
+
if (args.failFast) {
|
|
221
|
+
opts.continueOnError = false;
|
|
222
|
+
}
|
|
223
|
+
let res = await client.stackAnalysisBatch(workspaceRoot, html, opts);
|
|
224
|
+
const batchAnalysis = res && typeof res === 'object' && res != null && 'analysis' in res ? res.analysis : res;
|
|
225
|
+
if (summary && !html && typeof batchAnalysis === 'object') {
|
|
226
|
+
const summaries = {};
|
|
227
|
+
for (const [purl, report] of Object.entries(batchAnalysis)) {
|
|
228
|
+
if (report?.providers) {
|
|
229
|
+
for (const provider of Object.keys(report.providers)) {
|
|
230
|
+
const sources = report.providers[provider]?.sources;
|
|
231
|
+
if (sources) {
|
|
232
|
+
for (const [source, data] of Object.entries(sources)) {
|
|
233
|
+
if (data?.summary) {
|
|
234
|
+
if (!summaries[purl]) {
|
|
235
|
+
summaries[purl] = {};
|
|
236
|
+
}
|
|
237
|
+
if (!summaries[purl][provider]) {
|
|
238
|
+
summaries[purl][provider] = {};
|
|
239
|
+
}
|
|
240
|
+
summaries[purl][provider][source] = data.summary;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (res && typeof res === 'object' && res != null && 'metadata' in res) {
|
|
248
|
+
res = { analysis: summaries, metadata: res.metadata };
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
res = summaries;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (html) {
|
|
255
|
+
const htmlContent = res && typeof res === 'object' && 'analysis' in res ? res.analysis : res;
|
|
256
|
+
console.log(htmlContent);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
console.log(JSON.stringify(res, null, 2));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
// command for license checking
|
|
264
|
+
const license = {
|
|
265
|
+
command: 'license </path/to/manifest>',
|
|
266
|
+
desc: 'Display project license information from manifest and LICENSE file in JSON format',
|
|
267
|
+
builder: yargs => yargs.positional('/path/to/manifest', {
|
|
268
|
+
desc: 'manifest path for license analysis',
|
|
269
|
+
type: 'string',
|
|
270
|
+
normalize: true,
|
|
271
|
+
}),
|
|
272
|
+
handler: async (args) => {
|
|
273
|
+
let manifestPath = args['/path/to/manifest'];
|
|
274
|
+
const opts = {}; // CLI options can be extended in the future
|
|
275
|
+
try {
|
|
276
|
+
selectTrustifyDABackend(opts);
|
|
277
|
+
}
|
|
278
|
+
catch (err) {
|
|
279
|
+
console.error(JSON.stringify({ error: err.message }, null, 2));
|
|
280
|
+
process.exit(1);
|
|
281
|
+
}
|
|
282
|
+
let localResult;
|
|
283
|
+
try {
|
|
284
|
+
localResult = getProjectLicense(manifestPath);
|
|
285
|
+
}
|
|
286
|
+
catch (err) {
|
|
287
|
+
console.error(JSON.stringify({ error: `Failed to read manifest: ${err.message}` }, null, 2));
|
|
288
|
+
process.exit(1);
|
|
289
|
+
}
|
|
290
|
+
const errors = [];
|
|
291
|
+
// Build LicenseInfo objects
|
|
292
|
+
const buildLicenseInfo = async (spdxId) => {
|
|
293
|
+
if (!spdxId) {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
const licenseInfo = { spdxId };
|
|
297
|
+
try {
|
|
298
|
+
const details = await getLicenseDetails(spdxId, opts);
|
|
299
|
+
if (details) {
|
|
300
|
+
// Check if backend recognized the license as valid
|
|
301
|
+
if (details.category === 'UNKNOWN') {
|
|
302
|
+
errors.push(`"${spdxId}" is not a valid SPDX license identifier. Please use a valid SPDX expression (e.g., "Apache-2.0", "MIT"). See https://spdx.org/licenses/`);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
Object.assign(licenseInfo, details);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
errors.push(`No license details found for ${spdxId}`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
catch (err) {
|
|
313
|
+
errors.push(`Failed to fetch details for ${spdxId}: ${err.message}`);
|
|
314
|
+
}
|
|
315
|
+
return licenseInfo;
|
|
316
|
+
};
|
|
317
|
+
const output = {
|
|
318
|
+
manifestLicense: await buildLicenseInfo(localResult.fromManifest),
|
|
319
|
+
fileLicense: await buildLicenseInfo(localResult.fromFile),
|
|
320
|
+
mismatch: localResult.mismatch
|
|
321
|
+
};
|
|
322
|
+
if (errors.length > 0) {
|
|
323
|
+
output.errors = errors;
|
|
324
|
+
}
|
|
325
|
+
console.log(JSON.stringify(output, null, 2));
|
|
326
|
+
}
|
|
327
|
+
};
|
|
146
328
|
// parse and invoke the command
|
|
147
329
|
yargs(hideBin(process.argv))
|
|
148
|
-
.usage(`Usage: ${process.argv[0].includes("node") ? path.parse(process.argv[1]).base : path.parse(process.argv[0]).base} {component|stack|image|validate-token}`)
|
|
330
|
+
.usage(`Usage: ${process.argv[0].includes("node") ? path.parse(process.argv[1]).base : path.parse(process.argv[0]).base} {component|stack|stack-batch|image|validate-token|license}`)
|
|
149
331
|
.command(stack)
|
|
332
|
+
.command(stackBatch)
|
|
150
333
|
.command(component)
|
|
151
334
|
.command(image)
|
|
152
335
|
.command(validateToken)
|
|
336
|
+
.command(license)
|
|
153
337
|
.scriptName('')
|
|
154
338
|
.version(false)
|
|
155
339
|
.demandCommand(1)
|
|
@@ -6,9 +6,10 @@ export default class CycloneDxSbom {
|
|
|
6
6
|
sourceManifestForAuditTrail: any;
|
|
7
7
|
/**
|
|
8
8
|
* @param {PackageURL} root - add main/root component for sbom
|
|
9
|
+
* @param {string|Array} [licenses] - optional license(s) for the root component
|
|
9
10
|
* @return {CycloneDxSbom} the CycloneDxSbom Sbom Object
|
|
10
11
|
*/
|
|
11
|
-
addRoot(root: PackageURL): CycloneDxSbom;
|
|
12
|
+
addRoot(root: PackageURL, licenses?: string | any[]): CycloneDxSbom;
|
|
12
13
|
/**
|
|
13
14
|
* @return {{{"bom-ref": string, name, purl: string, type, version}}} root component of sbom.
|
|
14
15
|
*/
|
|
@@ -48,6 +49,7 @@ export default class CycloneDxSbom {
|
|
|
48
49
|
type: any;
|
|
49
50
|
version: any;
|
|
50
51
|
scope: any;
|
|
52
|
+
licenses?: any;
|
|
51
53
|
};
|
|
52
54
|
/**
|
|
53
55
|
* This method gets an array of dependencies to be ignored, and remove all of them from CycloneDx Sbom
|
|
@@ -5,10 +5,11 @@ import { PackageURL } from "packageurl-js";
|
|
|
5
5
|
* @param component {PackageURL}
|
|
6
6
|
* @param type type of package - application or library
|
|
7
7
|
* @param scope scope of the component - runtime or compile
|
|
8
|
-
* @
|
|
8
|
+
* @param licenses optional license string or array of licenses for the component
|
|
9
|
+
* @return {{"bom-ref": string, name, purl: string, type, version, scope, licenses?}}
|
|
9
10
|
* @private
|
|
10
11
|
*/
|
|
11
|
-
function getComponent(component, type, scope) {
|
|
12
|
+
function getComponent(component, type, scope, licenses) {
|
|
12
13
|
let componentObject;
|
|
13
14
|
if (component instanceof PackageURL) {
|
|
14
15
|
if (component.namespace) {
|
|
@@ -36,6 +37,16 @@ function getComponent(component, type, scope) {
|
|
|
36
37
|
else {
|
|
37
38
|
componentObject = component;
|
|
38
39
|
}
|
|
40
|
+
// Add licenses if provided (CycloneDX format). Callers must provide valid SPDX identifiers.
|
|
41
|
+
if (licenses) {
|
|
42
|
+
const licenseArray = Array.isArray(licenses) ? licenses : [licenses];
|
|
43
|
+
componentObject.licenses = licenseArray.map(lic => {
|
|
44
|
+
if (typeof lic === 'string') {
|
|
45
|
+
return { license: { id: lic } };
|
|
46
|
+
}
|
|
47
|
+
return lic;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
39
50
|
return componentObject;
|
|
40
51
|
}
|
|
41
52
|
function createDependency(dependency) {
|
|
@@ -56,11 +67,12 @@ export default class CycloneDxSbom {
|
|
|
56
67
|
}
|
|
57
68
|
/**
|
|
58
69
|
* @param {PackageURL} root - add main/root component for sbom
|
|
70
|
+
* @param {string|Array} [licenses] - optional license(s) for the root component
|
|
59
71
|
* @return {CycloneDxSbom} the CycloneDxSbom Sbom Object
|
|
60
72
|
*/
|
|
61
|
-
addRoot(root) {
|
|
73
|
+
addRoot(root, licenses) {
|
|
62
74
|
this.rootComponent =
|
|
63
|
-
getComponent(root, "application");
|
|
75
|
+
getComponent(root, "application", undefined, licenses);
|
|
64
76
|
this.components.push(this.rootComponent);
|
|
65
77
|
return this;
|
|
66
78
|
}
|
|
@@ -108,6 +120,7 @@ export default class CycloneDxSbom {
|
|
|
108
120
|
getAsJsonString(opts) {
|
|
109
121
|
let manifestType = opts["manifest-type"];
|
|
110
122
|
this.setSourceManifest(opts["source-manifest"]);
|
|
123
|
+
const rootPurl = this.rootComponent?.purl;
|
|
111
124
|
this.sbomObject = {
|
|
112
125
|
"bomFormat": "CycloneDX",
|
|
113
126
|
"specVersion": "1.4",
|
|
@@ -117,7 +130,7 @@ export default class CycloneDxSbom {
|
|
|
117
130
|
"component": this.rootComponent,
|
|
118
131
|
"properties": new Array()
|
|
119
132
|
},
|
|
120
|
-
"components": this.components,
|
|
133
|
+
"components": this.components.filter(c => c.purl !== rootPurl),
|
|
121
134
|
"dependencies": this.dependencies
|
|
122
135
|
};
|
|
123
136
|
if (this.rootComponent === undefined) {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -18,11 +18,13 @@ export { ImageRef } from "./oci_image/images.js";
|
|
|
18
18
|
declare namespace _default {
|
|
19
19
|
export { componentAnalysis };
|
|
20
20
|
export { stackAnalysis };
|
|
21
|
+
export { stackAnalysisBatch };
|
|
21
22
|
export { imageAnalysis };
|
|
22
23
|
export { validateToken };
|
|
23
24
|
}
|
|
24
25
|
export default _default;
|
|
25
26
|
export type Options = {
|
|
27
|
+
TRUSTIFY_DA_CARGO_PATH?: string | undefined;
|
|
26
28
|
TRUSTIFY_DA_DOCKER_PATH?: string | undefined;
|
|
27
29
|
TRUSTIFY_DA_GO_MVS_LOGIC_ENABLED?: string | undefined;
|
|
28
30
|
TRUSTIFY_DA_GO_PATH?: string | undefined;
|
|
@@ -47,11 +49,43 @@ export type Options = {
|
|
|
47
49
|
TRUSTIFY_DA_SYFT_CONFIG_PATH?: string | undefined;
|
|
48
50
|
TRUSTIFY_DA_SYFT_PATH?: string | undefined;
|
|
49
51
|
TRUSTIFY_DA_YARN_PATH?: string | undefined;
|
|
52
|
+
TRUSTIFY_DA_WORKSPACE_DIR?: string | undefined;
|
|
53
|
+
TRUSTIFY_DA_LICENSE_CHECK?: string | undefined;
|
|
50
54
|
MATCH_MANIFEST_VERSIONS?: string | undefined;
|
|
51
55
|
TRUSTIFY_DA_SOURCE?: string | undefined;
|
|
52
56
|
TRUSTIFY_DA_TOKEN?: string | undefined;
|
|
53
57
|
TRUSTIFY_DA_TELEMETRY_ID?: string | undefined;
|
|
54
|
-
|
|
58
|
+
TRUSTIFY_DA_WORKSPACE_DIR?: string | undefined;
|
|
59
|
+
batchConcurrency?: number | undefined;
|
|
60
|
+
TRUSTIFY_DA_BATCH_CONCURRENCY?: string | undefined;
|
|
61
|
+
workspaceDiscoveryIgnore?: string[] | undefined;
|
|
62
|
+
TRUSTIFY_DA_WORKSPACE_DISCOVERY_IGNORE?: string | undefined;
|
|
63
|
+
continueOnError?: boolean | undefined;
|
|
64
|
+
TRUSTIFY_DA_CONTINUE_ON_ERROR?: string | undefined;
|
|
65
|
+
batchMetadata?: boolean | undefined;
|
|
66
|
+
TRUSTIFY_DA_BATCH_METADATA?: string | undefined;
|
|
67
|
+
[key: string]: string | number | boolean | string[] | undefined;
|
|
68
|
+
};
|
|
69
|
+
export type BatchAnalysisMetadata = {
|
|
70
|
+
workspaceRoot: string;
|
|
71
|
+
ecosystem: "javascript" | "cargo" | "unknown";
|
|
72
|
+
total: number;
|
|
73
|
+
successful: number;
|
|
74
|
+
failed: number;
|
|
75
|
+
errors: Array<{
|
|
76
|
+
manifestPath: string;
|
|
77
|
+
phase: "validation" | "sbom";
|
|
78
|
+
reason: string;
|
|
79
|
+
}>;
|
|
80
|
+
};
|
|
81
|
+
export type SbomResult = {
|
|
82
|
+
ok: true;
|
|
83
|
+
purl: string;
|
|
84
|
+
sbom: object;
|
|
85
|
+
} | {
|
|
86
|
+
ok: false;
|
|
87
|
+
manifestPath: string;
|
|
88
|
+
reason: string;
|
|
55
89
|
};
|
|
56
90
|
/**
|
|
57
91
|
* Get component analysis report for a manifest content.
|
|
@@ -90,6 +124,26 @@ declare function stackAnalysis(manifest: string, html: false, opts?: Options | u
|
|
|
90
124
|
* or backend request failed
|
|
91
125
|
*/
|
|
92
126
|
declare function stackAnalysis(manifest: string, html?: boolean | undefined, opts?: Options | undefined): Promise<string | import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport>;
|
|
127
|
+
/**
|
|
128
|
+
* Get stack analysis for all workspace packages/crates (batch).
|
|
129
|
+
* Detects ecosystem from workspace root: Cargo (Cargo.toml + Cargo.lock) or JS/TS (package.json + lock file).
|
|
130
|
+
* SBOMs are generated in parallel (see `batchConcurrency`) unless `continueOnError: false` (fail-fast sequential).
|
|
131
|
+
* With `opts.batchMetadata` / `TRUSTIFY_DA_BATCH_METADATA`, returns `{ analysis, metadata }` including validation and SBOM errors.
|
|
132
|
+
*
|
|
133
|
+
* @param {string} workspaceRoot - Path to workspace root (containing lock file and workspace config)
|
|
134
|
+
* @param {boolean} [html=false] - true returns HTML, false returns JSON report
|
|
135
|
+
* @param {Options} [opts={}] - `batchConcurrency`, discovery ignores, `continueOnError` (default true), `batchMetadata` (default false)
|
|
136
|
+
* @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>|{ analysis: string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>, metadata: BatchAnalysisMetadata }>}
|
|
137
|
+
* @throws {Error} if workspace root invalid, no manifests found, no packages pass validation, no SBOMs produced, or backend request failed. When `opts.batchMetadata` is set, `error.batchMetadata` may be set on thrown errors.
|
|
138
|
+
*/
|
|
139
|
+
declare function stackAnalysisBatch(workspaceRoot: string, html?: boolean, opts?: Options): Promise<string | {
|
|
140
|
+
[x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
|
|
141
|
+
} | {
|
|
142
|
+
analysis: string | {
|
|
143
|
+
[x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
|
|
144
|
+
};
|
|
145
|
+
metadata: BatchAnalysisMetadata;
|
|
146
|
+
}>;
|
|
93
147
|
/**
|
|
94
148
|
* @overload
|
|
95
149
|
* @param {Array<string>} imageRefs
|
|
@@ -130,3 +184,12 @@ declare function imageAnalysis(imageRefs: Array<string>, html?: boolean | undefi
|
|
|
130
184
|
* @throws {Error} if the backend request failed.
|
|
131
185
|
*/
|
|
132
186
|
declare function validateToken(opts?: Options): Promise<object>;
|
|
187
|
+
import { discoverWorkspacePackages } from './workspace.js';
|
|
188
|
+
import { discoverWorkspaceCrates } from './workspace.js';
|
|
189
|
+
import { validatePackageJson } from './workspace.js';
|
|
190
|
+
import { resolveWorkspaceDiscoveryIgnore } from './workspace.js';
|
|
191
|
+
import { filterManifestPathsByDiscoveryIgnore } from './workspace.js';
|
|
192
|
+
import { resolveContinueOnError } from './batch_opts.js';
|
|
193
|
+
import { resolveBatchMetadata } from './batch_opts.js';
|
|
194
|
+
export { discoverWorkspacePackages, discoverWorkspaceCrates, validatePackageJson, resolveWorkspaceDiscoveryIgnore, filterManifestPathsByDiscoveryIgnore, resolveContinueOnError, resolveBatchMetadata };
|
|
195
|
+
export { getProjectLicense, findLicenseFilePath, identifyLicense, getLicenseDetails, licensesFromReport, normalizeLicensesResponse, runLicenseCheck, getCompatibility } from "./license/index.js";
|