@trustify-da/trustify-da-javascript-client 0.3.0-ea.b8af0f8 → 0.3.0-ea.bdaadb2
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 +250 -11
- package/dist/package.json +33 -25
- package/dist/src/analysis.d.ts +14 -7
- package/dist/src/analysis.js +32 -15
- package/dist/src/cli.js +156 -3
- package/dist/src/cyclone_dx_sbom.d.ts +27 -1
- package/dist/src/cyclone_dx_sbom.js +82 -9
- package/dist/src/index.d.ts +86 -11
- package/dist/src/index.js +102 -30
- 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/images.js +15 -1
- package/dist/src/oci_image/utils.d.ts +5 -5
- package/dist/src/oci_image/utils.js +11 -2
- package/dist/src/package_version.d.ts +8 -0
- package/dist/src/package_version.js +31 -0
- package/dist/src/provider.d.ts +4 -3
- package/dist/src/provider.js +12 -2
- package/dist/src/providers/base_java.d.ts +67 -12
- package/dist/src/providers/base_java.js +82 -61
- package/dist/src/providers/base_javascript.d.ts +74 -9
- package/dist/src/providers/base_javascript.js +149 -9
- package/dist/src/providers/base_pyproject.d.ts +158 -0
- package/dist/src/providers/base_pyproject.js +322 -0
- package/dist/src/providers/containerfile_parser.d.ts +5 -0
- package/dist/src/providers/containerfile_parser.js +20 -0
- package/dist/src/providers/golang_gomodules.d.ts +23 -13
- package/dist/src/providers/golang_gomodules.js +207 -120
- 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 +67 -0
- package/dist/src/providers/java_gradle.js +310 -17
- 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 +38 -5
- package/dist/src/providers/java_maven.js +261 -8
- package/dist/src/providers/javascript_bun.d.ts +22 -0
- package/dist/src/providers/javascript_bun.js +141 -0
- package/dist/src/providers/javascript_npm.d.ts +19 -0
- package/dist/src/providers/javascript_npm.js +61 -1
- package/dist/src/providers/javascript_pnpm.d.ts +13 -0
- package/dist/src/providers/javascript_pnpm.js +53 -3
- package/dist/src/providers/javascript_yarn.d.ts +12 -0
- package/dist/src/providers/javascript_yarn.js +75 -2
- 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/oci_dockerfile.d.ts +51 -0
- package/dist/src/providers/oci_dockerfile.js +177 -0
- package/dist/src/providers/processors/yarn_berry_processor.d.ts +6 -2
- package/dist/src/providers/processors/yarn_berry_processor.js +91 -7
- package/dist/src/providers/processors/yarn_classic_processor.d.ts +6 -2
- package/dist/src/providers/processors/yarn_classic_processor.js +8 -6
- package/dist/src/providers/python_controller.d.ts +5 -1
- package/dist/src/providers/python_controller.js +69 -8
- 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 +6 -2
- package/dist/src/providers/rust_cargo.js +101 -33
- package/dist/src/providers/tree-sitter-containerfile.wasm +0 -0
- package/dist/src/providers/tree-sitter-gomod.wasm +0 -0
- package/dist/src/remediate.d.ts +21 -0
- package/dist/src/remediate.js +149 -0
- package/dist/src/remediation.d.ts +57 -0
- package/dist/src/remediation.js +436 -0
- package/dist/src/remediation_report.d.ts +40 -0
- package/dist/src/remediation_report.js +159 -0
- package/dist/src/sbom.d.ts +25 -1
- package/dist/src/sbom.js +23 -2
- package/dist/src/tools.d.ts +28 -2
- package/dist/src/tools.js +82 -1
- package/dist/src/updaters/maven_updater.d.ts +26 -0
- package/dist/src/updaters/maven_updater.js +322 -0
- package/dist/src/updaters/toml_updater.d.ts +33 -0
- package/dist/src/updaters/toml_updater.js +244 -0
- package/dist/src/workspace.d.ts +9 -0
- package/dist/src/workspace.js +1 -1
- package/package.json +34 -26
package/README.md
CHANGED
|
@@ -103,14 +103,17 @@ Use as CLI Script
|
|
|
103
103
|
```shell
|
|
104
104
|
$ npx @trustify-da/trustify-da-javascript-client help
|
|
105
105
|
|
|
106
|
-
Usage: trustify-da-javascript-client {component|stack|image|validate-token|license}
|
|
106
|
+
Usage: trustify-da-javascript-client {component|stack|stack-batch|image|validate-token|license|sbom|remediate}
|
|
107
107
|
|
|
108
108
|
Commands:
|
|
109
109
|
trustify-da-javascript-client stack </path/to/manifest> [--workspace-dir <path>] [--html|--summary] produce stack report for manifest path
|
|
110
110
|
trustify-da-javascript-client stack-batch </path/to/workspace-root> [--html|--summary] produce stack report for all packages/crates in workspace
|
|
111
111
|
trustify-da-javascript-client component <path/to/manifest> [--workspace-dir <path>] produce component report for a manifest type and content
|
|
112
112
|
trustify-da-javascript-client image <image-refs..> [--html|--summary] produce image analysis report for OCI image references
|
|
113
|
+
trustify-da-javascript-client validate-token <token-provider> [--token-value <value>] validate input token if authentic and authorized
|
|
113
114
|
trustify-da-javascript-client license </path/to/manifest> display project license information from manifest and LICENSE file in JSON format
|
|
115
|
+
trustify-da-javascript-client sbom </path/to/manifest> [--output <file>] generate a CycloneDX SBOM from a manifest file
|
|
116
|
+
trustify-da-javascript-client remediate <path> [--dry-run] [--providers <list>] [--sources <list>] [--group-by <strategy>] scan and apply vulnerability remediations
|
|
114
117
|
|
|
115
118
|
Options:
|
|
116
119
|
--help Show help [boolean]
|
|
@@ -160,6 +163,27 @@ $ npx @trustify-da/trustify-da-javascript-client image httpd:2.4.49^^amd64
|
|
|
160
163
|
|
|
161
164
|
# get project license information
|
|
162
165
|
$ npx @trustify-da/trustify-da-javascript-client license /path/to/package.json
|
|
166
|
+
|
|
167
|
+
# generate a CycloneDX SBOM from a manifest file
|
|
168
|
+
$ npx @trustify-da/trustify-da-javascript-client sbom /path/to/pom.xml
|
|
169
|
+
|
|
170
|
+
# generate SBOM and write to a file
|
|
171
|
+
$ npx @trustify-da/trustify-da-javascript-client sbom /path/to/pom.xml --output sbom.json
|
|
172
|
+
|
|
173
|
+
# scan a manifest and apply vulnerability remediations
|
|
174
|
+
$ npx @trustify-da/trustify-da-javascript-client remediate /path/to/pom.xml
|
|
175
|
+
|
|
176
|
+
# preview remediations without modifying files
|
|
177
|
+
$ npx @trustify-da/trustify-da-javascript-client remediate /path/to/pom.xml --dry-run
|
|
178
|
+
|
|
179
|
+
# scan a directory for all supported manifests
|
|
180
|
+
$ npx @trustify-da/trustify-da-javascript-client remediate /path/to/project/
|
|
181
|
+
|
|
182
|
+
# filter by vulnerability providers (order determines priority)
|
|
183
|
+
$ npx @trustify-da/trustify-da-javascript-client remediate /path/to/pom.xml --providers provider1,provider2
|
|
184
|
+
|
|
185
|
+
# group report output by bundle instead of per-dependency
|
|
186
|
+
$ npx @trustify-da/trustify-da-javascript-client remediate /path/to/pom.xml --dry-run --group-by bundle
|
|
163
187
|
```
|
|
164
188
|
</li>
|
|
165
189
|
|
|
@@ -213,6 +237,27 @@ $ trustify-da-javascript-client image httpd:2.4.49^^amd64
|
|
|
213
237
|
|
|
214
238
|
# get project license information
|
|
215
239
|
$ trustify-da-javascript-client license /path/to/package.json
|
|
240
|
+
|
|
241
|
+
# generate a CycloneDX SBOM from a manifest file
|
|
242
|
+
$ trustify-da-javascript-client sbom /path/to/pom.xml
|
|
243
|
+
|
|
244
|
+
# generate SBOM and write to a file
|
|
245
|
+
$ trustify-da-javascript-client sbom /path/to/pom.xml --output sbom.json
|
|
246
|
+
|
|
247
|
+
# scan a manifest and apply vulnerability remediations
|
|
248
|
+
$ trustify-da-javascript-client remediate /path/to/pom.xml
|
|
249
|
+
|
|
250
|
+
# preview remediations without modifying files
|
|
251
|
+
$ trustify-da-javascript-client remediate /path/to/pom.xml --dry-run
|
|
252
|
+
|
|
253
|
+
# scan a directory for all supported manifests
|
|
254
|
+
$ trustify-da-javascript-client remediate /path/to/project/
|
|
255
|
+
|
|
256
|
+
# filter by vulnerability providers (order determines priority)
|
|
257
|
+
$ trustify-da-javascript-client remediate /path/to/pom.xml --providers provider1,provider2
|
|
258
|
+
|
|
259
|
+
# group report output by bundle instead of per-dependency
|
|
260
|
+
$ trustify-da-javascript-client remediate /path/to/pom.xml --dry-run --group-by bundle
|
|
216
261
|
```
|
|
217
262
|
</li>
|
|
218
263
|
</ul>
|
|
@@ -224,7 +269,8 @@ $ trustify-da-javascript-client license /path/to/package.json
|
|
|
224
269
|
<li><a href="https://www.javascript.com/">JavaScript</a> - <a href="https://pnpm.io/">pnpm</a></li>
|
|
225
270
|
<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>
|
|
226
271
|
<li><a href="https://go.dev/">Golang</a> - <a href="https://go.dev/blog/using-go-modules/">Go Modules</a></li>
|
|
227
|
-
<li><a href="https://www.python.org/">Python</a> - <a href="https://pypi.org/project/pip/">pip Installer</a
|
|
272
|
+
<li><a href="https://www.python.org/">Python</a> - <a href="https://pypi.org/project/pip/">pip Installer</a> (<code>requirements.txt</code>)</li>
|
|
273
|
+
<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>
|
|
228
274
|
<li><a href="https://gradle.org/">Gradle (Groovy and Kotlin DSL)</a> - <a href="https://gradle.org/install/">Gradle Installation</a></li>
|
|
229
275
|
<li><a href="https://www.rust-lang.org/">Rust</a> - <a href="https://doc.rust-lang.org/cargo/">Cargo</a></li>
|
|
230
276
|
</ul>
|
|
@@ -287,8 +333,11 @@ Excluding a package from any analysis can be achieved by marking the package for
|
|
|
287
333
|
]
|
|
288
334
|
}
|
|
289
335
|
```
|
|
336
|
+
</li>
|
|
337
|
+
|
|
338
|
+
<li>
|
|
339
|
+
<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:
|
|
290
340
|
|
|
291
|
-
<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:
|
|
292
341
|
```go
|
|
293
342
|
module github.com/trustify-da/SaaSi/deployer
|
|
294
343
|
|
|
@@ -297,7 +346,7 @@ go 1.19
|
|
|
297
346
|
require (
|
|
298
347
|
github.com/gin-gonic/gin v1.9.1
|
|
299
348
|
github.com/google/uuid v1.1.2
|
|
300
|
-
github.com/jessevdk/go-flags v1.5.0 //exhortignore
|
|
349
|
+
github.com/jessevdk/go-flags v1.5.0 // exhortignore
|
|
301
350
|
github.com/kr/pretty v0.3.1
|
|
302
351
|
gopkg.in/yaml.v2 v2.4.0
|
|
303
352
|
k8s.io/apimachinery v0.26.1
|
|
@@ -305,14 +354,20 @@ require (
|
|
|
305
354
|
)
|
|
306
355
|
|
|
307
356
|
require (
|
|
308
|
-
github.com/davecgh/go-spew v1.1.1 // indirect exhortignore
|
|
357
|
+
github.com/davecgh/go-spew v1.1.1 // indirect; exhortignore
|
|
309
358
|
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
|
|
310
|
-
github.com/go-logr/logr v1.2.3 // indirect
|
|
359
|
+
github.com/go-logr/logr v1.2.3 // indirect; exhortignore
|
|
311
360
|
|
|
312
361
|
)
|
|
313
362
|
```
|
|
314
363
|
|
|
364
|
+
<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.
|
|
365
|
+
</li>
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
<li>
|
|
315
369
|
<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:
|
|
370
|
+
|
|
316
371
|
```properties
|
|
317
372
|
anyio==3.6.2
|
|
318
373
|
asgiref==3.4.1
|
|
@@ -343,11 +398,14 @@ Werkzeug==2.0.3
|
|
|
343
398
|
zipp==3.6.0
|
|
344
399
|
|
|
345
400
|
```
|
|
401
|
+
</li>
|
|
346
402
|
|
|
403
|
+
<li>
|
|
347
404
|
<em>Gradle</em> users can add in build.gradle a comment with //exhortignore next to the package to be ignored:
|
|
405
|
+
|
|
348
406
|
```build.gradle
|
|
349
407
|
plugins {
|
|
350
|
-
id 'java'
|
|
408
|
+
id 'java'
|
|
351
409
|
}
|
|
352
410
|
|
|
353
411
|
group = 'groupName'
|
|
@@ -379,9 +437,31 @@ version = "1.10"
|
|
|
379
437
|
log = "0.4" # trustify-da-ignore
|
|
380
438
|
```
|
|
381
439
|
|
|
382
|
-
All of the 6 above examples are valid for marking a package to be ignored
|
|
383
|
-
</li>
|
|
384
440
|
|
|
441
|
+
<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>.
|
|
442
|
+
|
|
443
|
+
PEP 621 style (<code>[project]</code> dependencies):
|
|
444
|
+
```toml
|
|
445
|
+
[project]
|
|
446
|
+
dependencies = [
|
|
447
|
+
"flask>=2.0.3",
|
|
448
|
+
"requests>=2.25.1",
|
|
449
|
+
"uvicorn>=0.17.0", #exhortignore
|
|
450
|
+
"click>=8.0.4", # trustify-da-ignore
|
|
451
|
+
]
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
Poetry style (<code>[tool.poetry.dependencies]</code>):
|
|
455
|
+
```toml
|
|
456
|
+
[tool.poetry.dependencies]
|
|
457
|
+
flask = "^2.0.3"
|
|
458
|
+
requests = "^2.25.1"
|
|
459
|
+
uvicorn = "^0.17.0" #exhortignore
|
|
460
|
+
click = "^8.0.4" # trustify-da-ignore
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
All of the above examples are valid for marking a package to be ignored
|
|
464
|
+
</li>
|
|
385
465
|
</ul>
|
|
386
466
|
|
|
387
467
|
<h3>Customization</h3>
|
|
@@ -410,6 +490,8 @@ let options = {
|
|
|
410
490
|
'TRUSTIFY_DA_PIP3_PATH' : '/path/to/pip3',
|
|
411
491
|
'TRUSTIFY_DA_PYTHON_PATH' : '/path/to/python',
|
|
412
492
|
'TRUSTIFY_DA_PIP_PATH' : '/path/to/pip',
|
|
493
|
+
'TRUSTIFY_DA_UV_PATH' : '/path/to/uv',
|
|
494
|
+
'TRUSTIFY_DA_POETRY_PATH' : '/path/to/poetry',
|
|
413
495
|
'TRUSTIFY_DA_GRADLE_PATH' : '/path/to/gradle',
|
|
414
496
|
'TRUSTIFY_DA_CARGO_PATH' : '/path/to/cargo',
|
|
415
497
|
// Workspace root for monorepos (Cargo, npm/pnpm/yarn); lock file expected here
|
|
@@ -556,6 +638,16 @@ following keys for setting custom paths for the said executables.
|
|
|
556
638
|
<td>TRUSTIFY_DA_CARGO_PATH</td>
|
|
557
639
|
</tr>
|
|
558
640
|
<tr>
|
|
641
|
+
<td><a href="https://docs.astral.sh/uv/">uv</a></td>
|
|
642
|
+
<td><em>uv</em></td>
|
|
643
|
+
<td>TRUSTIFY_DA_UV_PATH</td>
|
|
644
|
+
</tr>
|
|
645
|
+
<tr>
|
|
646
|
+
<td><a href="https://python-poetry.org/">Poetry</a></td>
|
|
647
|
+
<td><em>poetry</em></td>
|
|
648
|
+
<td>TRUSTIFY_DA_POETRY_PATH</td>
|
|
649
|
+
</tr>
|
|
650
|
+
<tr>
|
|
559
651
|
<td>Workspace root (monorepos)</td>
|
|
560
652
|
<td>—</td>
|
|
561
653
|
<td>workspaceDir / TRUSTIFY_DA_WORKSPACE_DIR</td>
|
|
@@ -608,6 +700,24 @@ TRUSTIFY_DA_GO_MVS_LOGIC_ENABLED=false
|
|
|
608
700
|
|
|
609
701
|
#### Python Support
|
|
610
702
|
|
|
703
|
+
The client supports two Python manifest formats:
|
|
704
|
+
|
|
705
|
+
- **`requirements.txt`** — uses pip/pip3 to resolve dependencies
|
|
706
|
+
- **`pyproject.toml`** — uses [uv](https://docs.astral.sh/uv/) or [Poetry](https://python-poetry.org/) to resolve dependencies
|
|
707
|
+
|
|
708
|
+
##### pyproject.toml
|
|
709
|
+
|
|
710
|
+
For `pyproject.toml` projects, the client detects which tool manages the project by checking for lock files:
|
|
711
|
+
- If `poetry.lock` is present and `[tool.poetry]` is defined, **Poetry** is used (`poetry show --tree` and `poetry show --all`)
|
|
712
|
+
- If `uv.lock` is present, **uv** is used (`uv export --format requirements.txt --frozen --no-hashes`)
|
|
713
|
+
- If neither lock file is found, an error is thrown
|
|
714
|
+
|
|
715
|
+
Both PEP 621 (`[project]` dependencies) and Poetry-style (`[tool.poetry.dependencies]`) are supported.
|
|
716
|
+
|
|
717
|
+
Custom executable paths can be set via `TRUSTIFY_DA_UV_PATH` and `TRUSTIFY_DA_POETRY_PATH`.
|
|
718
|
+
|
|
719
|
+
##### requirements.txt
|
|
720
|
+
|
|
611
721
|
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
|
|
612
722
|
Binaries passed to environment variables. In any case, If the package is not installed , then an error will be thrown.
|
|
613
723
|
|
|
@@ -623,14 +733,14 @@ This increasing the chances and the probability that the automatic installation
|
|
|
623
733
|
###### Usage
|
|
624
734
|
A New setting is introduced - `TRUSTIFY_DA_PYTHON_INSTALL_BEST_EFFORTS` (as both env variable/key in `options` object)
|
|
625
735
|
1. `TRUSTIFY_DA_PYTHON_INSTALL_BEST_EFFORTS`="false" - install requirements.txt while respecting declared versions for all packages.
|
|
626
|
-
2. `TRUSTIFY_DA_PYTHON_INSTALL_BEST_EFFORTS`="true" - install all packages from requirements.txt, not respecting the declared version, but trying to install a version tailored for the used python version. When using this setting, you must set
|
|
736
|
+
2. `TRUSTIFY_DA_PYTHON_INSTALL_BEST_EFFORTS`="true" - install all packages from requirements.txt, not respecting the declared version, but trying to install a version tailored for the used python version. When using this setting, you must set `TRUSTIFY_DA_PYTHON_VIRTUAL_ENV` to 'true' and `MATCH_MANIFEST_VERSIONS` to 'false'.
|
|
627
737
|
|
|
628
738
|
##### Using `pipdeptree`
|
|
629
739
|
By default, The API algorithm will use native commands of PIP installer as data source to build the dependency tree.
|
|
630
740
|
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'.
|
|
631
741
|
|
|
632
742
|
#### Toggle Red Hat Trusted Content recommendations
|
|
633
|
-
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 `
|
|
743
|
+
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.
|
|
634
744
|
|
|
635
745
|
#### Additional CLI arguments
|
|
636
746
|
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.
|
|
@@ -640,6 +750,135 @@ For some ecosystems we support passing additional CLI arguments to the underlyin
|
|
|
640
750
|
|Maven |TRUSTIFY_DA_MVN_ARGS|
|
|
641
751
|
|
|
642
752
|
|
|
753
|
+
<h3>Remediation</h3>
|
|
754
|
+
<p>
|
|
755
|
+
The <code>remediate</code> command scans manifest files for known vulnerabilities and applies version upgrades to resolve them. By default, it modifies manifest files in place. Use <code>--dry-run</code> to preview changes without modifying any files.
|
|
756
|
+
</p>
|
|
757
|
+
|
|
758
|
+
<h4>Supported Manifest Formats</h4>
|
|
759
|
+
<ul>
|
|
760
|
+
<li><strong>Maven</strong> — <code>pom.xml</code> (single-module projects; updates dependency version elements and resolves property references)</li>
|
|
761
|
+
<li><strong>Gradle Version Catalog</strong> — <code>libs.versions.toml</code> or any <code>*.versions.toml</code> file (updates centralized version references and inline version declarations)</li>
|
|
762
|
+
</ul>
|
|
763
|
+
|
|
764
|
+
<h4>CLI Flags</h4>
|
|
765
|
+
<table>
|
|
766
|
+
<tr>
|
|
767
|
+
<th>Flag</th>
|
|
768
|
+
<th>Alias</th>
|
|
769
|
+
<th>Type</th>
|
|
770
|
+
<th>Default</th>
|
|
771
|
+
<th>Description</th>
|
|
772
|
+
</tr>
|
|
773
|
+
<tr>
|
|
774
|
+
<td><code><path></code></td>
|
|
775
|
+
<td>—</td>
|
|
776
|
+
<td>string (positional)</td>
|
|
777
|
+
<td><em>required</em></td>
|
|
778
|
+
<td>Path to a manifest file or directory to scan recursively</td>
|
|
779
|
+
</tr>
|
|
780
|
+
<tr>
|
|
781
|
+
<td><code>--dry-run</code></td>
|
|
782
|
+
<td><code>-d</code></td>
|
|
783
|
+
<td>boolean</td>
|
|
784
|
+
<td><code>false</code></td>
|
|
785
|
+
<td>Preview changes without modifying files</td>
|
|
786
|
+
</tr>
|
|
787
|
+
<tr>
|
|
788
|
+
<td><code>--providers</code></td>
|
|
789
|
+
<td>—</td>
|
|
790
|
+
<td>string</td>
|
|
791
|
+
<td>—</td>
|
|
792
|
+
<td>Comma-separated list of vulnerability providers (env: <code>TRUSTIFY_DA_PROVIDERS</code>)</td>
|
|
793
|
+
</tr>
|
|
794
|
+
<tr>
|
|
795
|
+
<td><code>--sources</code></td>
|
|
796
|
+
<td>—</td>
|
|
797
|
+
<td>string</td>
|
|
798
|
+
<td>—</td>
|
|
799
|
+
<td>Comma-separated list of vulnerability sources (env: <code>TRUSTIFY_DA_SOURCES</code>)</td>
|
|
800
|
+
</tr>
|
|
801
|
+
<tr>
|
|
802
|
+
<td><code>--group-by</code></td>
|
|
803
|
+
<td>—</td>
|
|
804
|
+
<td>string</td>
|
|
805
|
+
<td><code>dependency</code></td>
|
|
806
|
+
<td>Report grouping strategy (<code>dependency</code> or <code>bundle</code>)</td>
|
|
807
|
+
</tr>
|
|
808
|
+
</table>
|
|
809
|
+
|
|
810
|
+
<h4>Provider Priority Resolution</h4>
|
|
811
|
+
<p>
|
|
812
|
+
When multiple vulnerability providers suggest different remediation versions for the same dependency, the <code>--providers</code> flag determines priority. Providers listed first have the highest priority.
|
|
813
|
+
</p>
|
|
814
|
+
<ul>
|
|
815
|
+
<li>The provider ordering in <code>--providers</code> determines rank (first = highest priority).</li>
|
|
816
|
+
<li>Trustify vendor trusted packages always take precedence over non-trusted content at equal provider rank.</li>
|
|
817
|
+
<li>Two version selection strategies are used internally:
|
|
818
|
+
<ul>
|
|
819
|
+
<li><strong>Closest coverage</strong> (default) — prefers the remediation version closest to the current version within the same major version.</li>
|
|
820
|
+
<li><strong>Highest</strong> — always selects the highest available remediation version.</li>
|
|
821
|
+
</ul>
|
|
822
|
+
</li>
|
|
823
|
+
</ul>
|
|
824
|
+
|
|
825
|
+
<h4>Exit Codes</h4>
|
|
826
|
+
<ul>
|
|
827
|
+
<li><code>0</code> — no remediations needed, or remediations applied successfully</li>
|
|
828
|
+
<li><code>1</code> — error during execution</li>
|
|
829
|
+
<li><code>2</code> — remediations available (only returned in <code>--dry-run</code> mode when changes would be made; never returned when changes are applied)</li>
|
|
830
|
+
</ul>
|
|
831
|
+
|
|
832
|
+
<h4>Known Limitations</h4>
|
|
833
|
+
<ul>
|
|
834
|
+
<li>Gradle DSL files (<code>build.gradle</code>, <code>build.gradle.kts</code>) are not supported — only version catalog files (<code>*.versions.toml</code>).</li>
|
|
835
|
+
<li>Multi-module Maven projects with inherited dependency versions from parent POMs are not supported — only versions declared directly in the scanned <code>pom.xml</code> are updated.</li>
|
|
836
|
+
</ul>
|
|
837
|
+
|
|
838
|
+
<h4>Example: GitHub Action Workflow</h4>
|
|
839
|
+
<p>
|
|
840
|
+
The following workflow runs a scheduled remediation scan using the container image and opens a pull request with any version updates. Save this as <code>.github/workflows/trustify-da-remediation.yml</code> in your repository:
|
|
841
|
+
</p>
|
|
842
|
+
|
|
843
|
+
```yaml
|
|
844
|
+
name: Trustify DA Remediation Scan
|
|
845
|
+
|
|
846
|
+
on:
|
|
847
|
+
schedule:
|
|
848
|
+
# Run weekly on Monday at 08:00 UTC
|
|
849
|
+
- cron: '0 8 * * 1'
|
|
850
|
+
workflow_dispatch:
|
|
851
|
+
|
|
852
|
+
permissions:
|
|
853
|
+
contents: write
|
|
854
|
+
pull-requests: write
|
|
855
|
+
|
|
856
|
+
jobs:
|
|
857
|
+
remediate:
|
|
858
|
+
runs-on: ubuntu-latest
|
|
859
|
+
steps:
|
|
860
|
+
- uses: actions/checkout@v4
|
|
861
|
+
|
|
862
|
+
- name: Run remediation scan
|
|
863
|
+
uses: docker://ghcr.io/guacsec/trustify-da-javascript-client:latest
|
|
864
|
+
env:
|
|
865
|
+
TRUSTIFY_DA_BACKEND_URL: ${{ secrets.TRUSTIFY_DA_BACKEND_URL }}
|
|
866
|
+
with:
|
|
867
|
+
entrypoint: trustify-da-javascript-client
|
|
868
|
+
args: remediate . --providers provider1,provider2
|
|
869
|
+
|
|
870
|
+
- name: Create pull request
|
|
871
|
+
uses: peter-evans/create-pull-request@v7
|
|
872
|
+
with:
|
|
873
|
+
title: 'fix(deps): apply Trustify DA vulnerability remediations'
|
|
874
|
+
body: |
|
|
875
|
+
Automated dependency version updates from Trustify Dependency Analytics.
|
|
876
|
+
|
|
877
|
+
This PR was generated by a scheduled remediation scan.
|
|
878
|
+
branch: trustify-da-remediation
|
|
879
|
+
commit-message: 'fix(deps): apply Trustify DA vulnerability remediations'
|
|
880
|
+
```
|
|
881
|
+
|
|
643
882
|
<!-- Badge links -->
|
|
644
883
|
[0]: https://img.shields.io/github/v/release/guacsec/trustify-da-javascript-client?color=green&label=latest
|
|
645
884
|
[1]: https://img.shields.io/github/v/release/guacsec/trustify-da-javascript-client?color=yellow&include_prereleases&label=early-access
|
package/dist/package.json
CHANGED
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
"provenance": true
|
|
26
26
|
},
|
|
27
27
|
"type": "module",
|
|
28
|
-
"bin":
|
|
28
|
+
"bin": {
|
|
29
|
+
"trustify-da": "dist/src/cli.js"
|
|
30
|
+
},
|
|
29
31
|
"main": "dist/src/index.js",
|
|
30
32
|
"module": "dist/src/index.js",
|
|
31
33
|
"types": "dist/src/index.d.ts",
|
|
@@ -35,55 +37,60 @@
|
|
|
35
37
|
"config/**/*"
|
|
36
38
|
],
|
|
37
39
|
"scripts": {
|
|
38
|
-
"lint": "eslint src test
|
|
39
|
-
"lint:fix": "eslint src test --
|
|
40
|
+
"lint": "eslint src test",
|
|
41
|
+
"lint:fix": "eslint src test --fix",
|
|
40
42
|
"test": "c8 npm run tests",
|
|
41
|
-
"tests": "mocha --config .mocharc.json
|
|
43
|
+
"tests": "mocha --config .mocharc.json",
|
|
42
44
|
"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",
|
|
45
|
+
"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
46
|
"precompile": "rm -rf dist",
|
|
45
47
|
"compile": "tsc -p tsconfig.json",
|
|
46
48
|
"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"
|
|
49
|
+
"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
50
|
},
|
|
49
51
|
"dependencies": {
|
|
50
52
|
"@babel/core": "^7.23.2",
|
|
51
|
-
"@
|
|
53
|
+
"@yarnpkg/parsers": "^3.1.0",
|
|
52
54
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
53
55
|
"fast-glob": "^3.3.3",
|
|
54
|
-
"fast-toml": "^0.5.4",
|
|
55
56
|
"fast-xml-parser": "^5.3.4",
|
|
56
57
|
"help": "^3.0.2",
|
|
57
|
-
"https-proxy-agent": "^
|
|
58
|
+
"https-proxy-agent": "^9.0.0",
|
|
58
59
|
"js-yaml": "^4.1.1",
|
|
60
|
+
"jsonc-parser": "^3.3.1",
|
|
59
61
|
"micromatch": "^4.0.8",
|
|
60
62
|
"node-fetch": "^3.3.2",
|
|
61
|
-
"p-limit": "^
|
|
63
|
+
"p-limit": "^7.3.0",
|
|
62
64
|
"packageurl-js": "~1.0.2",
|
|
63
65
|
"smol-toml": "^1.6.0",
|
|
66
|
+
"tree-sitter-containerfile": "^0.8.1",
|
|
67
|
+
"tree-sitter-gomod": "github:strum355/tree-sitter-go-mod#56326f2ad478892ace58ff247a97d492a3cbcdda",
|
|
64
68
|
"tree-sitter-requirements": "github:Strum355/tree-sitter-requirements#d0261ee76b84253997fe70d7d397e78c006c3801",
|
|
65
|
-
"web-tree-sitter": "^0.26.
|
|
69
|
+
"web-tree-sitter": "^0.26.7",
|
|
66
70
|
"yargs": "^18.0.0"
|
|
67
71
|
},
|
|
68
72
|
"devDependencies": {
|
|
69
73
|
"@babel/core": "^7.23.2",
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
74
|
+
"@cyclonedx/cyclonedx-library": "^10.2.0",
|
|
75
|
+
"@eslint/js": "^10.0.0",
|
|
76
|
+
"@trustify-da/trustify-da-api-model": "^2.0.12",
|
|
77
|
+
"@types/node": "^25.9.1",
|
|
72
78
|
"@types/which": "^3.0.4",
|
|
79
|
+
"ajv": "^8.20.0",
|
|
73
80
|
"babel-plugin-rewire": "^1.2.0",
|
|
74
81
|
"c8": "^11.0.0",
|
|
75
|
-
"chai": "^
|
|
76
|
-
"eslint": "^
|
|
82
|
+
"chai": "^6.2.2",
|
|
83
|
+
"eslint": "^10.4.1",
|
|
77
84
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
78
|
-
"eslint-plugin-
|
|
79
|
-
"eslint-plugin-import": "^2.29.1",
|
|
85
|
+
"eslint-plugin-import-x": "^4.16.2",
|
|
80
86
|
"esmock": "^2.6.2",
|
|
81
|
-
"
|
|
87
|
+
"globals": "^17.6.0",
|
|
88
|
+
"mocha": "^11.7.6",
|
|
82
89
|
"msw": "^2.12.7",
|
|
83
|
-
"sinon": "^
|
|
84
|
-
"sinon-chai": "^
|
|
85
|
-
"typescript": "^
|
|
86
|
-
"which": "^
|
|
90
|
+
"sinon": "^22.0.0",
|
|
91
|
+
"sinon-chai": "^4.0.1",
|
|
92
|
+
"typescript": "^6.0.3",
|
|
93
|
+
"which": "^7.0.0"
|
|
87
94
|
},
|
|
88
95
|
"mocha": {
|
|
89
96
|
"check-leaks": false,
|
|
@@ -111,12 +118,13 @@
|
|
|
111
118
|
"reporter": [
|
|
112
119
|
"html",
|
|
113
120
|
"json",
|
|
121
|
+
"lcov",
|
|
114
122
|
"text"
|
|
115
123
|
]
|
|
116
124
|
},
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
|
|
125
|
+
"overrides": {
|
|
126
|
+
"tree-sitter": "0.22.4"
|
|
127
|
+
},
|
|
120
128
|
"resolutions": {
|
|
121
129
|
"@hapi/joi": "17.1.1"
|
|
122
130
|
}
|
package/dist/src/analysis.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare namespace _default {
|
|
|
6
6
|
export { requestStackBatch };
|
|
7
7
|
export { requestImages };
|
|
8
8
|
export { validateToken };
|
|
9
|
+
export { appendAnalysisQueryParams };
|
|
9
10
|
}
|
|
10
11
|
export default _default;
|
|
11
12
|
/**
|
|
@@ -16,7 +17,7 @@ export default _default;
|
|
|
16
17
|
* @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
|
|
17
18
|
* @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
|
|
18
19
|
*/
|
|
19
|
-
declare function requestComponent(provider:
|
|
20
|
+
declare function requestComponent(provider: any, manifest: string, url: string, opts?: any): Promise<any>;
|
|
20
21
|
/**
|
|
21
22
|
* Send a stack analysis request and get the report as 'text/html' or 'application/json'.
|
|
22
23
|
* @param {import('./provider').Provider} provider - the provided data for constructing the request
|
|
@@ -26,7 +27,7 @@ declare function requestComponent(provider: import("./provider").Provider, manif
|
|
|
26
27
|
* @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
|
|
27
28
|
* @returns {Promise<string|import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
|
|
28
29
|
*/
|
|
29
|
-
declare function requestStack(provider:
|
|
30
|
+
declare function requestStack(provider: any, manifest: string, url: string, html?: boolean, opts?: any): Promise<string | any>;
|
|
30
31
|
/**
|
|
31
32
|
* Send a batch stack analysis request for multiple manifests (SBOMs keyed by purl).
|
|
32
33
|
* @param {Object.<string, object>} sbomByPurl - Map of root purl to CycloneDX SBOM object
|
|
@@ -36,9 +37,9 @@ declare function requestStack(provider: import("./provider").Provider, manifest:
|
|
|
36
37
|
* @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
|
|
37
38
|
*/
|
|
38
39
|
declare function requestStackBatch(sbomByPurl: {
|
|
40
|
+
[x: string]: object;
|
|
41
|
+
}, url: string, html?: boolean, opts?: any): Promise<string | {
|
|
39
42
|
[x: string]: any;
|
|
40
|
-
}, url: string, html?: boolean, opts?: import("index.js").Options): Promise<string | {
|
|
41
|
-
[x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
|
|
42
43
|
}>;
|
|
43
44
|
/**
|
|
44
45
|
*
|
|
@@ -47,8 +48,8 @@ declare function requestStackBatch(sbomByPurl: {
|
|
|
47
48
|
* @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
|
|
48
49
|
* @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
|
|
49
50
|
*/
|
|
50
|
-
declare function requestImages(imageRefs: Array<string>, url: string, html?: boolean, opts?:
|
|
51
|
-
[x: string]:
|
|
51
|
+
declare function requestImages(imageRefs: Array<string>, url: string, html?: boolean, opts?: any): Promise<string | {
|
|
52
|
+
[x: string]: any;
|
|
52
53
|
}>;
|
|
53
54
|
/**
|
|
54
55
|
*
|
|
@@ -56,4 +57,10 @@ declare function requestImages(imageRefs: Array<string>, url: string, html?: boo
|
|
|
56
57
|
* @param {import("index.js").Options} [opts={}] - optional various options to pass headers for t he validateToken Request
|
|
57
58
|
* @return {Promise<number>} return the HTTP status Code of the response from the validate token request.
|
|
58
59
|
*/
|
|
59
|
-
declare function validateToken(url: any, opts?:
|
|
60
|
+
declare function validateToken(url: any, opts?: any): Promise<number>;
|
|
61
|
+
/**
|
|
62
|
+
* Append common analysis query parameters (recommend, providers, sources) to a URL.
|
|
63
|
+
* @param {URL} url - the URL object to append query parameters to
|
|
64
|
+
* @param {import("index.js").Options} [opts={}] - options containing parameter overrides
|
|
65
|
+
*/
|
|
66
|
+
declare function appendAnalysisQueryParams(url: URL, opts?: any): void;
|
package/dist/src/analysis.js
CHANGED
|
@@ -6,7 +6,7 @@ import { generateImageSBOM, parseImageRef } from "./oci_image/utils.js";
|
|
|
6
6
|
import { addProxyAgent, getCustom, getTokenHeaders, TRUSTIFY_DA_OPERATION_TYPE_HEADER, TRUSTIFY_DA_PACKAGE_MANAGER_HEADER } from "./tools.js";
|
|
7
7
|
/** Media type for CycloneDX JSON batch payloads (batch-analysis API). */
|
|
8
8
|
export const CYCLONEDX_JSON_MEDIA_TYPE = 'application/vnd.cyclonedx+json';
|
|
9
|
-
export default { requestComponent, requestStack, requestStackBatch, requestImages, validateToken };
|
|
9
|
+
export default { requestComponent, requestStack, requestStackBatch, requestImages, validateToken, appendAnalysisQueryParams };
|
|
10
10
|
/**
|
|
11
11
|
* Send a stack analysis request and get the report as 'text/html' or 'application/json'.
|
|
12
12
|
* @param {import('./provider').Provider} provider - the provided data for constructing the request
|
|
@@ -20,6 +20,9 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
|
|
|
20
20
|
opts["source-manifest"] = Buffer.from(fs.readFileSync(manifest).toString()).toString('base64');
|
|
21
21
|
opts["manifest-type"] = path.parse(manifest).base;
|
|
22
22
|
let provided = await provider.provideStack(manifest, opts); // throws error if content providing failed
|
|
23
|
+
if (provided.batch) {
|
|
24
|
+
return requestStackBatch(JSON.parse(provided.content), url, html, opts);
|
|
25
|
+
}
|
|
23
26
|
opts["source-manifest"] = "";
|
|
24
27
|
opts[TRUSTIFY_DA_OPERATION_TYPE_HEADER.toUpperCase().replaceAll("-", "_")] = "stack-analysis";
|
|
25
28
|
let startTime = new Date();
|
|
@@ -38,9 +41,7 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
|
|
|
38
41
|
body: provided.content
|
|
39
42
|
}, opts);
|
|
40
43
|
const finalUrl = new URL(`${url}/api/v5/analysis`);
|
|
41
|
-
|
|
42
|
-
finalUrl.searchParams.append('recommend', 'false');
|
|
43
|
-
}
|
|
44
|
+
appendAnalysisQueryParams(finalUrl, opts);
|
|
44
45
|
let resp = await fetch(finalUrl, fetchOptions);
|
|
45
46
|
let result;
|
|
46
47
|
if (resp.status === 200) {
|
|
@@ -79,6 +80,9 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
|
|
|
79
80
|
async function requestComponent(provider, manifest, url, opts = {}) {
|
|
80
81
|
opts["source-manifest"] = Buffer.from(fs.readFileSync(manifest).toString()).toString('base64');
|
|
81
82
|
let provided = await provider.provideComponent(manifest, opts); // throws error if content providing failed
|
|
83
|
+
if (provided.batch) {
|
|
84
|
+
return requestStackBatch(JSON.parse(provided.content), url, false, opts);
|
|
85
|
+
}
|
|
82
86
|
opts["source-manifest"] = "";
|
|
83
87
|
opts[TRUSTIFY_DA_OPERATION_TYPE_HEADER.toUpperCase().replaceAll("-", "_")] = "component-analysis";
|
|
84
88
|
if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
|
|
@@ -95,9 +99,7 @@ async function requestComponent(provider, manifest, url, opts = {}) {
|
|
|
95
99
|
body: provided.content
|
|
96
100
|
}, opts);
|
|
97
101
|
const finalUrl = new URL(`${url}/api/v5/analysis`);
|
|
98
|
-
|
|
99
|
-
finalUrl.searchParams.append('recommend', 'false');
|
|
100
|
-
}
|
|
102
|
+
appendAnalysisQueryParams(finalUrl, opts);
|
|
101
103
|
let resp = await fetch(finalUrl, fetchOptions);
|
|
102
104
|
let result;
|
|
103
105
|
if (resp.status === 200) {
|
|
@@ -136,9 +138,7 @@ async function requestComponent(provider, manifest, url, opts = {}) {
|
|
|
136
138
|
*/
|
|
137
139
|
async function requestStackBatch(sbomByPurl, url, html = false, opts = {}) {
|
|
138
140
|
const finalUrl = new URL(`${url}/api/v5/batch-analysis`);
|
|
139
|
-
|
|
140
|
-
finalUrl.searchParams.append('recommend', 'false');
|
|
141
|
-
}
|
|
141
|
+
appendAnalysisQueryParams(finalUrl, opts);
|
|
142
142
|
const fetchOptions = addProxyAgent({
|
|
143
143
|
method: 'POST',
|
|
144
144
|
headers: {
|
|
@@ -186,10 +186,8 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
|
|
|
186
186
|
imageSboms[parsedImageRef.getPackageURL().toString()] = generateImageSBOM(parsedImageRef, opts);
|
|
187
187
|
}
|
|
188
188
|
const finalUrl = new URL(`${url}/api/v5/batch-analysis`);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
const resp = await fetch(finalUrl, {
|
|
189
|
+
appendAnalysisQueryParams(finalUrl, opts);
|
|
190
|
+
const fetchOptions = addProxyAgent({
|
|
193
191
|
method: 'POST',
|
|
194
192
|
headers: {
|
|
195
193
|
'Accept': html ? 'text/html' : 'application/json',
|
|
@@ -197,7 +195,8 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
|
|
|
197
195
|
...getTokenHeaders(opts)
|
|
198
196
|
},
|
|
199
197
|
body: JSON.stringify(imageSboms),
|
|
200
|
-
});
|
|
198
|
+
}, opts);
|
|
199
|
+
const resp = await fetch(finalUrl, fetchOptions);
|
|
201
200
|
if (resp.status === 200) {
|
|
202
201
|
let result;
|
|
203
202
|
if (!html) {
|
|
@@ -221,6 +220,24 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
|
|
|
221
220
|
throw new Error(`Got error response from Trustify DA backend - http return code : ${resp.status}, ex-request-id: ${resp.headers.get("ex-request-id")} error message => ${await resp.text()}`);
|
|
222
221
|
}
|
|
223
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Append common analysis query parameters (recommend, providers, sources) to a URL.
|
|
225
|
+
* @param {URL} url - the URL object to append query parameters to
|
|
226
|
+
* @param {import("index.js").Options} [opts={}] - options containing parameter overrides
|
|
227
|
+
*/
|
|
228
|
+
function appendAnalysisQueryParams(url, opts = {}) {
|
|
229
|
+
if (getCustom('TRUSTIFY_DA_RECOMMEND', 'true', opts) === 'false') {
|
|
230
|
+
url.searchParams.append('recommend', 'false');
|
|
231
|
+
}
|
|
232
|
+
const providers = getCustom('TRUSTIFY_DA_PROVIDERS', null, opts);
|
|
233
|
+
if (providers) {
|
|
234
|
+
url.searchParams.append('providers', providers);
|
|
235
|
+
}
|
|
236
|
+
const sources = getCustom('TRUSTIFY_DA_SOURCES', null, opts);
|
|
237
|
+
if (sources) {
|
|
238
|
+
url.searchParams.append('sources', sources);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
224
241
|
/**
|
|
225
242
|
*
|
|
226
243
|
* @param url the backend url to send the request to
|