@trustify-da/trustify-da-javascript-client 0.3.0-ea.904e9f2 → 0.3.0-ea.9988076
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 +65 -2
- package/dist/package.json +17 -9
- package/dist/src/analysis.d.ts +5 -5
- package/dist/src/analysis.js +21 -76
- package/dist/src/cli.js +72 -6
- package/dist/src/cyclone_dx_sbom.d.ts +3 -2
- package/dist/src/cyclone_dx_sbom.js +18 -5
- package/dist/src/index.d.ts +66 -11
- package/dist/src/index.js +6 -3
- package/dist/src/license/index.d.ts +28 -0
- package/dist/src/license/index.js +100 -0
- package/dist/src/license/license_utils.d.ts +40 -0
- package/dist/src/license/license_utils.js +134 -0
- package/dist/src/license/licenses_api.d.ts +34 -0
- package/dist/src/license/licenses_api.js +98 -0
- package/dist/src/license/project_license.d.ts +20 -0
- package/dist/src/license/project_license.js +62 -0
- package/dist/src/oci_image/images.d.ts +4 -5
- package/dist/src/oci_image/utils.d.ts +4 -4
- package/dist/src/provider.d.ts +12 -3
- package/dist/src/provider.js +19 -2
- package/dist/src/providers/base_java.d.ts +3 -5
- package/dist/src/providers/base_javascript.d.ts +10 -4
- package/dist/src/providers/base_javascript.js +30 -4
- package/dist/src/providers/golang_gomodules.d.ts +11 -4
- package/dist/src/providers/golang_gomodules.js +13 -4
- package/dist/src/providers/java_gradle.d.ts +9 -3
- package/dist/src/providers/java_gradle.js +12 -2
- package/dist/src/providers/java_gradle_groovy.d.ts +1 -1
- package/dist/src/providers/java_gradle_kotlin.d.ts +1 -1
- package/dist/src/providers/java_maven.d.ts +12 -5
- package/dist/src/providers/java_maven.js +33 -5
- package/dist/src/providers/python_controller.d.ts +5 -2
- package/dist/src/providers/python_controller.js +56 -58
- package/dist/src/providers/python_pip.d.ts +11 -4
- package/dist/src/providers/python_pip.js +46 -53
- package/dist/src/providers/requirements_parser.d.ts +6 -0
- package/dist/src/providers/requirements_parser.js +24 -0
- package/dist/src/providers/rust_cargo.d.ts +47 -0
- package/dist/src/providers/rust_cargo.js +606 -0
- package/dist/src/providers/tree-sitter-requirements.wasm +0 -0
- package/dist/src/sbom.d.ts +3 -1
- package/dist/src/sbom.js +3 -2
- package/dist/src/tools.d.ts +22 -6
- package/dist/src/tools.js +56 -1
- package/package.json +18 -10
package/dist/src/tools.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="packageurl-js/src/package-url" />
|
|
3
1
|
/**
|
|
4
2
|
*
|
|
5
3
|
* @param {string} key to log its value from environment variables and from opts, if it exists
|
|
6
4
|
* @param {{}} [opts={}] different options of application, if key in it, log it.
|
|
7
5
|
* @param {string }defValue default value of key in case there is no option and environment variable values for key
|
|
8
6
|
*/
|
|
9
|
-
export function logValueFromObjects(key: string, opts?: {}
|
|
7
|
+
export function logValueFromObjects(key: string, opts?: {}, defValue: string): void;
|
|
10
8
|
/**
|
|
11
9
|
* Utility function will return the value for key from the environment variables,
|
|
12
10
|
* if not present will return the value for key from the opts objects only if it's a string,
|
|
@@ -17,7 +15,7 @@ export function logValueFromObjects(key: string, opts?: {} | undefined, defValue
|
|
|
17
15
|
* @returns {string|null} the value of the key found in the environment, options object, or the
|
|
18
16
|
* default supplied
|
|
19
17
|
*/
|
|
20
|
-
export function getCustom(key: string, def?: string | null
|
|
18
|
+
export function getCustom(key: string, def?: string | null, opts?: {}): string | null;
|
|
21
19
|
/**
|
|
22
20
|
* Utility function for looking up custom variable for a binary path.
|
|
23
21
|
* Will look in the environment variables (1) or in opts (2) for a key with TRUSTIFY_DA_x_PATH, x is an
|
|
@@ -28,7 +26,7 @@ export function getCustom(key: string, def?: string | null | undefined, opts?: {
|
|
|
28
26
|
* @returns {string|null} the value of the key found in the environment, options object, or the
|
|
29
27
|
* original name supplied
|
|
30
28
|
*/
|
|
31
|
-
export function getCustomPath(name: any, opts?: {}
|
|
29
|
+
export function getCustomPath(name: any, opts?: {}): string | null;
|
|
32
30
|
/**
|
|
33
31
|
* Utility function for determining whether wrappers for build tools such as gradlew/mvnw should be
|
|
34
32
|
* preferred over invoking the binary directly.
|
|
@@ -69,6 +67,24 @@ export function getGitRootDir(cwd: string): string | undefined;
|
|
|
69
67
|
* @param {import('child_process').ExecFileOptionsWithStringEncoding} [opts={}]
|
|
70
68
|
* @returns {string}
|
|
71
69
|
*/
|
|
72
|
-
export function invokeCommand(bin: string, args: Array<string>, opts?: import("child_process").ExecFileOptionsWithStringEncoding
|
|
70
|
+
export function invokeCommand(bin: string, args: Array<string>, opts?: import("child_process").ExecFileOptionsWithStringEncoding): string;
|
|
71
|
+
/**
|
|
72
|
+
* Adds proxy agent configuration to fetch options if a proxy URL is specified
|
|
73
|
+
* @param {RequestInit} options - The base fetch options
|
|
74
|
+
* @param {import("index.js").Options} opts - The trustify DA options that may contain proxy configuration
|
|
75
|
+
* @returns {RequestInit} The fetch options with proxy agent if applicable
|
|
76
|
+
*/
|
|
77
|
+
export function addProxyAgent(options: RequestInit, opts: import("index.js").Options): RequestInit;
|
|
78
|
+
/**
|
|
79
|
+
* Utility function for fetching vendor tokens
|
|
80
|
+
* @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
|
|
81
|
+
* @returns {{}}
|
|
82
|
+
*/
|
|
83
|
+
export function getTokenHeaders(opts?: import("index.js").Options): {};
|
|
73
84
|
export const RegexNotToBeLogged: RegExp;
|
|
85
|
+
export const TRUSTIFY_DA_TOKEN_HEADER: "trust-da-token";
|
|
86
|
+
export const TRUSTIFY_DA_TELEMETRY_ID_HEADER: "telemetry-anonymous-id";
|
|
87
|
+
export const TRUSTIFY_DA_SOURCE_HEADER: "trust-da-source";
|
|
88
|
+
export const TRUSTIFY_DA_OPERATION_TYPE_HEADER: "trust-da-operation-type";
|
|
89
|
+
export const TRUSTIFY_DA_PACKAGE_MANAGER_HEADER: "trust-da-pkg-manager";
|
|
74
90
|
import { PackageURL } from "packageurl-js";
|
package/dist/src/tools.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { execFileSync } from "child_process";
|
|
2
2
|
import { EOL } from "os";
|
|
3
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
3
4
|
import { PackageURL } from "packageurl-js";
|
|
4
|
-
export const RegexNotToBeLogged = /TRUSTIFY_DA_.*
|
|
5
|
+
export const RegexNotToBeLogged = /TRUSTIFY_DA_(.*_)?TOKEN|ex-.*-token|trust-.*-token/;
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
7
8
|
* @param {string} key to log its value from environment variables and from opts, if it exists
|
|
@@ -157,3 +158,57 @@ export function invokeCommand(bin, args, opts = {}) {
|
|
|
157
158
|
};
|
|
158
159
|
return execFileSync(bin, args, { ...{ stdio: 'pipe', encoding: 'utf-8' }, ...opts });
|
|
159
160
|
}
|
|
161
|
+
export const TRUSTIFY_DA_TOKEN_HEADER = "trust-da-token";
|
|
162
|
+
export const TRUSTIFY_DA_TELEMETRY_ID_HEADER = "telemetry-anonymous-id";
|
|
163
|
+
export const TRUSTIFY_DA_SOURCE_HEADER = "trust-da-source";
|
|
164
|
+
export const TRUSTIFY_DA_OPERATION_TYPE_HEADER = "trust-da-operation-type";
|
|
165
|
+
export const TRUSTIFY_DA_PACKAGE_MANAGER_HEADER = "trust-da-pkg-manager";
|
|
166
|
+
/**
|
|
167
|
+
* Adds proxy agent configuration to fetch options if a proxy URL is specified
|
|
168
|
+
* @param {RequestInit} options - The base fetch options
|
|
169
|
+
* @param {import("index.js").Options} opts - The trustify DA options that may contain proxy configuration
|
|
170
|
+
* @returns {RequestInit} The fetch options with proxy agent if applicable
|
|
171
|
+
*/
|
|
172
|
+
export function addProxyAgent(options, opts) {
|
|
173
|
+
const proxyUrl = getCustom('TRUSTIFY_DA_PROXY_URL', null, opts);
|
|
174
|
+
if (proxyUrl) {
|
|
175
|
+
options.agent = new HttpsProxyAgent(proxyUrl);
|
|
176
|
+
}
|
|
177
|
+
return options;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Utility function for fetching vendor tokens
|
|
181
|
+
* @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
|
|
182
|
+
* @returns {{}}
|
|
183
|
+
*/
|
|
184
|
+
export function getTokenHeaders(opts = {}) {
|
|
185
|
+
let headers = {};
|
|
186
|
+
setCustomHeader(TRUSTIFY_DA_TOKEN_HEADER, headers, 'TRUSTIFY_DA_TOKEN', opts);
|
|
187
|
+
setCustomHeader(TRUSTIFY_DA_SOURCE_HEADER, headers, 'TRUSTIFY_DA_SOURCE', opts);
|
|
188
|
+
setCustomHeader(TRUSTIFY_DA_OPERATION_TYPE_HEADER, headers, TRUSTIFY_DA_OPERATION_TYPE_HEADER.toUpperCase().replaceAll("-", "_"), opts);
|
|
189
|
+
setCustomHeader(TRUSTIFY_DA_PACKAGE_MANAGER_HEADER, headers, TRUSTIFY_DA_PACKAGE_MANAGER_HEADER.toUpperCase().replaceAll("-", "_"), opts);
|
|
190
|
+
setCustomHeader(TRUSTIFY_DA_TELEMETRY_ID_HEADER, headers, 'TRUSTIFY_DA_TELEMETRY_ID', opts);
|
|
191
|
+
if (getCustom("TRUSTIFY_DA_DEBUG", null, opts) === "true") {
|
|
192
|
+
console.log("Headers Values to be sent to Trustify DA backend:" + EOL);
|
|
193
|
+
for (const headerKey in headers) {
|
|
194
|
+
if (!headerKey.match(RegexNotToBeLogged)) {
|
|
195
|
+
console.log(`${headerKey}: ${headers[headerKey]}`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return headers;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
*
|
|
203
|
+
* @param {string} headerName - the header name to populate in request
|
|
204
|
+
* @param headers
|
|
205
|
+
* @param {string} optsKey - key in the options object to use the value for
|
|
206
|
+
* @param {import("index.js").Options} [opts={}] - options input object to fetch header values from
|
|
207
|
+
* @private
|
|
208
|
+
*/
|
|
209
|
+
function setCustomHeader(headerName, headers, optsKey, opts) {
|
|
210
|
+
let customHeaderValue = getCustom(optsKey, null, opts);
|
|
211
|
+
if (customHeaderValue) {
|
|
212
|
+
headers[headerName] = customHeaderValue;
|
|
213
|
+
}
|
|
214
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trustify-da/trustify-da-javascript-client",
|
|
3
|
-
"version": "0.3.0-ea.
|
|
3
|
+
"version": "0.3.0-ea.9988076",
|
|
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",
|
|
@@ -40,34 +40,42 @@
|
|
|
40
40
|
"test": "c8 npm run tests",
|
|
41
41
|
"tests": "mocha --config .mocharc.json --grep \".*analysis module.*\" --invert",
|
|
42
42
|
"tests:rep": "mocha --reporter-option maxDiffSize=0 --reporter json > unit-tests-result.json",
|
|
43
|
+
"pretest": "cp node_modules/tree-sitter-requirements/tree-sitter-requirements.wasm src/providers/tree-sitter-requirements.wasm",
|
|
43
44
|
"precompile": "rm -rf dist",
|
|
44
|
-
"compile": "tsc -p tsconfig.json"
|
|
45
|
+
"compile": "tsc -p tsconfig.json",
|
|
46
|
+
"compile:dev": "tsc -p tsconfig.dev.json",
|
|
47
|
+
"postcompile": "cp node_modules/tree-sitter-requirements/tree-sitter-requirements.wasm dist/src/providers/tree-sitter-requirements.wasm"
|
|
45
48
|
},
|
|
46
49
|
"dependencies": {
|
|
47
50
|
"@babel/core": "^7.23.2",
|
|
48
|
-
"@cyclonedx/cyclonedx-library": "
|
|
51
|
+
"@cyclonedx/cyclonedx-library": "^6.13.0",
|
|
52
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
49
53
|
"fast-toml": "^0.5.4",
|
|
50
|
-
"fast-xml-parser": "^
|
|
54
|
+
"fast-xml-parser": "^5.3.4",
|
|
51
55
|
"help": "^3.0.2",
|
|
52
56
|
"https-proxy-agent": "^7.0.6",
|
|
53
|
-
"node-fetch": "^
|
|
54
|
-
"packageurl-js": "
|
|
55
|
-
"
|
|
57
|
+
"node-fetch": "^3.3.2",
|
|
58
|
+
"packageurl-js": "~1.0.2",
|
|
59
|
+
"smol-toml": "^1.6.0",
|
|
60
|
+
"tree-sitter-requirements": "github:Strum355/tree-sitter-requirements#d0261ee76b84253997fe70d7d397e78c006c3801",
|
|
61
|
+
"web-tree-sitter": "^0.26.6",
|
|
62
|
+
"yargs": "^18.0.0"
|
|
56
63
|
},
|
|
57
64
|
"devDependencies": {
|
|
58
65
|
"@babel/core": "^7.23.2",
|
|
59
|
-
"@trustify-da/trustify-da-api-model": "^2.0.
|
|
66
|
+
"@trustify-da/trustify-da-api-model": "^2.0.7",
|
|
60
67
|
"@types/node": "^20.17.30",
|
|
61
68
|
"@types/which": "^3.0.4",
|
|
62
69
|
"babel-plugin-rewire": "^1.2.0",
|
|
63
|
-
"c8": "^
|
|
70
|
+
"c8": "^11.0.0",
|
|
64
71
|
"chai": "^4.3.7",
|
|
65
72
|
"eslint": "^8.42.0",
|
|
73
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
66
74
|
"eslint-plugin-editorconfig": "^4.0.3",
|
|
67
75
|
"eslint-plugin-import": "^2.29.1",
|
|
68
76
|
"esmock": "^2.6.2",
|
|
69
77
|
"mocha": "^10.2.0",
|
|
70
|
-
"msw": "^
|
|
78
|
+
"msw": "^2.12.7",
|
|
71
79
|
"sinon": "^15.1.2",
|
|
72
80
|
"sinon-chai": "^3.7.0",
|
|
73
81
|
"typescript": "^5.1.3",
|