Skip to content

Commit 2eeeeba

Browse files
authored
chore: rename Exhort to Trustify DA (#280)
* chore: rename Exhort to Trustify DA Signed-off-by: Ruben Romero Montes <rromerom@redhat.com> * feat: update tests Signed-off-by: Ruben Romero Montes <rromerom@redhat.com> --------- Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
1 parent 4321869 commit 2eeeeba

File tree

14 files changed

+130
-192
lines changed

14 files changed

+130
-192
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
name: Lint and test project
2121
strategy:
2222
matrix:
23-
node: ['18', '20', '24', 'latest']
23+
node: ['24', 'latest']
2424
env:
2525
MAIN_NODE_VER: '24'
2626
steps:
@@ -88,8 +88,7 @@ jobs:
8888
env:
8989
TRUSTIFY_DA_PYTHON3_PATH: "${{steps.python-location.outputs.python-bin-location}}/python3"
9090
TRUSTIFY_DA_PIP3_PATH: "${{steps.python-location.outputs.python-bin-location}}/pip3"
91-
TRUSTIFY_DA_DEV_MODE: 'true'
92-
DEV_TRUSTIFY_DA_BACKEND_URL: 'https://exhort.stage.devshift.net'
91+
TRUSTIFY_DA_BACKEND_URL: 'https://exhort.stage.devshift.net'
9392
run: npm run test
9493

9594
- name: Compile project
@@ -98,15 +97,13 @@ jobs:
9897
- name: Run integration tests
9998
run: npm run integration-tests
10099
env:
101-
TRUSTIFY_DA_DEV_MODE: 'true'
102-
DEV_TRUSTIFY_DA_BACKEND_URL: 'https://exhort.stage.devshift.net'
100+
TRUSTIFY_DA_BACKEND_URL: 'https://exhort.stage.devshift.net'
103101

104102
- name: Run integration tests cli
105103
working-directory: integration
106104
run: bash ./run_its.sh
107105
env:
108-
TRUSTIFY_DA_DEV_MODE: 'true'
109-
DEV_TRUSTIFY_DA_BACKEND_URL: 'https://exhort.stage.devshift.net'
106+
TRUSTIFY_DA_BACKEND_URL: 'https://exhort.stage.devshift.net'
110107

111108
- name: Upload coverage reports
112109
if: ${{ matrix.node == env.MAIN_NODE_VER }}

CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,5 @@ contribution. See the [DCO](DCO) file for details.
119119

120120
<!-- Real links -->
121121
[0]: https://www.conventionalcommits.org/en/v1.0.0/
122-
[1]: https://github.com/guacsec/exhort/blob/0.1.x/src/main/resources/META-INF/openapi.yaml
123-
124122
<!-- Badge links -->
125123
[10]: https://badgen.net/badge/NodeJS%20Version/18/68a063

README.md

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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]
22

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).
66

77
<h3>Usage</h3>
88
<p>
99

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+
1012
<ul>
1113
<li>
1214
Use as ESM Module from an ESM module
@@ -15,24 +17,29 @@ Use as ESM Module from an ESM module
1517
npm install @trustify-da/trustify-da-javascript-client
1618
```
1719

20+
```shell
21+
# Set the mandatory backend URL
22+
export TRUSTIFY_DA_BACKEND_URL=https://trustify-da.example.com
23+
```
24+
1825
```javascript
19-
import exhort from '@trustify-da/trustify-da-javascript-client'
26+
import client from '@trustify-da/trustify-da-javascript-client'
2027
import fs from 'node:fs'
2128

2229
// 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')
2431
// 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)
2633
// 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')
2835
// Get image analysis in JSON format
29-
let imageAnalysis = await exhort.imageAnalysis(['docker.io/library/node:18'])
36+
let imageAnalysis = await client.imageAnalysis(['docker.io/library/node:18'])
3037
// Get image analysis in HTML format (string)
31-
let imageAnalysisHtml = await exhort.imageAnalysis(['docker.io/library/node:18'], true)
38+
let imageAnalysisHtml = await client.imageAnalysis(['docker.io/library/node:18'], true)
3239
// Analyze multiple images
33-
let multipleImagesAnalysis = await exhort.imageAnalysis(['docker.io/library/node:18', 'docker.io/library/python:3.9'])
40+
let multipleImagesAnalysis = await client.imageAnalysis(['docker.io/library/node:18', 'docker.io/library/python:3.9'])
3441
// Specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
35-
let imageAnalysisWithArch = await exhort.imageAnalysis(['httpd:2.4.49^^amd64'])
42+
let imageAnalysisWithArch = await client.imageAnalysis(['httpd:2.4.49^^amd64'])
3643
```
3744
</li>
3845
</ul>
@@ -45,16 +52,16 @@ npm install @trustify-da/trustify-da-javascript-client
4552
```
4653

4754
```javascript
48-
async function loadExhort()
55+
async function loadTrustifyDa()
4956
{
5057
// dynamic import is the only way to import ESM module into commonJS module
51-
const { default: exhort } = await import('@trustify-da/trustify-da-javascript-client');
52-
return exhort
58+
const { default: client } = await import('@trustify-da/trustify-da-javascript-client');
59+
return client
5360
}
54-
const runExhort = (manifestPath) => {
61+
const runTrustifyDa = (manifestPath) => {
5562
return new Promise(async ( resolve, reject) => {
5663
try {
57-
let stackAnalysisReport = await (await loadExhort()).stackAnalysis(manifestPath,false)
64+
let stackAnalysisReport = await (await loadTrustifyDa()).stackAnalysis(manifestPath,false)
5865
resolve(stackAnalysisReport)
5966

6067
} catch (error)
@@ -64,7 +71,7 @@ const runExhort = (manifestPath) => {
6471
});
6572
};
6673

67-
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)))
6875
```
6976
</li>
7077

@@ -297,17 +304,21 @@ All of the 5 above examples are valid for marking a package to be ignored
297304

298305
<h3>Customization</h3>
299306
<p>
300-
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
301308
<em>Global Module</em>, a <em>Remote Script</em>, or an <em>ESM Module</em>, you can use <em>Environment Variables</em>
302309
for various customization.
303310

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+
304313
However, <em>ESM Module</em> users, can opt for customizing programmatically:
305314

306315
```javascript
307-
import exhort from '@trustify-da/trustify-da-javascript-client'
316+
import client from '@trustify-da/trustify-da-javascript-client'
308317
import fs from 'node:fs'
309318

310319
let options = {
320+
// Mandatory: Backend URL for Trustify Dependency Analytics service
321+
'TRUSTIFY_DA_BACKEND_URL': 'https://api.trustify.dev',
311322
'TRUSTIFY_DA_MVN_PATH': '/path/to/my/mvn',
312323
'TRUSTIFY_DA_NPM_PATH': '/path/to/npm',
313324
'TRUSTIFY_DA_PNPM_PATH': '/path/to/pnpm',
@@ -323,19 +334,19 @@ let options = {
323334
}
324335

325336
// Get stack analysis in JSON format ( all package managers, pom.xml is as an example here)
326-
let stackAnalysis = await exhort.stackAnalysis('/path/to/pom.xml', false, options)
337+
let stackAnalysis = await client.stackAnalysis('/path/to/pom.xml', false, options)
327338
// Get stack analysis in HTML format in string ( all package managers, pom.xml is as an example here)
328-
let stackAnalysisHtml = await exhort.stackAnalysis('/path/to/pom.xml', true, options)
339+
let stackAnalysisHtml = await client.stackAnalysis('/path/to/pom.xml', true, options)
329340

330341
// Get component analysis in JSON format
331-
let componentAnalysis = await exhort.componentAnalysis('/path/to/pom.xml', options)
342+
let componentAnalysis = await client.componentAnalysis('/path/to/pom.xml', options)
332343

333344
// Get image analysis in JSON format
334-
let imageAnalysis = await exhort.imageAnalysis(['docker.io/library/node:18'], false, options)
345+
let imageAnalysis = await client.imageAnalysis(['docker.io/library/node:18'], false, options)
335346
// Get image analysis in HTML format in string
336-
let imageAnalysisHtml = await exhort.imageAnalysis(['docker.io/library/node:18'], true, options)
347+
let imageAnalysisHtml = await client.imageAnalysis(['docker.io/library/node:18'], true, options)
337348
// Specify architecture using ^^ notation (e.g., httpd:2.4.49^^amd64)
338-
let imageAnalysisWithArch = await exhort.imageAnalysis(['httpd:2.4.49^^amd64'], false, options)
349+
let imageAnalysisWithArch = await client.imageAnalysis(['httpd:2.4.49^^amd64'], false, options)
339350
```
340351
**_Environment variables takes precedence._**
341352
</p>

integration/testers/javascript/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
#!/usr/bin/env node
22

3-
import exhort from '@trustify-da/trustify-da-javascript-client'
3+
import client from '@trustify-da/trustify-da-javascript-client'
44
import process from 'node:process'
55

66
const [,, ...args] = process.argv
77

88
if ('stack' === args[0]) {
99
// arg[1] = manifest path; arg[2] = is html boolean
1010
let html = args[2] === 'true'
11-
let res = await exhort.stackAnalysis(args[1], html)
11+
let res = await client.stackAnalysis(args[1], html)
1212
console.log(html ? res : JSON.stringify(res, null, 2))
1313
process.exit(0)
1414
}
1515
if ('component' === args[0]) {
1616
// arg[1] = manifest path
17-
let res = await exhort.componentAnalysis(args[1])
17+
let res = await client.componentAnalysis(args[1])
1818
console.log(JSON.stringify(res, null, 2))
1919
process.exit(0)
2020
}
@@ -24,7 +24,7 @@ if ('validateToken' === args[0]) {
2424
let tokens = {
2525
"TRUSTIFY_DA_SNYK_TOKEN" : args[1]
2626
}
27-
let res = await exhort.validateToken(tokens)
27+
let res = await client.validateToken(tokens)
2828
console.log(res)
2929
process.exit(0)
3030
}

integration/testers/typescript/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#!/usr/bin/env node
22

3-
import exhort from '@guacsec/trustify-da-javascript-client'
4-
import process from 'node:process'
5-
import { AnalysisReport } from '@trustify-da/trustify-da-api-model/model/v5/AnalysisReport'
3+
import client from '@trustify-da/trustify-da-javascript-client';
4+
import process from 'node:process';
5+
import type { AnalysisReport } from '@trustify-da/trustify-da-api-model/model/v5/AnalysisReport';
66

7-
const [,, ...args] = process.argv
7+
const args = process.argv.slice(2);
88

99
if ('stack' === args[0]) {
1010
// arg[1] = manifest path; arg[2] = is html boolean
1111
let html = args[2] === 'true'
12-
let res = await exhort.stackAnalysis(args[1], html)
12+
let res = await client.stackAnalysis(args[1], html)
1313
console.log(html ? res as string : JSON.stringify(res as AnalysisReport, null, 2))
1414
process.exit(0)
1515
}
1616
if ('component' === args[0]) {
1717
// arg[1] = manifest path
18-
let res = await exhort.componentAnalysis(args[1])
18+
let res = await client.componentAnalysis(args[1])
1919
console.log(JSON.stringify(res as AnalysisReport, null, 2))
2020
process.exit(0)
2121
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"exhort",
1313
"secure",
1414
"supply-chain",
15-
"vulnerability"
15+
"vulnerability",
16+
"trustify",
17+
"dependency analytics"
1618
],
1719
"engines": {
1820
"node": ">= 20.0.0",

src/analysis.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const rhdaPackageManagerHeader = "rhda-pkg-manager"
1818
/**
1919
* Adds proxy agent configuration to fetch options if a proxy URL is specified
2020
* @param {RequestInit} options - The base fetch options
21-
* @param {import("index.js").Options} opts - The exhort options that may contain proxy configuration
21+
* @param {import("index.js").Options} opts - The trustify DA options that may contain proxy configuration
2222
* @returns {RequestInit} The fetch options with proxy agent if applicable
2323
*/
2424
function addProxyAgent(options, opts) {
@@ -47,7 +47,7 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
4747
let startTime = new Date()
4848
let endTime
4949
if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
50-
console.log("Starting time of sending stack analysis request to exhort server= " + startTime)
50+
console.log("Starting time of sending stack analysis request to the dependency analytics server= " + startTime)
5151
}
5252
opts[rhdaPackageManagerHeader.toUpperCase().replaceAll("-", "_")] = provided.ecosystem
5353

@@ -80,15 +80,15 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
8080
console.log("Unique Identifier associated with this request - ex-request-id=" + exRequestId)
8181
}
8282
endTime = new Date()
83-
console.log("Response body received from exhort server : " + EOL + EOL)
83+
console.log("Response body received from Trustify DA backend server : " + EOL + EOL)
8484
console.log(console.log(JSON.stringify(result, null, 4)))
85-
console.log("Ending time of sending stack analysis request to exhort server= " + endTime)
85+
console.log("Ending time of sending stack analysis request to Trustify DA backend server= " + endTime)
8686
let time = (endTime - startTime) / 1000
8787
console.log("Total Time in seconds: " + time)
8888

8989
}
9090
} else {
91-
throw new Error(`Got error response from exhort backend - http return code : ${resp.status}, error message => ${await resp.text()}`)
91+
throw new Error(`Got error response from Trustify DA backend - http return code : ${resp.status}, error message => ${await resp.text()}`)
9292
}
9393

9494
return Promise.resolve(result)
@@ -109,7 +109,7 @@ async function requestComponent(provider, manifest, url, opts = {}) {
109109
opts["source-manifest"] = ""
110110
opts[rhdaOperationTypeHeader.toUpperCase().replaceAll("-", "_")] = "component-analysis"
111111
if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
112-
console.log("Starting time of sending component analysis request to exhort server= " + new Date())
112+
console.log("Starting time of sending component analysis request to Trustify DA backend server= " + new Date())
113113
}
114114
opts[rhdaPackageManagerHeader.toUpperCase().replaceAll("-", "_")] = provided.ecosystem
115115

@@ -137,14 +137,14 @@ async function requestComponent(provider, manifest, url, opts = {}) {
137137
if (exRequestId) {
138138
console.log("Unique Identifier associated with this request - ex-request-id=" + exRequestId)
139139
}
140-
console.log("Response body received from exhort server : " + EOL + EOL)
140+
console.log("Response body received from Trustify DA backend server : " + EOL + EOL)
141141
console.log(JSON.stringify(result, null, 4))
142-
console.log("Ending time of sending component analysis request to exhort server= " + new Date())
142+
console.log("Ending time of sending component analysis request to Trustify DA backend server= " + new Date())
143143

144144

145145
}
146146
} else {
147-
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()}`)
147+
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()}`)
148148
}
149149

150150
return Promise.resolve(result)
@@ -191,13 +191,13 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
191191
if (exRequestId) {
192192
console.log("Unique Identifier associated with this request - ex-request-id=" + exRequestId)
193193
}
194-
console.log("Response body received from exhort server : " + EOL + EOL)
194+
console.log("Response body received from Trustify DA backend server : " + EOL + EOL)
195195
console.log(JSON.stringify(result, null, 4))
196-
console.log("Ending time of sending component analysis request to exhort server= " + new Date())
196+
console.log("Ending time of sending component analysis request to Trustify DA backend server= " + new Date())
197197
}
198198
return result
199199
} else {
200-
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()}`)
200+
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()}`)
201201
}
202202
}
203203

@@ -264,7 +264,7 @@ function getTokenHeaders(opts = {}) {
264264
setRhdaHeader(rhdaTelemetryId, headers, opts);
265265

266266
if (process.env["TRUSTIFY_DA_DEBUG"] === "true") {
267-
console.log("Headers Values to be sent to exhort:" + EOL)
267+
console.log("Headers Values to be sent to Trustify DA backend:" + EOL)
268268
for (const headerKey in headers) {
269269
if (!headerKey.match(RegexNotToBeLogged)) {
270270
console.log(`${headerKey}: ${headers[headerKey]}`)

src/cli.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from "path";
55
import yargs from 'yargs'
66
import { hideBin } from 'yargs/helpers'
77

8-
import exhort from './index.js'
8+
import client from './index.js'
99

1010

1111
// command for component analysis take manifest type and content
@@ -22,7 +22,7 @@ const component = {
2222
),
2323
handler: async args => {
2424
let manifestName = args['/path/to/manifest']
25-
let res = await exhort.componentAnalysis(manifestName)
25+
let res = await client.componentAnalysis(manifestName)
2626
console.log(JSON.stringify(res, null, 2))
2727
}
2828
}
@@ -50,7 +50,7 @@ const validateToken = {
5050
let tokenValue = args['tokenValue'].trim()
5151
opts[`TRUSTIFY_DA_${tokenProvider}_TOKEN`] = tokenValue
5252
}
53-
let res = await exhort.validateToken(opts)
53+
let res = await client.validateToken(opts)
5454
console.log(res)
5555
}
5656
}
@@ -87,7 +87,7 @@ const image = {
8787
}
8888
let html = args['html']
8989
let summary = args['summary']
90-
let res = await exhort.imageAnalysis(imageRefs, html)
90+
let res = await client.imageAnalysis(imageRefs, html)
9191
if(summary && !html) {
9292
let summaries = {}
9393
for (let [imageRef, report] of Object.entries(res)) {
@@ -144,7 +144,7 @@ const stack = {
144144
let summary = args['summary']
145145
let theProvidersSummary = new Map();
146146
let theProvidersObject ={}
147-
let res = await exhort.stackAnalysis(manifest, html)
147+
let res = await client.stackAnalysis(manifest, html)
148148
if(summary)
149149
{
150150
for (let provider in res.providers ) {

0 commit comments

Comments
 (0)