@trustify-da/trustify-da-javascript-client 0.3.0-ea.bbe2094 → 0.3.0-ea.bdb4511

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 (39) hide show
  1. package/dist/package.json +18 -19
  2. package/dist/src/analysis.d.ts +7 -7
  3. package/dist/src/cyclone_dx_sbom.js +11 -3
  4. package/dist/src/index.d.ts +9 -9
  5. package/dist/src/index.js +3 -1
  6. package/dist/src/license/index.d.ts +3 -3
  7. package/dist/src/license/index.js +4 -1
  8. package/dist/src/license/license_utils.js +4 -1
  9. package/dist/src/license/licenses_api.d.ts +2 -2
  10. package/dist/src/oci_image/images.d.ts +1 -1
  11. package/dist/src/oci_image/utils.d.ts +5 -5
  12. package/dist/src/provider.d.ts +4 -3
  13. package/dist/src/provider.js +1 -1
  14. package/dist/src/providers/base_java.d.ts +14 -3
  15. package/dist/src/providers/base_java.js +16 -6
  16. package/dist/src/providers/base_javascript.d.ts +14 -9
  17. package/dist/src/providers/base_javascript.js +7 -0
  18. package/dist/src/providers/base_pyproject.d.ts +10 -5
  19. package/dist/src/providers/base_pyproject.js +7 -0
  20. package/dist/src/providers/golang_gomodules.d.ts +2 -1
  21. package/dist/src/providers/golang_gomodules.js +1 -1
  22. package/dist/src/providers/java_gradle_groovy.d.ts +1 -1
  23. package/dist/src/providers/java_gradle_kotlin.d.ts +1 -1
  24. package/dist/src/providers/java_maven.d.ts +2 -2
  25. package/dist/src/providers/java_maven.js +72 -0
  26. package/dist/src/providers/javascript_npm.d.ts +6 -1
  27. package/dist/src/providers/processors/yarn_berry_processor.d.ts +2 -2
  28. package/dist/src/providers/processors/yarn_classic_processor.d.ts +2 -2
  29. package/dist/src/providers/python_controller.js +57 -3
  30. package/dist/src/providers/python_pip.d.ts +1 -0
  31. package/dist/src/providers/python_pip.js +1 -1
  32. package/dist/src/providers/python_poetry.d.ts +31 -8
  33. package/dist/src/providers/python_poetry.js +62 -14
  34. package/dist/src/providers/python_uv.d.ts +5 -14
  35. package/dist/src/providers/python_uv.js +44 -2
  36. package/dist/src/providers/rust_cargo.d.ts +6 -2
  37. package/dist/src/providers/rust_cargo.js +31 -4
  38. package/dist/src/tools.d.ts +2 -2
  39. package/package.json +19 -20
@@ -4,9 +4,10 @@ declare namespace _default {
4
4
  export { provideComponent };
5
5
  export { provideStack };
6
6
  export { readLicenseFromManifest };
7
+ export function packageManagerName(): string;
7
8
  }
8
9
  export default _default;
9
- export type Provided = import("../provider").Provided;
10
+ export type Provided = any;
10
11
  /**
11
12
  * @param {string} manifestName - the subject manifest name-type
12
13
  * @returns {boolean} - return true if `Cargo.toml` is the manifest name-type
@@ -46,7 +47,10 @@ declare function provideStack(manifest: string, opts?: {}): Provided;
46
47
  * Read project license from Cargo.toml, with fallback to LICENSE file.
47
48
  * Supports the `license` field under `[package]` (single crate / workspace
48
49
  * with root) and under `[workspace.package]` (virtual workspaces).
50
+ * When a member crate uses `license = { workspace = true }`, the actual
51
+ * license is resolved from the workspace root Cargo.toml.
49
52
  * @param {string} manifestPath - path to Cargo.toml
53
+ * @param {object} [metadata] - cargo metadata output (needed for workspace license resolution)
50
54
  * @returns {string|null} SPDX identifier or null
51
55
  */
52
- declare function readLicenseFromManifest(manifestPath: string): string | null;
56
+ declare function readLicenseFromManifest(manifestPath: string, metadata?: object): string | null;
@@ -5,7 +5,7 @@ import { parse as parseToml } from 'smol-toml';
5
5
  import { getLicense } from '../license/license_utils.js';
6
6
  import Sbom from '../sbom.js';
7
7
  import { getCustom, getCustomPath, invokeCommand } from '../tools.js';
8
- export default { isSupported, validateLockFile, provideComponent, provideStack, readLicenseFromManifest };
8
+ export default { isSupported, validateLockFile, provideComponent, provideStack, readLicenseFromManifest, packageManagerName() { return 'cargo'; } };
9
9
  /** @typedef {import('../provider').Provider} */
10
10
  /** @typedef {import('../provider').Provided} Provided */
11
11
  /**
@@ -71,15 +71,22 @@ function isSupported(manifestName) {
71
71
  * Read project license from Cargo.toml, with fallback to LICENSE file.
72
72
  * Supports the `license` field under `[package]` (single crate / workspace
73
73
  * with root) and under `[workspace.package]` (virtual workspaces).
74
+ * When a member crate uses `license = { workspace = true }`, the actual
75
+ * license is resolved from the workspace root Cargo.toml.
74
76
  * @param {string} manifestPath - path to Cargo.toml
77
+ * @param {object} [metadata] - cargo metadata output (needed for workspace license resolution)
75
78
  * @returns {string|null} SPDX identifier or null
76
79
  */
77
- function readLicenseFromManifest(manifestPath) {
80
+ function readLicenseFromManifest(manifestPath, metadata) {
78
81
  let fromManifest = null;
79
82
  try {
80
83
  let content = fs.readFileSync(manifestPath, 'utf-8');
81
84
  let parsed = parseToml(content);
82
- fromManifest = parsed.package?.license
85
+ let packageLicense = parsed.package?.license;
86
+ if (typeof packageLicense === 'object' && packageLicense?.workspace === true) {
87
+ packageLicense = resolveWorkspaceLicense(parsed, metadata);
88
+ }
89
+ fromManifest = packageLicense
83
90
  || parsed.workspace?.package?.license
84
91
  || null;
85
92
  }
@@ -88,6 +95,26 @@ function readLicenseFromManifest(manifestPath) {
88
95
  }
89
96
  return getLicense(fromManifest, manifestPath);
90
97
  }
98
+ /**
99
+ * Resolve a workspace-inherited license from the workspace root Cargo.toml.
100
+ * @param {object} parsed - the parsed member crate Cargo.toml
101
+ * @param {object} [metadata] - cargo metadata output with workspace_root
102
+ * @returns {string|null} resolved license string or null
103
+ */
104
+ function resolveWorkspaceLicense(parsed, metadata) {
105
+ if (metadata?.workspace_root) {
106
+ let cargoTomlPath = path.join(metadata.workspace_root, 'Cargo.toml');
107
+ try {
108
+ let content = fs.readFileSync(cargoTomlPath, 'utf-8');
109
+ let workspaceParsed = parseToml(content);
110
+ return workspaceParsed.workspace?.package?.license || null;
111
+ }
112
+ catch (_) {
113
+ // fall through
114
+ }
115
+ }
116
+ return parsed.workspace?.package?.license || null;
117
+ }
91
118
  /**
92
119
  * Validates that Cargo.lock exists in the manifest directory or in a parent
93
120
  * workspace root directory. In Cargo workspaces the lock file always lives at
@@ -173,7 +200,7 @@ function getSBOM(manifest, opts = {}, includeTransitive) {
173
200
  let metadata = executeCargoMetadata(cargoBin, manifestDir);
174
201
  let ignoredDeps = getIgnoredDeps(manifest, metadata);
175
202
  let crateType = detectCrateType(metadata);
176
- let license = readLicenseFromManifest(manifest);
203
+ let license = readLicenseFromManifest(manifest, metadata);
177
204
  let sbom;
178
205
  if (crateType === CrateType.WORKSPACE_VIRTUAL) {
179
206
  sbom = handleVirtualWorkspace(manifest, metadata, ignoredDeps, includeTransitive, opts, license);
@@ -100,13 +100,13 @@ export function invokeCommand(bin: string, args: Array<string>, opts?: import("c
100
100
  * @param {import("index.js").Options} opts - The trustify DA options that may contain proxy configuration
101
101
  * @returns {RequestInit} The fetch options with proxy agent if applicable
102
102
  */
103
- export function addProxyAgent(options: RequestInit, opts: import("index.js").Options): RequestInit;
103
+ export function addProxyAgent(options: RequestInit, opts: any): RequestInit;
104
104
  /**
105
105
  * Utility function for fetching vendor tokens
106
106
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
107
107
  * @returns {{}}
108
108
  */
109
- export function getTokenHeaders(opts?: import("index.js").Options): {};
109
+ export function getTokenHeaders(opts?: any): {};
110
110
  export const RegexNotToBeLogged: RegExp;
111
111
  export const TRUSTIFY_DA_TOKEN_HEADER: "trust-da-token";
112
112
  export const TRUSTIFY_DA_TELEMETRY_ID_HEADER: "telemetry-anonymous-id";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustify-da/trustify-da-javascript-client",
3
- "version": "0.3.0-ea.bbe2094",
3
+ "version": "0.3.0-ea.bdb4511",
4
4
  "description": "Code-Ready Dependency Analytics JavaScript API.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/guacsec/trustify-da-javascript-client#README.md",
@@ -35,8 +35,8 @@
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",
@@ -48,17 +48,17 @@
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
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
64
  "tree-sitter-gomod": "github:strum355/tree-sitter-go-mod#56326f2ad478892ace58ff247a97d492a3cbcdda",
@@ -68,23 +68,24 @@
68
68
  },
69
69
  "devDependencies": {
70
70
  "@babel/core": "^7.23.2",
71
- "@trustify-da/trustify-da-api-model": "^2.0.7",
72
- "@types/node": "^20.17.30",
71
+ "@trustify-da/trustify-da-api-model": "^2.0.9",
72
+ "@types/node": "^25.9.1",
73
73
  "@types/which": "^3.0.4",
74
74
  "babel-plugin-rewire": "^1.2.0",
75
75
  "c8": "^11.0.0",
76
- "chai": "^4.3.7",
77
- "eslint": "^8.42.0",
76
+ "chai": "^6.2.2",
77
+ "@eslint/js": "^10.0.0",
78
+ "eslint": "^10.4.1",
78
79
  "eslint-import-resolver-typescript": "^4.4.4",
79
- "eslint-plugin-editorconfig": "^4.0.3",
80
- "eslint-plugin-import": "^2.29.1",
80
+ "eslint-plugin-import-x": "^4.16.2",
81
+ "globals": "^17.6.0",
81
82
  "esmock": "^2.6.2",
82
- "mocha": "^10.2.0",
83
+ "mocha": "^11.7.6",
83
84
  "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"
85
+ "sinon": "^22.0.0",
86
+ "sinon-chai": "^4.0.1",
87
+ "typescript": "^6.0.3",
88
+ "which": "^7.0.0"
88
89
  },
89
90
  "mocha": {
90
91
  "check-leaks": false,
@@ -112,12 +113,10 @@
112
113
  "reporter": [
113
114
  "html",
114
115
  "json",
116
+ "lcov",
115
117
  "text"
116
118
  ]
117
119
  },
118
- "eslintIgnore": [
119
- "index.js"
120
- ],
121
120
  "resolutions": {
122
121
  "@hapi/joi": "17.1.1"
123
122
  }