@trustify-da/trustify-da-javascript-client 0.2.4-ea-14 → 0.2.4-ea.2eeeeba

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 CHANGED
@@ -1,12 +1,14 @@
1
- # Exhort JavaScript API<br/>![latest-no-snapshot][0] ![latest-snapshot][1]
1
+ # Trustify Dependency Analytics JavaScript Client<br/>![latest-no-snapshot][0] ![latest-snapshot][1]
2
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).
3
+ * Looking for the OpenAPI Spec? Try [Trustify Dependency Analytics API](https://github.com/guacsec/trustify-da-api-spec)
4
+ * Looking for our Java API? Try [Trustify Dependency Analytics Java Client](https://github.com/guacsec/trustify-da-java-client).
5
+ * Looking for our Backend implementation? Try [Trustify Dependency Analytics](https://github.com/guacsec/trustify-dependency-analytics).
6
6
 
7
7
  <h3>Usage</h3>
8
8
  <p>
9
9
 
10
+ <strong>Prerequisites:</strong> The <code>TRUSTIFY_DA_BACKEND_URL</code> environment variable must be set to the URL of the Trustify Dependency Analytics backend service. You can set it as an environment variable or pass it in the options object (see <a href="#customization">Customization</a> section).
11
+
10
12
  <ul>
11
13
  <li>
12
14
  Use as ESM Module from an ESM module
@@ -15,16 +17,29 @@ Use as ESM Module from an ESM module
15
17
  npm install @trustify-da/trustify-da-javascript-client
16
18
  ```
17
19
 
20
+ ```shell
21
+ # Set the mandatory backend URL
22
+ export TRUSTIFY_DA_BACKEND_URL=https://trustify-da.example.com
23
+ ```
24
+
18
25
  ```javascript
19
- import exhort from '@trustify-da/trustify-da-javascript-client'
26
+ import client from '@trustify-da/trustify-da-javascript-client'
20
27
  import fs from 'node:fs'
21
28
 
22
29
  // Get stack analysis in JSON format
23
- let stackAnalysis = await exhort.stackAnalysis('/path/to/pom.xml')
30
+ let stackAnalysis = await client.stackAnalysis('/path/to/pom.xml')
24
31
  // Get stack analysis in HTML format (string)
25
- let stackAnalysisHtml = await exhort.stackAnalysis('/path/to/pom.xml', true)
32
+ let stackAnalysisHtml = await client.stackAnalysis('/path/to/pom.xml', true)
26
33
  // Get component analysis in JSON format
27
- let componentAnalysis = await exhort.componentAnalysis('/path/to/pom.xml')
34
+ let componentAnalysis = await client.componentAnalysis('/path/to/pom.xml')
35
+ // Get image analysis in JSON format
36
+ let imageAnalysis = await client.imageAnalysis(['docker.io/library/node:18'])
37
+ // Get image analysis in HTML format (string)
38
+ let imageAnalysisHtml = await client.imageAnalysis(['docker.io/library/node:18'], true)
39
+ // Analyze multiple images
40
+ let multipleImagesAnalysis = await client.imageAnalysis(['docker.io/library/node:18', 'docker.io/library/python:3.9'])
41
+ // Specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
42
+ let imageAnalysisWithArch = await client.imageAnalysis(['httpd:2.4.49^^amd64'])
28
43
  ```
29
44
  </li>
30
45
  </ul>
@@ -37,16 +52,16 @@ npm install @trustify-da/trustify-da-javascript-client
37
52
  ```
38
53
 
39
54
  ```javascript
40
- async function loadExhort()
55
+ async function loadTrustifyDa()
41
56
  {
42
57
  // 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
58
+ const { default: client } = await import('@trustify-da/trustify-da-javascript-client');
59
+ return client
45
60
  }
46
- const runExhort = (manifestPath) => {
61
+ const runTrustifyDa = (manifestPath) => {
47
62
  return new Promise(async ( resolve, reject) => {
48
63
  try {
49
- let stackAnalysisReport = await (await loadExhort()).stackAnalysis(manifestPath,false)
64
+ let stackAnalysisReport = await (await loadTrustifyDa()).stackAnalysis(manifestPath,false)
50
65
  resolve(stackAnalysisReport)
51
66
 
52
67
  } catch (error)
@@ -56,7 +71,7 @@ const runExhort = (manifestPath) => {
56
71
  });
57
72
  };
58
73
 
59
- runExhort("./path/to/manifest").then(resp => console.log(JSON.stringify(resp,null,4)))
74
+ runTrustifyDa("./path/to/manifest").then(resp => console.log(JSON.stringify(resp,null,4)))
60
75
  ```
61
76
  </li>
62
77
 
@@ -68,11 +83,12 @@ Use as CLI Script
68
83
  ```shell
69
84
  $ npx @trustify-da/trustify-da-javascript-client help
70
85
 
71
- Usage: trustify-da-javascript-client {component|stack}
86
+ Usage: trustify-da-javascript-client {component|stack|image|validate-token}
72
87
 
73
88
  Commands:
74
89
  trustify-da-javascript-client stack </path/to/manifest> [--html|--summary] produce stack report for manifest path
75
90
  trustify-da-javascript-client component <path/to/manifest> [--summary] produce component report for a manifest type and content
91
+ trustify-da-javascript-client image <image-refs..> [--html|--summary] produce image analysis report for OCI image references
76
92
 
77
93
  Options:
78
94
  --help Show help [boolean]
@@ -91,6 +107,22 @@ $ npx @trustify-da/trustify-da-javascript-client stack /path/to/pom.xml --html
91
107
 
92
108
  # get component analysis
93
109
  $ npx @trustify-da/trustify-da-javascript-client component /path/to/pom.xml
110
+
111
+ # get image analysis in json format
112
+ $ npx @trustify-da/trustify-da-javascript-client image docker.io/library/node:18
113
+
114
+ # get image analysis in json format (summary only)
115
+ # Note: summary returns an object with imageRef as key
116
+ $ npx @trustify-da/trustify-da-javascript-client image docker.io/library/node:18 --summary
117
+
118
+ # get image analysis in html format
119
+ $ npx @trustify-da/trustify-da-javascript-client image docker.io/library/node:18 --html
120
+
121
+ # analyze multiple images
122
+ $ npx @trustify-da/trustify-da-javascript-client image docker.io/library/node:18 docker.io/library/python:3.9
123
+
124
+ # specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
125
+ $ npx @trustify-da/trustify-da-javascript-client image httpd:2.4.49^^amd64
94
126
  ```
95
127
  </li>
96
128
 
@@ -113,6 +145,22 @@ $ trustify-da-javascript-client stack /path/to/pom.xml --html
113
145
 
114
146
  # get component analysis
115
147
  $ trustify-da-javascript-client component /path/to/pom.xml
148
+
149
+ # get image analysis in json format
150
+ $ trustify-da-javascript-client image docker.io/library/node:18
151
+
152
+ # get image analysis in json format (summary only)
153
+ # Note: summary returns an object with imageRef as key
154
+ $ trustify-da-javascript-client image docker.io/library/node:18 --summary
155
+
156
+ # get image analysis in html format
157
+ $ trustify-da-javascript-client image docker.io/library/node:18 --html
158
+
159
+ # analyze multiple images
160
+ $ trustify-da-javascript-client image docker.io/library/node:18 docker.io/library/python:3.9
161
+
162
+ # specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
163
+ $ trustify-da-javascript-client image httpd:2.4.49^^amd64
116
164
  ```
117
165
  </li>
118
166
  </ul>
@@ -256,17 +304,21 @@ All of the 5 above examples are valid for marking a package to be ignored
256
304
 
257
305
  <h3>Customization</h3>
258
306
  <p>
259
- There are 2 approaches for customizing <em>Exhort JavaScript API</em>. Whether you're using this API as a
307
+ There are 2 approaches for customizing <em>Trustify Dependency Analytics JavaScript Client</em>. Whether you're using this API as a
260
308
  <em>Global Module</em>, a <em>Remote Script</em>, or an <em>ESM Module</em>, you can use <em>Environment Variables</em>
261
309
  for various customization.
262
310
 
311
+ <strong>Note:</strong> The <code>TRUSTIFY_DA_BACKEND_URL</code> environment variable is <strong>mandatory</strong> and must be set to the URL of the Trustify Dependency Analytics backend service. Without this variable, the API will throw an error.
312
+
263
313
  However, <em>ESM Module</em> users, can opt for customizing programmatically:
264
314
 
265
315
  ```javascript
266
- import exhort from '@trustify-da/trustify-da-javascript-client'
316
+ import client from '@trustify-da/trustify-da-javascript-client'
267
317
  import fs from 'node:fs'
268
318
 
269
319
  let options = {
320
+ // Mandatory: Backend URL for Trustify Dependency Analytics service
321
+ 'TRUSTIFY_DA_BACKEND_URL': 'https://api.trustify.dev',
270
322
  'TRUSTIFY_DA_MVN_PATH': '/path/to/my/mvn',
271
323
  'TRUSTIFY_DA_NPM_PATH': '/path/to/npm',
272
324
  'TRUSTIFY_DA_PNPM_PATH': '/path/to/pnpm',
@@ -282,12 +334,19 @@ let options = {
282
334
  }
283
335
 
284
336
  // 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)
337
+ let stackAnalysis = await client.stackAnalysis('/path/to/pom.xml', false, options)
286
338
  // 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)
339
+ let stackAnalysisHtml = await client.stackAnalysis('/path/to/pom.xml', true, options)
288
340
 
289
341
  // Get component analysis in JSON format
290
- let componentAnalysis = await exhort.componentAnalysis('/path/to/pom.xml', options)
342
+ let componentAnalysis = await client.componentAnalysis('/path/to/pom.xml', options)
343
+
344
+ // Get image analysis in JSON format
345
+ let imageAnalysis = await client.imageAnalysis(['docker.io/library/node:18'], false, options)
346
+ // Get image analysis in HTML format in string
347
+ let imageAnalysisHtml = await client.imageAnalysis(['docker.io/library/node:18'], true, options)
348
+ // Specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
349
+ let imageAnalysisWithArch = await client.imageAnalysis(['httpd:2.4.49^^amd64'], false, options)
291
350
  ```
292
351
  **_Environment variables takes precedence._**
293
352
  </p>
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustify-da/trustify-da-javascript-client",
3
- "version": "0.2.4-ea-14",
3
+ "version": "0.2.4",
4
4
  "description": "Code-Ready Dependency Analytics JavaScript API.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/guacsec/trustify-da-javascript-client#README.md",
@@ -12,7 +12,9 @@
12
12
  "exhort",
13
13
  "secure",
14
14
  "supply-chain",
15
- "vulnerability"
15
+ "vulnerability",
16
+ "trustify",
17
+ "dependency analytics"
16
18
  ],
17
19
  "engines": {
18
20
  "node": ">= 20.0.0",
@@ -13,7 +13,7 @@ const rhdaPackageManagerHeader = "rhda-pkg-manager";
13
13
  /**
14
14
  * Adds proxy agent configuration to fetch options if a proxy URL is specified
15
15
  * @param {RequestInit} options - The base fetch options
16
- * @param {import("index.js").Options} opts - The exhort options that may contain proxy configuration
16
+ * @param {import("index.js").Options} opts - The trustify DA options that may contain proxy configuration
17
17
  * @returns {RequestInit} The fetch options with proxy agent if applicable
18
18
  */
19
19
  function addProxyAgent(options, opts) {
@@ -41,7 +41,7 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
41
41
  let startTime = new Date();
42
42
  let endTime;
43
43
  if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
44
- console.log("Starting time of sending stack analysis request to exhort server= " + startTime);
44
+ console.log("Starting time of sending stack analysis request to the dependency analytics server= " + startTime);
45
45
  }
46
46
  opts[rhdaPackageManagerHeader.toUpperCase().replaceAll("-", "_")] = provided.ecosystem;
47
47
  const fetchOptions = addProxyAgent({
@@ -72,15 +72,15 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
72
72
  console.log("Unique Identifier associated with this request - ex-request-id=" + exRequestId);
73
73
  }
74
74
  endTime = new Date();
75
- console.log("Response body received from exhort server : " + EOL + EOL);
75
+ console.log("Response body received from Trustify DA backend server : " + EOL + EOL);
76
76
  console.log(console.log(JSON.stringify(result, null, 4)));
77
- console.log("Ending time of sending stack analysis request to exhort server= " + endTime);
77
+ console.log("Ending time of sending stack analysis request to Trustify DA backend server= " + endTime);
78
78
  let time = (endTime - startTime) / 1000;
79
79
  console.log("Total Time in seconds: " + time);
80
80
  }
81
81
  }
82
82
  else {
83
- throw new Error(`Got error response from exhort backend - http return code : ${resp.status}, error message => ${await resp.text()}`);
83
+ throw new Error(`Got error response from Trustify DA backend - http return code : ${resp.status}, error message => ${await resp.text()}`);
84
84
  }
85
85
  return Promise.resolve(result);
86
86
  }
@@ -98,7 +98,7 @@ async function requestComponent(provider, manifest, url, opts = {}) {
98
98
  opts["source-manifest"] = "";
99
99
  opts[rhdaOperationTypeHeader.toUpperCase().replaceAll("-", "_")] = "component-analysis";
100
100
  if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
101
- console.log("Starting time of sending component analysis request to exhort server= " + new Date());
101
+ console.log("Starting time of sending component analysis request to Trustify DA backend server= " + new Date());
102
102
  }
103
103
  opts[rhdaPackageManagerHeader.toUpperCase().replaceAll("-", "_")] = provided.ecosystem;
104
104
  const fetchOptions = addProxyAgent({
@@ -123,13 +123,13 @@ async function requestComponent(provider, manifest, url, opts = {}) {
123
123
  if (exRequestId) {
124
124
  console.log("Unique Identifier associated with this request - ex-request-id=" + exRequestId);
125
125
  }
126
- console.log("Response body received from exhort server : " + EOL + EOL);
126
+ console.log("Response body received from Trustify DA backend server : " + EOL + EOL);
127
127
  console.log(JSON.stringify(result, null, 4));
128
- console.log("Ending time of sending component analysis request to exhort server= " + new Date());
128
+ console.log("Ending time of sending component analysis request to Trustify DA backend server= " + new Date());
129
129
  }
130
130
  }
131
131
  else {
132
- throw new Error(`Got error response from exhort backend - http return code : ${resp.status}, ex-request-id: ${resp.headers.get("ex-request-id")} error message => ${await resp.text()}`);
132
+ 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()}`);
133
133
  }
134
134
  return Promise.resolve(result);
135
135
  }
@@ -172,14 +172,14 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
172
172
  if (exRequestId) {
173
173
  console.log("Unique Identifier associated with this request - ex-request-id=" + exRequestId);
174
174
  }
175
- console.log("Response body received from exhort server : " + EOL + EOL);
175
+ console.log("Response body received from Trustify DA backend server : " + EOL + EOL);
176
176
  console.log(JSON.stringify(result, null, 4));
177
- console.log("Ending time of sending component analysis request to exhort server= " + new Date());
177
+ console.log("Ending time of sending component analysis request to Trustify DA backend server= " + new Date());
178
178
  }
179
179
  return result;
180
180
  }
181
181
  else {
182
- throw new Error(`Got error response from exhort backend - http return code : ${resp.status}, ex-request-id: ${resp.headers.get("ex-request-id")} error message => ${await resp.text()}`);
182
+ 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()}`);
183
183
  }
184
184
  }
185
185
  /**
@@ -241,7 +241,7 @@ function getTokenHeaders(opts = {}) {
241
241
  setRhdaHeader(rhdaPackageManagerHeader, headers, opts);
242
242
  setRhdaHeader(rhdaTelemetryId, headers, opts);
243
243
  if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
244
- console.log("Headers Values to be sent to exhort:" + EOL);
244
+ console.log("Headers Values to be sent to Trustify DA backend:" + EOL);
245
245
  for (const headerKey in headers) {
246
246
  if (!headerKey.match(RegexNotToBeLogged)) {
247
247
  console.log(`${headerKey}: ${headers[headerKey]}`);
package/dist/src/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import * as path from "path";
3
3
  import yargs from 'yargs';
4
4
  import { hideBin } from 'yargs/helpers';
5
- import exhort from './index.js';
5
+ import client from './index.js';
6
6
  // command for component analysis take manifest type and content
7
7
  const component = {
8
8
  command: 'component </path/to/manifest>',
@@ -14,7 +14,7 @@ const component = {
14
14
  }),
15
15
  handler: async (args) => {
16
16
  let manifestName = args['/path/to/manifest'];
17
- let res = await exhort.componentAnalysis(manifestName);
17
+ let res = await client.componentAnalysis(manifestName);
18
18
  console.log(JSON.stringify(res, null, 2));
19
19
  }
20
20
  };
@@ -39,10 +39,64 @@ const validateToken = {
39
39
  let tokenValue = args['tokenValue'].trim();
40
40
  opts[`TRUSTIFY_DA_${tokenProvider}_TOKEN`] = tokenValue;
41
41
  }
42
- let res = await exhort.validateToken(opts);
42
+ let res = await client.validateToken(opts);
43
43
  console.log(res);
44
44
  }
45
45
  };
46
+ // command for image analysis takes OCI image references
47
+ const image = {
48
+ command: 'image <image-refs..>',
49
+ desc: 'produce image analysis report for OCI image references',
50
+ builder: yargs => yargs.positional('image-refs', {
51
+ desc: 'OCI image references to analyze (one or more)',
52
+ type: 'string',
53
+ array: true,
54
+ }).options({
55
+ html: {
56
+ alias: 'r',
57
+ desc: 'Get the report as HTML instead of JSON',
58
+ type: 'boolean',
59
+ conflicts: 'summary'
60
+ },
61
+ summary: {
62
+ alias: 's',
63
+ desc: 'For JSON report, get only the \'summary\'',
64
+ type: 'boolean',
65
+ conflicts: 'html'
66
+ }
67
+ }),
68
+ handler: async (args) => {
69
+ let imageRefs = args['image-refs'];
70
+ if (!Array.isArray(imageRefs)) {
71
+ imageRefs = [imageRefs];
72
+ }
73
+ let html = args['html'];
74
+ let summary = args['summary'];
75
+ let res = await client.imageAnalysis(imageRefs, html);
76
+ if (summary && !html) {
77
+ let summaries = {};
78
+ for (let [imageRef, report] of Object.entries(res)) {
79
+ for (let provider in report.providers) {
80
+ if (report.providers[provider].sources !== undefined) {
81
+ for (let source in report.providers[provider].sources) {
82
+ if (report.providers[provider].sources[source].summary) {
83
+ if (!summaries[imageRef]) {
84
+ summaries[imageRef] = {};
85
+ }
86
+ if (!summaries[imageRef][provider]) {
87
+ summaries[imageRef][provider] = {};
88
+ }
89
+ summaries[imageRef][provider][source] = report.providers[provider].sources[source].summary;
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ res = summaries;
96
+ }
97
+ console.log(html ? res : JSON.stringify(res, null, 2));
98
+ }
99
+ };
46
100
  // command for stack analysis takes a manifest path
47
101
  const stack = {
48
102
  command: 'stack </path/to/manifest> [--html|--summary]',
@@ -71,7 +125,7 @@ const stack = {
71
125
  let summary = args['summary'];
72
126
  let theProvidersSummary = new Map();
73
127
  let theProvidersObject = {};
74
- let res = await exhort.stackAnalysis(manifest, html);
128
+ let res = await client.stackAnalysis(manifest, html);
75
129
  if (summary) {
76
130
  for (let provider in res.providers) {
77
131
  if (res.providers[provider].sources !== undefined) {
@@ -91,9 +145,10 @@ const stack = {
91
145
  };
92
146
  // parse and invoke the command
93
147
  yargs(hideBin(process.argv))
94
- .usage(`Usage: ${process.argv[0].includes("node") ? path.parse(process.argv[1]).base : path.parse(process.argv[0]).base} {component|stack|validate-token}`)
148
+ .usage(`Usage: ${process.argv[0].includes("node") ? path.parse(process.argv[1]).base : path.parse(process.argv[0]).base} {component|stack|image|validate-token}`)
95
149
  .command(stack)
96
150
  .command(component)
151
+ .command(image)
97
152
  .command(validateToken)
98
153
  .scriptName('')
99
154
  .version(false)
@@ -1,17 +1,15 @@
1
1
  /**
2
- * This function is used to determine exhort theUrl backend according to the following logic:
3
- * If TRUSTIFY_DA_DEV_MODE = true, then take the value of the EXHORT BACKEND URL of dev/staging environment in such a way:
4
- * take it as environment variable if exists, otherwise, take it from opts object if exists, otherwise, use the hardcoded default of DEV environment.
5
- * If TRUSTIFY_DA_DEV_MODE = false , then select the production theUrl of EXHORT Backend, which is hardcoded.
6
- * TRUSTIFY_DA_DEV_MODE evaluated in the following order and selected when it finds it first:
2
+ * This function is used to determine the Trustify DA backend URL.
3
+ * The TRUSTIFY_DA_BACKEND_URL is evaluated in the following order and selected when it finds it first:
7
4
  * 1. Environment Variable
8
5
  * 2. (key,value) from opts object
9
- * 3. Default False ( points to production URL )
6
+ * If TRUSTIFY_DA_BACKEND_URL is not set, the function will throw an error.
10
7
  * @param {{TRUSTIFY_DA_DEBUG?: string | undefined; TRUSTIFY_DA_BACKEND_URL?: string | undefined}} [opts={}]
11
- * @return {string} - The selected exhort backend
8
+ * @return {string} - The selected Trustify DA backend URL
9
+ * @throws {Error} if TRUSTIFY_DA_BACKEND_URL is unset
12
10
  * @private
13
11
  */
14
- export function selectExhortBackend(opts?: {
12
+ export function selectTrustifyDABackend(opts?: {
15
13
  TRUSTIFY_DA_DEBUG?: string | undefined;
16
14
  TRUSTIFY_DA_BACKEND_URL?: string | undefined;
17
15
  } | undefined): string;
package/dist/src/index.js CHANGED
@@ -77,33 +77,25 @@ function readAndPrintVersionFromPackageJson() {
77
77
  logOptionsAndEnvironmentsVariables("trustify-da-javascript-client analysis started, version: ", packageJson.version);
78
78
  }
79
79
  /**
80
- * This function is used to determine exhort theUrl backend according to the following logic:
81
- * If TRUSTIFY_DA_DEV_MODE = true, then take the value of the EXHORT BACKEND URL of dev/staging environment in such a way:
82
- * take it as environment variable if exists, otherwise, take it from opts object if exists, otherwise, use the hardcoded default of DEV environment.
83
- * If TRUSTIFY_DA_DEV_MODE = false , then select the production theUrl of EXHORT Backend, which is hardcoded.
84
- * TRUSTIFY_DA_DEV_MODE evaluated in the following order and selected when it finds it first:
80
+ * This function is used to determine the Trustify DA backend URL.
81
+ * The TRUSTIFY_DA_BACKEND_URL is evaluated in the following order and selected when it finds it first:
85
82
  * 1. Environment Variable
86
83
  * 2. (key,value) from opts object
87
- * 3. Default False ( points to production URL )
84
+ * If TRUSTIFY_DA_BACKEND_URL is not set, the function will throw an error.
88
85
  * @param {{TRUSTIFY_DA_DEBUG?: string | undefined; TRUSTIFY_DA_BACKEND_URL?: string | undefined}} [opts={}]
89
- * @return {string} - The selected exhort backend
86
+ * @return {string} - The selected Trustify DA backend URL
87
+ * @throws {Error} if TRUSTIFY_DA_BACKEND_URL is unset
90
88
  * @private
91
89
  */
92
- export function selectExhortBackend(opts = {}) {
90
+ export function selectTrustifyDABackend(opts = {}) {
93
91
  if (getCustom("TRUSTIFY_DA_DEBUG", "false", opts) === "true") {
94
92
  readAndPrintVersionFromPackageJson();
95
93
  }
96
- let url;
97
- if (getCustom('TRUSTIFY_DA_DEV_MODE', 'false', opts) === 'true') {
98
- url = getCustom('DEV_TRUSTIFY_DA_BACKEND_URL', undefined, opts);
99
- }
100
- else {
101
- url = getCustom('TRUSTIFY_DA_BACKEND_URL', undefined, opts);
102
- }
94
+ let url = getCustom('TRUSTIFY_DA_BACKEND_URL', null, opts);
103
95
  if (!url) {
104
96
  throw new Error(`TRUSTIFY_DA_BACKEND_URL is unset`);
105
97
  }
106
- logOptionsAndEnvironmentsVariables("Chosen exhort backend URL:", url);
98
+ logOptionsAndEnvironmentsVariables("Chosen Trustify DA backend URL:", url);
107
99
  return url;
108
100
  }
109
101
  /**
@@ -133,7 +125,7 @@ export function selectExhortBackend(opts = {}) {
133
125
  * or backend request failed
134
126
  */
135
127
  async function stackAnalysis(manifest, html = false, opts = {}) {
136
- const theUrl = selectExhortBackend(opts);
128
+ const theUrl = selectTrustifyDABackend(opts);
137
129
  fs.accessSync(manifest, fs.constants.R_OK); // throws error if file unreadable
138
130
  let provider = match(manifest, availableProviders); // throws error if no matching provider
139
131
  return await analysis.requestStack(provider, manifest, theUrl, html, opts); // throws error request sending failed
@@ -146,7 +138,7 @@ async function stackAnalysis(manifest, html = false, opts = {}) {
146
138
  * @throws {Error} if no matching provider, failed to get create content, or backend request failed
147
139
  */
148
140
  async function componentAnalysis(manifest, opts = {}) {
149
- const theUrl = selectExhortBackend(opts);
141
+ const theUrl = selectTrustifyDABackend(opts);
150
142
  fs.accessSync(manifest, fs.constants.R_OK);
151
143
  opts["manifest-type"] = path.basename(manifest);
152
144
  let provider = match(manifest, availableProviders); // throws error if no matching provider
@@ -179,7 +171,7 @@ async function componentAnalysis(manifest, opts = {}) {
179
171
  * or backend request failed
180
172
  */
181
173
  async function imageAnalysis(imageRefs, html = false, opts = {}) {
182
- const theUrl = selectExhortBackend(opts);
174
+ const theUrl = selectTrustifyDABackend(opts);
183
175
  return await analysis.requestImages(imageRefs, theUrl, html, opts);
184
176
  }
185
177
  /**
@@ -189,6 +181,6 @@ async function imageAnalysis(imageRefs, html = false, opts = {}) {
189
181
  * @throws {Error} if the backend request failed.
190
182
  */
191
183
  async function validateToken(opts = {}) {
192
- const theUrl = selectExhortBackend(opts);
184
+ const theUrl = selectTrustifyDABackend(opts);
193
185
  return await analysis.validateToken(theUrl, opts); // throws error request sending failed
194
186
  }
@@ -73,7 +73,7 @@ export default class Java_maven extends Base_java {
73
73
  throw new Error(`failed to clean maven target`, { cause: error });
74
74
  }
75
75
  // create dependency graph in a temp file
76
- let tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'exhort_'));
76
+ let tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'trustify_da_'));
77
77
  let tmpDepTree = path.join(tmpDir, 'mvn_deptree.txt');
78
78
  // build initial command (dot outputType is not available for verbose mode)
79
79
  let depTreeCmdArgs = ['-q', 'org.apache.maven.plugins:maven-dependency-plugin:3.6.0:tree',
@@ -44,7 +44,7 @@ export default class Python_controller {
44
44
  }
45
45
  prepareEnvironment() {
46
46
  if (!this.realEnvironment) {
47
- this.pythonEnvDir = path.join(path.sep, "tmp", "exhort_env_js");
47
+ this.pythonEnvDir = path.join(path.sep, "tmp", "trustify_da_env_js");
48
48
  try {
49
49
  invokeCommand(this.pathToPythonBin, ['-m', 'venv', this.pythonEnvDir]);
50
50
  }
@@ -188,7 +188,7 @@ function createSbomStackAnalysis(manifest, opts = {}) {
188
188
  });
189
189
  let requirementTxtContent = fs.readFileSync(manifest).toString();
190
190
  handleIgnoredDependencies(requirementTxtContent, sbom, opts);
191
- // In python there is no root component, then we must remove the dummy root we added, so the sbom json will be accepted by exhort backend
191
+ // In python there is no root component, then we must remove the dummy root we added, so the sbom json will be accepted by the DA backend
192
192
  // sbom.removeRootComponent()
193
193
  return sbom.getAsJsonString(opts);
194
194
  }
@@ -212,7 +212,7 @@ function getSbomForComponentAnalysis(manifest, opts = {}) {
212
212
  });
213
213
  let requirementTxtContent = fs.readFileSync(manifest).toString();
214
214
  handleIgnoredDependencies(requirementTxtContent, sbom, opts);
215
- // In python there is no root component, then we must remove the dummy root we added, so the sbom json will be accepted by exhort backend
215
+ // In python there is no root component, then we must remove the dummy root we added, so the sbom json will be accepted by the DA backend
216
216
  // sbom.removeRootComponent()
217
217
  return sbom.getAsJsonString(opts);
218
218
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustify-da/trustify-da-javascript-client",
3
- "version": "0.2.4-ea-14",
3
+ "version": "0.2.4-ea.2eeeeba",
4
4
  "description": "Code-Ready Dependency Analytics JavaScript API.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/guacsec/trustify-da-javascript-client#README.md",
@@ -12,7 +12,9 @@
12
12
  "exhort",
13
13
  "secure",
14
14
  "supply-chain",
15
- "vulnerability"
15
+ "vulnerability",
16
+ "trustify",
17
+ "dependency analytics"
16
18
  ],
17
19
  "engines": {
18
20
  "node": ">= 20.0.0",