@trustify-da/trustify-da-javascript-client 0.2.4-ea.13

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 (57) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +482 -0
  3. package/config/config.properties +1 -0
  4. package/dist/package.json +106 -0
  5. package/dist/src/analysis.d.ts +43 -0
  6. package/dist/src/analysis.js +252 -0
  7. package/dist/src/cli.d.ts +2 -0
  8. package/dist/src/cli.js +102 -0
  9. package/dist/src/cyclone_dx_sbom.d.ts +77 -0
  10. package/dist/src/cyclone_dx_sbom.js +244 -0
  11. package/dist/src/index.d.ts +82 -0
  12. package/dist/src/index.js +194 -0
  13. package/dist/src/oci_image/images.d.ts +99 -0
  14. package/dist/src/oci_image/images.js +263 -0
  15. package/dist/src/oci_image/platform.d.ts +59 -0
  16. package/dist/src/oci_image/platform.js +138 -0
  17. package/dist/src/oci_image/utils.d.ts +42 -0
  18. package/dist/src/oci_image/utils.js +496 -0
  19. package/dist/src/provider.d.ts +29 -0
  20. package/dist/src/provider.js +47 -0
  21. package/dist/src/providers/base_java.d.ts +85 -0
  22. package/dist/src/providers/base_java.js +191 -0
  23. package/dist/src/providers/base_javascript.d.ts +127 -0
  24. package/dist/src/providers/base_javascript.js +350 -0
  25. package/dist/src/providers/golang_gomodules.d.ts +42 -0
  26. package/dist/src/providers/golang_gomodules.js +403 -0
  27. package/dist/src/providers/java_gradle.d.ts +35 -0
  28. package/dist/src/providers/java_gradle.js +399 -0
  29. package/dist/src/providers/java_gradle_groovy.d.ts +7 -0
  30. package/dist/src/providers/java_gradle_groovy.js +19 -0
  31. package/dist/src/providers/java_gradle_kotlin.d.ts +11 -0
  32. package/dist/src/providers/java_gradle_kotlin.js +23 -0
  33. package/dist/src/providers/java_maven.d.ts +52 -0
  34. package/dist/src/providers/java_maven.js +263 -0
  35. package/dist/src/providers/javascript_npm.d.ts +4 -0
  36. package/dist/src/providers/javascript_npm.js +15 -0
  37. package/dist/src/providers/javascript_pnpm.d.ts +5 -0
  38. package/dist/src/providers/javascript_pnpm.js +22 -0
  39. package/dist/src/providers/javascript_yarn.d.ts +11 -0
  40. package/dist/src/providers/javascript_yarn.js +39 -0
  41. package/dist/src/providers/manifest.d.ts +11 -0
  42. package/dist/src/providers/manifest.js +48 -0
  43. package/dist/src/providers/processors/yarn_berry_processor.d.ts +41 -0
  44. package/dist/src/providers/processors/yarn_berry_processor.js +130 -0
  45. package/dist/src/providers/processors/yarn_classic_processor.d.ts +37 -0
  46. package/dist/src/providers/processors/yarn_classic_processor.js +109 -0
  47. package/dist/src/providers/processors/yarn_processor.d.ts +9 -0
  48. package/dist/src/providers/processors/yarn_processor.js +20 -0
  49. package/dist/src/providers/python_controller.d.ts +31 -0
  50. package/dist/src/providers/python_controller.js +406 -0
  51. package/dist/src/providers/python_pip.d.ts +35 -0
  52. package/dist/src/providers/python_pip.js +227 -0
  53. package/dist/src/sbom.d.ts +59 -0
  54. package/dist/src/sbom.js +84 -0
  55. package/dist/src/tools.d.ts +74 -0
  56. package/dist/src/tools.js +159 -0
  57. package/package.json +106 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,482 @@
1
+ # Exhort JavaScript API<br/>![latest-no-snapshot][0] ![latest-snapshot][1]
2
+
3
+ * Looking for the OpenAPI Spec? Try [Exhort API Spec](https://github.com/trustify-da/trustify-da-api-model)
4
+ * Looking for our Java API? Try [Exhort Java API](https://github.com/guacsec/exhort-java-api).
5
+ * Looking for our Backend implementation? Try [Exhort](https://github.com/guacsec/exhort).
6
+
7
+ <h3>Usage</h3>
8
+ <p>
9
+
10
+ <ul>
11
+ <li>
12
+ Use as ESM Module from an ESM module
13
+
14
+ ```shell
15
+ npm install @trustify-da/trustify-da-javascript-client
16
+ ```
17
+
18
+ ```javascript
19
+ import exhort from '@trustify-da/trustify-da-javascript-client'
20
+ import fs from 'node:fs'
21
+
22
+ // Get stack analysis in JSON format
23
+ let stackAnalysis = await exhort.stackAnalysis('/path/to/pom.xml')
24
+ // Get stack analysis in HTML format (string)
25
+ let stackAnalysisHtml = await exhort.stackAnalysis('/path/to/pom.xml', true)
26
+ // Get component analysis in JSON format
27
+ let componentAnalysis = await exhort.componentAnalysis('/path/to/pom.xml')
28
+ ```
29
+ </li>
30
+ </ul>
31
+ <ul>
32
+ <li>
33
+ Use as ESM Module from Common-JS module
34
+
35
+ ```shell
36
+ npm install @trustify-da/trustify-da-javascript-client
37
+ ```
38
+
39
+ ```javascript
40
+ async function loadExhort()
41
+ {
42
+ // dynamic import is the only way to import ESM module into commonJS module
43
+ const { default: exhort } = await import('@trustify-da/trustify-da-javascript-client');
44
+ return exhort
45
+ }
46
+ const runExhort = (manifestPath) => {
47
+ return new Promise(async ( resolve, reject) => {
48
+ try {
49
+ let stackAnalysisReport = await (await loadExhort()).stackAnalysis(manifestPath,false)
50
+ resolve(stackAnalysisReport)
51
+
52
+ } catch (error)
53
+ {
54
+ reject(error)
55
+ }
56
+ });
57
+ };
58
+
59
+ runExhort("./path/to/manifest").then(resp => console.log(JSON.stringify(resp,null,4)))
60
+ ```
61
+ </li>
62
+
63
+ <li>
64
+ Use as CLI Script
65
+ <details>
66
+ <summary>Click for help menu</summary>
67
+
68
+ ```shell
69
+ $ npx @trustify-da/trustify-da-javascript-client help
70
+
71
+ Usage: trustify-da-javascript-client {component|stack}
72
+
73
+ Commands:
74
+ trustify-da-javascript-client stack </path/to/manifest> [--html|--summary] produce stack report for manifest path
75
+ trustify-da-javascript-client component <path/to/manifest> [--summary] produce component report for a manifest type and content
76
+
77
+ Options:
78
+ --help Show help [boolean]
79
+ ```
80
+ </details>
81
+
82
+ ```shell
83
+ # get stack analysis in json format
84
+ $ npx @trustify-da/trustify-da-javascript-client stack /path/to/pom.xml
85
+
86
+ # get stack analysis in json format (summary only)
87
+ $ npx @trustify-da/trustify-da-javascript-client stack /path/to/pom.xml --summary
88
+
89
+ # get stack analysis in html format format
90
+ $ npx @trustify-da/trustify-da-javascript-client stack /path/to/pom.xml --html
91
+
92
+ # get component analysis
93
+ $ npx @trustify-da/trustify-da-javascript-client component /path/to/pom.xml
94
+ ```
95
+ </li>
96
+
97
+ <li>
98
+ Use as Global Binary
99
+
100
+ ```shell
101
+ npm install --global @trustify-da/trustify-da-javascript-client
102
+ ```
103
+
104
+ ```shell
105
+ # get stack analysis in json format
106
+ $ trustify-da-javascript-client stack /path/to/pom.xml
107
+
108
+ # get stack analysis in json format (summary only)
109
+ $ trustify-da-javascript-client stack /path/to/pom.xml --summary
110
+
111
+ # get stack analysis in html format format
112
+ $ trustify-da-javascript-client stack /path/to/pom.xml --html
113
+
114
+ # get component analysis
115
+ $ trustify-da-javascript-client component /path/to/pom.xml
116
+ ```
117
+ </li>
118
+ </ul>
119
+
120
+ <h3>Supported Ecosystems</h3>
121
+ <ul>
122
+ <li><a href="https://www.java.com/">Java</a> - <a href="https://maven.apache.org/">Maven</a></li>
123
+ <li><a href="https://www.javascript.com/">JavaScript</a> - <a href="https://www.npmjs.com/">Npm</a></li>
124
+ <li><a href="https://www.javascript.com/">JavaScript</a> - <a href="https://pnpm.io/">pnpm</a></li>
125
+ <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>
126
+ <li><a href="https://go.dev/">Golang</a> - <a href="https://go.dev/blog/using-go-modules/">Go Modules</a></li>
127
+ <li><a href="https://www.python.org/">Python</a> - <a href="https://pypi.org/project/pip/">pip Installer</a></li>
128
+ <li><a href="https://gradle.org/">Gradle (Groovy and Kotlin DSL)</a> - <a href="https://gradle.org/install/">Gradle Installation</a></li>
129
+ </ul>
130
+
131
+ <h3>Excluding Packages</h3>
132
+ <p>
133
+ Excluding a package from any analysis can be achieved by marking the package for exclusion.
134
+ </p>
135
+
136
+ <ul>
137
+ <li>
138
+ <em>Java Maven</em> users can add a comment in <em>pom.xml</em>
139
+
140
+ ```xml
141
+ <dependency> <!--exhortignore-->
142
+ <groupId>...</groupId>
143
+ <artifactId>...</artifactId>
144
+ <version>...</version>
145
+ </dependency>
146
+ ```
147
+ </li>
148
+
149
+ </ul>
150
+ <ul>
151
+ <li>
152
+ <em>Javascript</em> users can add a root (key, value) pair with value of list of names (strings) to be ignored (without versions), and key called <b>exhortignore</b> in <em>package.json</em>, example:
153
+
154
+ ```json
155
+ {
156
+ "name": "sample",
157
+ "version": "1.0.0",
158
+ "description": "",
159
+ "main": "js",
160
+ "keywords": [],
161
+ "author": "",
162
+ "license": "ISC",
163
+ "dependencies": {
164
+ "dotenv": "^8.2.0",
165
+ "express": "^4.17.1",
166
+ "jsonwebtoken": "^8.5.1",
167
+ "mongoose": "^5.9.18"
168
+ },
169
+ "exhortignore": [
170
+ "jsonwebtoken"
171
+ ]
172
+ }
173
+ ```
174
+
175
+ <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:
176
+ ```go
177
+ module github.com/trustify-da/SaaSi/deployer
178
+
179
+ go 1.19
180
+
181
+ require (
182
+ github.com/gin-gonic/gin v1.9.1
183
+ github.com/google/uuid v1.1.2
184
+ github.com/jessevdk/go-flags v1.5.0 //exhortignore
185
+ github.com/kr/pretty v0.3.1
186
+ gopkg.in/yaml.v2 v2.4.0
187
+ k8s.io/apimachinery v0.26.1
188
+ k8s.io/client-go v0.26.1
189
+ )
190
+
191
+ require (
192
+ github.com/davecgh/go-spew v1.1.1 // indirect exhortignore
193
+ github.com/emicklei/go-restful/v3 v3.9.0 // indirect
194
+ github.com/go-logr/logr v1.2.3 // indirect //exhortignore
195
+
196
+ )
197
+ ```
198
+
199
+ <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:
200
+ ```properties
201
+ anyio==3.6.2
202
+ asgiref==3.4.1
203
+ beautifulsoup4==4.12.2
204
+ certifi==2023.7.22
205
+ chardet==4.0.0
206
+ click==8.0.4 #exhortignore
207
+ contextlib2==21.6.0
208
+ fastapi==0.75.1
209
+ Flask==2.0.3
210
+ h11==0.13.0
211
+ idna==2.10
212
+ immutables==0.19
213
+ importlib-metadata==4.8.3
214
+ itsdangerous==2.0.1
215
+ Jinja2==3.0.3
216
+ MarkupSafe==2.0.1
217
+ pydantic==1.9.2 # exhortignore
218
+ requests==2.25.1
219
+ six==1.16.0
220
+ sniffio==1.2.0
221
+ soupsieve==2.3.2.post1
222
+ starlette==0.17.1
223
+ typing_extensions==4.1.1
224
+ urllib3==1.26.16
225
+ uvicorn==0.17.0
226
+ Werkzeug==2.0.3
227
+ zipp==3.6.0
228
+
229
+ ```
230
+
231
+ <em>Gradle</em> users can add in build.gradle a comment with //exhortignore next to the package to be ignored:
232
+ ```build.gradle
233
+ plugins {
234
+ id 'java'
235
+ }
236
+
237
+ group = 'groupName'
238
+ version = 'version'
239
+
240
+ repositories {
241
+ mavenCentral()
242
+ }
243
+
244
+ dependencies {
245
+ implementation "groupId:artifactId:version" // exhortignore
246
+ }
247
+ test {
248
+ useJUnitPlatform()
249
+ }
250
+ ```
251
+
252
+ All of the 5 above examples are valid for marking a package to be ignored
253
+ </li>
254
+
255
+ </ul>
256
+
257
+ <h3>Customization</h3>
258
+ <p>
259
+ There are 2 approaches for customizing <em>Exhort JavaScript API</em>. Whether you're using this API as a
260
+ <em>Global Module</em>, a <em>Remote Script</em>, or an <em>ESM Module</em>, you can use <em>Environment Variables</em>
261
+ for various customization.
262
+
263
+ However, <em>ESM Module</em> users, can opt for customizing programmatically:
264
+
265
+ ```javascript
266
+ import exhort from '@trustify-da/trustify-da-javascript-client'
267
+ import fs from 'node:fs'
268
+
269
+ let options = {
270
+ 'TRUSTIFY_DA_MVN_PATH': '/path/to/my/mvn',
271
+ 'TRUSTIFY_DA_NPM_PATH': '/path/to/npm',
272
+ 'TRUSTIFY_DA_PNPM_PATH': '/path/to/pnpm',
273
+ 'TRUSTIFY_DA_GO_PATH': '/path/to/go',
274
+ //python - python3, pip3 take precedence if python version > 3 installed
275
+ 'TRUSTIFY_DA_PYTHON3_PATH' : '/path/to/python3',
276
+ 'TRUSTIFY_DA_PIP3_PATH' : '/path/to/pip3',
277
+ 'TRUSTIFY_DA_PYTHON_PATH' : '/path/to/python',
278
+ 'TRUSTIFY_DA_PIP_PATH' : '/path/to/pip',
279
+ 'TRUSTIFY_DA_GRADLE_PATH' : '/path/to/gradle',
280
+ // Configure proxy for all requests
281
+ 'TRUSTIFY_DA_PROXY_URL': 'http://proxy.example.com:8080'
282
+ }
283
+
284
+ // Get stack analysis in JSON format ( all package managers, pom.xml is as an example here)
285
+ let stackAnalysis = await exhort.stackAnalysis('/path/to/pom.xml', false, options)
286
+ // Get stack analysis in HTML format in string ( all package managers, pom.xml is as an example here)
287
+ let stackAnalysisHtml = await exhort.stackAnalysis('/path/to/pom.xml', true, options)
288
+
289
+ // Get component analysis in JSON format
290
+ let componentAnalysis = await exhort.componentAnalysis('/path/to/pom.xml', options)
291
+ ```
292
+ **_Environment variables takes precedence._**
293
+ </p>
294
+
295
+ <h4>Proxy Configuration</h4>
296
+ <p>
297
+ 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.
298
+
299
+ You can set the proxy URL in two ways:
300
+
301
+ 1. Using environment variable:
302
+ ```shell
303
+ export TRUSTIFY_DA_PROXY_URL=http://proxy.example.com:8080
304
+ ```
305
+
306
+ 2. Using the options object when calling the API programmatically:
307
+ ```javascript
308
+ const options = {
309
+ 'TRUSTIFY_DA_PROXY_URL': 'http://proxy.example.com:8080'
310
+ }
311
+ ```
312
+
313
+ 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.
314
+ </p>
315
+
316
+ <h4>Customizing Executables</h4>
317
+ <p>
318
+ This project uses each ecosystem's executable for creating dependency trees. These executables are expected to be
319
+ present on the system's PATH environment. If they are not, or perhaps you want to use custom ones. Use can use the
320
+ following keys for setting custom paths for the said executables.
321
+ </p>
322
+
323
+ <table>
324
+ <tr>
325
+ <th>Ecosystem</th>
326
+ <th>Default</th>
327
+ <th>Executable Key</th>
328
+ </tr>
329
+ <tr>
330
+ <td><a href="https://maven.apache.org/">Maven</a></td>
331
+ <td><em>mvn</em></td>
332
+ <td>TRUSTIFY_DA_MVN_PATH</td>
333
+ </tr>
334
+ <tr>
335
+ <td><a href="https://maven.apache.org/">Maven</a></td>
336
+ <td><em>maven</em></td>
337
+ <td>TRUSTIFY_DA_PREFER_MVNW</td>
338
+ </tr>
339
+ <tr>
340
+ <td><a href="https://www.npmjs.com/">NPM</a></td>
341
+ <td><em>npm</em></td>
342
+ <td>TRUSTIFY_DA_NPM_PATH</td>
343
+ </tr>
344
+ <tr>
345
+ <td><a href="https://pnpm.io/">PNPM</a></td>
346
+ <td><em>pnpm</em></td>
347
+ <td>TRUSTIFY_DA_PNPM_PATH</td>
348
+ </tr>
349
+ <tr>
350
+ <td><a href="https://classic.yarnpkg.com/">Yarn Classic</a> / <a href="https://yarnpkg.com/">Yarn Berry</a></td>
351
+ <td><em>yarn</em></td>
352
+ <td>TRUSTIFY_DA_YARN_PATH</td>
353
+ </tr>
354
+ <tr>
355
+ <td><a href="https://go.dev/blog/using-go-modules/">Go Modules</a></td>
356
+ <td><em>go</em></td>
357
+ <td>TRUSTIFY_DA_GO_PATH</td>
358
+ </tr>
359
+ <tr>
360
+ <td><a href="https://www.python.org/">Python programming language</a></td>
361
+ <td><em>python3</em></td>
362
+ <td>TRUSTIFY_DA_PYTHON3_PATH</td>
363
+ </tr>
364
+ <tr>
365
+ <td><a href="https://pypi.org/project/pip/">Python pip Package Installer</a></td>
366
+ <td><em>pip3</em></td>
367
+ <td>TRUSTIFY_DA_PIP3_PATH</td>
368
+ </tr>
369
+ <tr>
370
+ <td><a href="https://www.python.org/">Python programming language</a></td>
371
+ <td><em>python</em></td>
372
+ <td>TRUSTIFY_DA_PYTHON_PATH</td>
373
+ </tr>
374
+ <tr>
375
+ <td><a href="https://pypi.org/project/pip/">Python pip Package Installer</a></td>
376
+ <td><em>pip</em></td>
377
+ <td>TRUSTIFY_DA_PIP_PATH</td>
378
+ </tr>
379
+ <tr>
380
+ <td><a href="https://gradle.org/">Gradle</a></td>
381
+ <td><em>gradle</em></td>
382
+ <td>TRUSTIFY_DA_GRADLE_PATH</td>
383
+ </tr>
384
+ <tr>
385
+ <td><a href="https://gradle.org/">Gradle</a></td>
386
+ <td><em>gradle</em></td>
387
+ <td>TRUSTIFY_DA_PREFER_GRADLEW</td>
388
+ </tr>
389
+ </table>
390
+
391
+ #### Match Manifest Versions Feature
392
+
393
+ ##### Background
394
+
395
+ In Python pip and in golang go modules package managers ( especially in Python pip) , There is a big chance that for a certain manifest and a given package inside it, the client machine environment has different version installed/resolved
396
+ for that package, which can lead to perform the analysis on the installed packages' versions , instead on the declared versions ( in manifests - that is requirements.txt/go.mod ), and this
397
+ can cause a confusion for the user in the client consuming the API and leads to inconsistent output ( in THE manifest there is version X For a given Package `A` , and in the analysis report there is another version for the same package `A` - Y).
398
+
399
+ ##### Usage
400
+
401
+ To eliminate confusion and improve clarity as discussed above, the following setting was introduced - `MATCH_MANIFEST_VERSIONS`, in the form of environment variable/key in opts ( as usual , environment variable takes precedence )
402
+ for two ecosystems:
403
+ - Golang - Go Modules
404
+ - Python - pip
405
+
406
+ Two possible values for this setting:
407
+
408
+ 1. MATCH_MANIFEST_VERSIONS="false" - means that if installed/resolved versions of packages are different than the ones declared in the manifest, the process will ignore this difference and will continue to analysis with installed/resolved versions ( this is the original logic flow )
409
+ <br>
410
+
411
+
412
+ 2. MATCH_MANIFEST_VERSIONS="true" - means that before starting the analysis,
413
+ the api will compare all the versions of packages in manifest against installed/resolved versions on client' environment, in case there is a difference, it will throw an error to the client/user with message containing the first encountered versions mismatch, including package name, and the versions difference, and will suggest to set setting `MATCH_MANIFEST_VERSIONS`="false" to ignore all differences
414
+
415
+ #### Golang Support
416
+
417
+ By default, Golang dependency resolution follows the [Minimal Version Selection (MVS) Algorithm](https://go.dev/ref/mod#minimal-version-selection).
418
+ This means that when analyzing a project, only the module versions that would actually be included in the final executable are considered.
419
+
420
+ For example, if your `go.mod` file declares two modules, `a` and `b`, and both depend on the same package `c` (same major version `v1`) but with different minor versions:
421
+
422
+ - `namespace/c/v1@v1.1`
423
+ - `namespace/c/v1@v1.2`
424
+
425
+ Only one of these versions — the minimal version selected by MVS — will be included in the generated SBOM and analysis results.
426
+ This mirrors the behavior of a real Go build, where only one minor version of a given major version can be present in the executable (since Go treats packages with the same name and major version as identical).
427
+
428
+ The MVS-based resolution is **enabled by default**.
429
+ If you want to disable this behavior and instead include **all transitive module versions** (as listed in `go.mod` dependencies), set the system property or environment variable:
430
+
431
+ ```bash
432
+ TRUSTIFY_DA_GO_MVS_LOGIC_ENABLED=false
433
+ ```
434
+
435
+ #### Python Support
436
+
437
+ 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
438
+ Binaries passed to environment variables. In any case, If the package is not installed , then an error will be thrown.
439
+
440
+ There is an experimental feature of installing the requirements.txt on a virtual env(only python3 or later is supported for this feature) - in this case,
441
+ it's important to pass in a path to python3 binary as `TRUSTIFY_DA_PYTHON3_PATH` or instead make sure that python3 is on the system path.
442
+ in such case, You can use that feature by setting environment variable `TRUSTIFY_DA_PYTHON_VIRTUAL_ENV` to true.
443
+
444
+ ##### "Best Efforts Installation"
445
+ Since Python pip packages are very sensitive/picky regarding python version changes( every small range of versions is only tailored for a certain python version), I'm introducing this feature, that
446
+ tries to install all packages in requirements.txt onto created virtual environment while **disregarding** versions declared for packages in requirements.txt.
447
+ This increasing the chances and the probability that the automatic installation will succeed.
448
+
449
+ ###### Usage
450
+ A New setting is introduced - `TRUSTIFY_DA_PYTHON_INSTALL_BEST_EFFORTS` (as both env variable/key in `options` object)
451
+ 1. `TRUSTIFY_DA_PYTHON_INSTALL_BEST_EFFORTS`="false" - install requirements.txt while respecting declared versions for all packages.
452
+ 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 setting `MATCH_MANIFEST_VERSIONS` to 'false'.
453
+
454
+ ##### Using `pipdeptree`
455
+ By default, The API algorithm will use native commands of PIP installer as data source to build the dependency tree.
456
+ 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'.
457
+
458
+ #### Toggle Red Hat Trusted Content recommendations
459
+ Both the HTML-based report and JSON response will by default contain recommendations for migrating to Red Hat-based Trusted Content repositories. This feature can be disabled by setting `TRUSTIFY_DA_RECOMMENDATIONS_ENABLED` to 'false' via environment variables or options.
460
+
461
+ #### Additional CLI arguments
462
+ 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.
463
+
464
+ |Ecosystem|Key |
465
+ |---------|---------------|
466
+ |Maven |TRUSTIFY_DA_MVN_ARGS|
467
+
468
+
469
+ <!-- Badge links -->
470
+ [0]: https://img.shields.io/github/v/release/guacsec/trustify-da-javascript-client?color=green&label=latest
471
+ [1]: https://img.shields.io/github/v/release/guacsec/trustify-da-javascript-client?color=yellow&include_prereleases&label=early-access
472
+
473
+ ### Known Issues
474
+
475
+ - For pip requirements.txt - It's been observed that for python versions 3.11.x, there might be slowness for invoking the analysis.
476
+ If you encounter a performance issue with version >= 3.11.x, kindly try to set environment variable/option `TRUSTIFY_DA_PIP_USE_DEP_TREE=true`, before calling the analysis.
477
+
478
+
479
+ - For maven pom.xml, it has been noticed that using java 17 might cause stack analysis to hang forever.
480
+ This is caused by maven [`dependency` plugin](https://maven.apache.org/plugins/maven-dependency-plugin/) bug when running with JDK/JRE' JVM version 17.
481
+
482
+ To overcome this, you can use any other java version (14,20,21, etc..). ( best way is to install JDK/JRE version different from 17 , and set the location of the installation in environment variable `JAVA_HOME` so maven will use it.)