@trustify-da/trustify-da-javascript-client 0.3.0-ea.a8c3942 → 0.3.0-ea.a9624b2

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.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/dist/package.json +25 -21
  3. package/dist/src/analysis.d.ts +14 -7
  4. package/dist/src/analysis.js +29 -13
  5. package/dist/src/cli.js +58 -1
  6. package/dist/src/cyclone_dx_sbom.js +11 -3
  7. package/dist/src/index.d.ts +12 -10
  8. package/dist/src/index.js +8 -3
  9. package/dist/src/license/index.d.ts +3 -3
  10. package/dist/src/license/index.js +4 -1
  11. package/dist/src/license/license_utils.js +4 -1
  12. package/dist/src/license/licenses_api.d.ts +2 -2
  13. package/dist/src/oci_image/images.d.ts +1 -1
  14. package/dist/src/oci_image/images.js +15 -1
  15. package/dist/src/oci_image/utils.d.ts +5 -5
  16. package/dist/src/provider.d.ts +4 -3
  17. package/dist/src/provider.js +6 -2
  18. package/dist/src/providers/base_java.d.ts +14 -3
  19. package/dist/src/providers/base_java.js +16 -6
  20. package/dist/src/providers/base_javascript.d.ts +20 -9
  21. package/dist/src/providers/base_javascript.js +10 -3
  22. package/dist/src/providers/base_pyproject.d.ts +10 -5
  23. package/dist/src/providers/base_pyproject.js +7 -0
  24. package/dist/src/providers/containerfile_parser.d.ts +5 -0
  25. package/dist/src/providers/containerfile_parser.js +20 -0
  26. package/dist/src/providers/golang_gomodules.d.ts +2 -1
  27. package/dist/src/providers/golang_gomodules.js +1 -1
  28. package/dist/src/providers/java_gradle_groovy.d.ts +1 -1
  29. package/dist/src/providers/java_gradle_kotlin.d.ts +1 -1
  30. package/dist/src/providers/java_maven.d.ts +2 -2
  31. package/dist/src/providers/java_maven.js +72 -0
  32. package/dist/src/providers/javascript_bun.d.ts +10 -0
  33. package/dist/src/providers/javascript_bun.js +100 -0
  34. package/dist/src/providers/javascript_npm.d.ts +6 -1
  35. package/dist/src/providers/oci_dockerfile.d.ts +51 -0
  36. package/dist/src/providers/oci_dockerfile.js +177 -0
  37. package/dist/src/providers/processors/yarn_berry_processor.d.ts +2 -2
  38. package/dist/src/providers/processors/yarn_classic_processor.d.ts +2 -2
  39. package/dist/src/providers/python_controller.js +57 -3
  40. package/dist/src/providers/python_pip.d.ts +1 -0
  41. package/dist/src/providers/python_pip.js +1 -1
  42. package/dist/src/providers/python_poetry.d.ts +31 -8
  43. package/dist/src/providers/python_poetry.js +62 -14
  44. package/dist/src/providers/python_uv.d.ts +5 -14
  45. package/dist/src/providers/python_uv.js +44 -2
  46. package/dist/src/providers/rust_cargo.d.ts +6 -2
  47. package/dist/src/providers/rust_cargo.js +31 -4
  48. package/dist/src/providers/tree-sitter-containerfile.wasm +0 -0
  49. package/dist/src/tools.d.ts +2 -2
  50. package/dist/src/updaters/maven_updater.d.ts +26 -0
  51. package/dist/src/updaters/maven_updater.js +322 -0
  52. package/package.json +26 -22
package/README.md CHANGED
@@ -695,7 +695,7 @@ By default, The API algorithm will use native commands of PIP installer as data
695
695
  It's also possible to use the lightweight Python PIP utility [pipdeptree](https://pypi.org/project/pipdeptree/) as data source instead. In order to activate this, you need to set the environment variable/option `TRUSTIFY_DA_PIP_USE_DEP_TREE` to 'true'.
696
696
 
697
697
  #### Toggle Red Hat Trusted Content recommendations
698
- Both the HTML-based report and JSON response will by default contain recommendations for migrating to Red Hat-based Trusted Content repositories. This feature can be disabled by setting `TRUSTIFY_DA_RECOMMENDATIONS_ENABLED` to 'false' via environment variables or options.
698
+ Both the HTML-based report and JSON response will by default contain recommendations for migrating to Red Hat-based Trusted Content repositories. This feature can be disabled by setting `TRUSTIFY_DA_RECOMMEND` to 'false' via environment variables or options.
699
699
 
700
700
  #### Additional CLI arguments
701
701
  For some ecosystems we support passing additional CLI arguments to the underlying tools. The following table outlines the supported ecosystems and the environment variable/option that configures this. Note that the arguments are expected to be in the format of a JSON array.
package/dist/package.json CHANGED
@@ -35,31 +35,33 @@
35
35
  "config/**/*"
36
36
  ],
37
37
  "scripts": {
38
- "lint": "eslint src test --ext js",
39
- "lint:fix": "eslint src test --ext js --fix",
38
+ "lint": "eslint src test",
39
+ "lint:fix": "eslint src test --fix",
40
40
  "test": "c8 npm run tests",
41
41
  "tests": "mocha --config .mocharc.json",
42
42
  "tests:rep": "mocha --reporter-option maxDiffSize=0 --reporter json > unit-tests-result.json",
43
- "pretest": "cp node_modules/tree-sitter-requirements/tree-sitter-requirements.wasm src/providers/tree-sitter-requirements.wasm && cp node_modules/tree-sitter-gomod/tree-sitter-gomod.wasm src/providers/tree-sitter-gomod.wasm",
43
+ "pretest": "cp node_modules/tree-sitter-requirements/tree-sitter-requirements.wasm src/providers/tree-sitter-requirements.wasm && cp node_modules/tree-sitter-gomod/tree-sitter-gomod.wasm src/providers/tree-sitter-gomod.wasm && cp node_modules/tree-sitter-containerfile/tree-sitter-containerfile.wasm src/providers/tree-sitter-containerfile.wasm",
44
44
  "precompile": "rm -rf dist",
45
45
  "compile": "tsc -p tsconfig.json",
46
46
  "compile:dev": "tsc -p tsconfig.dev.json",
47
- "postcompile": "cp node_modules/tree-sitter-requirements/tree-sitter-requirements.wasm dist/src/providers/tree-sitter-requirements.wasm && cp node_modules/tree-sitter-gomod/tree-sitter-gomod.wasm dist/src/providers/tree-sitter-gomod.wasm"
47
+ "postcompile": "cp node_modules/tree-sitter-requirements/tree-sitter-requirements.wasm dist/src/providers/tree-sitter-requirements.wasm && cp node_modules/tree-sitter-gomod/tree-sitter-gomod.wasm dist/src/providers/tree-sitter-gomod.wasm && cp node_modules/tree-sitter-containerfile/tree-sitter-containerfile.wasm dist/src/providers/tree-sitter-containerfile.wasm"
48
48
  },
49
49
  "dependencies": {
50
50
  "@babel/core": "^7.23.2",
51
- "@cyclonedx/cyclonedx-library": "^6.13.0",
51
+ "@cyclonedx/cyclonedx-library": "^10.0.0",
52
52
  "eslint-import-resolver-typescript": "^4.4.4",
53
53
  "fast-glob": "^3.3.3",
54
54
  "fast-xml-parser": "^5.3.4",
55
55
  "help": "^3.0.2",
56
- "https-proxy-agent": "^7.0.6",
56
+ "https-proxy-agent": "^9.0.0",
57
57
  "js-yaml": "^4.1.1",
58
+ "jsonc-parser": "^3.3.1",
58
59
  "micromatch": "^4.0.8",
59
60
  "node-fetch": "^3.3.2",
60
- "p-limit": "^4.0.0",
61
+ "p-limit": "^7.3.0",
61
62
  "packageurl-js": "~1.0.2",
62
63
  "smol-toml": "^1.6.0",
64
+ "tree-sitter-containerfile": "^0.8.1",
63
65
  "tree-sitter-gomod": "github:strum355/tree-sitter-go-mod#56326f2ad478892ace58ff247a97d492a3cbcdda",
64
66
  "tree-sitter-requirements": "github:Strum355/tree-sitter-requirements#d0261ee76b84253997fe70d7d397e78c006c3801",
65
67
  "web-tree-sitter": "^0.26.7",
@@ -67,23 +69,24 @@
67
69
  },
68
70
  "devDependencies": {
69
71
  "@babel/core": "^7.23.2",
70
- "@trustify-da/trustify-da-api-model": "^2.0.7",
71
- "@types/node": "^20.17.30",
72
+ "@eslint/js": "^10.0.0",
73
+ "@trustify-da/trustify-da-api-model": "^2.0.12",
74
+ "@types/node": "^25.9.1",
72
75
  "@types/which": "^3.0.4",
73
76
  "babel-plugin-rewire": "^1.2.0",
74
77
  "c8": "^11.0.0",
75
- "chai": "^4.3.7",
76
- "eslint": "^8.42.0",
78
+ "chai": "^6.2.2",
79
+ "eslint": "^10.4.1",
77
80
  "eslint-import-resolver-typescript": "^4.4.4",
78
- "eslint-plugin-editorconfig": "^4.0.3",
79
- "eslint-plugin-import": "^2.29.1",
81
+ "eslint-plugin-import-x": "^4.16.2",
80
82
  "esmock": "^2.6.2",
81
- "mocha": "^10.2.0",
83
+ "globals": "^17.6.0",
84
+ "mocha": "^11.7.6",
82
85
  "msw": "^2.12.7",
83
- "sinon": "^15.1.2",
84
- "sinon-chai": "^3.7.0",
85
- "typescript": "^5.1.3",
86
- "which": "^5.0.0"
86
+ "sinon": "^22.0.0",
87
+ "sinon-chai": "^4.0.1",
88
+ "typescript": "^6.0.3",
89
+ "which": "^7.0.0"
87
90
  },
88
91
  "mocha": {
89
92
  "check-leaks": false,
@@ -111,12 +114,13 @@
111
114
  "reporter": [
112
115
  "html",
113
116
  "json",
117
+ "lcov",
114
118
  "text"
115
119
  ]
116
120
  },
117
- "eslintIgnore": [
118
- "index.js"
119
- ],
121
+ "overrides": {
122
+ "tree-sitter": "0.22.4"
123
+ },
120
124
  "resolutions": {
121
125
  "@hapi/joi": "17.1.1"
122
126
  }
@@ -6,6 +6,7 @@ declare namespace _default {
6
6
  export { requestStackBatch };
7
7
  export { requestImages };
8
8
  export { validateToken };
9
+ export { appendAnalysisQueryParams };
9
10
  }
10
11
  export default _default;
11
12
  /**
@@ -16,7 +17,7 @@ export default _default;
16
17
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
17
18
  * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
18
19
  */
19
- declare function requestComponent(provider: import("./provider").Provider, manifest: string, url: string, opts?: import("index.js").Options): Promise<import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport>;
20
+ declare function requestComponent(provider: any, manifest: string, url: string, opts?: any): Promise<any>;
20
21
  /**
21
22
  * Send a stack analysis request and get the report as 'text/html' or 'application/json'.
22
23
  * @param {import('./provider').Provider} provider - the provided data for constructing the request
@@ -26,7 +27,7 @@ declare function requestComponent(provider: import("./provider").Provider, manif
26
27
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
27
28
  * @returns {Promise<string|import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
28
29
  */
29
- declare function requestStack(provider: import("./provider").Provider, manifest: string, url: string, html?: boolean, opts?: import("index.js").Options): Promise<string | import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport>;
30
+ declare function requestStack(provider: any, manifest: string, url: string, html?: boolean, opts?: any): Promise<string | any>;
30
31
  /**
31
32
  * Send a batch stack analysis request for multiple manifests (SBOMs keyed by purl).
32
33
  * @param {Object.<string, object>} sbomByPurl - Map of root purl to CycloneDX SBOM object
@@ -36,9 +37,9 @@ declare function requestStack(provider: import("./provider").Provider, manifest:
36
37
  * @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
37
38
  */
38
39
  declare function requestStackBatch(sbomByPurl: {
40
+ [x: string]: object;
41
+ }, url: string, html?: boolean, opts?: any): Promise<string | {
39
42
  [x: string]: any;
40
- }, url: string, html?: boolean, opts?: import("index.js").Options): Promise<string | {
41
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
42
43
  }>;
43
44
  /**
44
45
  *
@@ -47,8 +48,8 @@ declare function requestStackBatch(sbomByPurl: {
47
48
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
48
49
  * @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
49
50
  */
50
- declare function requestImages(imageRefs: Array<string>, url: string, html?: boolean, opts?: import("index.js").Options): Promise<string | {
51
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
51
+ declare function requestImages(imageRefs: Array<string>, url: string, html?: boolean, opts?: any): Promise<string | {
52
+ [x: string]: any;
52
53
  }>;
53
54
  /**
54
55
  *
@@ -56,4 +57,10 @@ declare function requestImages(imageRefs: Array<string>, url: string, html?: boo
56
57
  * @param {import("index.js").Options} [opts={}] - optional various options to pass headers for t he validateToken Request
57
58
  * @return {Promise<number>} return the HTTP status Code of the response from the validate token request.
58
59
  */
59
- declare function validateToken(url: any, opts?: import("index.js").Options): Promise<number>;
60
+ declare function validateToken(url: any, opts?: any): Promise<number>;
61
+ /**
62
+ * Append common analysis query parameters (recommend, providers, sources) to a URL.
63
+ * @param {URL} url - the URL object to append query parameters to
64
+ * @param {import("index.js").Options} [opts={}] - options containing parameter overrides
65
+ */
66
+ declare function appendAnalysisQueryParams(url: URL, opts?: any): void;
@@ -6,7 +6,7 @@ import { generateImageSBOM, parseImageRef } from "./oci_image/utils.js";
6
6
  import { addProxyAgent, getCustom, getTokenHeaders, TRUSTIFY_DA_OPERATION_TYPE_HEADER, TRUSTIFY_DA_PACKAGE_MANAGER_HEADER } from "./tools.js";
7
7
  /** Media type for CycloneDX JSON batch payloads (batch-analysis API). */
8
8
  export const CYCLONEDX_JSON_MEDIA_TYPE = 'application/vnd.cyclonedx+json';
9
- export default { requestComponent, requestStack, requestStackBatch, requestImages, validateToken };
9
+ export default { requestComponent, requestStack, requestStackBatch, requestImages, validateToken, appendAnalysisQueryParams };
10
10
  /**
11
11
  * Send a stack analysis request and get the report as 'text/html' or 'application/json'.
12
12
  * @param {import('./provider').Provider} provider - the provided data for constructing the request
@@ -20,6 +20,9 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
20
20
  opts["source-manifest"] = Buffer.from(fs.readFileSync(manifest).toString()).toString('base64');
21
21
  opts["manifest-type"] = path.parse(manifest).base;
22
22
  let provided = await provider.provideStack(manifest, opts); // throws error if content providing failed
23
+ if (provided.batch) {
24
+ return requestStackBatch(JSON.parse(provided.content), url, html, opts);
25
+ }
23
26
  opts["source-manifest"] = "";
24
27
  opts[TRUSTIFY_DA_OPERATION_TYPE_HEADER.toUpperCase().replaceAll("-", "_")] = "stack-analysis";
25
28
  let startTime = new Date();
@@ -38,9 +41,7 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
38
41
  body: provided.content
39
42
  }, opts);
40
43
  const finalUrl = new URL(`${url}/api/v5/analysis`);
41
- if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
42
- finalUrl.searchParams.append('recommend', 'false');
43
- }
44
+ appendAnalysisQueryParams(finalUrl, opts);
44
45
  let resp = await fetch(finalUrl, fetchOptions);
45
46
  let result;
46
47
  if (resp.status === 200) {
@@ -79,6 +80,9 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
79
80
  async function requestComponent(provider, manifest, url, opts = {}) {
80
81
  opts["source-manifest"] = Buffer.from(fs.readFileSync(manifest).toString()).toString('base64');
81
82
  let provided = await provider.provideComponent(manifest, opts); // throws error if content providing failed
83
+ if (provided.batch) {
84
+ return requestStackBatch(JSON.parse(provided.content), url, false, opts);
85
+ }
82
86
  opts["source-manifest"] = "";
83
87
  opts[TRUSTIFY_DA_OPERATION_TYPE_HEADER.toUpperCase().replaceAll("-", "_")] = "component-analysis";
84
88
  if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
@@ -95,9 +99,7 @@ async function requestComponent(provider, manifest, url, opts = {}) {
95
99
  body: provided.content
96
100
  }, opts);
97
101
  const finalUrl = new URL(`${url}/api/v5/analysis`);
98
- if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
99
- finalUrl.searchParams.append('recommend', 'false');
100
- }
102
+ appendAnalysisQueryParams(finalUrl, opts);
101
103
  let resp = await fetch(finalUrl, fetchOptions);
102
104
  let result;
103
105
  if (resp.status === 200) {
@@ -136,9 +138,7 @@ async function requestComponent(provider, manifest, url, opts = {}) {
136
138
  */
137
139
  async function requestStackBatch(sbomByPurl, url, html = false, opts = {}) {
138
140
  const finalUrl = new URL(`${url}/api/v5/batch-analysis`);
139
- if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
140
- finalUrl.searchParams.append('recommend', 'false');
141
- }
141
+ appendAnalysisQueryParams(finalUrl, opts);
142
142
  const fetchOptions = addProxyAgent({
143
143
  method: 'POST',
144
144
  headers: {
@@ -186,9 +186,7 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
186
186
  imageSboms[parsedImageRef.getPackageURL().toString()] = generateImageSBOM(parsedImageRef, opts);
187
187
  }
188
188
  const finalUrl = new URL(`${url}/api/v5/batch-analysis`);
189
- if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
190
- finalUrl.searchParams.append('recommend', 'false');
191
- }
189
+ appendAnalysisQueryParams(finalUrl, opts);
192
190
  const fetchOptions = addProxyAgent({
193
191
  method: 'POST',
194
192
  headers: {
@@ -222,6 +220,24 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
222
220
  throw new Error(`Got error response from Trustify DA backend - http return code : ${resp.status}, ex-request-id: ${resp.headers.get("ex-request-id")} error message => ${await resp.text()}`);
223
221
  }
224
222
  }
223
+ /**
224
+ * Append common analysis query parameters (recommend, providers, sources) to a URL.
225
+ * @param {URL} url - the URL object to append query parameters to
226
+ * @param {import("index.js").Options} [opts={}] - options containing parameter overrides
227
+ */
228
+ function appendAnalysisQueryParams(url, opts = {}) {
229
+ if (getCustom('TRUSTIFY_DA_RECOMMEND', 'true', opts) === 'false') {
230
+ url.searchParams.append('recommend', 'false');
231
+ }
232
+ const providers = getCustom('TRUSTIFY_DA_PROVIDERS', null, opts);
233
+ if (providers) {
234
+ url.searchParams.append('providers', providers);
235
+ }
236
+ const sources = getCustom('TRUSTIFY_DA_SOURCES', null, opts);
237
+ if (sources) {
238
+ url.searchParams.append('sources', sources);
239
+ }
240
+ }
225
241
  /**
226
242
  *
227
243
  * @param url the backend url to send the request to
package/dist/src/cli.js CHANGED
@@ -19,11 +19,25 @@ const component = {
19
19
  desc: 'Workspace root directory (for monorepos; lock file is expected here)',
20
20
  type: 'string',
21
21
  normalize: true,
22
+ },
23
+ providers: {
24
+ desc: 'Comma-separated list of vulnerability providers (env: TRUSTIFY_DA_PROVIDERS)',
25
+ type: 'string',
26
+ },
27
+ sources: {
28
+ desc: 'Comma-separated list of vulnerability sources (env: TRUSTIFY_DA_SOURCES)',
29
+ type: 'string',
22
30
  }
23
31
  }),
24
32
  handler: async (args) => {
25
33
  let manifestName = args['/path/to/manifest'];
26
34
  const opts = args.workspaceDir ? { TRUSTIFY_DA_WORKSPACE_DIR: args.workspaceDir } : {};
35
+ if (args.providers) {
36
+ opts.TRUSTIFY_DA_PROVIDERS = args.providers;
37
+ }
38
+ if (args.sources) {
39
+ opts.TRUSTIFY_DA_SOURCES = args.sources;
40
+ }
27
41
  let res = await client.componentAnalysis(manifestName, opts);
28
42
  console.log(JSON.stringify(res, null, 2));
29
43
  }
@@ -72,6 +86,14 @@ const image = {
72
86
  desc: 'For JSON report, get only the \'summary\'',
73
87
  type: 'boolean',
74
88
  conflicts: 'html'
89
+ },
90
+ providers: {
91
+ desc: 'Comma-separated list of vulnerability providers (env: TRUSTIFY_DA_PROVIDERS)',
92
+ type: 'string',
93
+ },
94
+ sources: {
95
+ desc: 'Comma-separated list of vulnerability sources (env: TRUSTIFY_DA_SOURCES)',
96
+ type: 'string',
75
97
  }
76
98
  }),
77
99
  handler: async (args) => {
@@ -81,7 +103,14 @@ const image = {
81
103
  }
82
104
  let html = args['html'];
83
105
  let summary = args['summary'];
84
- let res = await client.imageAnalysis(imageRefs, html);
106
+ const opts = {};
107
+ if (args.providers) {
108
+ opts.TRUSTIFY_DA_PROVIDERS = args.providers;
109
+ }
110
+ if (args.sources) {
111
+ opts.TRUSTIFY_DA_SOURCES = args.sources;
112
+ }
113
+ let res = await client.imageAnalysis(imageRefs, html, opts);
85
114
  if (summary && !html) {
86
115
  let summaries = {};
87
116
  for (let [imageRef, report] of Object.entries(res)) {
@@ -132,6 +161,14 @@ const stack = {
132
161
  desc: 'Workspace root directory (for monorepos; lock file is expected here)',
133
162
  type: 'string',
134
163
  normalize: true,
164
+ },
165
+ providers: {
166
+ desc: 'Comma-separated list of vulnerability providers (env: TRUSTIFY_DA_PROVIDERS)',
167
+ type: 'string',
168
+ },
169
+ sources: {
170
+ desc: 'Comma-separated list of vulnerability sources (env: TRUSTIFY_DA_SOURCES)',
171
+ type: 'string',
135
172
  }
136
173
  }),
137
174
  handler: async (args) => {
@@ -139,6 +176,12 @@ const stack = {
139
176
  let html = args['html'];
140
177
  let summary = args['summary'];
141
178
  const opts = args.workspaceDir ? { TRUSTIFY_DA_WORKSPACE_DIR: args.workspaceDir } : {};
179
+ if (args.providers) {
180
+ opts.TRUSTIFY_DA_PROVIDERS = args.providers;
181
+ }
182
+ if (args.sources) {
183
+ opts.TRUSTIFY_DA_SOURCES = args.sources;
184
+ }
142
185
  let theProvidersSummary = new Map();
143
186
  let theProvidersObject = {};
144
187
  let res = await client.stackAnalysis(manifest, html, opts);
@@ -201,6 +244,14 @@ const stackBatch = {
201
244
  desc: 'Stop on first invalid package.json or SBOM error (env: TRUSTIFY_DA_CONTINUE_ON_ERROR=false)',
202
245
  type: 'boolean',
203
246
  default: false,
247
+ },
248
+ providers: {
249
+ desc: 'Comma-separated list of vulnerability providers (env: TRUSTIFY_DA_PROVIDERS)',
250
+ type: 'string',
251
+ },
252
+ sources: {
253
+ desc: 'Comma-separated list of vulnerability sources (env: TRUSTIFY_DA_SOURCES)',
254
+ type: 'string',
204
255
  }
205
256
  }),
206
257
  handler: async (args) => {
@@ -221,6 +272,12 @@ const stackBatch = {
221
272
  if (args.failFast) {
222
273
  opts.continueOnError = false;
223
274
  }
275
+ if (args.providers) {
276
+ opts.TRUSTIFY_DA_PROVIDERS = args.providers;
277
+ }
278
+ if (args.sources) {
279
+ opts.TRUSTIFY_DA_SOURCES = args.sources;
280
+ }
224
281
  let res = await client.stackAnalysisBatch(workspaceRoot, html, opts);
225
282
  const batchAnalysis = res && typeof res === 'object' && res != null && 'analysis' in res ? res.analysis : res;
226
283
  if (summary && !html && typeof batchAnalysis === 'object') {
@@ -41,12 +41,20 @@ function getComponent(component, type, scope, licenses, hashes) {
41
41
  // Add licenses if provided (CycloneDX format). Callers must provide valid SPDX identifiers.
42
42
  if (licenses) {
43
43
  const licenseArray = Array.isArray(licenses) ? licenses : [licenses];
44
- componentObject.licenses = licenseArray.map(lic => {
44
+ const validLicenses = licenseArray
45
+ .map(lic => {
45
46
  if (typeof lic === 'string') {
46
47
  return { license: { id: lic } };
47
48
  }
48
- return lic;
49
- });
49
+ if (typeof lic === 'object' && lic !== null && ('license' in lic || 'expression' in lic)) {
50
+ return lic;
51
+ }
52
+ return null;
53
+ })
54
+ .filter(Boolean);
55
+ if (validLicenses.length > 0) {
56
+ componentObject.licenses = validLicenses;
57
+ }
50
58
  }
51
59
  // Add hashes if provided (CycloneDX 1.4 format).
52
60
  if (hashes && hashes.length > 0) {
@@ -53,7 +53,9 @@ export type Options = {
53
53
  TRUSTIFY_DA_PYTHON_PATH?: string | undefined;
54
54
  TRUSTIFY_DA_PYTHON_VIRTUAL_ENV?: string | undefined;
55
55
  TRUSTIFY_DA_PYTHON3_PATH?: string | undefined;
56
- TRUSTIFY_DA_RECOMMENDATIONS_ENABLED?: string | undefined;
56
+ TRUSTIFY_DA_PROVIDERS?: string | undefined;
57
+ TRUSTIFY_DA_RECOMMEND?: string | undefined;
58
+ TRUSTIFY_DA_SOURCES?: string | undefined;
57
59
  TRUSTIFY_DA_SKOPEO_CONFIG_PATH?: string | undefined;
58
60
  TRUSTIFY_DA_SKOPEO_PATH?: string | undefined;
59
61
  TRUSTIFY_DA_SYFT_CONFIG_PATH?: string | undefined;
@@ -106,7 +108,7 @@ export type SbomResult = {
106
108
  * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
107
109
  * @throws {Error} if no matching provider, failed to get create content, or backend request failed
108
110
  */
109
- declare function componentAnalysis(manifest: string, opts?: Options): Promise<import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport>;
111
+ declare function componentAnalysis(manifest: string, opts?: Options): Promise<any>;
110
112
  /**
111
113
  * @overload
112
114
  * @param {string} manifest
@@ -124,7 +126,7 @@ declare function stackAnalysis(manifest: string, html: true, opts?: Options | un
124
126
  * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
125
127
  * @throws {Error}
126
128
  */
127
- declare function stackAnalysis(manifest: string, html: false, opts?: Options | undefined): Promise<import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport>;
129
+ declare function stackAnalysis(manifest: string, html: false, opts?: Options | undefined): Promise<any>;
128
130
  /**
129
131
  * Get stack analysis report for a manifest file.
130
132
  * @overload
@@ -135,7 +137,7 @@ declare function stackAnalysis(manifest: string, html: false, opts?: Options | u
135
137
  * @throws {Error} if manifest inaccessible, no matching provider, failed to get create content,
136
138
  * or backend request failed
137
139
  */
138
- declare function stackAnalysis(manifest: string, html?: boolean | undefined, opts?: Options | undefined): Promise<string | import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport>;
140
+ declare function stackAnalysis(manifest: string, html?: boolean | undefined, opts?: Options | undefined): Promise<string | any>;
139
141
  /**
140
142
  * @overload
141
143
  * @param {string} workspaceRoot
@@ -173,7 +175,7 @@ declare function stackAnalysisBatch(workspaceRoot: string, html: false, opts: Op
173
175
  batchMetadata: true;
174
176
  }): Promise<{
175
177
  analysis: {
176
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
178
+ [x: string]: any;
177
179
  };
178
180
  metadata: BatchAnalysisMetadata;
179
181
  }>;
@@ -188,7 +190,7 @@ declare function stackAnalysisBatch(workspaceRoot: string, html: false, opts: Op
188
190
  declare function stackAnalysisBatch(workspaceRoot: string, html: false, opts?: (Options & {
189
191
  batchMetadata?: false;
190
192
  }) | undefined): Promise<{
191
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
193
+ [x: string]: any;
192
194
  }>;
193
195
  /**
194
196
  * Get stack analysis for all workspace packages/crates (batch).
@@ -204,10 +206,10 @@ declare function stackAnalysisBatch(workspaceRoot: string, html: false, opts?: (
204
206
  * @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.
205
207
  */
206
208
  declare function stackAnalysisBatch(workspaceRoot: string, html?: boolean | undefined, opts?: Options | undefined): Promise<string | {
207
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
209
+ [x: string]: any;
208
210
  } | {
209
211
  analysis: string | {
210
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
212
+ [x: string]: any;
211
213
  };
212
214
  metadata: BatchAnalysisMetadata;
213
215
  }>;
@@ -229,7 +231,7 @@ declare function imageAnalysis(imageRefs: Array<string>, html: true, opts?: Opti
229
231
  * @throws {Error}
230
232
  */
231
233
  declare function imageAnalysis(imageRefs: Array<string>, html: false, opts?: Options | undefined): Promise<{
232
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
234
+ [x: string]: any;
233
235
  }>;
234
236
  /**
235
237
  * Get image analysis report for a set of OCI image references.
@@ -242,7 +244,7 @@ declare function imageAnalysis(imageRefs: Array<string>, html: false, opts?: Opt
242
244
  * or backend request failed
243
245
  */
244
246
  declare function imageAnalysis(imageRefs: Array<string>, html?: boolean | undefined, opts?: Options | undefined): Promise<string | {
245
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
247
+ [x: string]: any;
246
248
  }>;
247
249
  /**
248
250
  * Validates the Exhort token.
package/dist/src/index.js CHANGED
@@ -39,7 +39,9 @@ export { discoverMavenModules, discoverGradleSubprojects, discoverGoWorkspaceMod
39
39
  * TRUSTIFY_DA_PYTHON_PATH?: string | undefined,
40
40
  * TRUSTIFY_DA_PYTHON_VIRTUAL_ENV?: string | undefined,
41
41
  * TRUSTIFY_DA_PYTHON3_PATH?: string | undefined,
42
- * TRUSTIFY_DA_RECOMMENDATIONS_ENABLED?: string | undefined,
42
+ * TRUSTIFY_DA_PROVIDERS?: string | undefined,
43
+ * TRUSTIFY_DA_RECOMMEND?: string | undefined,
44
+ * TRUSTIFY_DA_SOURCES?: string | undefined,
43
45
  * TRUSTIFY_DA_SKOPEO_CONFIG_PATH?: string | undefined,
44
46
  * TRUSTIFY_DA_SKOPEO_PATH?: string | undefined,
45
47
  * TRUSTIFY_DA_SYFT_CONFIG_PATH?: string | undefined,
@@ -175,7 +177,9 @@ async function componentAnalysis(manifest, opts = {}) {
175
177
  fs.accessSync(manifest, fs.constants.R_OK);
176
178
  opts["manifest-type"] = path.basename(manifest);
177
179
  let provider = match(manifest, availableProviders, opts); // throws error if no matching provider
178
- return await analysis.requestComponent(provider, manifest, theUrl, opts); // throws error request sending failed
180
+ const result = await analysis.requestComponent(provider, manifest, theUrl, opts); // throws error request sending failed
181
+ result.packageManager = provider.packageManagerName();
182
+ return result;
179
183
  }
180
184
  /**
181
185
  * @overload
@@ -320,7 +324,8 @@ async function detectWorkspaceManifests(root, opts) {
320
324
  return { ecosystem: 'pyproject', manifestPaths };
321
325
  }
322
326
  }
323
- const hasJsLock = fs.existsSync(path.join(root, 'pnpm-lock.yaml'))
327
+ const hasJsLock = fs.existsSync(path.join(root, 'bun.lock'))
328
+ || fs.existsSync(path.join(root, 'pnpm-lock.yaml'))
324
329
  || fs.existsSync(path.join(root, 'yarn.lock'))
325
330
  || fs.existsSync(path.join(root, 'package-lock.json'));
326
331
  if (fs.existsSync(packageJson) && hasJsLock) {
@@ -9,10 +9,10 @@
9
9
  * @param {import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport} [analysisResult] - analysis result that includes licenses array from backend
10
10
  * @returns {Promise<{ projectLicense: { manifest: Object|null, file: Object|null, mismatch: boolean }, incompatibleDependencies: Array<{ purl: string, licenses: string[], category?: string, reason: string }>, error?: string }>}
11
11
  */
12
- export function runLicenseCheck(sbomContent: string, manifestPath: string, url: string, opts?: import("../index.js").Options, analysisResult?: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport): Promise<{
12
+ export function runLicenseCheck(sbomContent: string, manifestPath: string, url: string, opts?: import("../index.js").Options, analysisResult?: any): Promise<{
13
13
  projectLicense: {
14
- manifest: any | null;
15
- file: any | null;
14
+ manifest: Object | null;
15
+ file: Object | null;
16
16
  mismatch: boolean;
17
17
  };
18
18
  incompatibleDependencies: Array<{
@@ -85,11 +85,14 @@ export async function runLicenseCheck(sbomContent, manifestPath, url, opts = {},
85
85
  continue;
86
86
  const status = getCompatibility(projectCategory, entry.category);
87
87
  if (status === 'incompatible') {
88
+ const reason = entry.category?.toUpperCase() === 'UNKNOWN'
89
+ ? 'License not recognized as a standard SPDX identifier. Manual review recommended to verify compatibility.'
90
+ : 'Dependency license(s) are incompatible with the project license.';
88
91
  incompatibleDependencies.push({
89
92
  purl,
90
93
  licenses: entry.licenses,
91
94
  category: entry.category,
92
- reason: 'Dependency license(s) are incompatible with the project license.'
95
+ reason
93
96
  });
94
97
  }
95
98
  }
@@ -114,9 +114,12 @@ export function getCompatibility(projectCategory, dependencyCategory) {
114
114
  }
115
115
  const proj = projectCategory.toUpperCase();
116
116
  const dep = dependencyCategory.toUpperCase();
117
- if (proj === 'UNKNOWN' || dep === 'UNKNOWN') {
117
+ if (proj === 'UNKNOWN') {
118
118
  return 'unknown';
119
119
  }
120
+ if (dep === 'UNKNOWN') {
121
+ return 'incompatible';
122
+ }
120
123
  const restrictiveness = {
121
124
  'PERMISSIVE': 1,
122
125
  'WEAK_COPYLEFT': 2,
@@ -6,7 +6,7 @@
6
6
  * @param {import('../index.js').Options} [opts={}] - options (proxy, token, TRUSTIFY_DA_BACKEND_URL, etc.)
7
7
  * @returns {Promise<Object|null>} License details or null if not found
8
8
  */
9
- export function getLicenseDetails(spdxId: string, opts?: import("../index.js").Options): Promise<any | null>;
9
+ export function getLicenseDetails(spdxId: string, opts?: import("../index.js").Options): Promise<Object | null>;
10
10
  /**
11
11
  * Normalize the LicensesResponse shape (array of LicenseProviderResult) into a map of purl -> license info.
12
12
  * Each provider result has { status, summary, packages } where packages is { [purl]: { concluded, evidence } }.
@@ -28,7 +28,7 @@ export function normalizeLicensesResponse(data: unknown, purls?: string[]): Map<
28
28
  * @param {string[]} [purls] - optional list of purls to restrict to
29
29
  * @returns {Map<string, { licenses: string[], category?: string }>}
30
30
  */
31
- export function licensesFromReport(analysisReport: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport, purls?: string[]): Map<string, {
31
+ export function licensesFromReport(analysisReport: any, purls?: string[]): Map<string, {
32
32
  licenses: string[];
33
33
  category?: string;
34
34
  }>;
@@ -78,7 +78,7 @@ export class ImageRef {
78
78
  * @param {string} [platform]
79
79
  * @param {import("index.js").Options} [opts={}]
80
80
  */
81
- constructor(image: string, platform?: string, opts?: import("index.js").Options);
81
+ constructor(image: string, platform?: string, opts?: any);
82
82
  /** @type {Image} */
83
83
  image: Image;
84
84
  /** @type {Platform} */
@@ -242,8 +242,22 @@ export class ImageRef {
242
242
  getPackageURL() {
243
243
  /** @type {Object.<string, string>} */
244
244
  const qualifiers = {};
245
- const repositoryUrl = this.image.getNameWithoutTag();
245
+ let repositoryUrl = this.image.getNameWithoutTag();
246
246
  const simpleName = this.image.getSimpleName();
247
+ // Normalize Docker Hub image references so all forms produce the same PURL:
248
+ // node → docker.io/node
249
+ // docker.io/library/node → docker.io/node
250
+ if (repositoryUrl != null) {
251
+ const lower = repositoryUrl.toLowerCase();
252
+ if (lower === simpleName.toLowerCase()) {
253
+ // Bare name (e.g. "node") — default to docker.io
254
+ repositoryUrl = `docker.io/${simpleName}`;
255
+ }
256
+ else if (lower.startsWith('docker.io/library/')) {
257
+ // Official image with library/ prefix — strip it
258
+ repositoryUrl = `docker.io/${lower.substring('docker.io/library/'.length)}`;
259
+ }
260
+ }
247
261
  if (repositoryUrl != null && repositoryUrl.toLowerCase() !== simpleName.toLowerCase()) {
248
262
  qualifiers[ImageRef.REPOSITORY_QUALIFIER] = repositoryUrl.toLowerCase();
249
263
  }