@trustify-da/trustify-da-javascript-client 0.3.0-ea.9988076 → 0.3.0-ea.9a6adf7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -10
- package/dist/package.json +27 -23
- package/dist/src/analysis.d.ts +21 -5
- package/dist/src/analysis.js +53 -4
- package/dist/src/batch_opts.d.ts +24 -0
- package/dist/src/batch_opts.js +35 -0
- package/dist/src/cli.js +171 -4
- package/dist/src/cyclone_dx_sbom.d.ts +14 -1
- package/dist/src/cyclone_dx_sbom.js +43 -8
- package/dist/src/index.d.ts +137 -6
- package/dist/src/index.js +350 -5
- package/dist/src/license/index.d.ts +3 -3
- package/dist/src/license/index.js +4 -1
- package/dist/src/license/license_utils.js +4 -1
- package/dist/src/license/licenses_api.d.ts +2 -2
- package/dist/src/oci_image/images.d.ts +1 -1
- package/dist/src/oci_image/utils.d.ts +5 -5
- package/dist/src/oci_image/utils.js +11 -2
- package/dist/src/provider.d.ts +8 -4
- package/dist/src/provider.js +13 -4
- package/dist/src/providers/base_java.d.ts +14 -12
- package/dist/src/providers/base_java.js +18 -44
- package/dist/src/providers/base_javascript.d.ts +37 -10
- package/dist/src/providers/base_javascript.js +108 -20
- package/dist/src/providers/base_pyproject.d.ts +158 -0
- package/dist/src/providers/base_pyproject.js +322 -0
- package/dist/src/providers/golang_gomodules.d.ts +23 -13
- package/dist/src/providers/golang_gomodules.js +165 -119
- package/dist/src/providers/gomod_parser.d.ts +4 -0
- package/dist/src/providers/gomod_parser.js +16 -0
- package/dist/src/providers/java_gradle.d.ts +19 -0
- package/dist/src/providers/java_gradle.js +116 -2
- package/dist/src/providers/java_gradle_groovy.d.ts +1 -1
- package/dist/src/providers/java_gradle_kotlin.d.ts +1 -1
- package/dist/src/providers/java_maven.d.ts +10 -2
- package/dist/src/providers/java_maven.js +165 -1
- package/dist/src/providers/javascript_bun.d.ts +10 -0
- package/dist/src/providers/javascript_bun.js +100 -0
- package/dist/src/providers/javascript_npm.d.ts +6 -0
- package/dist/src/providers/javascript_npm.js +21 -0
- package/dist/src/providers/javascript_pnpm.d.ts +1 -1
- package/dist/src/providers/javascript_pnpm.js +8 -4
- package/dist/src/providers/manifest.d.ts +2 -0
- package/dist/src/providers/manifest.js +22 -4
- package/dist/src/providers/marker_evaluator.d.ts +14 -0
- package/dist/src/providers/marker_evaluator.js +191 -0
- package/dist/src/providers/processors/yarn_berry_processor.d.ts +2 -2
- package/dist/src/providers/processors/yarn_berry_processor.js +88 -5
- package/dist/src/providers/processors/yarn_classic_processor.d.ts +2 -2
- package/dist/src/providers/python_controller.d.ts +5 -1
- package/dist/src/providers/python_controller.js +65 -7
- package/dist/src/providers/python_pip.d.ts +5 -0
- package/dist/src/providers/python_pip.js +6 -6
- package/dist/src/providers/python_pip_pyproject.d.ts +61 -0
- package/dist/src/providers/python_pip_pyproject.js +146 -0
- package/dist/src/providers/python_poetry.d.ts +98 -0
- package/dist/src/providers/python_poetry.js +286 -0
- package/dist/src/providers/python_uv.d.ts +46 -0
- package/dist/src/providers/python_uv.js +269 -0
- package/dist/src/providers/rust_cargo.d.ts +12 -3
- package/dist/src/providers/rust_cargo.js +41 -6
- package/dist/src/providers/tree-sitter-gomod.wasm +0 -0
- package/dist/src/sbom.d.ts +14 -1
- package/dist/src/sbom.js +13 -2
- package/dist/src/tools.d.ts +28 -2
- package/dist/src/tools.js +58 -0
- package/dist/src/workspace.d.ts +70 -0
- package/dist/src/workspace.js +256 -0
- package/package.json +28 -24
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)
|
|
@@ -101,8 +106,9 @@ $ npx @trustify-da/trustify-da-javascript-client help
|
|
|
101
106
|
Usage: trustify-da-javascript-client {component|stack|image|validate-token|license}
|
|
102
107
|
|
|
103
108
|
Commands:
|
|
104
|
-
trustify-da-javascript-client stack </path/to/manifest> [--html|--summary] produce stack report for manifest path
|
|
105
|
-
trustify-da-javascript-client
|
|
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
|
|
106
112
|
trustify-da-javascript-client image <image-refs..> [--html|--summary] produce image analysis report for OCI image references
|
|
107
113
|
trustify-da-javascript-client license </path/to/manifest> display project license information from manifest and LICENSE file in JSON format
|
|
108
114
|
|
|
@@ -121,9 +127,21 @@ $ npx @trustify-da/trustify-da-javascript-client stack /path/to/pom.xml --summar
|
|
|
121
127
|
# get stack analysis in html format format
|
|
122
128
|
$ npx @trustify-da/trustify-da-javascript-client stack /path/to/pom.xml --html
|
|
123
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
|
+
|
|
124
133
|
# get component analysis
|
|
125
134
|
$ npx @trustify-da/trustify-da-javascript-client component /path/to/pom.xml
|
|
126
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
|
+
|
|
127
145
|
# get image analysis in json format
|
|
128
146
|
$ npx @trustify-da/trustify-da-javascript-client image docker.io/library/node:18
|
|
129
147
|
|
|
@@ -162,9 +180,21 @@ $ trustify-da-javascript-client stack /path/to/pom.xml --summary
|
|
|
162
180
|
# get stack analysis in html format format
|
|
163
181
|
$ trustify-da-javascript-client stack /path/to/pom.xml --html
|
|
164
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
|
+
|
|
165
186
|
# get component analysis
|
|
166
187
|
$ trustify-da-javascript-client component /path/to/pom.xml
|
|
167
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
|
+
|
|
168
198
|
# get image analysis in json format
|
|
169
199
|
$ trustify-da-javascript-client image docker.io/library/node:18
|
|
170
200
|
|
|
@@ -194,7 +224,8 @@ $ trustify-da-javascript-client license /path/to/package.json
|
|
|
194
224
|
<li><a href="https://www.javascript.com/">JavaScript</a> - <a href="https://pnpm.io/">pnpm</a></li>
|
|
195
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>
|
|
196
226
|
<li><a href="https://go.dev/">Golang</a> - <a href="https://go.dev/blog/using-go-modules/">Go Modules</a></li>
|
|
197
|
-
<li><a href="https://www.python.org/">Python</a> - <a href="https://pypi.org/project/pip/">pip Installer</a
|
|
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>
|
|
198
229
|
<li><a href="https://gradle.org/">Gradle (Groovy and Kotlin DSL)</a> - <a href="https://gradle.org/install/">Gradle Installation</a></li>
|
|
199
230
|
<li><a href="https://www.rust-lang.org/">Rust</a> - <a href="https://doc.rust-lang.org/cargo/">Cargo</a></li>
|
|
200
231
|
</ul>
|
|
@@ -257,8 +288,11 @@ Excluding a package from any analysis can be achieved by marking the package for
|
|
|
257
288
|
]
|
|
258
289
|
}
|
|
259
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:
|
|
260
295
|
|
|
261
|
-
<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:
|
|
262
296
|
```go
|
|
263
297
|
module github.com/trustify-da/SaaSi/deployer
|
|
264
298
|
|
|
@@ -267,7 +301,7 @@ go 1.19
|
|
|
267
301
|
require (
|
|
268
302
|
github.com/gin-gonic/gin v1.9.1
|
|
269
303
|
github.com/google/uuid v1.1.2
|
|
270
|
-
github.com/jessevdk/go-flags v1.5.0 //exhortignore
|
|
304
|
+
github.com/jessevdk/go-flags v1.5.0 // exhortignore
|
|
271
305
|
github.com/kr/pretty v0.3.1
|
|
272
306
|
gopkg.in/yaml.v2 v2.4.0
|
|
273
307
|
k8s.io/apimachinery v0.26.1
|
|
@@ -275,14 +309,20 @@ require (
|
|
|
275
309
|
)
|
|
276
310
|
|
|
277
311
|
require (
|
|
278
|
-
github.com/davecgh/go-spew v1.1.1 // indirect exhortignore
|
|
312
|
+
github.com/davecgh/go-spew v1.1.1 // indirect; exhortignore
|
|
279
313
|
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
|
|
280
|
-
github.com/go-logr/logr v1.2.3 // indirect
|
|
314
|
+
github.com/go-logr/logr v1.2.3 // indirect; exhortignore
|
|
281
315
|
|
|
282
316
|
)
|
|
283
317
|
```
|
|
284
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>
|
|
285
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
|
+
|
|
286
326
|
```properties
|
|
287
327
|
anyio==3.6.2
|
|
288
328
|
asgiref==3.4.1
|
|
@@ -313,11 +353,14 @@ Werkzeug==2.0.3
|
|
|
313
353
|
zipp==3.6.0
|
|
314
354
|
|
|
315
355
|
```
|
|
356
|
+
</li>
|
|
316
357
|
|
|
358
|
+
<li>
|
|
317
359
|
<em>Gradle</em> users can add in build.gradle a comment with //exhortignore next to the package to be ignored:
|
|
360
|
+
|
|
318
361
|
```build.gradle
|
|
319
362
|
plugins {
|
|
320
|
-
id 'java'
|
|
363
|
+
id 'java'
|
|
321
364
|
}
|
|
322
365
|
|
|
323
366
|
group = 'groupName'
|
|
@@ -349,9 +392,31 @@ version = "1.10"
|
|
|
349
392
|
log = "0.4" # trustify-da-ignore
|
|
350
393
|
```
|
|
351
394
|
|
|
352
|
-
All of the 6 above examples are valid for marking a package to be ignored
|
|
353
|
-
</li>
|
|
354
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>
|
|
355
420
|
</ul>
|
|
356
421
|
|
|
357
422
|
<h3>Customization</h3>
|
|
@@ -380,8 +445,12 @@ let options = {
|
|
|
380
445
|
'TRUSTIFY_DA_PIP3_PATH' : '/path/to/pip3',
|
|
381
446
|
'TRUSTIFY_DA_PYTHON_PATH' : '/path/to/python',
|
|
382
447
|
'TRUSTIFY_DA_PIP_PATH' : '/path/to/pip',
|
|
448
|
+
'TRUSTIFY_DA_UV_PATH' : '/path/to/uv',
|
|
449
|
+
'TRUSTIFY_DA_POETRY_PATH' : '/path/to/poetry',
|
|
383
450
|
'TRUSTIFY_DA_GRADLE_PATH' : '/path/to/gradle',
|
|
384
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',
|
|
385
454
|
// Configure proxy for all requests
|
|
386
455
|
'TRUSTIFY_DA_PROXY_URL': 'http://proxy.example.com:8080'
|
|
387
456
|
}
|
|
@@ -404,6 +473,21 @@ let imageAnalysisWithArch = await client.imageAnalysis(['httpd:2.4.49^^amd64'],
|
|
|
404
473
|
**_Environment variables takes precedence._**
|
|
405
474
|
</p>
|
|
406
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
|
+
|
|
407
491
|
<h4>Proxy Configuration</h4>
|
|
408
492
|
<p>
|
|
409
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.
|
|
@@ -508,6 +592,21 @@ following keys for setting custom paths for the said executables.
|
|
|
508
592
|
<td><em>cargo</em></td>
|
|
509
593
|
<td>TRUSTIFY_DA_CARGO_PATH</td>
|
|
510
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>
|
|
511
610
|
</table>
|
|
512
611
|
|
|
513
612
|
#### Match Manifest Versions Feature
|
|
@@ -556,6 +655,24 @@ TRUSTIFY_DA_GO_MVS_LOGIC_ENABLED=false
|
|
|
556
655
|
|
|
557
656
|
#### Python Support
|
|
558
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
|
+
|
|
559
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
|
|
560
677
|
Binaries passed to environment variables. In any case, If the package is not installed , then an error will be thrown.
|
|
561
678
|
|
package/dist/package.json
CHANGED
|
@@ -35,51 +35,57 @@
|
|
|
35
35
|
"config/**/*"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"lint": "eslint src test
|
|
39
|
-
"lint:fix": "eslint src test --
|
|
38
|
+
"lint": "eslint src test",
|
|
39
|
+
"lint:fix": "eslint src test --fix",
|
|
40
40
|
"test": "c8 npm run tests",
|
|
41
|
-
"tests": "mocha --config .mocharc.json
|
|
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",
|
|
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",
|
|
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"
|
|
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"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@babel/core": "^7.23.2",
|
|
51
|
-
"@cyclonedx/cyclonedx-library": "^
|
|
51
|
+
"@cyclonedx/cyclonedx-library": "^10.0.0",
|
|
52
52
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
53
|
-
"fast-
|
|
53
|
+
"fast-glob": "^3.3.3",
|
|
54
54
|
"fast-xml-parser": "^5.3.4",
|
|
55
55
|
"help": "^3.0.2",
|
|
56
|
-
"https-proxy-agent": "^
|
|
56
|
+
"https-proxy-agent": "^9.0.0",
|
|
57
|
+
"js-yaml": "^4.1.1",
|
|
58
|
+
"jsonc-parser": "^3.3.1",
|
|
59
|
+
"micromatch": "^4.0.8",
|
|
57
60
|
"node-fetch": "^3.3.2",
|
|
61
|
+
"p-limit": "^7.3.0",
|
|
58
62
|
"packageurl-js": "~1.0.2",
|
|
59
63
|
"smol-toml": "^1.6.0",
|
|
64
|
+
"tree-sitter-gomod": "github:strum355/tree-sitter-go-mod#56326f2ad478892ace58ff247a97d492a3cbcdda",
|
|
60
65
|
"tree-sitter-requirements": "github:Strum355/tree-sitter-requirements#d0261ee76b84253997fe70d7d397e78c006c3801",
|
|
61
|
-
"web-tree-sitter": "^0.26.
|
|
66
|
+
"web-tree-sitter": "^0.26.7",
|
|
62
67
|
"yargs": "^18.0.0"
|
|
63
68
|
},
|
|
64
69
|
"devDependencies": {
|
|
65
70
|
"@babel/core": "^7.23.2",
|
|
66
|
-
"@trustify-da/trustify-da-api-model": "^2.0.
|
|
67
|
-
"@types/node": "^
|
|
71
|
+
"@trustify-da/trustify-da-api-model": "^2.0.8",
|
|
72
|
+
"@types/node": "^25.9.1",
|
|
68
73
|
"@types/which": "^3.0.4",
|
|
69
74
|
"babel-plugin-rewire": "^1.2.0",
|
|
70
75
|
"c8": "^11.0.0",
|
|
71
|
-
"chai": "^
|
|
72
|
-
"eslint": "^
|
|
76
|
+
"chai": "^6.2.2",
|
|
77
|
+
"@eslint/js": "^10.0.0",
|
|
78
|
+
"eslint": "^10.4.1",
|
|
73
79
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
74
|
-
"eslint-plugin-
|
|
75
|
-
"
|
|
80
|
+
"eslint-plugin-import-x": "^4.16.2",
|
|
81
|
+
"globals": "^17.6.0",
|
|
76
82
|
"esmock": "^2.6.2",
|
|
77
|
-
"mocha": "^
|
|
83
|
+
"mocha": "^11.7.6",
|
|
78
84
|
"msw": "^2.12.7",
|
|
79
|
-
"sinon": "^
|
|
80
|
-
"sinon-chai": "^
|
|
81
|
-
"typescript": "^
|
|
82
|
-
"which": "^
|
|
85
|
+
"sinon": "^22.0.0",
|
|
86
|
+
"sinon-chai": "^4.0.1",
|
|
87
|
+
"typescript": "^6.0.3",
|
|
88
|
+
"which": "^7.0.0"
|
|
83
89
|
},
|
|
84
90
|
"mocha": {
|
|
85
91
|
"check-leaks": false,
|
|
@@ -107,12 +113,10 @@
|
|
|
107
113
|
"reporter": [
|
|
108
114
|
"html",
|
|
109
115
|
"json",
|
|
116
|
+
"lcov",
|
|
110
117
|
"text"
|
|
111
118
|
]
|
|
112
119
|
},
|
|
113
|
-
"eslintIgnore": [
|
|
114
|
-
"index.js"
|
|
115
|
-
],
|
|
116
120
|
"resolutions": {
|
|
117
121
|
"@hapi/joi": "17.1.1"
|
|
118
122
|
}
|
package/dist/src/analysis.d.ts
CHANGED
|
@@ -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:
|
|
19
|
+
declare function requestComponent(provider: any, manifest: string, url: string, opts?: any): Promise<any>;
|
|
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:
|
|
29
|
+
declare function requestStack(provider: any, manifest: string, url: string, html?: boolean, opts?: any): Promise<string | any>;
|
|
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]: object;
|
|
40
|
+
}, url: string, html?: boolean, opts?: any): Promise<string | {
|
|
41
|
+
[x: string]: any;
|
|
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?:
|
|
35
|
-
[x: string]:
|
|
50
|
+
declare function requestImages(imageRefs: Array<string>, url: string, html?: boolean, opts?: any): Promise<string | {
|
|
51
|
+
[x: string]: any;
|
|
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?:
|
|
59
|
+
declare function validateToken(url: any, opts?: any): Promise<number>;
|
package/dist/src/analysis.js
CHANGED
|
@@ -4,7 +4,9 @@ import { EOL } from "os";
|
|
|
4
4
|
import { runLicenseCheck } from "./license/index.js";
|
|
5
5
|
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
|
+
export const CYCLONEDX_JSON_MEDIA_TYPE = 'application/vnd.cyclonedx+json';
|
|
9
|
+
export default { requestComponent, requestStack, requestStackBatch, requestImages, validateToken };
|
|
8
10
|
/**
|
|
9
11
|
* Send a stack analysis request and get the report as 'text/html' or 'application/json'.
|
|
10
12
|
* @param {import('./provider').Provider} provider - the provided data for constructing the request
|
|
@@ -124,6 +126,52 @@ async function requestComponent(provider, manifest, url, opts = {}) {
|
|
|
124
126
|
}
|
|
125
127
|
return Promise.resolve(result);
|
|
126
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Send a batch stack analysis request for multiple manifests (SBOMs keyed by purl).
|
|
131
|
+
* @param {Object.<string, object>} sbomByPurl - Map of root purl to CycloneDX SBOM object
|
|
132
|
+
* @param {string} url - the backend url
|
|
133
|
+
* @param {boolean} [html=false] - true returns HTML, false returns JSON
|
|
134
|
+
* @param {import("index.js").Options} [opts={}]
|
|
135
|
+
* @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
|
|
136
|
+
*/
|
|
137
|
+
async function requestStackBatch(sbomByPurl, url, html = false, opts = {}) {
|
|
138
|
+
const finalUrl = new URL(`${url}/api/v5/batch-analysis`);
|
|
139
|
+
if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
|
|
140
|
+
finalUrl.searchParams.append('recommend', 'false');
|
|
141
|
+
}
|
|
142
|
+
const fetchOptions = addProxyAgent({
|
|
143
|
+
method: 'POST',
|
|
144
|
+
headers: {
|
|
145
|
+
'Accept': html ? 'text/html' : 'application/json',
|
|
146
|
+
'Content-Type': CYCLONEDX_JSON_MEDIA_TYPE,
|
|
147
|
+
...getTokenHeaders(opts)
|
|
148
|
+
},
|
|
149
|
+
body: JSON.stringify(sbomByPurl)
|
|
150
|
+
}, opts);
|
|
151
|
+
const resp = await fetch(finalUrl, fetchOptions);
|
|
152
|
+
if (resp.status === 200) {
|
|
153
|
+
let result;
|
|
154
|
+
if (!html) {
|
|
155
|
+
result = await resp.json();
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
result = await resp.text();
|
|
159
|
+
}
|
|
160
|
+
if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
|
|
161
|
+
const exRequestId = resp.headers.get("ex-request-id");
|
|
162
|
+
if (exRequestId) {
|
|
163
|
+
console.log("Unique Identifier associated with this request - ex-request-id=" + exRequestId);
|
|
164
|
+
}
|
|
165
|
+
console.log("Response body received from Trustify DA backend server : " + EOL + EOL);
|
|
166
|
+
console.log(JSON.stringify(result, null, 4));
|
|
167
|
+
console.log("Ending time of sending batch stack analysis request to Trustify DA backend server= " + new Date());
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
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()}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
127
175
|
/**
|
|
128
176
|
*
|
|
129
177
|
* @param {Array<string>} imageRefs
|
|
@@ -141,15 +189,16 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
|
|
|
141
189
|
if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
|
|
142
190
|
finalUrl.searchParams.append('recommend', 'false');
|
|
143
191
|
}
|
|
144
|
-
const
|
|
192
|
+
const fetchOptions = addProxyAgent({
|
|
145
193
|
method: 'POST',
|
|
146
194
|
headers: {
|
|
147
195
|
'Accept': html ? 'text/html' : 'application/json',
|
|
148
|
-
'Content-Type':
|
|
196
|
+
'Content-Type': CYCLONEDX_JSON_MEDIA_TYPE,
|
|
149
197
|
...getTokenHeaders(opts)
|
|
150
198
|
},
|
|
151
199
|
body: JSON.stringify(imageSboms),
|
|
152
|
-
});
|
|
200
|
+
}, opts);
|
|
201
|
+
const resp = await fetch(finalUrl, fetchOptions);
|
|
153
202
|
if (resp.status === 200) {
|
|
154
203
|
let result;
|
|
155
204
|
if (!html) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether to skip failed manifests and continue (default), or fail on first SBOM/validation error.
|
|
3
|
+
* `opts.continueOnError` overrides; env `TRUSTIFY_DA_CONTINUE_ON_ERROR=false` disables continuation.
|
|
4
|
+
*
|
|
5
|
+
* @param {{ continueOnError?: boolean, TRUSTIFY_DA_CONTINUE_ON_ERROR?: string, [key: string]: unknown }} [opts={}]
|
|
6
|
+
* @returns {boolean} true = collect errors (default), false = fail-fast
|
|
7
|
+
*/
|
|
8
|
+
export function resolveContinueOnError(opts?: {
|
|
9
|
+
continueOnError?: boolean;
|
|
10
|
+
TRUSTIFY_DA_CONTINUE_ON_ERROR?: string;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* When true, `stackAnalysisBatch` returns `{ analysis, metadata }` instead of the backend response only.
|
|
15
|
+
* `opts.batchMetadata` overrides; env `TRUSTIFY_DA_BATCH_METADATA=true` enables.
|
|
16
|
+
*
|
|
17
|
+
* @param {{ batchMetadata?: boolean, TRUSTIFY_DA_BATCH_METADATA?: string, [key: string]: unknown }} [opts={}]
|
|
18
|
+
* @returns {boolean}
|
|
19
|
+
*/
|
|
20
|
+
export function resolveBatchMetadata(opts?: {
|
|
21
|
+
batchMetadata?: boolean;
|
|
22
|
+
TRUSTIFY_DA_BATCH_METADATA?: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}): boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getCustom } from './tools.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether to skip failed manifests and continue (default), or fail on first SBOM/validation error.
|
|
4
|
+
* `opts.continueOnError` overrides; env `TRUSTIFY_DA_CONTINUE_ON_ERROR=false` disables continuation.
|
|
5
|
+
*
|
|
6
|
+
* @param {{ continueOnError?: boolean, TRUSTIFY_DA_CONTINUE_ON_ERROR?: string, [key: string]: unknown }} [opts={}]
|
|
7
|
+
* @returns {boolean} true = collect errors (default), false = fail-fast
|
|
8
|
+
*/
|
|
9
|
+
export function resolveContinueOnError(opts = {}) {
|
|
10
|
+
if (typeof opts.continueOnError === 'boolean') {
|
|
11
|
+
return opts.continueOnError;
|
|
12
|
+
}
|
|
13
|
+
const v = getCustom('TRUSTIFY_DA_CONTINUE_ON_ERROR', null, opts);
|
|
14
|
+
if (v != null && String(v).trim() !== '') {
|
|
15
|
+
return String(v).toLowerCase() !== 'false';
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* When true, `stackAnalysisBatch` returns `{ analysis, metadata }` instead of the backend response only.
|
|
21
|
+
* `opts.batchMetadata` overrides; env `TRUSTIFY_DA_BATCH_METADATA=true` enables.
|
|
22
|
+
*
|
|
23
|
+
* @param {{ batchMetadata?: boolean, TRUSTIFY_DA_BATCH_METADATA?: string, [key: string]: unknown }} [opts={}]
|
|
24
|
+
* @returns {boolean}
|
|
25
|
+
*/
|
|
26
|
+
export function resolveBatchMetadata(opts = {}) {
|
|
27
|
+
if (typeof opts.batchMetadata === 'boolean') {
|
|
28
|
+
return opts.batchMetadata;
|
|
29
|
+
}
|
|
30
|
+
const v = getCustom('TRUSTIFY_DA_BATCH_METADATA', null, opts);
|
|
31
|
+
if (v != null && String(v).trim() !== '') {
|
|
32
|
+
return String(v).toLowerCase() === 'true';
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|