@trustify-da/trustify-da-javascript-client 0.3.0-ea.608d6fa → 0.3.0-ea.62b88e5

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 (94) hide show
  1. package/README.md +326 -21
  2. package/dist/package.json +36 -27
  3. package/dist/src/analysis.d.ts +58 -14
  4. package/dist/src/analysis.js +118 -17
  5. package/dist/src/batch_opts.d.ts +24 -0
  6. package/dist/src/batch_opts.js +35 -0
  7. package/dist/src/cli.js +357 -8
  8. package/dist/src/config.d.ts +120 -0
  9. package/dist/src/config.js +260 -0
  10. package/dist/src/cyclone_dx_sbom.d.ts +27 -1
  11. package/dist/src/cyclone_dx_sbom.js +84 -10
  12. package/dist/src/index.d.ts +151 -16
  13. package/dist/src/index.js +369 -36
  14. package/dist/src/license/index.d.ts +4 -4
  15. package/dist/src/license/index.js +13 -7
  16. package/dist/src/license/license_utils.js +4 -1
  17. package/dist/src/license/licenses_api.d.ts +3 -3
  18. package/dist/src/license/licenses_api.js +1 -1
  19. package/dist/src/oci_image/images.d.ts +1 -1
  20. package/dist/src/oci_image/images.js +15 -1
  21. package/dist/src/oci_image/utils.d.ts +5 -5
  22. package/dist/src/oci_image/utils.js +11 -2
  23. package/dist/src/package_version.d.ts +8 -0
  24. package/dist/src/package_version.js +31 -0
  25. package/dist/src/provider.d.ts +8 -4
  26. package/dist/src/provider.js +16 -5
  27. package/dist/src/providers/base_java.d.ts +67 -12
  28. package/dist/src/providers/base_java.js +82 -61
  29. package/dist/src/providers/base_javascript.d.ts +91 -10
  30. package/dist/src/providers/base_javascript.js +214 -24
  31. package/dist/src/providers/base_pyproject.d.ts +158 -0
  32. package/dist/src/providers/base_pyproject.js +322 -0
  33. package/dist/src/providers/containerfile_parser.d.ts +5 -0
  34. package/dist/src/providers/containerfile_parser.js +20 -0
  35. package/dist/src/providers/golang_gomodules.d.ts +23 -13
  36. package/dist/src/providers/golang_gomodules.js +208 -120
  37. package/dist/src/providers/gomod_parser.d.ts +4 -0
  38. package/dist/src/providers/gomod_parser.js +16 -0
  39. package/dist/src/providers/java_gradle.d.ts +67 -0
  40. package/dist/src/providers/java_gradle.js +320 -22
  41. package/dist/src/providers/java_gradle_groovy.d.ts +1 -1
  42. package/dist/src/providers/java_gradle_kotlin.d.ts +1 -1
  43. package/dist/src/providers/java_maven.d.ts +37 -9
  44. package/dist/src/providers/java_maven.js +269 -11
  45. package/dist/src/providers/javascript_bun.d.ts +22 -0
  46. package/dist/src/providers/javascript_bun.js +141 -0
  47. package/dist/src/providers/javascript_npm.d.ts +19 -0
  48. package/dist/src/providers/javascript_npm.js +61 -1
  49. package/dist/src/providers/javascript_pnpm.d.ts +14 -1
  50. package/dist/src/providers/javascript_pnpm.js +55 -5
  51. package/dist/src/providers/javascript_yarn.d.ts +12 -0
  52. package/dist/src/providers/javascript_yarn.js +75 -2
  53. package/dist/src/providers/manifest.d.ts +2 -0
  54. package/dist/src/providers/manifest.js +28 -7
  55. package/dist/src/providers/marker_evaluator.d.ts +14 -0
  56. package/dist/src/providers/marker_evaluator.js +191 -0
  57. package/dist/src/providers/oci_dockerfile.d.ts +51 -0
  58. package/dist/src/providers/oci_dockerfile.js +177 -0
  59. package/dist/src/providers/processors/yarn_berry_processor.d.ts +6 -2
  60. package/dist/src/providers/processors/yarn_berry_processor.js +91 -7
  61. package/dist/src/providers/processors/yarn_classic_processor.d.ts +6 -2
  62. package/dist/src/providers/processors/yarn_classic_processor.js +8 -6
  63. package/dist/src/providers/python_controller.d.ts +5 -1
  64. package/dist/src/providers/python_controller.js +69 -8
  65. package/dist/src/providers/python_pip.d.ts +5 -0
  66. package/dist/src/providers/python_pip.js +6 -6
  67. package/dist/src/providers/python_pip_pyproject.d.ts +61 -0
  68. package/dist/src/providers/python_pip_pyproject.js +146 -0
  69. package/dist/src/providers/python_poetry.d.ts +98 -0
  70. package/dist/src/providers/python_poetry.js +286 -0
  71. package/dist/src/providers/python_uv.d.ts +46 -0
  72. package/dist/src/providers/python_uv.js +275 -0
  73. package/dist/src/providers/requirements_parser.js +1 -1
  74. package/dist/src/providers/rust_cargo.d.ts +12 -3
  75. package/dist/src/providers/rust_cargo.js +107 -31
  76. package/dist/src/providers/tree-sitter-containerfile.wasm +0 -0
  77. package/dist/src/providers/tree-sitter-gomod.wasm +0 -0
  78. package/dist/src/remediate.d.ts +107 -0
  79. package/dist/src/remediate.js +244 -0
  80. package/dist/src/remediation.d.ts +81 -0
  81. package/dist/src/remediation.js +475 -0
  82. package/dist/src/remediation_report.d.ts +23 -0
  83. package/dist/src/remediation_report.js +180 -0
  84. package/dist/src/sbom.d.ts +25 -1
  85. package/dist/src/sbom.js +23 -2
  86. package/dist/src/tools.d.ts +37 -13
  87. package/dist/src/tools.js +92 -13
  88. package/dist/src/updaters/maven_updater.d.ts +58 -0
  89. package/dist/src/updaters/maven_updater.js +345 -0
  90. package/dist/src/updaters/toml_updater.d.ts +62 -0
  91. package/dist/src/updaters/toml_updater.js +276 -0
  92. package/dist/src/workspace.d.ts +71 -0
  93. package/dist/src/workspace.js +257 -0
  94. package/package.json +37 -28
@@ -1,8 +1,12 @@
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 };
9
+ export { appendAnalysisQueryParams };
6
10
  }
7
11
  export default _default;
8
12
  /**
@@ -11,28 +15,62 @@ export default _default;
11
15
  * @param {string} manifest - path for the manifest
12
16
  * @param {string} url - the backend url to send the request to
13
17
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
14
- * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
18
+ * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts').AnalysisReport>}
15
19
  */
16
- declare function requestComponent(provider: import("./provider").Provider, manifest: string, url: string, opts?: import("index.js").Options): Promise<import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport>;
20
+ declare function requestComponent(provider: any, manifest: string, url: string, opts?: any): Promise<import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts").AnalysisReport>;
17
21
  /**
18
- * Send a stack analysis request and get the report as 'text/html' or 'application/json'.
19
- * @param {import('./provider').Provider} provider - the provided data for constructing the request
20
- * @param {string} manifest - path for the manifest
21
- * @param {string} url - the backend url to send the request to
22
- * @param {boolean} [html=false] - true will return 'text/html', false will return 'application/json'
23
- * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
24
- * @returns {Promise<string|import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
22
+ * @overload
23
+ * @param {import('./provider').Provider} provider
24
+ * @param {string} manifest
25
+ * @param {string} url
26
+ * @param {true} [html]
27
+ * @param {import("index.js").Options} [opts={}]
28
+ * @returns {Promise<string>}
25
29
  */
26
- declare function requestStack(provider: import("./provider").Provider, manifest: string, url: string, html?: boolean, opts?: import("index.js").Options): Promise<string | import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport>;
30
+ declare function requestStack(provider: any, manifest: string, url: string, html?: true | undefined, opts?: any): Promise<string>;
31
+ /**
32
+ * @overload
33
+ * @param {import('./provider').Provider} provider
34
+ * @param {string} manifest
35
+ * @param {string} url
36
+ * @param {false} [html]
37
+ * @param {import("index.js").Options} [opts={}]
38
+ * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts').AnalysisReport>>}
39
+ */
40
+ declare function requestStack(provider: any, manifest: string, url: string, html?: false | undefined, opts?: any): Promise<import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts").AnalysisReport>;
41
+ /**
42
+ * @overload
43
+ * @param {Object.<string, object>} sbomByPurl
44
+ * @param {string} url
45
+ * @param {true} [html=false]
46
+ * @param {import("index.js").Options} [opts={}]
47
+ * @returns {Promise<string>}
48
+ */
49
+ declare function requestStackBatch(sbomByPurl: {
50
+ [x: string]: object;
51
+ }, url: string, html?: true | undefined, opts?: any): Promise<string>;
52
+ /**
53
+ * @overload
54
+ * @param {Object.<string, object>} sbomByPurl
55
+ * @param {string} url
56
+ * @param {false} [html=false]
57
+ * @param {import("index.js").Options} [opts={}]
58
+ * @returns {Promise<Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts').AnalysisReport>>}
59
+ */
60
+ declare function requestStackBatch(sbomByPurl: {
61
+ [x: string]: object;
62
+ }, url: string, html?: false | undefined, opts?: any): Promise<{
63
+ [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts").AnalysisReport;
64
+ }>;
27
65
  /**
28
66
  *
29
67
  * @param {Array<string>} imageRefs
30
68
  * @param {string} url
31
69
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
32
- * @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
70
+ * @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts').AnalysisReport>>}
33
71
  */
34
- declare function requestImages(imageRefs: Array<string>, url: string, html?: boolean, opts?: import("index.js").Options): Promise<string | {
35
- [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
72
+ declare function requestImages(imageRefs: Array<string>, url: string, html?: boolean, opts?: any): Promise<string | {
73
+ [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts").AnalysisReport;
36
74
  }>;
37
75
  /**
38
76
  *
@@ -40,4 +78,10 @@ declare function requestImages(imageRefs: Array<string>, url: string, html?: boo
40
78
  * @param {import("index.js").Options} [opts={}] - optional various options to pass headers for t he validateToken Request
41
79
  * @return {Promise<number>} return the HTTP status Code of the response from the validate token request.
42
80
  */
43
- declare function validateToken(url: any, opts?: import("index.js").Options): Promise<number>;
81
+ declare function validateToken(url: any, opts?: any): Promise<number>;
82
+ /**
83
+ * Append common analysis query parameters (recommend, providers, sources) to a URL.
84
+ * @param {URL} url - the URL object to append query parameters to
85
+ * @param {import("index.js").Options} [opts={}] - options containing parameter overrides
86
+ */
87
+ declare function appendAnalysisQueryParams(url: URL, opts?: any): void;
@@ -4,7 +4,27 @@ 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
- export default { requestComponent, requestStack, requestImages, validateToken };
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, appendAnalysisQueryParams };
10
+ /**
11
+ * @overload
12
+ * @param {import('./provider').Provider} provider
13
+ * @param {string} manifest
14
+ * @param {string} url
15
+ * @param {true} [html]
16
+ * @param {import("index.js").Options} [opts={}]
17
+ * @returns {Promise<string>}
18
+ */
19
+ /**
20
+ * @overload
21
+ * @param {import('./provider').Provider} provider
22
+ * @param {string} manifest
23
+ * @param {string} url
24
+ * @param {false} [html]
25
+ * @param {import("index.js").Options} [opts={}]
26
+ * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts').AnalysisReport>>}
27
+ */
8
28
  /**
9
29
  * Send a stack analysis request and get the report as 'text/html' or 'application/json'.
10
30
  * @param {import('./provider').Provider} provider - the provided data for constructing the request
@@ -12,12 +32,15 @@ export default { requestComponent, requestStack, requestImages, validateToken };
12
32
  * @param {string} url - the backend url to send the request to
13
33
  * @param {boolean} [html=false] - true will return 'text/html', false will return 'application/json'
14
34
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
15
- * @returns {Promise<string|import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
35
+ * @returns {Promise<string|import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts').AnalysisReport>}
16
36
  */
17
37
  async function requestStack(provider, manifest, url, html = false, opts = {}) {
18
38
  opts["source-manifest"] = Buffer.from(fs.readFileSync(manifest).toString()).toString('base64');
19
39
  opts["manifest-type"] = path.parse(manifest).base;
20
40
  let provided = await provider.provideStack(manifest, opts); // throws error if content providing failed
41
+ if (provided.batch) {
42
+ return requestStackBatch(JSON.parse(provided.content), url, html, opts);
43
+ }
21
44
  opts["source-manifest"] = "";
22
45
  opts[TRUSTIFY_DA_OPERATION_TYPE_HEADER.toUpperCase().replaceAll("-", "_")] = "stack-analysis";
23
46
  let startTime = new Date();
@@ -36,9 +59,7 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
36
59
  body: provided.content
37
60
  }, opts);
38
61
  const finalUrl = new URL(`${url}/api/v5/analysis`);
39
- if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
40
- finalUrl.searchParams.append('recommend', 'false');
41
- }
62
+ appendAnalysisQueryParams(finalUrl, opts);
42
63
  let resp = await fetch(finalUrl, fetchOptions);
43
64
  let result;
44
65
  if (resp.status === 200) {
@@ -72,11 +93,14 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
72
93
  * @param {string} manifest - path for the manifest
73
94
  * @param {string} url - the backend url to send the request to
74
95
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
75
- * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
96
+ * @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts').AnalysisReport>}
76
97
  */
77
98
  async function requestComponent(provider, manifest, url, opts = {}) {
78
99
  opts["source-manifest"] = Buffer.from(fs.readFileSync(manifest).toString()).toString('base64');
79
100
  let provided = await provider.provideComponent(manifest, opts); // throws error if content providing failed
101
+ if (provided.batch) {
102
+ return requestStackBatch(JSON.parse(provided.content), url, false, opts);
103
+ }
80
104
  opts["source-manifest"] = "";
81
105
  opts[TRUSTIFY_DA_OPERATION_TYPE_HEADER.toUpperCase().replaceAll("-", "_")] = "component-analysis";
82
106
  if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
@@ -93,9 +117,7 @@ async function requestComponent(provider, manifest, url, opts = {}) {
93
117
  body: provided.content
94
118
  }, opts);
95
119
  const finalUrl = new URL(`${url}/api/v5/analysis`);
96
- if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
97
- finalUrl.searchParams.append('recommend', 'false');
98
- }
120
+ appendAnalysisQueryParams(finalUrl, opts);
99
121
  let resp = await fetch(finalUrl, fetchOptions);
100
122
  let result;
101
123
  if (resp.status === 200) {
@@ -109,7 +131,9 @@ async function requestComponent(provider, manifest, url, opts = {}) {
109
131
  console.log(JSON.stringify(result, null, 4));
110
132
  console.log("Ending time of sending component analysis request to Trustify DA backend server= " + new Date());
111
133
  }
112
- const licenseCheckEnabled = getCustom('TRUSTIFY_DA_LICENSE_CHECK', 'true', opts) !== 'false' && opts.licenseCheck !== false;
134
+ const licenseCheckEnabled = typeof opts.licenseCheck === 'boolean'
135
+ ? opts.licenseCheck
136
+ : getCustom('TRUSTIFY_DA_LICENSE_CHECK', 'true', opts) !== 'false';
113
137
  if (licenseCheckEnabled) {
114
138
  try {
115
139
  result.licenseSummary = await runLicenseCheck(provided.content, manifest, url, opts, result);
@@ -124,12 +148,72 @@ async function requestComponent(provider, manifest, url, opts = {}) {
124
148
  }
125
149
  return Promise.resolve(result);
126
150
  }
151
+ /**
152
+ * @overload
153
+ * @param {Object.<string, object>} sbomByPurl
154
+ * @param {string} url
155
+ * @param {true} [html=false]
156
+ * @param {import("index.js").Options} [opts={}]
157
+ * @returns {Promise<string>}
158
+ */
159
+ /**
160
+ * @overload
161
+ * @param {Object.<string, object>} sbomByPurl
162
+ * @param {string} url
163
+ * @param {false} [html=false]
164
+ * @param {import("index.js").Options} [opts={}]
165
+ * @returns {Promise<Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts').AnalysisReport>>}
166
+ */
167
+ /**
168
+ * Send a batch stack analysis request for multiple manifests (SBOMs keyed by purl).
169
+ * @param {Object.<string, object>} sbomByPurl - Map of root purl to CycloneDX SBOM object
170
+ * @param {string} url - the backend url
171
+ * @param {boolean} [html=false] - true returns HTML, false returns JSON
172
+ * @param {import("index.js").Options} [opts={}]
173
+ * @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts').AnalysisReport>>}
174
+ */
175
+ async function requestStackBatch(sbomByPurl, url, html = false, opts = {}) {
176
+ const finalUrl = new URL(`${url}/api/v5/batch-analysis`);
177
+ appendAnalysisQueryParams(finalUrl, opts);
178
+ const fetchOptions = addProxyAgent({
179
+ method: 'POST',
180
+ headers: {
181
+ 'Accept': html ? 'text/html' : 'application/json',
182
+ 'Content-Type': CYCLONEDX_JSON_MEDIA_TYPE,
183
+ ...getTokenHeaders(opts)
184
+ },
185
+ body: JSON.stringify(sbomByPurl)
186
+ }, opts);
187
+ const resp = await fetch(finalUrl, fetchOptions);
188
+ if (resp.status === 200) {
189
+ let result;
190
+ if (!html) {
191
+ result = await resp.json();
192
+ }
193
+ else {
194
+ result = await resp.text();
195
+ }
196
+ if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
197
+ const exRequestId = resp.headers.get("ex-request-id");
198
+ if (exRequestId) {
199
+ console.log("Unique Identifier associated with this request - ex-request-id=" + exRequestId);
200
+ }
201
+ console.log("Response body received from Trustify DA backend server : " + EOL + EOL);
202
+ console.log(JSON.stringify(result, null, 4));
203
+ console.log("Ending time of sending batch stack analysis request to Trustify DA backend server= " + new Date());
204
+ }
205
+ return result;
206
+ }
207
+ else {
208
+ 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()}`);
209
+ }
210
+ }
127
211
  /**
128
212
  *
129
213
  * @param {Array<string>} imageRefs
130
214
  * @param {string} url
131
215
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
132
- * @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
216
+ * @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport.ts').AnalysisReport>>}
133
217
  */
134
218
  async function requestImages(imageRefs, url, html = false, opts = {}) {
135
219
  const imageSboms = {};
@@ -138,18 +222,17 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
138
222
  imageSboms[parsedImageRef.getPackageURL().toString()] = generateImageSBOM(parsedImageRef, opts);
139
223
  }
140
224
  const finalUrl = new URL(`${url}/api/v5/batch-analysis`);
141
- if (opts['TRUSTIFY_DA_RECOMMENDATIONS_ENABLED'] === 'false') {
142
- finalUrl.searchParams.append('recommend', 'false');
143
- }
144
- const resp = await fetch(finalUrl, {
225
+ appendAnalysisQueryParams(finalUrl, opts);
226
+ const fetchOptions = addProxyAgent({
145
227
  method: 'POST',
146
228
  headers: {
147
229
  'Accept': html ? 'text/html' : 'application/json',
148
- 'Content-Type': 'application/vnd.cyclonedx+json',
230
+ 'Content-Type': CYCLONEDX_JSON_MEDIA_TYPE,
149
231
  ...getTokenHeaders(opts)
150
232
  },
151
233
  body: JSON.stringify(imageSboms),
152
- });
234
+ }, opts);
235
+ const resp = await fetch(finalUrl, fetchOptions);
153
236
  if (resp.status === 200) {
154
237
  let result;
155
238
  if (!html) {
@@ -173,6 +256,24 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
173
256
  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()}`);
174
257
  }
175
258
  }
259
+ /**
260
+ * Append common analysis query parameters (recommend, providers, sources) to a URL.
261
+ * @param {URL} url - the URL object to append query parameters to
262
+ * @param {import("index.js").Options} [opts={}] - options containing parameter overrides
263
+ */
264
+ function appendAnalysisQueryParams(url, opts = {}) {
265
+ if (getCustom('TRUSTIFY_DA_RECOMMEND', 'true', opts) === 'false') {
266
+ url.searchParams.append('recommend', 'false');
267
+ }
268
+ const providers = getCustom('TRUSTIFY_DA_PROVIDERS', null, opts);
269
+ if (providers) {
270
+ url.searchParams.append('providers', providers);
271
+ }
272
+ const sources = getCustom('TRUSTIFY_DA_SOURCES', null, opts);
273
+ if (sources) {
274
+ url.searchParams.append('sources', sources);
275
+ }
276
+ }
176
277
  /**
177
278
  *
178
279
  * @param url the backend url to send the request to
@@ -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
+ }