@trustify-da/trustify-da-javascript-client 0.3.0-ea.030d439 → 0.3.0-ea.0c4e031

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 (67) hide show
  1. package/README.md +1 -1
  2. package/dist/package.json +25 -22
  3. package/dist/src/analysis.d.ts +7 -7
  4. package/dist/src/analysis.js +10 -4
  5. package/dist/src/cyclone_dx_sbom.d.ts +7 -1
  6. package/dist/src/cyclone_dx_sbom.js +29 -8
  7. package/dist/src/index.d.ts +70 -11
  8. package/dist/src/index.js +74 -7
  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 +8 -2
  18. package/dist/src/providers/base_java.d.ts +14 -12
  19. package/dist/src/providers/base_java.js +18 -44
  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 +19 -31
  23. package/dist/src/providers/base_pyproject.js +57 -73
  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 +11 -1
  27. package/dist/src/providers/golang_gomodules.js +65 -8
  28. package/dist/src/providers/java_gradle.d.ts +19 -0
  29. package/dist/src/providers/java_gradle.js +116 -2
  30. package/dist/src/providers/java_gradle_groovy.d.ts +1 -1
  31. package/dist/src/providers/java_gradle_kotlin.d.ts +1 -1
  32. package/dist/src/providers/java_maven.d.ts +10 -2
  33. package/dist/src/providers/java_maven.js +165 -1
  34. package/dist/src/providers/javascript_bun.d.ts +10 -0
  35. package/dist/src/providers/javascript_bun.js +100 -0
  36. package/dist/src/providers/javascript_npm.d.ts +6 -0
  37. package/dist/src/providers/javascript_npm.js +21 -0
  38. package/dist/src/providers/javascript_pnpm.js +6 -2
  39. package/dist/src/providers/marker_evaluator.d.ts +14 -0
  40. package/dist/src/providers/marker_evaluator.js +191 -0
  41. package/dist/src/providers/oci_dockerfile.d.ts +51 -0
  42. package/dist/src/providers/oci_dockerfile.js +177 -0
  43. package/dist/src/providers/processors/yarn_berry_processor.d.ts +2 -2
  44. package/dist/src/providers/processors/yarn_berry_processor.js +6 -2
  45. package/dist/src/providers/processors/yarn_classic_processor.d.ts +2 -2
  46. package/dist/src/providers/python_controller.d.ts +5 -1
  47. package/dist/src/providers/python_controller.js +65 -7
  48. package/dist/src/providers/python_pip.d.ts +5 -0
  49. package/dist/src/providers/python_pip.js +5 -5
  50. package/dist/src/providers/python_pip_pyproject.d.ts +61 -0
  51. package/dist/src/providers/python_pip_pyproject.js +146 -0
  52. package/dist/src/providers/python_poetry.d.ts +64 -8
  53. package/dist/src/providers/python_poetry.js +139 -22
  54. package/dist/src/providers/python_uv.d.ts +20 -1
  55. package/dist/src/providers/python_uv.js +126 -3
  56. package/dist/src/providers/rust_cargo.d.ts +6 -2
  57. package/dist/src/providers/rust_cargo.js +31 -4
  58. package/dist/src/providers/tree-sitter-containerfile.wasm +0 -0
  59. package/dist/src/sbom.d.ts +7 -1
  60. package/dist/src/sbom.js +4 -2
  61. package/dist/src/tools.d.ts +28 -2
  62. package/dist/src/tools.js +58 -0
  63. package/dist/src/updaters/maven_updater.d.ts +26 -0
  64. package/dist/src/updaters/maven_updater.js +322 -0
  65. package/dist/src/workspace.d.ts +9 -0
  66. package/dist/src/workspace.js +1 -1
  67. package/package.json +26 -23
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,32 +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
- "fast-toml": "^0.5.4",
55
54
  "fast-xml-parser": "^5.3.4",
56
55
  "help": "^3.0.2",
57
- "https-proxy-agent": "^7.0.6",
56
+ "https-proxy-agent": "^9.0.0",
58
57
  "js-yaml": "^4.1.1",
58
+ "jsonc-parser": "^3.3.1",
59
59
  "micromatch": "^4.0.8",
60
60
  "node-fetch": "^3.3.2",
61
- "p-limit": "^4.0.0",
61
+ "p-limit": "^7.3.0",
62
62
  "packageurl-js": "~1.0.2",
63
63
  "smol-toml": "^1.6.0",
64
+ "tree-sitter-containerfile": "^0.8.1",
64
65
  "tree-sitter-gomod": "github:strum355/tree-sitter-go-mod#56326f2ad478892ace58ff247a97d492a3cbcdda",
65
66
  "tree-sitter-requirements": "github:Strum355/tree-sitter-requirements#d0261ee76b84253997fe70d7d397e78c006c3801",
66
67
  "web-tree-sitter": "^0.26.7",
@@ -68,23 +69,24 @@
68
69
  },
69
70
  "devDependencies": {
70
71
  "@babel/core": "^7.23.2",
71
- "@trustify-da/trustify-da-api-model": "^2.0.7",
72
- "@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",
73
75
  "@types/which": "^3.0.4",
74
76
  "babel-plugin-rewire": "^1.2.0",
75
77
  "c8": "^11.0.0",
76
- "chai": "^4.3.7",
77
- "eslint": "^8.42.0",
78
+ "chai": "^6.2.2",
79
+ "eslint": "^10.4.1",
78
80
  "eslint-import-resolver-typescript": "^4.4.4",
79
- "eslint-plugin-editorconfig": "^4.0.3",
80
- "eslint-plugin-import": "^2.29.1",
81
+ "eslint-plugin-import-x": "^4.16.2",
81
82
  "esmock": "^2.6.2",
82
- "mocha": "^10.2.0",
83
+ "globals": "^17.6.0",
84
+ "mocha": "^11.7.6",
83
85
  "msw": "^2.12.7",
84
- "sinon": "^15.1.2",
85
- "sinon-chai": "^3.7.0",
86
- "typescript": "^5.1.3",
87
- "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"
88
90
  },
89
91
  "mocha": {
90
92
  "check-leaks": false,
@@ -112,12 +114,13 @@
112
114
  "reporter": [
113
115
  "html",
114
116
  "json",
117
+ "lcov",
115
118
  "text"
116
119
  ]
117
120
  },
118
- "eslintIgnore": [
119
- "index.js"
120
- ],
121
+ "overrides": {
122
+ "tree-sitter": "0.22.4"
123
+ },
121
124
  "resolutions": {
122
125
  "@hapi/joi": "17.1.1"
123
126
  }
@@ -16,7 +16,7 @@ export default _default;
16
16
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
17
17
  * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
18
18
  */
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>;
19
+ declare function requestComponent(provider: any, manifest: string, url: string, opts?: any): Promise<any>;
20
20
  /**
21
21
  * Send a stack analysis request and get the report as 'text/html' or 'application/json'.
22
22
  * @param {import('./provider').Provider} provider - the provided data for constructing the request
@@ -26,7 +26,7 @@ declare function requestComponent(provider: import("./provider").Provider, manif
26
26
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
27
27
  * @returns {Promise<string|import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
28
28
  */
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>;
29
+ declare function requestStack(provider: any, manifest: string, url: string, html?: boolean, opts?: any): Promise<string | any>;
30
30
  /**
31
31
  * Send a batch stack analysis request for multiple manifests (SBOMs keyed by purl).
32
32
  * @param {Object.<string, object>} sbomByPurl - Map of root purl to CycloneDX SBOM object
@@ -36,9 +36,9 @@ declare function requestStack(provider: import("./provider").Provider, manifest:
36
36
  * @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
37
37
  */
38
38
  declare function requestStackBatch(sbomByPurl: {
39
+ [x: string]: object;
40
+ }, url: string, html?: boolean, opts?: any): Promise<string | {
39
41
  [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
42
  }>;
43
43
  /**
44
44
  *
@@ -47,8 +47,8 @@ declare function requestStackBatch(sbomByPurl: {
47
47
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
48
48
  * @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
49
49
  */
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;
50
+ declare function requestImages(imageRefs: Array<string>, url: string, html?: boolean, opts?: any): Promise<string | {
51
+ [x: string]: any;
52
52
  }>;
53
53
  /**
54
54
  *
@@ -56,4 +56,4 @@ declare function requestImages(imageRefs: Array<string>, url: string, html?: boo
56
56
  * @param {import("index.js").Options} [opts={}] - optional various options to pass headers for t he validateToken Request
57
57
  * @return {Promise<number>} return the HTTP status Code of the response from the validate token request.
58
58
  */
59
- declare function validateToken(url: any, opts?: import("index.js").Options): Promise<number>;
59
+ declare function validateToken(url: any, opts?: any): Promise<number>;
@@ -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,7 +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') {
44
+ if (getCustom('TRUSTIFY_DA_RECOMMEND', 'true', opts) === 'false') {
42
45
  finalUrl.searchParams.append('recommend', 'false');
43
46
  }
44
47
  let resp = await fetch(finalUrl, fetchOptions);
@@ -79,6 +82,9 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
79
82
  async function requestComponent(provider, manifest, url, opts = {}) {
80
83
  opts["source-manifest"] = Buffer.from(fs.readFileSync(manifest).toString()).toString('base64');
81
84
  let provided = await provider.provideComponent(manifest, opts); // throws error if content providing failed
85
+ if (provided.batch) {
86
+ return requestStackBatch(JSON.parse(provided.content), url, false, opts);
87
+ }
82
88
  opts["source-manifest"] = "";
83
89
  opts[TRUSTIFY_DA_OPERATION_TYPE_HEADER.toUpperCase().replaceAll("-", "_")] = "component-analysis";
84
90
  if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
@@ -95,7 +101,7 @@ async function requestComponent(provider, manifest, url, opts = {}) {
95
101
  body: provided.content
96
102
  }, opts);
97
103
  const finalUrl = new URL(`${url}/api/v5/analysis`);
98
- if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
104
+ if (getCustom('TRUSTIFY_DA_RECOMMEND', 'true', opts) === 'false') {
99
105
  finalUrl.searchParams.append('recommend', 'false');
100
106
  }
101
107
  let resp = await fetch(finalUrl, fetchOptions);
@@ -136,7 +142,7 @@ async function requestComponent(provider, manifest, url, opts = {}) {
136
142
  */
137
143
  async function requestStackBatch(sbomByPurl, url, html = false, opts = {}) {
138
144
  const finalUrl = new URL(`${url}/api/v5/batch-analysis`);
139
- if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
145
+ if (getCustom('TRUSTIFY_DA_RECOMMEND', 'true', opts) === 'false') {
140
146
  finalUrl.searchParams.append('recommend', 'false');
141
147
  }
142
148
  const fetchOptions = addProxyAgent({
@@ -186,7 +192,7 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
186
192
  imageSboms[parsedImageRef.getPackageURL().toString()] = generateImageSBOM(parsedImageRef, opts);
187
193
  }
188
194
  const finalUrl = new URL(`${url}/api/v5/batch-analysis`);
189
- if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
195
+ if (getCustom('TRUSTIFY_DA_RECOMMEND', 'true', opts) === 'false') {
190
196
  finalUrl.searchParams.append('recommend', 'false');
191
197
  }
192
198
  const fetchOptions = addProxyAgent({
@@ -18,9 +18,14 @@ export default class CycloneDxSbom {
18
18
  * Adds a dependency relationship between two components in the SBOM
19
19
  * @param {PackageURL} sourceRef - The source component (parent)
20
20
  * @param {PackageURL} targetRef - The target component (dependency)
21
+ * @param {string} [scope] - Scope of the dependency
22
+ * @param {Array<{alg: string, content: string}>} [targetHashes] - Optional hashes for the target component
21
23
  * @return {CycloneDxSbom} The updated SBOM
22
24
  */
23
- addDependency(sourceRef: PackageURL, targetRef: PackageURL, scope: any): CycloneDxSbom;
25
+ addDependency(sourceRef: PackageURL, targetRef: PackageURL, scope?: string, targetHashes?: Array<{
26
+ alg: string;
27
+ content: string;
28
+ }>): CycloneDxSbom;
24
29
  /** @param {{}} opts - various options, settings and configuration of application.
25
30
  * @return String CycloneDx Sbom json object in a string format
26
31
  */
@@ -50,6 +55,7 @@ export default class CycloneDxSbom {
50
55
  version: any;
51
56
  scope: any;
52
57
  licenses?: any;
58
+ hashes?: any;
53
59
  };
54
60
  /**
55
61
  * This method gets an array of dependencies to be ignored, and remove all of them from CycloneDx Sbom
@@ -6,10 +6,11 @@ import { PackageURL } from "packageurl-js";
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
+ * @param hashes optional array of hash objects for the component, e.g. [{alg: "SHA-256", content: "..."}]
10
+ * @return {{"bom-ref": string, name, purl: string, type, version, scope, licenses?, hashes?}}
10
11
  * @private
11
12
  */
12
- function getComponent(component, type, scope, licenses) {
13
+ function getComponent(component, type, scope, licenses, hashes) {
13
14
  let componentObject;
14
15
  if (component instanceof PackageURL) {
15
16
  if (component.namespace) {
@@ -40,12 +41,24 @@ function getComponent(component, type, scope, licenses) {
40
41
  // Add licenses if provided (CycloneDX format). Callers must provide valid SPDX identifiers.
41
42
  if (licenses) {
42
43
  const licenseArray = Array.isArray(licenses) ? licenses : [licenses];
43
- componentObject.licenses = licenseArray.map(lic => {
44
+ const validLicenses = licenseArray
45
+ .map(lic => {
44
46
  if (typeof lic === 'string') {
45
47
  return { license: { id: lic } };
46
48
  }
47
- return lic;
48
- });
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
+ }
58
+ }
59
+ // Add hashes if provided (CycloneDX 1.4 format).
60
+ if (hashes && hashes.length > 0) {
61
+ componentObject.hashes = hashes;
49
62
  }
50
63
  return componentObject;
51
64
  }
@@ -86,16 +99,24 @@ export default class CycloneDxSbom {
86
99
  * Adds a dependency relationship between two components in the SBOM
87
100
  * @param {PackageURL} sourceRef - The source component (parent)
88
101
  * @param {PackageURL} targetRef - The target component (dependency)
102
+ * @param {string} [scope] - Scope of the dependency
103
+ * @param {Array<{alg: string, content: string}>} [targetHashes] - Optional hashes for the target component
89
104
  * @return {CycloneDxSbom} The updated SBOM
90
105
  */
91
- addDependency(sourceRef, targetRef, scope) {
106
+ addDependency(sourceRef, targetRef, scope, targetHashes) {
92
107
  const sourcePurl = sourceRef.toString();
93
108
  const targetPurl = targetRef.toString();
94
109
  // Ensure both components exist in the components list
95
110
  [sourceRef, targetRef].forEach((ref, index) => {
96
111
  const purl = index === 0 ? sourcePurl : targetPurl;
97
- if (this.getComponentIndex(purl) < 0) {
98
- this.components.push(getComponent(ref, "library", scope));
112
+ const existingIndex = this.getComponentIndex(purl);
113
+ if (existingIndex < 0) {
114
+ const hashes = index === 1 ? targetHashes : undefined;
115
+ this.components.push(getComponent(ref, "library", scope, undefined, hashes));
116
+ }
117
+ else if (index === 1 && targetHashes && targetHashes.length > 0 && !this.components[existingIndex].hashes) {
118
+ // Update hashes if the component was first seen without them (e.g. as a source)
119
+ this.components[existingIndex].hashes = targetHashes;
99
120
  }
100
121
  });
101
122
  // Ensure source dependency exists
@@ -53,7 +53,7 @@ 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_RECOMMEND?: string | undefined;
57
57
  TRUSTIFY_DA_SKOPEO_CONFIG_PATH?: string | undefined;
58
58
  TRUSTIFY_DA_SKOPEO_PATH?: string | undefined;
59
59
  TRUSTIFY_DA_SYFT_CONFIG_PATH?: string | undefined;
@@ -80,7 +80,7 @@ export type Options = {
80
80
  };
81
81
  export type BatchAnalysisMetadata = {
82
82
  workspaceRoot: string;
83
- ecosystem: "javascript" | "cargo" | "unknown";
83
+ ecosystem: "javascript" | "cargo" | "pyproject" | "unknown";
84
84
  total: number;
85
85
  successful: number;
86
86
  failed: number;
@@ -106,7 +106,7 @@ export type SbomResult = {
106
106
  * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
107
107
  * @throws {Error} if no matching provider, failed to get create content, or backend request failed
108
108
  */
109
- declare function componentAnalysis(manifest: string, opts?: Options): Promise<import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport>;
109
+ declare function componentAnalysis(manifest: string, opts?: Options): Promise<any>;
110
110
  /**
111
111
  * @overload
112
112
  * @param {string} manifest
@@ -124,7 +124,7 @@ declare function stackAnalysis(manifest: string, html: true, opts?: Options | un
124
124
  * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
125
125
  * @throws {Error}
126
126
  */
127
- declare function stackAnalysis(manifest: string, html: false, opts?: Options | undefined): Promise<import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport>;
127
+ declare function stackAnalysis(manifest: string, html: false, opts?: Options | undefined): Promise<any>;
128
128
  /**
129
129
  * Get stack analysis report for a manifest file.
130
130
  * @overload
@@ -135,24 +135,79 @@ declare function stackAnalysis(manifest: string, html: false, opts?: Options | u
135
135
  * @throws {Error} if manifest inaccessible, no matching provider, failed to get create content,
136
136
  * or backend request failed
137
137
  */
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>;
138
+ declare function stackAnalysis(manifest: string, html?: boolean | undefined, opts?: Options | undefined): Promise<string | any>;
139
+ /**
140
+ * @overload
141
+ * @param {string} workspaceRoot
142
+ * @param {true} html
143
+ * @param {Options & { batchMetadata: true }} opts
144
+ * @returns {Promise<{ analysis: string, metadata: BatchAnalysisMetadata }>}
145
+ * @throws {Error}
146
+ */
147
+ declare function stackAnalysisBatch(workspaceRoot: string, html: true, opts: Options & {
148
+ batchMetadata: true;
149
+ }): Promise<{
150
+ analysis: string;
151
+ metadata: BatchAnalysisMetadata;
152
+ }>;
153
+ /**
154
+ * @overload
155
+ * @param {string} workspaceRoot
156
+ * @param {true} html
157
+ * @param {Options & { batchMetadata?: false }} [opts={}]
158
+ * @returns {Promise<string>}
159
+ * @throws {Error}
160
+ */
161
+ declare function stackAnalysisBatch(workspaceRoot: string, html: true, opts?: (Options & {
162
+ batchMetadata?: false;
163
+ }) | undefined): Promise<string>;
164
+ /**
165
+ * @overload
166
+ * @param {string} workspaceRoot
167
+ * @param {false} html
168
+ * @param {Options & { batchMetadata: true }} opts
169
+ * @returns {Promise<{ analysis: Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>, metadata: BatchAnalysisMetadata }>}
170
+ * @throws {Error}
171
+ */
172
+ declare function stackAnalysisBatch(workspaceRoot: string, html: false, opts: Options & {
173
+ batchMetadata: true;
174
+ }): Promise<{
175
+ analysis: {
176
+ [x: string]: any;
177
+ };
178
+ metadata: BatchAnalysisMetadata;
179
+ }>;
180
+ /**
181
+ * @overload
182
+ * @param {string} workspaceRoot
183
+ * @param {false} html
184
+ * @param {Options & { batchMetadata?: false }} [opts={}]
185
+ * @returns {Promise<Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
186
+ * @throws {Error}
187
+ */
188
+ declare function stackAnalysisBatch(workspaceRoot: string, html: false, opts?: (Options & {
189
+ batchMetadata?: false;
190
+ }) | undefined): Promise<{
191
+ [x: string]: any;
192
+ }>;
139
193
  /**
140
194
  * Get stack analysis for all workspace packages/crates (batch).
141
195
  * Detects ecosystem from workspace root: Cargo (Cargo.toml + Cargo.lock) or JS/TS (package.json + lock file).
142
196
  * SBOMs are generated in parallel (see `batchConcurrency`) unless `continueOnError: false` (fail-fast sequential).
143
197
  * With `opts.batchMetadata` / `TRUSTIFY_DA_BATCH_METADATA`, returns `{ analysis, metadata }` including validation and SBOM errors.
144
198
  *
199
+ * @overload
145
200
  * @param {string} workspaceRoot - Path to workspace root (containing lock file and workspace config)
146
201
  * @param {boolean} [html=false] - true returns HTML, false returns JSON report
147
202
  * @param {Options} [opts={}] - `batchConcurrency`, discovery ignores, `continueOnError` (default true), `batchMetadata` (default false)
148
203
  * @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 }>}
149
204
  * @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.
150
205
  */
151
- declare function stackAnalysisBatch(workspaceRoot: string, html?: boolean, opts?: Options): Promise<string | {
152
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
206
+ declare function stackAnalysisBatch(workspaceRoot: string, html?: boolean | undefined, opts?: Options | undefined): Promise<string | {
207
+ [x: string]: any;
153
208
  } | {
154
209
  analysis: string | {
155
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
210
+ [x: string]: any;
156
211
  };
157
212
  metadata: BatchAnalysisMetadata;
158
213
  }>;
@@ -174,7 +229,7 @@ declare function imageAnalysis(imageRefs: Array<string>, html: true, opts?: Opti
174
229
  * @throws {Error}
175
230
  */
176
231
  declare function imageAnalysis(imageRefs: Array<string>, html: false, opts?: Options | undefined): Promise<{
177
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
232
+ [x: string]: any;
178
233
  }>;
179
234
  /**
180
235
  * Get image analysis report for a set of OCI image references.
@@ -187,7 +242,7 @@ declare function imageAnalysis(imageRefs: Array<string>, html: false, opts?: Opt
187
242
  * or backend request failed
188
243
  */
189
244
  declare function imageAnalysis(imageRefs: Array<string>, html?: boolean | undefined, opts?: Options | undefined): Promise<string | {
190
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
245
+ [x: string]: any;
191
246
  }>;
192
247
  /**
193
248
  * Validates the Exhort token.
@@ -196,6 +251,10 @@ declare function imageAnalysis(imageRefs: Array<string>, html?: boolean | undefi
196
251
  * @throws {Error} if the backend request failed.
197
252
  */
198
253
  declare function validateToken(opts?: Options): Promise<object>;
254
+ import { discoverMavenModules } from './providers/java_maven.js';
255
+ import { discoverGradleSubprojects } from './providers/java_gradle.js';
256
+ import { discoverGoWorkspaceModules } from './providers/golang_gomodules.js';
257
+ import { discoverUvWorkspaceMembers } from './providers/python_uv.js';
199
258
  import { discoverWorkspacePackages } from './workspace.js';
200
259
  import { discoverWorkspaceCrates } from './workspace.js';
201
260
  import { validatePackageJson } from './workspace.js';
@@ -203,5 +262,5 @@ import { resolveWorkspaceDiscoveryIgnore } from './workspace.js';
203
262
  import { filterManifestPathsByDiscoveryIgnore } from './workspace.js';
204
263
  import { resolveContinueOnError } from './batch_opts.js';
205
264
  import { resolveBatchMetadata } from './batch_opts.js';
206
- export { discoverWorkspacePackages, discoverWorkspaceCrates, validatePackageJson, resolveWorkspaceDiscoveryIgnore, filterManifestPathsByDiscoveryIgnore, resolveContinueOnError, resolveBatchMetadata };
265
+ export { discoverMavenModules, discoverGradleSubprojects, discoverGoWorkspaceModules, discoverUvWorkspaceMembers, discoverWorkspacePackages, discoverWorkspaceCrates, validatePackageJson, resolveWorkspaceDiscoveryIgnore, filterManifestPathsByDiscoveryIgnore, resolveContinueOnError, resolveBatchMetadata };
207
266
  export { getProjectLicense, findLicenseFilePath, identifyLicense, getLicenseDetails, licensesFromReport, normalizeLicensesResponse, runLicenseCheck, getCompatibility } from "./license/index.js";
package/dist/src/index.js CHANGED
@@ -6,6 +6,10 @@ import analysis from './analysis.js';
6
6
  import fs from 'node:fs';
7
7
  import { getCustom } from "./tools.js";
8
8
  import { resolveBatchMetadata, resolveContinueOnError } from './batch_opts.js';
9
+ import { discoverMavenModules } from './providers/java_maven.js';
10
+ import { discoverGradleSubprojects } from './providers/java_gradle.js';
11
+ import { discoverGoWorkspaceModules } from './providers/golang_gomodules.js';
12
+ import { discoverUvWorkspaceMembers } from './providers/python_uv.js';
9
13
  import { discoverWorkspaceCrates, discoverWorkspacePackages, filterManifestPathsByDiscoveryIgnore, resolveWorkspaceDiscoveryIgnore, validatePackageJson, } from './workspace.js';
10
14
  import.meta.dirname;
11
15
  import * as url from 'url';
@@ -13,7 +17,7 @@ export { parseImageRef } from "./oci_image/utils.js";
13
17
  export { ImageRef } from "./oci_image/images.js";
14
18
  export { getProjectLicense, findLicenseFilePath, identifyLicense, getLicenseDetails, licensesFromReport, normalizeLicensesResponse, runLicenseCheck, getCompatibility } from "./license/index.js";
15
19
  export default { componentAnalysis, stackAnalysis, stackAnalysisBatch, imageAnalysis, validateToken, generateSbom };
16
- export { discoverWorkspacePackages, discoverWorkspaceCrates, validatePackageJson, resolveWorkspaceDiscoveryIgnore, filterManifestPathsByDiscoveryIgnore, resolveContinueOnError, resolveBatchMetadata, };
20
+ export { discoverMavenModules, discoverGradleSubprojects, discoverGoWorkspaceModules, discoverUvWorkspaceMembers, discoverWorkspacePackages, discoverWorkspaceCrates, validatePackageJson, resolveWorkspaceDiscoveryIgnore, filterManifestPathsByDiscoveryIgnore, resolveContinueOnError, resolveBatchMetadata, };
17
21
  /**
18
22
  * @typedef {{
19
23
  * TRUSTIFY_DA_CARGO_PATH?: string | undefined,
@@ -35,7 +39,7 @@ export { discoverWorkspacePackages, discoverWorkspaceCrates, validatePackageJson
35
39
  * TRUSTIFY_DA_PYTHON_PATH?: string | undefined,
36
40
  * TRUSTIFY_DA_PYTHON_VIRTUAL_ENV?: string | undefined,
37
41
  * TRUSTIFY_DA_PYTHON3_PATH?: string | undefined,
38
- * TRUSTIFY_DA_RECOMMENDATIONS_ENABLED?: string | undefined,
42
+ * TRUSTIFY_DA_RECOMMEND?: string | undefined,
39
43
  * TRUSTIFY_DA_SKOPEO_CONFIG_PATH?: string | undefined,
40
44
  * TRUSTIFY_DA_SKOPEO_PATH?: string | undefined,
41
45
  * TRUSTIFY_DA_SYFT_CONFIG_PATH?: string | undefined,
@@ -64,7 +68,7 @@ export { discoverWorkspacePackages, discoverWorkspaceCrates, validatePackageJson
64
68
  /**
65
69
  * @typedef {{
66
70
  * workspaceRoot: string,
67
- * ecosystem: 'javascript' | 'cargo' | 'unknown',
71
+ * ecosystem: 'javascript' | 'cargo' | 'pyproject' | 'unknown',
68
72
  * total: number,
69
73
  * successful: number,
70
74
  * failed: number,
@@ -171,7 +175,9 @@ async function componentAnalysis(manifest, opts = {}) {
171
175
  fs.accessSync(manifest, fs.constants.R_OK);
172
176
  opts["manifest-type"] = path.basename(manifest);
173
177
  let provider = match(manifest, availableProviders, opts); // throws error if no matching provider
174
- return await analysis.requestComponent(provider, manifest, theUrl, opts); // throws error request sending failed
178
+ const result = await analysis.requestComponent(provider, manifest, theUrl, opts); // throws error request sending failed
179
+ result.packageManager = provider.packageManagerName();
180
+ return result;
175
181
  }
176
182
  /**
177
183
  * @overload
@@ -279,17 +285,45 @@ async function generateOneSbom(manifestPath, workspaceOpts) {
279
285
  *
280
286
  * @param {string} root - Resolved workspace root
281
287
  * @param {Options} opts
282
- * @returns {Promise<{ ecosystem: 'javascript' | 'cargo' | 'unknown', manifestPaths: string[] }>}
288
+ * @returns {Promise<{ ecosystem: 'javascript' | 'cargo' | 'maven' | 'gradle' | 'gomodules' | 'pyproject' | 'unknown', manifestPaths: string[] }>}
283
289
  * @private
284
290
  */
285
291
  async function detectWorkspaceManifests(root, opts) {
286
292
  const cargoToml = path.join(root, 'Cargo.toml');
287
293
  const cargoLock = path.join(root, 'Cargo.lock');
288
294
  const packageJson = path.join(root, 'package.json');
295
+ const pomXml = path.join(root, 'pom.xml');
289
296
  if (fs.existsSync(cargoToml) && fs.existsSync(cargoLock)) {
290
297
  return { ecosystem: 'cargo', manifestPaths: await discoverWorkspaceCrates(root, opts) };
291
298
  }
292
- const hasJsLock = fs.existsSync(path.join(root, 'pnpm-lock.yaml'))
299
+ if (fs.existsSync(pomXml)) {
300
+ const manifestPaths = await discoverMavenModules(root, opts);
301
+ if (manifestPaths.length > 0) {
302
+ return { ecosystem: 'maven', manifestPaths };
303
+ }
304
+ }
305
+ const hasGradleSettings = fs.existsSync(path.join(root, 'settings.gradle'))
306
+ || fs.existsSync(path.join(root, 'settings.gradle.kts'));
307
+ if (hasGradleSettings) {
308
+ const manifestPaths = await discoverGradleSubprojects(root, opts);
309
+ if (manifestPaths.length > 0) {
310
+ return { ecosystem: 'gradle', manifestPaths };
311
+ }
312
+ }
313
+ if (fs.existsSync(path.join(root, 'go.work'))) {
314
+ const manifestPaths = await discoverGoWorkspaceModules(root, opts);
315
+ if (manifestPaths.length > 0) {
316
+ return { ecosystem: 'gomodules', manifestPaths };
317
+ }
318
+ }
319
+ if (fs.existsSync(path.join(root, 'pyproject.toml')) && fs.existsSync(path.join(root, 'uv.lock'))) {
320
+ const manifestPaths = await discoverUvWorkspaceMembers(root, opts);
321
+ if (manifestPaths.length > 0) {
322
+ return { ecosystem: 'pyproject', manifestPaths };
323
+ }
324
+ }
325
+ const hasJsLock = fs.existsSync(path.join(root, 'bun.lock'))
326
+ || fs.existsSync(path.join(root, 'pnpm-lock.yaml'))
293
327
  || fs.existsSync(path.join(root, 'yarn.lock'))
294
328
  || fs.existsSync(path.join(root, 'package-lock.json'));
295
329
  if (fs.existsSync(packageJson) && hasJsLock) {
@@ -398,12 +432,45 @@ function batchError(message, wantMetadata, metadata) {
398
432
  }
399
433
  return err;
400
434
  }
435
+ /**
436
+ * @overload
437
+ * @param {string} workspaceRoot
438
+ * @param {true} html
439
+ * @param {Options & { batchMetadata: true }} opts
440
+ * @returns {Promise<{ analysis: string, metadata: BatchAnalysisMetadata }>}
441
+ * @throws {Error}
442
+ */
443
+ /**
444
+ * @overload
445
+ * @param {string} workspaceRoot
446
+ * @param {true} html
447
+ * @param {Options & { batchMetadata?: false }} [opts={}]
448
+ * @returns {Promise<string>}
449
+ * @throws {Error}
450
+ */
451
+ /**
452
+ * @overload
453
+ * @param {string} workspaceRoot
454
+ * @param {false} html
455
+ * @param {Options & { batchMetadata: true }} opts
456
+ * @returns {Promise<{ analysis: Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>, metadata: BatchAnalysisMetadata }>}
457
+ * @throws {Error}
458
+ */
459
+ /**
460
+ * @overload
461
+ * @param {string} workspaceRoot
462
+ * @param {false} html
463
+ * @param {Options & { batchMetadata?: false }} [opts={}]
464
+ * @returns {Promise<Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
465
+ * @throws {Error}
466
+ */
401
467
  /**
402
468
  * Get stack analysis for all workspace packages/crates (batch).
403
469
  * Detects ecosystem from workspace root: Cargo (Cargo.toml + Cargo.lock) or JS/TS (package.json + lock file).
404
470
  * SBOMs are generated in parallel (see `batchConcurrency`) unless `continueOnError: false` (fail-fast sequential).
405
471
  * With `opts.batchMetadata` / `TRUSTIFY_DA_BATCH_METADATA`, returns `{ analysis, metadata }` including validation and SBOM errors.
406
472
  *
473
+ * @overload
407
474
  * @param {string} workspaceRoot - Path to workspace root (containing lock file and workspace config)
408
475
  * @param {boolean} [html=false] - true returns HTML, false returns JSON report
409
476
  * @param {Options} [opts={}] - `batchConcurrency`, discovery ignores, `continueOnError` (default true), `batchMetadata` (default false)
@@ -434,7 +501,7 @@ async function stackAnalysisBatch(workspaceRoot, html = false, opts = {}) {
434
501
  }
435
502
  }
436
503
  if (manifestPaths.length === 0) {
437
- throw new Error(`No workspace manifests found at ${root}. Ensure Cargo.toml+Cargo.lock or package.json+lock file exist.`);
504
+ throw new Error(`No workspace manifests found at ${root}. Ensure a supported workspace root exists (Cargo.toml+Cargo.lock, pom.xml, build.gradle, go.work, pyproject.toml+uv.lock, or package.json+lock file).`);
438
505
  }
439
506
  const workspaceOpts = { ...opts, TRUSTIFY_DA_WORKSPACE_DIR: root };
440
507
  const concurrency = resolveBatchConcurrency(opts);
@@ -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
  }