@trustify-da/trustify-da-javascript-client 0.3.0-ea.e12bc82 → 0.3.0-ea.e5bb86c

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 (64) hide show
  1. package/README.md +191 -11
  2. package/dist/package.json +23 -10
  3. package/dist/src/analysis.d.ts +21 -5
  4. package/dist/src/analysis.js +74 -80
  5. package/dist/src/batch_opts.d.ts +24 -0
  6. package/dist/src/batch_opts.js +35 -0
  7. package/dist/src/cli.js +192 -8
  8. package/dist/src/cyclone_dx_sbom.d.ts +10 -2
  9. package/dist/src/cyclone_dx_sbom.js +32 -5
  10. package/dist/src/index.d.ts +128 -11
  11. package/dist/src/index.js +272 -7
  12. package/dist/src/license/index.d.ts +28 -0
  13. package/dist/src/license/index.js +100 -0
  14. package/dist/src/license/license_utils.d.ts +40 -0
  15. package/dist/src/license/license_utils.js +134 -0
  16. package/dist/src/license/licenses_api.d.ts +34 -0
  17. package/dist/src/license/licenses_api.js +98 -0
  18. package/dist/src/license/project_license.d.ts +20 -0
  19. package/dist/src/license/project_license.js +62 -0
  20. package/dist/src/oci_image/images.d.ts +4 -5
  21. package/dist/src/oci_image/utils.d.ts +4 -4
  22. package/dist/src/provider.d.ts +17 -5
  23. package/dist/src/provider.js +27 -5
  24. package/dist/src/providers/base_java.d.ts +3 -5
  25. package/dist/src/providers/base_javascript.d.ts +29 -7
  26. package/dist/src/providers/base_javascript.js +129 -22
  27. package/dist/src/providers/base_pyproject.d.ts +147 -0
  28. package/dist/src/providers/base_pyproject.js +279 -0
  29. package/dist/src/providers/golang_gomodules.d.ts +20 -13
  30. package/dist/src/providers/golang_gomodules.js +112 -114
  31. package/dist/src/providers/gomod_parser.d.ts +4 -0
  32. package/dist/src/providers/gomod_parser.js +16 -0
  33. package/dist/src/providers/java_gradle.d.ts +9 -3
  34. package/dist/src/providers/java_gradle.js +12 -2
  35. package/dist/src/providers/java_gradle_groovy.d.ts +1 -1
  36. package/dist/src/providers/java_gradle_kotlin.d.ts +1 -1
  37. package/dist/src/providers/java_maven.d.ts +12 -5
  38. package/dist/src/providers/java_maven.js +33 -5
  39. package/dist/src/providers/javascript_pnpm.d.ts +1 -1
  40. package/dist/src/providers/javascript_pnpm.js +2 -2
  41. package/dist/src/providers/manifest.d.ts +2 -0
  42. package/dist/src/providers/manifest.js +22 -4
  43. package/dist/src/providers/processors/yarn_berry_processor.js +82 -3
  44. package/dist/src/providers/python_controller.d.ts +5 -2
  45. package/dist/src/providers/python_controller.js +56 -58
  46. package/dist/src/providers/python_pip.d.ts +11 -4
  47. package/dist/src/providers/python_pip.js +47 -54
  48. package/dist/src/providers/python_poetry.d.ts +42 -0
  49. package/dist/src/providers/python_poetry.js +146 -0
  50. package/dist/src/providers/python_uv.d.ts +26 -0
  51. package/dist/src/providers/python_uv.js +118 -0
  52. package/dist/src/providers/requirements_parser.d.ts +6 -0
  53. package/dist/src/providers/requirements_parser.js +24 -0
  54. package/dist/src/providers/rust_cargo.d.ts +52 -0
  55. package/dist/src/providers/rust_cargo.js +614 -0
  56. package/dist/src/providers/tree-sitter-gomod.wasm +0 -0
  57. package/dist/src/providers/tree-sitter-requirements.wasm +0 -0
  58. package/dist/src/sbom.d.ts +10 -1
  59. package/dist/src/sbom.js +12 -2
  60. package/dist/src/tools.d.ts +22 -6
  61. package/dist/src/tools.js +56 -1
  62. package/dist/src/workspace.d.ts +61 -0
  63. package/dist/src/workspace.js +256 -0
  64. package/package.json +24 -11
package/README.md CHANGED
@@ -32,6 +32,11 @@ let stackAnalysis = await client.stackAnalysis('/path/to/pom.xml')
32
32
  let stackAnalysisHtml = await client.stackAnalysis('/path/to/pom.xml', true)
33
33
  // Get component analysis in JSON format
34
34
  let componentAnalysis = await client.componentAnalysis('/path/to/pom.xml')
35
+ // For monorepos, pass workspace root so the client finds the lock file
36
+ let monorepoOpts = { workspaceDir: '/path/to/workspace-root' }
37
+ let stackAnalysisMonorepo = await client.stackAnalysis('/path/to/package.json', false, monorepoOpts)
38
+ // Batch analysis for entire workspace (Cargo or JS/TS); optional parallel SBOM generation
39
+ let batchReport = await client.stackAnalysisBatch('/path/to/workspace-root', false, { batchConcurrency: 10 })
35
40
  // Get image analysis in JSON format
36
41
  let imageAnalysis = await client.imageAnalysis(['docker.io/library/node:18'])
37
42
  // Get image analysis in HTML format (string)
@@ -43,6 +48,21 @@ let imageAnalysisWithArch = await client.imageAnalysis(['httpd:2.4.49^^amd64'])
43
48
  ```
44
49
  </li>
45
50
  </ul>
51
+
52
+ <h3>License Detection</h3>
53
+ <p>
54
+ The client automatically detects your project's license with intelligent fallback:
55
+ </p>
56
+ <ul>
57
+ <li><strong>Manifest-first:</strong> For ecosystems with license support (Maven, JavaScript, Rust Cargo), reads from manifest file (<code>pom.xml</code>, <code>package.json</code>, <code>Cargo.toml</code>)</li>
58
+ <li><strong>LICENSE file fallback:</strong> If no license in manifest, or for ecosystems without license support (Gradle, Go, Python), automatically reads from <code>LICENSE</code>, <code>LICENSE.md</code>, or <code>LICENSE.txt</code></li>
59
+ <li><strong>SBOM integration:</strong> Detected licenses are included in generated SBOMs for all ecosystems</li>
60
+ <li><strong>SPDX support:</strong> Automatically detects common licenses (Apache-2.0, MIT, GPL, BSD) from LICENSE file content</li>
61
+ </ul>
62
+ <p>
63
+ See <a href="./docs/license-resolution-and-compliance.md">License Resolution and Compliance</a> for detailed documentation.
64
+ </p>
65
+
46
66
  <ul>
47
67
  <li>
48
68
  Use as ESM Module from Common-JS module
@@ -83,12 +103,14 @@ Use as CLI Script
83
103
  ```shell
84
104
  $ npx @trustify-da/trustify-da-javascript-client help
85
105
 
86
- Usage: trustify-da-javascript-client {component|stack|image|validate-token}
106
+ Usage: trustify-da-javascript-client {component|stack|image|validate-token|license}
87
107
 
88
108
  Commands:
89
- trustify-da-javascript-client stack </path/to/manifest> [--html|--summary] produce stack report for manifest path
90
- trustify-da-javascript-client component <path/to/manifest> [--summary] produce component report for a manifest type and content
109
+ trustify-da-javascript-client stack </path/to/manifest> [--workspace-dir <path>] [--html|--summary] produce stack report for manifest path
110
+ trustify-da-javascript-client stack-batch </path/to/workspace-root> [--html|--summary] produce stack report for all packages/crates in workspace
111
+ trustify-da-javascript-client component <path/to/manifest> [--workspace-dir <path>] produce component report for a manifest type and content
91
112
  trustify-da-javascript-client image <image-refs..> [--html|--summary] produce image analysis report for OCI image references
113
+ trustify-da-javascript-client license </path/to/manifest> display project license information from manifest and LICENSE file in JSON format
92
114
 
93
115
  Options:
94
116
  --help Show help [boolean]
@@ -105,9 +127,21 @@ $ npx @trustify-da/trustify-da-javascript-client stack /path/to/pom.xml --summar
105
127
  # get stack analysis in html format format
106
128
  $ npx @trustify-da/trustify-da-javascript-client stack /path/to/pom.xml --html
107
129
 
130
+ # get stack analysis for monorepo (lock file at workspace root)
131
+ $ npx @trustify-da/trustify-da-javascript-client stack /path/to/package.json --workspace-dir /path/to/workspace-root
132
+
108
133
  # get component analysis
109
134
  $ npx @trustify-da/trustify-da-javascript-client component /path/to/pom.xml
110
135
 
136
+ # get component analysis for monorepo
137
+ $ npx @trustify-da/trustify-da-javascript-client component /path/to/package.json -w /path/to/workspace-root
138
+
139
+ # batch stack analysis for entire workspace (Cargo or JS/TS)
140
+ $ npx @trustify-da/trustify-da-javascript-client stack-batch /path/to/workspace-root
141
+
142
+ # optional: extra discovery excludes (merged with defaults); repeat --ignore or use TRUSTIFY_DA_WORKSPACE_DISCOVERY_IGNORE
143
+ $ npx @trustify-da/trustify-da-javascript-client stack-batch /path/to/workspace-root --ignore '**/fixtures/**'
144
+
111
145
  # get image analysis in json format
112
146
  $ npx @trustify-da/trustify-da-javascript-client image docker.io/library/node:18
113
147
 
@@ -123,6 +157,9 @@ $ npx @trustify-da/trustify-da-javascript-client image docker.io/library/node:18
123
157
 
124
158
  # specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
125
159
  $ npx @trustify-da/trustify-da-javascript-client image httpd:2.4.49^^amd64
160
+
161
+ # get project license information
162
+ $ npx @trustify-da/trustify-da-javascript-client license /path/to/package.json
126
163
  ```
127
164
  </li>
128
165
 
@@ -143,9 +180,21 @@ $ trustify-da-javascript-client stack /path/to/pom.xml --summary
143
180
  # get stack analysis in html format format
144
181
  $ trustify-da-javascript-client stack /path/to/pom.xml --html
145
182
 
183
+ # get stack analysis for monorepo (lock file at workspace root)
184
+ $ trustify-da-javascript-client stack /path/to/package.json --workspace-dir /path/to/workspace-root
185
+
146
186
  # get component analysis
147
187
  $ trustify-da-javascript-client component /path/to/pom.xml
148
188
 
189
+ # get component analysis for monorepo
190
+ $ trustify-da-javascript-client component /path/to/package.json -w /path/to/workspace-root
191
+
192
+ # batch stack analysis for entire workspace
193
+ $ trustify-da-javascript-client stack-batch /path/to/workspace-root
194
+
195
+ # with extra discovery excludes
196
+ $ trustify-da-javascript-client stack-batch /path/to/workspace-root -i '**/vendor/**'
197
+
149
198
  # get image analysis in json format
150
199
  $ trustify-da-javascript-client image docker.io/library/node:18
151
200
 
@@ -161,6 +210,9 @@ $ trustify-da-javascript-client image docker.io/library/node:18 docker.io/librar
161
210
 
162
211
  # specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
163
212
  $ trustify-da-javascript-client image httpd:2.4.49^^amd64
213
+
214
+ # get project license information
215
+ $ trustify-da-javascript-client license /path/to/package.json
164
216
  ```
165
217
  </li>
166
218
  </ul>
@@ -172,9 +224,26 @@ $ trustify-da-javascript-client image httpd:2.4.49^^amd64
172
224
  <li><a href="https://www.javascript.com/">JavaScript</a> - <a href="https://pnpm.io/">pnpm</a></li>
173
225
  <li><a href="https://www.javascript.com/">JavaScript</a> - <a href="https://classic.yarnpkg.com/">Yarn Classic</a> / <a href="https://yarnpkg.com/">Yarn Berry</a></li>
174
226
  <li><a href="https://go.dev/">Golang</a> - <a href="https://go.dev/blog/using-go-modules/">Go Modules</a></li>
175
- <li><a href="https://www.python.org/">Python</a> - <a href="https://pypi.org/project/pip/">pip Installer</a></li>
227
+ <li><a href="https://www.python.org/">Python</a> - <a href="https://pypi.org/project/pip/">pip Installer</a> (<code>requirements.txt</code>)</li>
228
+ <li><a href="https://www.python.org/">Python</a> - <a href="https://python-poetry.org/">Poetry</a> / <a href="https://docs.astral.sh/uv/">uv</a> (<code>pyproject.toml</code>)</li>
176
229
  <li><a href="https://gradle.org/">Gradle (Groovy and Kotlin DSL)</a> - <a href="https://gradle.org/install/">Gradle Installation</a></li>
230
+ <li><a href="https://www.rust-lang.org/">Rust</a> - <a href="https://doc.rust-lang.org/cargo/">Cargo</a></li>
231
+ </ul>
232
+
233
+ <h3>License Detection</h3>
234
+ <p>
235
+ The client automatically detects your project's license with intelligent fallback:
236
+ </p>
237
+ <ul>
238
+ <li><strong>Manifest-first:</strong> For ecosystems with license support (Maven, JavaScript, Rust Cargo), reads from manifest file (<code>pom.xml</code>, <code>package.json</code>, <code>Cargo.toml</code>)</li>
239
+ <li><strong>LICENSE file fallback:</strong> If no license in manifest, or for ecosystems without license support (Gradle, Go, Python), automatically reads from <code>LICENSE</code>, <code>LICENSE.md</code>, or <code>LICENSE.txt</code></li>
240
+ <li><strong>SBOM integration:</strong> Detected licenses are included in generated SBOMs for all ecosystems</li>
241
+ <li><strong>SPDX support:</strong> Automatically detects common licenses (Apache-2.0, MIT, GPL, BSD) from LICENSE file content</li>
177
242
  </ul>
243
+ <p>
244
+ See <a href="./docs/license-resolution-and-compliance.md">License Resolution and Compliance</a> for detailed documentation.
245
+ </p>
246
+
178
247
 
179
248
  <h3>Excluding Packages</h3>
180
249
  <p>
@@ -219,8 +288,11 @@ Excluding a package from any analysis can be achieved by marking the package for
219
288
  ]
220
289
  }
221
290
  ```
291
+ </li>
292
+
293
+ <li>
294
+ <em>Golang</em> users can add in go.mod a comment with <code>// exhortignore</code> next to the package to be ignored, or to "piggyback" on existing comment ( e.g - <code>// indirect</code>), for example:
222
295
 
223
- <em>Golang</em> users can add in go.mod a comment with //exhortignore next to the package to be ignored, or to "piggyback" on existing comment ( e.g - //indirect) , for example:
224
296
  ```go
225
297
  module github.com/trustify-da/SaaSi/deployer
226
298
 
@@ -229,7 +301,7 @@ go 1.19
229
301
  require (
230
302
  github.com/gin-gonic/gin v1.9.1
231
303
  github.com/google/uuid v1.1.2
232
- github.com/jessevdk/go-flags v1.5.0 //exhortignore
304
+ github.com/jessevdk/go-flags v1.5.0 // exhortignore
233
305
  github.com/kr/pretty v0.3.1
234
306
  gopkg.in/yaml.v2 v2.4.0
235
307
  k8s.io/apimachinery v0.26.1
@@ -237,14 +309,20 @@ require (
237
309
  )
238
310
 
239
311
  require (
240
- github.com/davecgh/go-spew v1.1.1 // indirect exhortignore
312
+ github.com/davecgh/go-spew v1.1.1 // indirect; exhortignore
241
313
  github.com/emicklei/go-restful/v3 v3.9.0 // indirect
242
- github.com/go-logr/logr v1.2.3 // indirect //exhortignore
314
+ github.com/go-logr/logr v1.2.3 // indirect; exhortignore
243
315
 
244
316
  )
245
317
  ```
246
318
 
319
+ <b>NOTE</b>: It is important to format <code>exhortignore</code> markers on indirect dependencies as shown above, otherwise the Go tooling (as well as this library) may incorrectly parse dependencies marked as indirect as being direct dependencies instead.
320
+ </li>
321
+
322
+
323
+ <li>
247
324
  <em>Python pip</em> users can add in requirements.txt a comment with #exhortignore(or # exhortignore) to the right of the same artifact to be ignored, for example:
325
+
248
326
  ```properties
249
327
  anyio==3.6.2
250
328
  asgiref==3.4.1
@@ -275,11 +353,14 @@ Werkzeug==2.0.3
275
353
  zipp==3.6.0
276
354
 
277
355
  ```
356
+ </li>
278
357
 
358
+ <li>
279
359
  <em>Gradle</em> users can add in build.gradle a comment with //exhortignore next to the package to be ignored:
360
+
280
361
  ```build.gradle
281
362
  plugins {
282
- id 'java'
363
+ id 'java'
283
364
  }
284
365
 
285
366
  group = 'groupName'
@@ -297,9 +378,45 @@ test {
297
378
  }
298
379
  ```
299
380
 
300
- All of the 5 above examples are valid for marking a package to be ignored
301
- </li>
381
+ <em>Rust Cargo</em> users can add a comment with <code># trustify-da-ignore</code> (or <code># exhortignore</code>) in <em>Cargo.toml</em> next to the dependency to be ignored. This works for inline declarations, table-based declarations, and workspace-level dependency sections:
302
382
 
383
+ ```toml
384
+ [dependencies]
385
+ serde = "1.0" # trustify-da-ignore
386
+ tokio = { version = "1.35", features = ["full"] }
387
+
388
+ [dependencies.regex] # trustify-da-ignore
389
+ version = "1.10"
390
+
391
+ [workspace.dependencies]
392
+ log = "0.4" # trustify-da-ignore
393
+ ```
394
+
395
+
396
+ <em>Python pyproject.toml</em> users can add a comment with <code>#exhortignore</code> (or <code># trustify-da-ignore</code>) next to the dependency in <code>pyproject.toml</code>.
397
+
398
+ PEP 621 style (<code>[project]</code> dependencies):
399
+ ```toml
400
+ [project]
401
+ dependencies = [
402
+ "flask>=2.0.3",
403
+ "requests>=2.25.1",
404
+ "uvicorn>=0.17.0", #exhortignore
405
+ "click>=8.0.4", # trustify-da-ignore
406
+ ]
407
+ ```
408
+
409
+ Poetry style (<code>[tool.poetry.dependencies]</code>):
410
+ ```toml
411
+ [tool.poetry.dependencies]
412
+ flask = "^2.0.3"
413
+ requests = "^2.25.1"
414
+ uvicorn = "^0.17.0" #exhortignore
415
+ click = "^8.0.4" # trustify-da-ignore
416
+ ```
417
+
418
+ All of the above examples are valid for marking a package to be ignored
419
+ </li>
303
420
  </ul>
304
421
 
305
422
  <h3>Customization</h3>
@@ -328,7 +445,12 @@ let options = {
328
445
  'TRUSTIFY_DA_PIP3_PATH' : '/path/to/pip3',
329
446
  'TRUSTIFY_DA_PYTHON_PATH' : '/path/to/python',
330
447
  'TRUSTIFY_DA_PIP_PATH' : '/path/to/pip',
448
+ 'TRUSTIFY_DA_UV_PATH' : '/path/to/uv',
449
+ 'TRUSTIFY_DA_POETRY_PATH' : '/path/to/poetry',
331
450
  'TRUSTIFY_DA_GRADLE_PATH' : '/path/to/gradle',
451
+ 'TRUSTIFY_DA_CARGO_PATH' : '/path/to/cargo',
452
+ // Workspace root for monorepos (Cargo, npm/pnpm/yarn); lock file expected here
453
+ 'workspaceDir': '/path/to/workspace-root',
332
454
  // Configure proxy for all requests
333
455
  'TRUSTIFY_DA_PROXY_URL': 'http://proxy.example.com:8080'
334
456
  }
@@ -351,6 +473,21 @@ let imageAnalysisWithArch = await client.imageAnalysis(['httpd:2.4.49^^amd64'],
351
473
  **_Environment variables takes precedence._**
352
474
  </p>
353
475
 
476
+ <h4>Monorepo / Workspace Support</h4>
477
+ <p>
478
+ For monorepos (Cargo workspaces, npm/pnpm/yarn workspaces) where the lock file lives at the workspace root rather than next to the manifest, pass the workspace root via <code>workspaceDir</code> or <code>TRUSTIFY_DA_WORKSPACE_DIR</code>:
479
+ </p>
480
+ <ul>
481
+ <li><strong>Cargo:</strong> When set, the client checks only the given directory for <code>Cargo.lock</code> instead of walking up from the manifest.</li>
482
+ <li><strong>JavaScript (npm, pnpm, yarn):</strong> When set, the client looks for the lock file (<code>package-lock.json</code>, <code>pnpm-lock.yaml</code>, <code>yarn.lock</code>) at the workspace root.</li>
483
+ </ul>
484
+ <p>
485
+ Use <code>stackAnalysisBatch(workspaceRoot, html, opts)</code> to analyze all packages/crates in a workspace in one request. Supports Cargo workspaces and JS/TS workspaces (pnpm, npm, yarn). Optional <code>batchConcurrency</code> (or <code>TRUSTIFY_DA_BATCH_CONCURRENCY</code>) limits parallel SBOM generation (default 10). For JS/TS, each <code>package.json</code> must have non-empty <code>name</code> and <code>version</code>; invalid manifests are skipped (warnings). Per-manifest SBOM failures are skipped if at least one SBOM succeeds (unless <code>continueOnError: false</code>). Set <code>batchMetadata: true</code> (or <code>TRUSTIFY_DA_BATCH_METADATA</code>) to receive <code>{ analysis, metadata }</code> with <code>errors[]</code>. CLI: <code>stack-batch --metadata</code>, <code>--fail-fast</code>. See <a href="./docs/monorepo-implementation-plan.md">monorepo implementation plan</a> §2.3 and §3.5.
486
+ </p>
487
+ <p>
488
+ See <a href="./docs/vscode-extension-integration-requirements.md">VS Code Extension Integration Requirements</a> for integration details.
489
+ </p>
490
+
354
491
  <h4>Proxy Configuration</h4>
355
492
  <p>
356
493
  You can configure a proxy for all HTTP/HTTPS requests made by the API. This is useful when your environment requires going through a proxy to access external services.
@@ -372,6 +509,11 @@ const options = {
372
509
  The proxy URL should be in the format: `http://host:port` or `https://host:port`. The API will automatically use the appropriate protocol (HTTP or HTTPS) based on the proxy URL provided.
373
510
  </p>
374
511
 
512
+ <h4>License resolution and dependency license compliance</h4>
513
+ <p>
514
+ The client can resolve the <strong>project license</strong> from the manifest (e.g. <code>package.json</code> <code>license</code>, <code>pom.xml</code> <code>&lt;licenses&gt;</code>, <code>Cargo.toml</code> <code>license</code>) and from a <code>LICENSE</code> or <code>LICENSE.md</code> file in the project, and report when they differ. For <strong>component analysis</strong>, you can optionally run a license check: the client fetches dependency licenses from the backend (by purl) and reports dependencies whose licenses are incompatible with the project license. See <a href="docs/license-resolution-and-compliance.md">License resolution and compliance</a> for design and behavior. To disable the check on component analysis, set <code>TRUSTIFY_DA_LICENSE_CHECK=false</code> or pass <code>licenseCheck: false</code> in the options.
515
+ </p>
516
+
375
517
  <h4>Customizing Executables</h4>
376
518
  <p>
377
519
  This project uses each ecosystem's executable for creating dependency trees. These executables are expected to be
@@ -445,6 +587,26 @@ following keys for setting custom paths for the said executables.
445
587
  <td><em>gradle</em></td>
446
588
  <td>TRUSTIFY_DA_PREFER_GRADLEW</td>
447
589
  </tr>
590
+ <tr>
591
+ <td><a href="https://www.rust-lang.org/">Rust Cargo</a></td>
592
+ <td><em>cargo</em></td>
593
+ <td>TRUSTIFY_DA_CARGO_PATH</td>
594
+ </tr>
595
+ <tr>
596
+ <td><a href="https://docs.astral.sh/uv/">uv</a></td>
597
+ <td><em>uv</em></td>
598
+ <td>TRUSTIFY_DA_UV_PATH</td>
599
+ </tr>
600
+ <tr>
601
+ <td><a href="https://python-poetry.org/">Poetry</a></td>
602
+ <td><em>poetry</em></td>
603
+ <td>TRUSTIFY_DA_POETRY_PATH</td>
604
+ </tr>
605
+ <tr>
606
+ <td>Workspace root (monorepos)</td>
607
+ <td>—</td>
608
+ <td>workspaceDir / TRUSTIFY_DA_WORKSPACE_DIR</td>
609
+ </tr>
448
610
  </table>
449
611
 
450
612
  #### Match Manifest Versions Feature
@@ -493,6 +655,24 @@ TRUSTIFY_DA_GO_MVS_LOGIC_ENABLED=false
493
655
 
494
656
  #### Python Support
495
657
 
658
+ The client supports two Python manifest formats:
659
+
660
+ - **`requirements.txt`** — uses pip/pip3 to resolve dependencies
661
+ - **`pyproject.toml`** — uses [uv](https://docs.astral.sh/uv/) or [Poetry](https://python-poetry.org/) to resolve dependencies
662
+
663
+ ##### pyproject.toml
664
+
665
+ For `pyproject.toml` projects, the client detects which tool manages the project by checking for lock files:
666
+ - If `poetry.lock` is present and `[tool.poetry]` is defined, **Poetry** is used (`poetry show --tree` and `poetry show --all`)
667
+ - If `uv.lock` is present, **uv** is used (`uv export --format requirements.txt --frozen --no-hashes`)
668
+ - If neither lock file is found, an error is thrown
669
+
670
+ Both PEP 621 (`[project]` dependencies) and Poetry-style (`[tool.poetry.dependencies]`) are supported.
671
+
672
+ Custom executable paths can be set via `TRUSTIFY_DA_UV_PATH` and `TRUSTIFY_DA_POETRY_PATH`.
673
+
674
+ ##### requirements.txt
675
+
496
676
  By default, For python support, the api assumes that the package is installed using the pip/pip3 binary on the system PATH, or using the customized
497
677
  Binaries passed to environment variables. In any case, If the package is not installed , then an error will be thrown.
498
678
 
package/dist/package.json CHANGED
@@ -38,36 +38,49 @@
38
38
  "lint": "eslint src test --ext js",
39
39
  "lint:fix": "eslint src test --ext js --fix",
40
40
  "test": "c8 npm run tests",
41
- "tests": "mocha --config .mocharc.json --grep \".*analysis module.*\" --invert",
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
44
  "precompile": "rm -rf dist",
44
- "compile": "tsc -p tsconfig.json"
45
+ "compile": "tsc -p tsconfig.json",
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"
45
48
  },
46
49
  "dependencies": {
47
50
  "@babel/core": "^7.23.2",
48
- "@cyclonedx/cyclonedx-library": "~1.13.3",
51
+ "@cyclonedx/cyclonedx-library": "^6.13.0",
52
+ "eslint-import-resolver-typescript": "^4.4.4",
53
+ "fast-glob": "^3.3.3",
49
54
  "fast-toml": "^0.5.4",
50
- "fast-xml-parser": "^4.5.3",
55
+ "fast-xml-parser": "^5.3.4",
51
56
  "help": "^3.0.2",
52
57
  "https-proxy-agent": "^7.0.6",
53
- "node-fetch": "^2.7.0",
54
- "packageurl-js": "^1.0.2",
55
- "yargs": "^17.7.2"
58
+ "js-yaml": "^4.1.1",
59
+ "micromatch": "^4.0.8",
60
+ "node-fetch": "^3.3.2",
61
+ "p-limit": "^4.0.0",
62
+ "packageurl-js": "~1.0.2",
63
+ "smol-toml": "^1.6.0",
64
+ "tree-sitter-gomod": "github:strum355/tree-sitter-go-mod#56326f2ad478892ace58ff247a97d492a3cbcdda",
65
+ "tree-sitter-requirements": "github:Strum355/tree-sitter-requirements#d0261ee76b84253997fe70d7d397e78c006c3801",
66
+ "web-tree-sitter": "^0.26.7",
67
+ "yargs": "^18.0.0"
56
68
  },
57
69
  "devDependencies": {
58
70
  "@babel/core": "^7.23.2",
59
- "@trustify-da/trustify-da-api-model": "^2.0.1",
71
+ "@trustify-da/trustify-da-api-model": "^2.0.7",
60
72
  "@types/node": "^20.17.30",
61
73
  "@types/which": "^3.0.4",
62
74
  "babel-plugin-rewire": "^1.2.0",
63
- "c8": "^8.0.0",
75
+ "c8": "^11.0.0",
64
76
  "chai": "^4.3.7",
65
77
  "eslint": "^8.42.0",
78
+ "eslint-import-resolver-typescript": "^4.4.4",
66
79
  "eslint-plugin-editorconfig": "^4.0.3",
67
80
  "eslint-plugin-import": "^2.29.1",
68
81
  "esmock": "^2.6.2",
69
82
  "mocha": "^10.2.0",
70
- "msw": "^1.3.2",
83
+ "msw": "^2.12.7",
71
84
  "sinon": "^15.1.2",
72
85
  "sinon-chai": "^3.7.0",
73
86
  "typescript": "^5.1.3",
@@ -1,6 +1,9 @@
1
+ /** Media type for CycloneDX JSON batch payloads (batch-analysis API). */
2
+ export const CYCLONEDX_JSON_MEDIA_TYPE: "application/vnd.cyclonedx+json";
1
3
  declare namespace _default {
2
4
  export { requestComponent };
3
5
  export { requestStack };
6
+ export { requestStackBatch };
4
7
  export { requestImages };
5
8
  export { validateToken };
6
9
  }
@@ -13,7 +16,7 @@ export default _default;
13
16
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
14
17
  * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
15
18
  */
16
- declare function requestComponent(provider: import('./provider').Provider, manifest: string, url: string, opts?: import("index.js").Options | undefined): Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>;
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>;
17
20
  /**
18
21
  * Send a stack analysis request and get the report as 'text/html' or 'application/json'.
19
22
  * @param {import('./provider').Provider} provider - the provided data for constructing the request
@@ -23,7 +26,20 @@ declare function requestComponent(provider: import('./provider').Provider, manif
23
26
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
24
27
  * @returns {Promise<string|import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
25
28
  */
26
- declare function requestStack(provider: import('./provider').Provider, manifest: string, url: string, html?: boolean | undefined, opts?: import("index.js").Options | undefined): Promise<string | import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>;
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
+ /**
31
+ * Send a batch stack analysis request for multiple manifests (SBOMs keyed by purl).
32
+ * @param {Object.<string, object>} sbomByPurl - Map of root purl to CycloneDX SBOM object
33
+ * @param {string} url - the backend url
34
+ * @param {boolean} [html=false] - true returns HTML, false returns JSON
35
+ * @param {import("index.js").Options} [opts={}]
36
+ * @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
37
+ */
38
+ declare function requestStackBatch(sbomByPurl: {
39
+ [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
+ }>;
27
43
  /**
28
44
  *
29
45
  * @param {Array<string>} imageRefs
@@ -31,8 +47,8 @@ declare function requestStack(provider: import('./provider').Provider, manifest:
31
47
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
32
48
  * @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
33
49
  */
34
- declare function requestImages(imageRefs: Array<string>, url: string, html?: boolean, opts?: import("index.js").Options | undefined): Promise<string | {
35
- [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?: import("index.js").Options): Promise<string | {
51
+ [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
36
52
  }>;
37
53
  /**
38
54
  *
@@ -40,4 +56,4 @@ declare function requestImages(imageRefs: Array<string>, url: string, html?: boo
40
56
  * @param {import("index.js").Options} [opts={}] - optional various options to pass headers for t he validateToken Request
41
57
  * @return {Promise<number>} return the HTTP status Code of the response from the validate token request.
42
58
  */
43
- declare function validateToken(url: any, opts?: import("index.js").Options | undefined): Promise<number>;
59
+ declare function validateToken(url: any, opts?: import("index.js").Options): Promise<number>;