@trustify-da/trustify-da-javascript-client 0.3.0-ea.bbe2094 → 0.3.0-ea.be56bee
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 +1 -1
- package/dist/package.json +24 -21
- package/dist/src/analysis.d.ts +7 -7
- package/dist/src/analysis.js +4 -4
- package/dist/src/cyclone_dx_sbom.js +11 -3
- package/dist/src/index.d.ts +10 -10
- package/dist/src/index.js +4 -2
- package/dist/src/license/index.d.ts +3 -3
- package/dist/src/license/index.js +4 -1
- package/dist/src/license/license_utils.js +4 -1
- package/dist/src/license/licenses_api.d.ts +2 -2
- package/dist/src/oci_image/images.d.ts +1 -1
- package/dist/src/oci_image/images.js +15 -1
- package/dist/src/oci_image/utils.d.ts +5 -5
- package/dist/src/provider.d.ts +4 -3
- package/dist/src/provider.js +4 -2
- package/dist/src/providers/base_java.d.ts +14 -3
- package/dist/src/providers/base_java.js +16 -6
- package/dist/src/providers/base_javascript.d.ts +14 -9
- package/dist/src/providers/base_javascript.js +7 -0
- package/dist/src/providers/base_pyproject.d.ts +10 -5
- package/dist/src/providers/base_pyproject.js +7 -0
- package/dist/src/providers/containerfile_parser.d.ts +4 -0
- package/dist/src/providers/containerfile_parser.js +16 -0
- package/dist/src/providers/golang_gomodules.d.ts +2 -1
- package/dist/src/providers/golang_gomodules.js +1 -1
- 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 +2 -2
- package/dist/src/providers/java_maven.js +72 -0
- package/dist/src/providers/javascript_npm.d.ts +6 -1
- package/dist/src/providers/oci_dockerfile.d.ts +49 -0
- package/dist/src/providers/oci_dockerfile.js +104 -0
- package/dist/src/providers/processors/yarn_berry_processor.d.ts +2 -2
- package/dist/src/providers/processors/yarn_classic_processor.d.ts +2 -2
- package/dist/src/providers/python_controller.js +57 -3
- package/dist/src/providers/python_pip.d.ts +1 -0
- package/dist/src/providers/python_pip.js +1 -1
- package/dist/src/providers/python_poetry.d.ts +31 -8
- package/dist/src/providers/python_poetry.js +62 -14
- package/dist/src/providers/python_uv.d.ts +5 -14
- package/dist/src/providers/python_uv.js +44 -2
- package/dist/src/providers/rust_cargo.d.ts +6 -2
- package/dist/src/providers/rust_cargo.js +31 -4
- package/dist/src/providers/tree-sitter-containerfile.wasm +0 -0
- package/dist/src/tools.d.ts +2 -2
- package/package.json +25 -22
package/README.md
CHANGED
|
@@ -695,7 +695,7 @@ By default, The API algorithm will use native commands of PIP installer as data
|
|
|
695
695
|
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'.
|
|
696
696
|
|
|
697
697
|
#### Toggle Red Hat Trusted Content recommendations
|
|
698
|
-
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 `
|
|
698
|
+
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_RECOMMEND` to 'false' via environment variables or options.
|
|
699
699
|
|
|
700
700
|
#### Additional CLI arguments
|
|
701
701
|
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.
|
package/dist/package.json
CHANGED
|
@@ -35,32 +35,33 @@
|
|
|
35
35
|
"config/**/*"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"lint": "eslint src test
|
|
39
|
-
"lint:fix": "eslint src test --
|
|
38
|
+
"lint": "eslint src test",
|
|
39
|
+
"lint:fix": "eslint src test --fix",
|
|
40
40
|
"test": "c8 npm run tests",
|
|
41
41
|
"tests": "mocha --config .mocharc.json",
|
|
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 && cp node_modules/tree-sitter-gomod/tree-sitter-gomod.wasm src/providers/tree-sitter-gomod.wasm",
|
|
43
|
+
"pretest": "cp node_modules/tree-sitter-requirements/tree-sitter-requirements.wasm src/providers/tree-sitter-requirements.wasm && cp node_modules/tree-sitter-gomod/tree-sitter-gomod.wasm src/providers/tree-sitter-gomod.wasm && cp node_modules/tree-sitter-containerfile/tree-sitter-containerfile.wasm src/providers/tree-sitter-containerfile.wasm",
|
|
44
44
|
"precompile": "rm -rf dist",
|
|
45
45
|
"compile": "tsc -p tsconfig.json",
|
|
46
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 && cp node_modules/tree-sitter-gomod/tree-sitter-gomod.wasm dist/src/providers/tree-sitter-gomod.wasm"
|
|
47
|
+
"postcompile": "cp node_modules/tree-sitter-requirements/tree-sitter-requirements.wasm dist/src/providers/tree-sitter-requirements.wasm && cp node_modules/tree-sitter-gomod/tree-sitter-gomod.wasm dist/src/providers/tree-sitter-gomod.wasm && cp node_modules/tree-sitter-containerfile/tree-sitter-containerfile.wasm dist/src/providers/tree-sitter-containerfile.wasm"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@babel/core": "^7.23.2",
|
|
51
|
-
"@cyclonedx/cyclonedx-library": "^
|
|
51
|
+
"@cyclonedx/cyclonedx-library": "^10.0.0",
|
|
52
52
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
53
53
|
"fast-glob": "^3.3.3",
|
|
54
54
|
"fast-xml-parser": "^5.3.4",
|
|
55
55
|
"help": "^3.0.2",
|
|
56
|
-
"https-proxy-agent": "^
|
|
56
|
+
"https-proxy-agent": "^9.0.0",
|
|
57
57
|
"js-yaml": "^4.1.1",
|
|
58
58
|
"jsonc-parser": "^3.3.1",
|
|
59
59
|
"micromatch": "^4.0.8",
|
|
60
60
|
"node-fetch": "^3.3.2",
|
|
61
|
-
"p-limit": "^
|
|
61
|
+
"p-limit": "^7.3.0",
|
|
62
62
|
"packageurl-js": "~1.0.2",
|
|
63
63
|
"smol-toml": "^1.6.0",
|
|
64
|
+
"tree-sitter-containerfile": "^0.8.1",
|
|
64
65
|
"tree-sitter-gomod": "github:strum355/tree-sitter-go-mod#56326f2ad478892ace58ff247a97d492a3cbcdda",
|
|
65
66
|
"tree-sitter-requirements": "github:Strum355/tree-sitter-requirements#d0261ee76b84253997fe70d7d397e78c006c3801",
|
|
66
67
|
"web-tree-sitter": "^0.26.7",
|
|
@@ -68,23 +69,24 @@
|
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"@babel/core": "^7.23.2",
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
72
|
+
"@eslint/js": "^10.0.0",
|
|
73
|
+
"@trustify-da/trustify-da-api-model": "^2.0.9",
|
|
74
|
+
"@types/node": "^25.9.1",
|
|
73
75
|
"@types/which": "^3.0.4",
|
|
74
76
|
"babel-plugin-rewire": "^1.2.0",
|
|
75
77
|
"c8": "^11.0.0",
|
|
76
|
-
"chai": "^
|
|
77
|
-
"eslint": "^
|
|
78
|
+
"chai": "^6.2.2",
|
|
79
|
+
"eslint": "^10.4.1",
|
|
78
80
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
79
|
-
"eslint-plugin-
|
|
80
|
-
"eslint-plugin-import": "^2.29.1",
|
|
81
|
+
"eslint-plugin-import-x": "^4.16.2",
|
|
81
82
|
"esmock": "^2.6.2",
|
|
82
|
-
"
|
|
83
|
+
"globals": "^17.6.0",
|
|
84
|
+
"mocha": "^11.7.6",
|
|
83
85
|
"msw": "^2.12.7",
|
|
84
|
-
"sinon": "^
|
|
85
|
-
"sinon-chai": "^
|
|
86
|
-
"typescript": "^
|
|
87
|
-
"which": "^
|
|
86
|
+
"sinon": "^22.0.0",
|
|
87
|
+
"sinon-chai": "^4.0.1",
|
|
88
|
+
"typescript": "^6.0.3",
|
|
89
|
+
"which": "^7.0.0"
|
|
88
90
|
},
|
|
89
91
|
"mocha": {
|
|
90
92
|
"check-leaks": false,
|
|
@@ -112,12 +114,13 @@
|
|
|
112
114
|
"reporter": [
|
|
113
115
|
"html",
|
|
114
116
|
"json",
|
|
117
|
+
"lcov",
|
|
115
118
|
"text"
|
|
116
119
|
]
|
|
117
120
|
},
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
+
"overrides": {
|
|
122
|
+
"tree-sitter": "0.22.4"
|
|
123
|
+
},
|
|
121
124
|
"resolutions": {
|
|
122
125
|
"@hapi/joi": "17.1.1"
|
|
123
126
|
}
|
package/dist/src/analysis.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export default _default;
|
|
|
16
16
|
* @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
|
|
17
17
|
* @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
|
|
18
18
|
*/
|
|
19
|
-
declare function requestComponent(provider:
|
|
19
|
+
declare function requestComponent(provider: any, manifest: string, url: string, opts?: any): Promise<any>;
|
|
20
20
|
/**
|
|
21
21
|
* Send a stack analysis request and get the report as 'text/html' or 'application/json'.
|
|
22
22
|
* @param {import('./provider').Provider} provider - the provided data for constructing the request
|
|
@@ -26,7 +26,7 @@ declare function requestComponent(provider: import("./provider").Provider, manif
|
|
|
26
26
|
* @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
|
|
27
27
|
* @returns {Promise<string|import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
|
|
28
28
|
*/
|
|
29
|
-
declare function requestStack(provider:
|
|
29
|
+
declare function requestStack(provider: any, manifest: string, url: string, html?: boolean, opts?: any): Promise<string | any>;
|
|
30
30
|
/**
|
|
31
31
|
* Send a batch stack analysis request for multiple manifests (SBOMs keyed by purl).
|
|
32
32
|
* @param {Object.<string, object>} sbomByPurl - Map of root purl to CycloneDX SBOM object
|
|
@@ -36,9 +36,9 @@ declare function requestStack(provider: import("./provider").Provider, manifest:
|
|
|
36
36
|
* @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
|
|
37
37
|
*/
|
|
38
38
|
declare function requestStackBatch(sbomByPurl: {
|
|
39
|
+
[x: string]: object;
|
|
40
|
+
}, url: string, html?: boolean, opts?: any): Promise<string | {
|
|
39
41
|
[x: string]: any;
|
|
40
|
-
}, url: string, html?: boolean, opts?: import("index.js").Options): Promise<string | {
|
|
41
|
-
[x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
|
|
42
42
|
}>;
|
|
43
43
|
/**
|
|
44
44
|
*
|
|
@@ -47,8 +47,8 @@ declare function requestStackBatch(sbomByPurl: {
|
|
|
47
47
|
* @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
|
|
48
48
|
* @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
|
|
49
49
|
*/
|
|
50
|
-
declare function requestImages(imageRefs: Array<string>, url: string, html?: boolean, opts?:
|
|
51
|
-
[x: string]:
|
|
50
|
+
declare function requestImages(imageRefs: Array<string>, url: string, html?: boolean, opts?: any): Promise<string | {
|
|
51
|
+
[x: string]: any;
|
|
52
52
|
}>;
|
|
53
53
|
/**
|
|
54
54
|
*
|
|
@@ -56,4 +56,4 @@ declare function requestImages(imageRefs: Array<string>, url: string, html?: boo
|
|
|
56
56
|
* @param {import("index.js").Options} [opts={}] - optional various options to pass headers for t he validateToken Request
|
|
57
57
|
* @return {Promise<number>} return the HTTP status Code of the response from the validate token request.
|
|
58
58
|
*/
|
|
59
|
-
declare function validateToken(url: any, opts?:
|
|
59
|
+
declare function validateToken(url: any, opts?: any): Promise<number>;
|
package/dist/src/analysis.js
CHANGED
|
@@ -38,7 +38,7 @@ async function requestStack(provider, manifest, url, html = false, opts = {}) {
|
|
|
38
38
|
body: provided.content
|
|
39
39
|
}, opts);
|
|
40
40
|
const finalUrl = new URL(`${url}/api/v5/analysis`);
|
|
41
|
-
if (
|
|
41
|
+
if (getCustom('TRUSTIFY_DA_RECOMMEND', 'true', opts) === 'false') {
|
|
42
42
|
finalUrl.searchParams.append('recommend', 'false');
|
|
43
43
|
}
|
|
44
44
|
let resp = await fetch(finalUrl, fetchOptions);
|
|
@@ -95,7 +95,7 @@ async function requestComponent(provider, manifest, url, opts = {}) {
|
|
|
95
95
|
body: provided.content
|
|
96
96
|
}, opts);
|
|
97
97
|
const finalUrl = new URL(`${url}/api/v5/analysis`);
|
|
98
|
-
if (
|
|
98
|
+
if (getCustom('TRUSTIFY_DA_RECOMMEND', 'true', opts) === 'false') {
|
|
99
99
|
finalUrl.searchParams.append('recommend', 'false');
|
|
100
100
|
}
|
|
101
101
|
let resp = await fetch(finalUrl, fetchOptions);
|
|
@@ -136,7 +136,7 @@ async function requestComponent(provider, manifest, url, opts = {}) {
|
|
|
136
136
|
*/
|
|
137
137
|
async function requestStackBatch(sbomByPurl, url, html = false, opts = {}) {
|
|
138
138
|
const finalUrl = new URL(`${url}/api/v5/batch-analysis`);
|
|
139
|
-
if (
|
|
139
|
+
if (getCustom('TRUSTIFY_DA_RECOMMEND', 'true', opts) === 'false') {
|
|
140
140
|
finalUrl.searchParams.append('recommend', 'false');
|
|
141
141
|
}
|
|
142
142
|
const fetchOptions = addProxyAgent({
|
|
@@ -186,7 +186,7 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
|
|
|
186
186
|
imageSboms[parsedImageRef.getPackageURL().toString()] = generateImageSBOM(parsedImageRef, opts);
|
|
187
187
|
}
|
|
188
188
|
const finalUrl = new URL(`${url}/api/v5/batch-analysis`);
|
|
189
|
-
if (
|
|
189
|
+
if (getCustom('TRUSTIFY_DA_RECOMMEND', 'true', opts) === 'false') {
|
|
190
190
|
finalUrl.searchParams.append('recommend', 'false');
|
|
191
191
|
}
|
|
192
192
|
const fetchOptions = addProxyAgent({
|
|
@@ -41,12 +41,20 @@ function getComponent(component, type, scope, licenses, hashes) {
|
|
|
41
41
|
// Add licenses if provided (CycloneDX format). Callers must provide valid SPDX identifiers.
|
|
42
42
|
if (licenses) {
|
|
43
43
|
const licenseArray = Array.isArray(licenses) ? licenses : [licenses];
|
|
44
|
-
|
|
44
|
+
const validLicenses = licenseArray
|
|
45
|
+
.map(lic => {
|
|
45
46
|
if (typeof lic === 'string') {
|
|
46
47
|
return { license: { id: lic } };
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
if (typeof lic === 'object' && lic !== null && ('license' in lic || 'expression' in lic)) {
|
|
50
|
+
return lic;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
})
|
|
54
|
+
.filter(Boolean);
|
|
55
|
+
if (validLicenses.length > 0) {
|
|
56
|
+
componentObject.licenses = validLicenses;
|
|
57
|
+
}
|
|
50
58
|
}
|
|
51
59
|
// Add hashes if provided (CycloneDX 1.4 format).
|
|
52
60
|
if (hashes && hashes.length > 0) {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export type Options = {
|
|
|
53
53
|
TRUSTIFY_DA_PYTHON_PATH?: string | undefined;
|
|
54
54
|
TRUSTIFY_DA_PYTHON_VIRTUAL_ENV?: string | undefined;
|
|
55
55
|
TRUSTIFY_DA_PYTHON3_PATH?: string | undefined;
|
|
56
|
-
|
|
56
|
+
TRUSTIFY_DA_RECOMMEND?: string | undefined;
|
|
57
57
|
TRUSTIFY_DA_SKOPEO_CONFIG_PATH?: string | undefined;
|
|
58
58
|
TRUSTIFY_DA_SKOPEO_PATH?: string | undefined;
|
|
59
59
|
TRUSTIFY_DA_SYFT_CONFIG_PATH?: string | undefined;
|
|
@@ -106,7 +106,7 @@ export type SbomResult = {
|
|
|
106
106
|
* @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
|
|
107
107
|
* @throws {Error} if no matching provider, failed to get create content, or backend request failed
|
|
108
108
|
*/
|
|
109
|
-
declare function componentAnalysis(manifest: string, opts?: Options): Promise<
|
|
109
|
+
declare function componentAnalysis(manifest: string, opts?: Options): Promise<any>;
|
|
110
110
|
/**
|
|
111
111
|
* @overload
|
|
112
112
|
* @param {string} manifest
|
|
@@ -124,7 +124,7 @@ declare function stackAnalysis(manifest: string, html: true, opts?: Options | un
|
|
|
124
124
|
* @returns {Promise<import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>}
|
|
125
125
|
* @throws {Error}
|
|
126
126
|
*/
|
|
127
|
-
declare function stackAnalysis(manifest: string, html: false, opts?: Options | undefined): Promise<
|
|
127
|
+
declare function stackAnalysis(manifest: string, html: false, opts?: Options | undefined): Promise<any>;
|
|
128
128
|
/**
|
|
129
129
|
* Get stack analysis report for a manifest file.
|
|
130
130
|
* @overload
|
|
@@ -135,7 +135,7 @@ declare function stackAnalysis(manifest: string, html: false, opts?: Options | u
|
|
|
135
135
|
* @throws {Error} if manifest inaccessible, no matching provider, failed to get create content,
|
|
136
136
|
* or backend request failed
|
|
137
137
|
*/
|
|
138
|
-
declare function stackAnalysis(manifest: string, html?: boolean | undefined, opts?: Options | undefined): Promise<string |
|
|
138
|
+
declare function stackAnalysis(manifest: string, html?: boolean | undefined, opts?: Options | undefined): Promise<string | any>;
|
|
139
139
|
/**
|
|
140
140
|
* @overload
|
|
141
141
|
* @param {string} workspaceRoot
|
|
@@ -173,7 +173,7 @@ declare function stackAnalysisBatch(workspaceRoot: string, html: false, opts: Op
|
|
|
173
173
|
batchMetadata: true;
|
|
174
174
|
}): Promise<{
|
|
175
175
|
analysis: {
|
|
176
|
-
[x: string]:
|
|
176
|
+
[x: string]: any;
|
|
177
177
|
};
|
|
178
178
|
metadata: BatchAnalysisMetadata;
|
|
179
179
|
}>;
|
|
@@ -188,7 +188,7 @@ declare function stackAnalysisBatch(workspaceRoot: string, html: false, opts: Op
|
|
|
188
188
|
declare function stackAnalysisBatch(workspaceRoot: string, html: false, opts?: (Options & {
|
|
189
189
|
batchMetadata?: false;
|
|
190
190
|
}) | undefined): Promise<{
|
|
191
|
-
[x: string]:
|
|
191
|
+
[x: string]: any;
|
|
192
192
|
}>;
|
|
193
193
|
/**
|
|
194
194
|
* Get stack analysis for all workspace packages/crates (batch).
|
|
@@ -204,10 +204,10 @@ declare function stackAnalysisBatch(workspaceRoot: string, html: false, opts?: (
|
|
|
204
204
|
* @throws {Error} if workspace root invalid, no manifests found, no packages pass validation, no SBOMs produced, or backend request failed. When `opts.batchMetadata` is set, `error.batchMetadata` may be set on thrown errors.
|
|
205
205
|
*/
|
|
206
206
|
declare function stackAnalysisBatch(workspaceRoot: string, html?: boolean | undefined, opts?: Options | undefined): Promise<string | {
|
|
207
|
-
[x: string]:
|
|
207
|
+
[x: string]: any;
|
|
208
208
|
} | {
|
|
209
209
|
analysis: string | {
|
|
210
|
-
[x: string]:
|
|
210
|
+
[x: string]: any;
|
|
211
211
|
};
|
|
212
212
|
metadata: BatchAnalysisMetadata;
|
|
213
213
|
}>;
|
|
@@ -229,7 +229,7 @@ declare function imageAnalysis(imageRefs: Array<string>, html: true, opts?: Opti
|
|
|
229
229
|
* @throws {Error}
|
|
230
230
|
*/
|
|
231
231
|
declare function imageAnalysis(imageRefs: Array<string>, html: false, opts?: Options | undefined): Promise<{
|
|
232
|
-
[x: string]:
|
|
232
|
+
[x: string]: any;
|
|
233
233
|
}>;
|
|
234
234
|
/**
|
|
235
235
|
* Get image analysis report for a set of OCI image references.
|
|
@@ -242,7 +242,7 @@ declare function imageAnalysis(imageRefs: Array<string>, html: false, opts?: Opt
|
|
|
242
242
|
* or backend request failed
|
|
243
243
|
*/
|
|
244
244
|
declare function imageAnalysis(imageRefs: Array<string>, html?: boolean | undefined, opts?: Options | undefined): Promise<string | {
|
|
245
|
-
[x: string]:
|
|
245
|
+
[x: string]: any;
|
|
246
246
|
}>;
|
|
247
247
|
/**
|
|
248
248
|
* Validates the Exhort token.
|
package/dist/src/index.js
CHANGED
|
@@ -39,7 +39,7 @@ export { discoverMavenModules, discoverGradleSubprojects, discoverGoWorkspaceMod
|
|
|
39
39
|
* TRUSTIFY_DA_PYTHON_PATH?: string | undefined,
|
|
40
40
|
* TRUSTIFY_DA_PYTHON_VIRTUAL_ENV?: string | undefined,
|
|
41
41
|
* TRUSTIFY_DA_PYTHON3_PATH?: string | undefined,
|
|
42
|
-
*
|
|
42
|
+
* TRUSTIFY_DA_RECOMMEND?: string | undefined,
|
|
43
43
|
* TRUSTIFY_DA_SKOPEO_CONFIG_PATH?: string | undefined,
|
|
44
44
|
* TRUSTIFY_DA_SKOPEO_PATH?: string | undefined,
|
|
45
45
|
* TRUSTIFY_DA_SYFT_CONFIG_PATH?: string | undefined,
|
|
@@ -175,7 +175,9 @@ async function componentAnalysis(manifest, opts = {}) {
|
|
|
175
175
|
fs.accessSync(manifest, fs.constants.R_OK);
|
|
176
176
|
opts["manifest-type"] = path.basename(manifest);
|
|
177
177
|
let provider = match(manifest, availableProviders, opts); // throws error if no matching provider
|
|
178
|
-
|
|
178
|
+
const result = await analysis.requestComponent(provider, manifest, theUrl, opts); // throws error request sending failed
|
|
179
|
+
result.packageManager = provider.packageManagerName();
|
|
180
|
+
return result;
|
|
179
181
|
}
|
|
180
182
|
/**
|
|
181
183
|
* @overload
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* @param {import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport} [analysisResult] - analysis result that includes licenses array from backend
|
|
10
10
|
* @returns {Promise<{ projectLicense: { manifest: Object|null, file: Object|null, mismatch: boolean }, incompatibleDependencies: Array<{ purl: string, licenses: string[], category?: string, reason: string }>, error?: string }>}
|
|
11
11
|
*/
|
|
12
|
-
export function runLicenseCheck(sbomContent: string, manifestPath: string, url: string, opts?: import("../index.js").Options, analysisResult?:
|
|
12
|
+
export function runLicenseCheck(sbomContent: string, manifestPath: string, url: string, opts?: import("../index.js").Options, analysisResult?: any): Promise<{
|
|
13
13
|
projectLicense: {
|
|
14
|
-
manifest:
|
|
15
|
-
file:
|
|
14
|
+
manifest: Object | null;
|
|
15
|
+
file: Object | null;
|
|
16
16
|
mismatch: boolean;
|
|
17
17
|
};
|
|
18
18
|
incompatibleDependencies: Array<{
|
|
@@ -85,11 +85,14 @@ export async function runLicenseCheck(sbomContent, manifestPath, url, opts = {},
|
|
|
85
85
|
continue;
|
|
86
86
|
const status = getCompatibility(projectCategory, entry.category);
|
|
87
87
|
if (status === 'incompatible') {
|
|
88
|
+
const reason = entry.category?.toUpperCase() === 'UNKNOWN'
|
|
89
|
+
? 'License not recognized as a standard SPDX identifier. Manual review recommended to verify compatibility.'
|
|
90
|
+
: 'Dependency license(s) are incompatible with the project license.';
|
|
88
91
|
incompatibleDependencies.push({
|
|
89
92
|
purl,
|
|
90
93
|
licenses: entry.licenses,
|
|
91
94
|
category: entry.category,
|
|
92
|
-
reason
|
|
95
|
+
reason
|
|
93
96
|
});
|
|
94
97
|
}
|
|
95
98
|
}
|
|
@@ -114,9 +114,12 @@ export function getCompatibility(projectCategory, dependencyCategory) {
|
|
|
114
114
|
}
|
|
115
115
|
const proj = projectCategory.toUpperCase();
|
|
116
116
|
const dep = dependencyCategory.toUpperCase();
|
|
117
|
-
if (proj === 'UNKNOWN'
|
|
117
|
+
if (proj === 'UNKNOWN') {
|
|
118
118
|
return 'unknown';
|
|
119
119
|
}
|
|
120
|
+
if (dep === 'UNKNOWN') {
|
|
121
|
+
return 'incompatible';
|
|
122
|
+
}
|
|
120
123
|
const restrictiveness = {
|
|
121
124
|
'PERMISSIVE': 1,
|
|
122
125
|
'WEAK_COPYLEFT': 2,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {import('../index.js').Options} [opts={}] - options (proxy, token, TRUSTIFY_DA_BACKEND_URL, etc.)
|
|
7
7
|
* @returns {Promise<Object|null>} License details or null if not found
|
|
8
8
|
*/
|
|
9
|
-
export function getLicenseDetails(spdxId: string, opts?: import("../index.js").Options): Promise<
|
|
9
|
+
export function getLicenseDetails(spdxId: string, opts?: import("../index.js").Options): Promise<Object | null>;
|
|
10
10
|
/**
|
|
11
11
|
* Normalize the LicensesResponse shape (array of LicenseProviderResult) into a map of purl -> license info.
|
|
12
12
|
* Each provider result has { status, summary, packages } where packages is { [purl]: { concluded, evidence } }.
|
|
@@ -28,7 +28,7 @@ export function normalizeLicensesResponse(data: unknown, purls?: string[]): Map<
|
|
|
28
28
|
* @param {string[]} [purls] - optional list of purls to restrict to
|
|
29
29
|
* @returns {Map<string, { licenses: string[], category?: string }>}
|
|
30
30
|
*/
|
|
31
|
-
export function licensesFromReport(analysisReport:
|
|
31
|
+
export function licensesFromReport(analysisReport: any, purls?: string[]): Map<string, {
|
|
32
32
|
licenses: string[];
|
|
33
33
|
category?: string;
|
|
34
34
|
}>;
|
|
@@ -78,7 +78,7 @@ export class ImageRef {
|
|
|
78
78
|
* @param {string} [platform]
|
|
79
79
|
* @param {import("index.js").Options} [opts={}]
|
|
80
80
|
*/
|
|
81
|
-
constructor(image: string, platform?: string, opts?:
|
|
81
|
+
constructor(image: string, platform?: string, opts?: any);
|
|
82
82
|
/** @type {Image} */
|
|
83
83
|
image: Image;
|
|
84
84
|
/** @type {Platform} */
|
|
@@ -242,8 +242,22 @@ export class ImageRef {
|
|
|
242
242
|
getPackageURL() {
|
|
243
243
|
/** @type {Object.<string, string>} */
|
|
244
244
|
const qualifiers = {};
|
|
245
|
-
|
|
245
|
+
let repositoryUrl = this.image.getNameWithoutTag();
|
|
246
246
|
const simpleName = this.image.getSimpleName();
|
|
247
|
+
// Normalize Docker Hub image references so all forms produce the same PURL:
|
|
248
|
+
// node → docker.io/node
|
|
249
|
+
// docker.io/library/node → docker.io/node
|
|
250
|
+
if (repositoryUrl != null) {
|
|
251
|
+
const lower = repositoryUrl.toLowerCase();
|
|
252
|
+
if (lower === simpleName.toLowerCase()) {
|
|
253
|
+
// Bare name (e.g. "node") — default to docker.io
|
|
254
|
+
repositoryUrl = `docker.io/${simpleName}`;
|
|
255
|
+
}
|
|
256
|
+
else if (lower.startsWith('docker.io/library/')) {
|
|
257
|
+
// Official image with library/ prefix — strip it
|
|
258
|
+
repositoryUrl = `docker.io/${lower.substring('docker.io/library/'.length)}`;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
247
261
|
if (repositoryUrl != null && repositoryUrl.toLowerCase() !== simpleName.toLowerCase()) {
|
|
248
262
|
qualifiers[ImageRef.REPOSITORY_QUALIFIER] = repositoryUrl.toLowerCase();
|
|
249
263
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @param {import("../index.js").Options} [opts={}] - optional various options to pass along the application
|
|
5
5
|
* @returns {{}}
|
|
6
6
|
*/
|
|
7
|
-
export function generateImageSBOM(imageRef:
|
|
7
|
+
export function generateImageSBOM(imageRef: any, opts?: import("../index.js").Options): {};
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* @param {string} image
|
|
@@ -25,7 +25,7 @@ export function getImagePlatform(opts?: import("../index.js").Options): Platform
|
|
|
25
25
|
* @returns {Object.<string, string>} - The image digests
|
|
26
26
|
* @throws {Error} If the image info is invalid
|
|
27
27
|
*/
|
|
28
|
-
export function getImageDigests(imageRef:
|
|
28
|
+
export function getImageDigests(imageRef: any, opts?: import("../index.js").Options): {
|
|
29
29
|
[x: string]: string;
|
|
30
30
|
};
|
|
31
31
|
export type SyftImageSource = {
|
|
@@ -34,9 +34,9 @@ export type SyftImageSource = {
|
|
|
34
34
|
getVariant: () => string;
|
|
35
35
|
};
|
|
36
36
|
export type SyftImageSourceType = {
|
|
37
|
-
getOs: (arg0:
|
|
38
|
-
getArch: (arg0:
|
|
39
|
-
getVariant: (arg0:
|
|
37
|
+
getOs: (arg0: Object) => string;
|
|
38
|
+
getArch: (arg0: Object) => string;
|
|
39
|
+
getVariant: (arg0: Object) => string;
|
|
40
40
|
};
|
|
41
41
|
import { ImageRef } from './images.js';
|
|
42
42
|
import { Platform } from './platform.js';
|
package/dist/src/provider.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export function match(manifest: string, providers: [Provider], opts?: {
|
|
|
21
21
|
TRUSTIFY_DA_WORKSPACE_DIR?: string;
|
|
22
22
|
}): Provider;
|
|
23
23
|
/** @typedef {{ecosystem: string, contentType: string, content: string}} Provided */
|
|
24
|
-
/** @typedef {{isSupported: function(string): boolean, validateLockFile: function(string, Object): void, provideComponent: function(string, {}): Provided | Promise<Provided>, provideStack: function(string, {}): Provided | Promise<Provided>, readLicenseFromManifest: function(string): string | null}} Provider */
|
|
24
|
+
/** @typedef {{isSupported: function(string): boolean, validateLockFile: function(string, Object): void, provideComponent: function(string, {}): Provided | Promise<Provided>, provideStack: function(string, {}): Provided | Promise<Provided>, readLicenseFromManifest: function(string, Object=): string | null, packageManagerName: function(): string}} Provider */
|
|
25
25
|
/**
|
|
26
26
|
* MUST include all providers here.
|
|
27
27
|
* @type {[Provider]}
|
|
@@ -34,8 +34,9 @@ export type Provided = {
|
|
|
34
34
|
};
|
|
35
35
|
export type Provider = {
|
|
36
36
|
isSupported: (arg0: string) => boolean;
|
|
37
|
-
validateLockFile: (arg0: string, arg1:
|
|
37
|
+
validateLockFile: (arg0: string, arg1: Object) => void;
|
|
38
38
|
provideComponent: (arg0: string, arg1: {}) => Provided | Promise<Provided>;
|
|
39
39
|
provideStack: (arg0: string, arg1: {}) => Provided | Promise<Provided>;
|
|
40
|
-
readLicenseFromManifest: (arg0: string) => string | null;
|
|
40
|
+
readLicenseFromManifest: (arg0: string, arg1: Object | undefined) => string | null;
|
|
41
|
+
packageManagerName: () => string;
|
|
41
42
|
};
|
package/dist/src/provider.js
CHANGED
|
@@ -7,13 +7,14 @@ import Javascript_bun from './providers/javascript_bun.js';
|
|
|
7
7
|
import Javascript_npm from './providers/javascript_npm.js';
|
|
8
8
|
import Javascript_pnpm from './providers/javascript_pnpm.js';
|
|
9
9
|
import Javascript_yarn from './providers/javascript_yarn.js';
|
|
10
|
+
import dockerfileProvider from './providers/oci_dockerfile.js';
|
|
10
11
|
import pythonPipProvider from './providers/python_pip.js';
|
|
11
12
|
import Python_pip_pyproject from './providers/python_pip_pyproject.js';
|
|
12
13
|
import Python_poetry from './providers/python_poetry.js';
|
|
13
14
|
import Python_uv from './providers/python_uv.js';
|
|
14
15
|
import rustCargoProvider from './providers/rust_cargo.js';
|
|
15
16
|
/** @typedef {{ecosystem: string, contentType: string, content: string}} Provided */
|
|
16
|
-
/** @typedef {{isSupported: function(string): boolean, validateLockFile: function(string, Object): void, provideComponent: function(string, {}): Provided | Promise<Provided>, provideStack: function(string, {}): Provided | Promise<Provided>, readLicenseFromManifest: function(string): string | null}} Provider */
|
|
17
|
+
/** @typedef {{isSupported: function(string): boolean, validateLockFile: function(string, Object): void, provideComponent: function(string, {}): Provided | Promise<Provided>, provideStack: function(string, {}): Provided | Promise<Provided>, readLicenseFromManifest: function(string, Object=): string | null, packageManagerName: function(): string}} Provider */
|
|
17
18
|
/**
|
|
18
19
|
* MUST include all providers here.
|
|
19
20
|
* @type {[Provider]}
|
|
@@ -31,7 +32,8 @@ export const availableProviders = [
|
|
|
31
32
|
new Python_poetry(),
|
|
32
33
|
new Python_uv(),
|
|
33
34
|
new Python_pip_pyproject(),
|
|
34
|
-
rustCargoProvider
|
|
35
|
+
rustCargoProvider,
|
|
36
|
+
dockerfileProvider
|
|
35
37
|
];
|
|
36
38
|
/**
|
|
37
39
|
* Match a provider by manifest type only (no lock file check). Used for license reading.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ecosystem_maven =
|
|
1
|
+
export type ecosystem_maven = any;
|
|
2
2
|
/** @typedef {import('../provider').Provider} */
|
|
3
3
|
/** @typedef {import('../provider').Provided} Provided */
|
|
4
4
|
/** @typedef {{name: string, version: string}} Package */
|
|
@@ -20,6 +20,11 @@ export default class Base_Java {
|
|
|
20
20
|
CONFLICT_REGEX: RegExp;
|
|
21
21
|
globalBinary: string;
|
|
22
22
|
localWrapper: string;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the package manager name (e.g. mvn, gradle)
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
packageManagerName(): string;
|
|
23
28
|
/**
|
|
24
29
|
* Recursively populates the SBOM instance with the parsed graph
|
|
25
30
|
* @param {string} src - Source dependency to start the calculations from
|
|
@@ -28,6 +33,13 @@ export default class Base_Java {
|
|
|
28
33
|
* @param {Sbom} sbom - The SBOM where the dependencies are being added
|
|
29
34
|
*/
|
|
30
35
|
parseDependencyTree(src: string, srcDepth: number, lines: any[], sbom: Sbom): void;
|
|
36
|
+
/**
|
|
37
|
+
* Calculates how deep in the graph is the given line
|
|
38
|
+
* @param {string} line - line to calculate the depth from
|
|
39
|
+
* @returns {number} The calculated depth
|
|
40
|
+
* @protected
|
|
41
|
+
*/
|
|
42
|
+
protected _getDepth(line: string): number;
|
|
31
43
|
/**
|
|
32
44
|
* Create a PackageURL from any line in a Text Graph dependency tree for a manifest path.
|
|
33
45
|
* @param {string} line - line to parse from a dependencies.txt file
|
|
@@ -57,9 +69,8 @@ export default class Base_Java {
|
|
|
57
69
|
* @returns string
|
|
58
70
|
*/
|
|
59
71
|
selectToolBinary(manifestPath: string, opts: {}): string | null;
|
|
60
|
-
#private;
|
|
61
72
|
}
|
|
62
|
-
export type Provided =
|
|
73
|
+
export type Provided = any;
|
|
63
74
|
export type Package = {
|
|
64
75
|
name: string;
|
|
65
76
|
version: string;
|
|
@@ -25,6 +25,13 @@ export default class Base_Java {
|
|
|
25
25
|
this.globalBinary = globalBinary;
|
|
26
26
|
this.localWrapper = localWrapper;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns the package manager name (e.g. mvn, gradle)
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
packageManagerName() {
|
|
33
|
+
return this.globalBinary;
|
|
34
|
+
}
|
|
28
35
|
/**
|
|
29
36
|
* Recursively populates the SBOM instance with the parsed graph
|
|
30
37
|
* @param {string} src - Source dependency to start the calculations from
|
|
@@ -41,7 +48,7 @@ export default class Base_Java {
|
|
|
41
48
|
}
|
|
42
49
|
let index = 0;
|
|
43
50
|
let target = lines[index];
|
|
44
|
-
let targetDepth = this
|
|
51
|
+
let targetDepth = this._getDepth(target);
|
|
45
52
|
while (targetDepth > srcDepth && index < lines.length) {
|
|
46
53
|
if (targetDepth === srcDepth + 1) {
|
|
47
54
|
let from = this.parseDep(src);
|
|
@@ -54,22 +61,25 @@ export default class Base_Java {
|
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
else {
|
|
57
|
-
this.parseDependencyTree(lines[index - 1], this
|
|
64
|
+
this.parseDependencyTree(lines[index - 1], this._getDepth(lines[index - 1]), lines.slice(index), sbom);
|
|
58
65
|
}
|
|
59
66
|
target = lines[++index];
|
|
60
|
-
targetDepth = this
|
|
67
|
+
targetDepth = this._getDepth(target);
|
|
61
68
|
}
|
|
62
69
|
}
|
|
63
70
|
/**
|
|
64
71
|
* Calculates how deep in the graph is the given line
|
|
65
72
|
* @param {string} line - line to calculate the depth from
|
|
66
73
|
* @returns {number} The calculated depth
|
|
67
|
-
* @
|
|
74
|
+
* @protected
|
|
68
75
|
*/
|
|
69
|
-
|
|
70
|
-
if (line ===
|
|
76
|
+
_getDepth(line) {
|
|
77
|
+
if (!line || line.trim() === '') {
|
|
71
78
|
return -1;
|
|
72
79
|
}
|
|
80
|
+
if (line.match(/^\w/)) {
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
73
83
|
return ((line.indexOf('-') - 1) / 3) + 1;
|
|
74
84
|
}
|
|
75
85
|
/**
|