@trustify-da/trustify-da-javascript-client 0.3.0-ea.c2f6c64 → 0.3.0-ea.c300d9f
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 +199 -11
- package/dist/package.json +30 -26
- package/dist/src/analysis.d.ts +14 -7
- package/dist/src/analysis.js +32 -14
- package/dist/src/cli.js +188 -6
- package/dist/src/config.d.ts +120 -0
- package/dist/src/config.js +260 -0
- package/dist/src/cyclone_dx_sbom.d.ts +20 -1
- package/dist/src/cyclone_dx_sbom.js +68 -9
- package/dist/src/index.d.ts +79 -15
- package/dist/src/index.js +90 -34
- 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/package_version.d.ts +8 -0
- package/dist/src/package_version.js +31 -0
- package/dist/src/provider.d.ts +4 -3
- package/dist/src/provider.js +8 -2
- package/dist/src/providers/base_java.d.ts +67 -12
- package/dist/src/providers/base_java.js +82 -61
- package/dist/src/providers/base_javascript.d.ts +74 -9
- package/dist/src/providers/base_javascript.js +116 -7
- package/dist/src/providers/base_pyproject.d.ts +42 -31
- package/dist/src/providers/base_pyproject.js +121 -78
- package/dist/src/providers/containerfile_parser.d.ts +5 -0
- package/dist/src/providers/containerfile_parser.js +20 -0
- package/dist/src/providers/golang_gomodules.d.ts +11 -1
- package/dist/src/providers/golang_gomodules.js +114 -15
- package/dist/src/providers/java_gradle.d.ts +67 -0
- package/dist/src/providers/java_gradle.js +312 -20
- 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 +37 -9
- package/dist/src/providers/java_maven.js +269 -11
- package/dist/src/providers/javascript_bun.d.ts +22 -0
- package/dist/src/providers/javascript_bun.js +141 -0
- package/dist/src/providers/javascript_npm.d.ts +19 -0
- package/dist/src/providers/javascript_npm.js +61 -1
- package/dist/src/providers/javascript_pnpm.d.ts +13 -0
- package/dist/src/providers/javascript_pnpm.js +53 -3
- package/dist/src/providers/javascript_yarn.d.ts +12 -0
- package/dist/src/providers/javascript_yarn.js +75 -2
- package/dist/src/providers/manifest.js +6 -3
- package/dist/src/providers/marker_evaluator.d.ts +14 -0
- package/dist/src/providers/marker_evaluator.js +191 -0
- package/dist/src/providers/oci_dockerfile.d.ts +51 -0
- package/dist/src/providers/oci_dockerfile.js +177 -0
- package/dist/src/providers/processors/yarn_berry_processor.d.ts +6 -2
- package/dist/src/providers/processors/yarn_berry_processor.js +9 -4
- package/dist/src/providers/processors/yarn_classic_processor.d.ts +6 -2
- package/dist/src/providers/processors/yarn_classic_processor.js +8 -6
- package/dist/src/providers/python_controller.d.ts +5 -1
- package/dist/src/providers/python_controller.js +69 -8
- package/dist/src/providers/python_pip.d.ts +5 -0
- package/dist/src/providers/python_pip.js +5 -5
- package/dist/src/providers/python_pip_pyproject.d.ts +61 -0
- package/dist/src/providers/python_pip_pyproject.js +146 -0
- package/dist/src/providers/python_poetry.d.ts +64 -8
- package/dist/src/providers/python_poetry.js +165 -25
- package/dist/src/providers/python_uv.d.ts +22 -2
- package/dist/src/providers/python_uv.js +157 -6
- package/dist/src/providers/requirements_parser.js +1 -1
- package/dist/src/providers/rust_cargo.d.ts +6 -2
- package/dist/src/providers/rust_cargo.js +101 -33
- package/dist/src/providers/tree-sitter-containerfile.wasm +0 -0
- package/dist/src/remediate.d.ts +120 -0
- package/dist/src/remediate.js +253 -0
- package/dist/src/remediation.d.ts +57 -0
- package/dist/src/remediation.js +436 -0
- package/dist/src/remediation_report.d.ts +40 -0
- package/dist/src/remediation_report.js +159 -0
- package/dist/src/sbom.d.ts +18 -1
- package/dist/src/sbom.js +14 -2
- package/dist/src/tools.d.ts +37 -13
- package/dist/src/tools.js +92 -13
- package/dist/src/updaters/maven_updater.d.ts +58 -0
- package/dist/src/updaters/maven_updater.js +345 -0
- package/dist/src/updaters/toml_updater.d.ts +62 -0
- package/dist/src/updaters/toml_updater.js +276 -0
- package/dist/src/workspace.d.ts +11 -1
- package/dist/src/workspace.js +3 -2
- package/package.json +31 -27
package/dist/src/sbom.d.ts
CHANGED
|
@@ -25,9 +25,25 @@ export default class Sbom {
|
|
|
25
25
|
/**
|
|
26
26
|
* @param {component} sourceRef current source Component ( Starting from root component by clients)
|
|
27
27
|
* @param {PackageURL} targetRef current dependency to add to Dependencies list of component sourceRef
|
|
28
|
+
* @param {string} [scope] - Scope of the dependency
|
|
29
|
+
* @param {Array<{alg: string, content: string}>} [targetHashes] - Optional hashes for the target component
|
|
28
30
|
* @return Sbom
|
|
29
31
|
*/
|
|
30
|
-
addDependency(sourceRef: component, targetRef: PackageURL, scope
|
|
32
|
+
addDependency(sourceRef: component, targetRef: PackageURL, scope?: string, targetHashes?: Array<{
|
|
33
|
+
alg: string;
|
|
34
|
+
content: string;
|
|
35
|
+
}>): CycloneDxSbom;
|
|
36
|
+
/**
|
|
37
|
+
* Attach hashes to existing components by matching their PURL. Post-processing
|
|
38
|
+
* step used by ecosystem-specific providers (e.g. Maven) to enrich the SBOM
|
|
39
|
+
* with artifact hashes without leaking their concern into the shared parser.
|
|
40
|
+
* @param {Map<string, Array<{alg: string, content: string}>>} hashMap - PURL→hashes map
|
|
41
|
+
* @return {Sbom}
|
|
42
|
+
*/
|
|
43
|
+
attachHashes(hashMap: Map<string, Array<{
|
|
44
|
+
alg: string;
|
|
45
|
+
content: string;
|
|
46
|
+
}>>): Sbom;
|
|
31
47
|
/**
|
|
32
48
|
* @return String sbom json in a string format
|
|
33
49
|
*/
|
|
@@ -45,6 +61,7 @@ export default class Sbom {
|
|
|
45
61
|
version: any;
|
|
46
62
|
scope: any;
|
|
47
63
|
licenses?: any;
|
|
64
|
+
hashes?: any;
|
|
48
65
|
};
|
|
49
66
|
/** This method gets a component object, and a string name, and checks if the name is a substring of the component' purl.
|
|
50
67
|
* @param {} component to search in its dependencies
|
package/dist/src/sbom.js
CHANGED
|
@@ -43,10 +43,22 @@ export default class Sbom {
|
|
|
43
43
|
/**
|
|
44
44
|
* @param {component} sourceRef current source Component ( Starting from root component by clients)
|
|
45
45
|
* @param {PackageURL} targetRef current dependency to add to Dependencies list of component sourceRef
|
|
46
|
+
* @param {string} [scope] - Scope of the dependency
|
|
47
|
+
* @param {Array<{alg: string, content: string}>} [targetHashes] - Optional hashes for the target component
|
|
46
48
|
* @return Sbom
|
|
47
49
|
*/
|
|
48
|
-
addDependency(sourceRef, targetRef, scope) {
|
|
49
|
-
return this.sbomModel.addDependency(sourceRef, targetRef, scope);
|
|
50
|
+
addDependency(sourceRef, targetRef, scope, targetHashes) {
|
|
51
|
+
return this.sbomModel.addDependency(sourceRef, targetRef, scope, targetHashes);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Attach hashes to existing components by matching their PURL. Post-processing
|
|
55
|
+
* step used by ecosystem-specific providers (e.g. Maven) to enrich the SBOM
|
|
56
|
+
* with artifact hashes without leaking their concern into the shared parser.
|
|
57
|
+
* @param {Map<string, Array<{alg: string, content: string}>>} hashMap - PURL→hashes map
|
|
58
|
+
* @return {Sbom}
|
|
59
|
+
*/
|
|
60
|
+
attachHashes(hashMap) {
|
|
61
|
+
return this.sbomModel.attachHashes(hashMap);
|
|
50
62
|
}
|
|
51
63
|
/**
|
|
52
64
|
* @return String sbom json in a string format
|
package/dist/src/tools.d.ts
CHANGED
|
@@ -6,24 +6,22 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export function logValueFromObjects(key: string, opts?: {}, defValue: string): void;
|
|
8
8
|
/**
|
|
9
|
-
* Utility function
|
|
10
|
-
*
|
|
11
|
-
* if not present, or not string will return the default value supplied which default to null.
|
|
9
|
+
* Utility function returns the value for key from opts, then environment variables,
|
|
10
|
+
* then the supplied default. Values from opts are used only if they are strings.
|
|
12
11
|
* @param {string} key the key to look for in the environment variables and the opts object
|
|
13
12
|
* @param {string|null} [def=null] the value to return if nothing else found
|
|
14
|
-
* @param {{}} [opts={}] the options object to
|
|
15
|
-
* @returns {string|null} the value of the key found in the
|
|
13
|
+
* @param {{}} [opts={}] the options object to check before the environment
|
|
14
|
+
* @returns {string|null} the value of the key found in the options object, environment, or the
|
|
16
15
|
* default supplied
|
|
17
16
|
*/
|
|
18
17
|
export function getCustom(key: string, def?: string | null, opts?: {}): string | null;
|
|
19
18
|
/**
|
|
20
19
|
* Utility function for looking up custom variable for a binary path.
|
|
21
|
-
*
|
|
22
|
-
* uppercase version of
|
|
23
|
-
* found.
|
|
20
|
+
* Looks in opts, then environment variables, for a key with TRUSTIFY_DA_x_PATH, where x is an
|
|
21
|
+
* uppercase version of the supplied name. The name is returned if neither contains the key.
|
|
24
22
|
* @param name the binary name to look for, will be returned as value in nothing else found
|
|
25
|
-
* @param {{}} [opts={}] the options object to
|
|
26
|
-
* @returns {string|null} the value of the key found in the
|
|
23
|
+
* @param {{}} [opts={}] the options object to check before the environment
|
|
24
|
+
* @returns {string|null} the value of the key found in the options object, environment, or the
|
|
27
25
|
* original name supplied
|
|
28
26
|
*/
|
|
29
27
|
export function getCustomPath(name: any, opts?: {}): string | null;
|
|
@@ -31,7 +29,7 @@ export function getCustomPath(name: any, opts?: {}): string | null;
|
|
|
31
29
|
* Utility function for determining whether wrappers for build tools such as gradlew/mvnw should be
|
|
32
30
|
* preferred over invoking the binary directly.
|
|
33
31
|
* @param {string} name - binary for which to search for its wrapper
|
|
34
|
-
* @param {{}} opts - the options object to
|
|
32
|
+
* @param {{}} opts - the options object to check before the environment
|
|
35
33
|
* @returns {boolean} whether to prefer the wrapper if exists or not
|
|
36
34
|
*/
|
|
37
35
|
export function getWrapperPreference(name: string, opts?: {}): boolean;
|
|
@@ -61,6 +59,32 @@ export function toPurlFromString(strPurl: any): PackageURL | null;
|
|
|
61
59
|
* @param {string} cwd - directory for which to find the root of the git repository.
|
|
62
60
|
*/
|
|
63
61
|
export function getGitRootDir(cwd: string): string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Normalize a filesystem path, lowercasing on Windows for case-insensitive comparison.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} thePath
|
|
66
|
+
* @returns {string}
|
|
67
|
+
*/
|
|
68
|
+
export function normalizePath(thePath: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Walk up from `startDir` to `repoRoot` looking for an executable wrapper script.
|
|
71
|
+
*
|
|
72
|
+
* @param {string} startDir - Absolute directory to start from
|
|
73
|
+
* @param {string} wrapperName - Wrapper filename (e.g. `mvnw`, `gradlew`)
|
|
74
|
+
* @param {string} [repoRoot] - Stop boundary (defaults to git root or filesystem root)
|
|
75
|
+
* @returns {string | undefined}
|
|
76
|
+
*/
|
|
77
|
+
export function traverseForWrapper(startDir: string, wrapperName: string, repoRoot?: string): string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Resolve a build-tool binary, preferring a wrapper when configured.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} globalBinary - Global binary name (e.g. `mvn`, `gradle`)
|
|
82
|
+
* @param {string} localWrapper - Wrapper filename (e.g. `mvnw`, `gradlew.bat`)
|
|
83
|
+
* @param {string} startDir - Directory from which to start the wrapper search
|
|
84
|
+
* @param {import('./index.js').Options} [opts={}]
|
|
85
|
+
* @returns {string} Path to the resolved binary
|
|
86
|
+
*/
|
|
87
|
+
export function resolveBinary(globalBinary: string, localWrapper: string, startDir: string, opts?: import("./index.js").Options): string;
|
|
64
88
|
/** this method invokes command string in a process in a synchronous way.
|
|
65
89
|
* @param {string} bin - the command to be invoked
|
|
66
90
|
* @param {Array<string>} args - the args to pass to the binary
|
|
@@ -74,13 +98,13 @@ export function invokeCommand(bin: string, args: Array<string>, opts?: import("c
|
|
|
74
98
|
* @param {import("index.js").Options} opts - The trustify DA options that may contain proxy configuration
|
|
75
99
|
* @returns {RequestInit} The fetch options with proxy agent if applicable
|
|
76
100
|
*/
|
|
77
|
-
export function addProxyAgent(options: RequestInit, opts:
|
|
101
|
+
export function addProxyAgent(options: RequestInit, opts: any): RequestInit;
|
|
78
102
|
/**
|
|
79
103
|
* Utility function for fetching vendor tokens
|
|
80
104
|
* @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
|
|
81
105
|
* @returns {{}}
|
|
82
106
|
*/
|
|
83
|
-
export function getTokenHeaders(opts?:
|
|
107
|
+
export function getTokenHeaders(opts?: any): {};
|
|
84
108
|
export const RegexNotToBeLogged: RegExp;
|
|
85
109
|
export const TRUSTIFY_DA_TOKEN_HEADER: "trust-da-token";
|
|
86
110
|
export const TRUSTIFY_DA_TELEMETRY_ID_HEADER: "telemetry-anonymous-id";
|
package/dist/src/tools.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { execFileSync } from "child_process";
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
2
4
|
import { EOL } from "os";
|
|
3
5
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
4
6
|
import { PackageURL } from "packageurl-js";
|
|
@@ -25,39 +27,60 @@ export function logValueFromObjects(key, opts, defValue) {
|
|
|
25
27
|
console.log(`default value for ${key} = ${defValue} ${EOL}`);
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
|
-
* Utility function
|
|
29
|
-
*
|
|
30
|
-
* if not present, or not string will return the default value supplied which default to null.
|
|
30
|
+
* Utility function returns the value for key from opts, then environment variables,
|
|
31
|
+
* then the supplied default. Values from opts are used only if they are strings.
|
|
31
32
|
* @param {string} key the key to look for in the environment variables and the opts object
|
|
32
33
|
* @param {string|null} [def=null] the value to return if nothing else found
|
|
33
|
-
* @param {{}} [opts={}] the options object to
|
|
34
|
-
* @returns {string|null} the value of the key found in the
|
|
34
|
+
* @param {{}} [opts={}] the options object to check before the environment
|
|
35
|
+
* @returns {string|null} the value of the key found in the options object, environment, or the
|
|
35
36
|
* default supplied
|
|
36
37
|
*/
|
|
37
38
|
export function getCustom(key, def = null, opts = {}) {
|
|
38
39
|
if (process.env["TRUSTIFY_DA_DEBUG"] === "true" && !key.match(RegexNotToBeLogged)) {
|
|
39
40
|
logValueFromObjects(key, opts, def);
|
|
40
41
|
}
|
|
41
|
-
return key in
|
|
42
|
+
return key in opts && typeof opts[key] === 'string' ? opts[key] : key in process.env ? process.env[key] : def;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Validates that an executable path does not use directory traversal or relative segments.
|
|
46
|
+
* @param {string} binPath - The executable path to validate.
|
|
47
|
+
* @returns {string} The validated path.
|
|
48
|
+
* @throws {Error} If the path contains '..' segments or is a relative path with separators.
|
|
49
|
+
*/
|
|
50
|
+
function validateExecutablePath(binPath) {
|
|
51
|
+
if (typeof binPath !== 'string' || binPath.length === 0) {
|
|
52
|
+
throw new Error('Executable path rejected: expected a non-empty string');
|
|
53
|
+
}
|
|
54
|
+
if (binPath.startsWith('./') || binPath.startsWith('.\\')) {
|
|
55
|
+
throw new Error(`Executable path rejected: relative paths starting with './' are not allowed: ${binPath}`);
|
|
56
|
+
}
|
|
57
|
+
const segments = binPath.split(/[/\\]/);
|
|
58
|
+
if (segments.includes('..')) {
|
|
59
|
+
throw new Error(`Executable path rejected: path contains directory traversal segment (..): ${binPath}`);
|
|
60
|
+
}
|
|
61
|
+
if ((binPath.includes('/') || binPath.includes('\\')) && !path.isAbsolute(binPath)) {
|
|
62
|
+
throw new Error(`Executable path rejected: relative paths are not allowed, use an absolute path or a bare command name: ${binPath}`);
|
|
63
|
+
}
|
|
64
|
+
return binPath;
|
|
42
65
|
}
|
|
43
66
|
/**
|
|
44
67
|
* Utility function for looking up custom variable for a binary path.
|
|
45
|
-
*
|
|
46
|
-
* uppercase version of
|
|
47
|
-
* found.
|
|
68
|
+
* Looks in opts, then environment variables, for a key with TRUSTIFY_DA_x_PATH, where x is an
|
|
69
|
+
* uppercase version of the supplied name. The name is returned if neither contains the key.
|
|
48
70
|
* @param name the binary name to look for, will be returned as value in nothing else found
|
|
49
|
-
* @param {{}} [opts={}] the options object to
|
|
50
|
-
* @returns {string|null} the value of the key found in the
|
|
71
|
+
* @param {{}} [opts={}] the options object to check before the environment
|
|
72
|
+
* @returns {string|null} the value of the key found in the options object, environment, or the
|
|
51
73
|
* original name supplied
|
|
52
74
|
*/
|
|
53
75
|
export function getCustomPath(name, opts = {}) {
|
|
54
|
-
|
|
76
|
+
const resolvedPath = getCustom(`TRUSTIFY_DA_${name.toUpperCase()}_PATH`, name, opts);
|
|
77
|
+
return validateExecutablePath(resolvedPath);
|
|
55
78
|
}
|
|
56
79
|
/**
|
|
57
80
|
* Utility function for determining whether wrappers for build tools such as gradlew/mvnw should be
|
|
58
81
|
* preferred over invoking the binary directly.
|
|
59
82
|
* @param {string} name - binary for which to search for its wrapper
|
|
60
|
-
* @param {{}} opts - the options object to
|
|
83
|
+
* @param {{}} opts - the options object to check before the environment
|
|
61
84
|
* @returns {boolean} whether to prefer the wrapper if exists or not
|
|
62
85
|
*/
|
|
63
86
|
export function getWrapperPreference(name, opts = {}) {
|
|
@@ -128,6 +151,62 @@ export function getGitRootDir(cwd) {
|
|
|
128
151
|
return undefined;
|
|
129
152
|
}
|
|
130
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Normalize a filesystem path, lowercasing on Windows for case-insensitive comparison.
|
|
156
|
+
*
|
|
157
|
+
* @param {string} thePath
|
|
158
|
+
* @returns {string}
|
|
159
|
+
*/
|
|
160
|
+
export function normalizePath(thePath) {
|
|
161
|
+
const normalized = path.resolve(thePath).normalize();
|
|
162
|
+
return process.platform === 'win32' ? normalized.toLowerCase() : normalized;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Walk up from `startDir` to `repoRoot` looking for an executable wrapper script.
|
|
166
|
+
*
|
|
167
|
+
* @param {string} startDir - Absolute directory to start from
|
|
168
|
+
* @param {string} wrapperName - Wrapper filename (e.g. `mvnw`, `gradlew`)
|
|
169
|
+
* @param {string} [repoRoot] - Stop boundary (defaults to git root or filesystem root)
|
|
170
|
+
* @returns {string | undefined}
|
|
171
|
+
*/
|
|
172
|
+
export function traverseForWrapper(startDir, wrapperName, repoRoot = undefined) {
|
|
173
|
+
const currentDir = normalizePath(startDir);
|
|
174
|
+
repoRoot = repoRoot || getGitRootDir(currentDir) || path.parse(currentDir).root;
|
|
175
|
+
const wrapperPath = path.join(currentDir, wrapperName);
|
|
176
|
+
try {
|
|
177
|
+
fs.accessSync(wrapperPath, fs.constants.X_OK);
|
|
178
|
+
return wrapperPath;
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
const rootDir = path.parse(currentDir).root;
|
|
182
|
+
if (currentDir === repoRoot || currentDir === rootDir) {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
const parentDir = path.dirname(currentDir);
|
|
186
|
+
if (parentDir === currentDir || parentDir === rootDir) {
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
return traverseForWrapper(parentDir, wrapperName, repoRoot);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Resolve a build-tool binary, preferring a wrapper when configured.
|
|
194
|
+
*
|
|
195
|
+
* @param {string} globalBinary - Global binary name (e.g. `mvn`, `gradle`)
|
|
196
|
+
* @param {string} localWrapper - Wrapper filename (e.g. `mvnw`, `gradlew.bat`)
|
|
197
|
+
* @param {string} startDir - Directory from which to start the wrapper search
|
|
198
|
+
* @param {import('./index.js').Options} [opts={}]
|
|
199
|
+
* @returns {string} Path to the resolved binary
|
|
200
|
+
*/
|
|
201
|
+
export function resolveBinary(globalBinary, localWrapper, startDir, opts = {}) {
|
|
202
|
+
if (getWrapperPreference(globalBinary, opts)) {
|
|
203
|
+
const wrapper = traverseForWrapper(startDir, localWrapper);
|
|
204
|
+
if (wrapper !== undefined) {
|
|
205
|
+
return wrapper;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return getCustomPath(globalBinary, opts);
|
|
209
|
+
}
|
|
131
210
|
/** this method invokes command string in a process in a synchronous way.
|
|
132
211
|
* @param {string} bin - the command to be invoked
|
|
133
212
|
* @param {Array<string>} args - the args to pass to the binary
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One entry in {@link updateMavenVersions}' `applied` list: a version that was changed and
|
|
3
|
+
* where. `type` discriminates the edit site — `'direct'` for a dependency's own `<version>`,
|
|
4
|
+
* `'property'` for a `${property}` reference (then `property` names the resolved property).
|
|
5
|
+
* @typedef {{
|
|
6
|
+
* groupId: string,
|
|
7
|
+
* artifactId: string,
|
|
8
|
+
* newVersion: string,
|
|
9
|
+
* type: ('direct'|'property'),
|
|
10
|
+
* property?: string
|
|
11
|
+
* }} MavenAppliedChange
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Stable edit-site key for a Maven change: same key => same commit/PR. Deps whose versions
|
|
15
|
+
* resolve to one `${property}` share the property key and are therefore inseparable.
|
|
16
|
+
* @param {string} manifestPath
|
|
17
|
+
* @param {MavenAppliedChange} applied
|
|
18
|
+
* @returns {string}
|
|
19
|
+
*/
|
|
20
|
+
export function mavenChangeKey(manifestPath: string, applied: MavenAppliedChange): string;
|
|
21
|
+
/**
|
|
22
|
+
* Updates dependency versions in a Maven pom.xml while preserving file formatting.
|
|
23
|
+
*
|
|
24
|
+
* Uses `fast-xml-parser` to understand the XML structure (dependencies and properties),
|
|
25
|
+
* then performs position-based string splice to replace version strings without altering
|
|
26
|
+
* any other formatting, comments, whitespace, or indentation.
|
|
27
|
+
*
|
|
28
|
+
* Supports `${property}` indirection: when a dependency's `<version>` is a property
|
|
29
|
+
* reference, the updater resolves the property chain (including recursive references)
|
|
30
|
+
* and updates the terminal property value in `<properties>` instead.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} pomContent - the raw pom.xml file content
|
|
33
|
+
* @param {import('../remediate.js').VersionChangeRequest[]} versionChanges - list of version changes to apply
|
|
34
|
+
* @returns {{content: string, applied: MavenAppliedChange[], skipped: Array<{groupId: string, artifactId: string, newVersion: string, reason: string}>}} the updated content and
|
|
35
|
+
* lists of applied and skipped changes
|
|
36
|
+
*/
|
|
37
|
+
export function updateMavenVersions(pomContent: string, versionChanges: import("../remediate.js").VersionChangeRequest[]): {
|
|
38
|
+
content: string;
|
|
39
|
+
applied: MavenAppliedChange[];
|
|
40
|
+
skipped: Array<{
|
|
41
|
+
groupId: string;
|
|
42
|
+
artifactId: string;
|
|
43
|
+
newVersion: string;
|
|
44
|
+
reason: string;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* One entry in {@link updateMavenVersions}' `applied` list: a version that was changed and
|
|
49
|
+
* where. `type` discriminates the edit site — `'direct'` for a dependency's own `<version>`,
|
|
50
|
+
* `'property'` for a `${property}` reference (then `property` names the resolved property).
|
|
51
|
+
*/
|
|
52
|
+
export type MavenAppliedChange = {
|
|
53
|
+
groupId: string;
|
|
54
|
+
artifactId: string;
|
|
55
|
+
newVersion: string;
|
|
56
|
+
type: ("direct" | "property");
|
|
57
|
+
property?: string;
|
|
58
|
+
};
|