@trustify-da/trustify-da-javascript-client 0.3.0-ea.b8af0f8 → 0.3.0-ea.bdaadb2

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.
Files changed (88) hide show
  1. package/README.md +250 -11
  2. package/dist/package.json +33 -25
  3. package/dist/src/analysis.d.ts +14 -7
  4. package/dist/src/analysis.js +32 -15
  5. package/dist/src/cli.js +156 -3
  6. package/dist/src/cyclone_dx_sbom.d.ts +27 -1
  7. package/dist/src/cyclone_dx_sbom.js +82 -9
  8. package/dist/src/index.d.ts +86 -11
  9. package/dist/src/index.js +102 -30
  10. package/dist/src/license/index.d.ts +3 -3
  11. package/dist/src/license/index.js +4 -1
  12. package/dist/src/license/license_utils.js +4 -1
  13. package/dist/src/license/licenses_api.d.ts +2 -2
  14. package/dist/src/oci_image/images.d.ts +1 -1
  15. package/dist/src/oci_image/images.js +15 -1
  16. package/dist/src/oci_image/utils.d.ts +5 -5
  17. package/dist/src/oci_image/utils.js +11 -2
  18. package/dist/src/package_version.d.ts +8 -0
  19. package/dist/src/package_version.js +31 -0
  20. package/dist/src/provider.d.ts +4 -3
  21. package/dist/src/provider.js +12 -2
  22. package/dist/src/providers/base_java.d.ts +67 -12
  23. package/dist/src/providers/base_java.js +82 -61
  24. package/dist/src/providers/base_javascript.d.ts +74 -9
  25. package/dist/src/providers/base_javascript.js +149 -9
  26. package/dist/src/providers/base_pyproject.d.ts +158 -0
  27. package/dist/src/providers/base_pyproject.js +322 -0
  28. package/dist/src/providers/containerfile_parser.d.ts +5 -0
  29. package/dist/src/providers/containerfile_parser.js +20 -0
  30. package/dist/src/providers/golang_gomodules.d.ts +23 -13
  31. package/dist/src/providers/golang_gomodules.js +207 -120
  32. package/dist/src/providers/gomod_parser.d.ts +4 -0
  33. package/dist/src/providers/gomod_parser.js +16 -0
  34. package/dist/src/providers/java_gradle.d.ts +67 -0
  35. package/dist/src/providers/java_gradle.js +310 -17
  36. package/dist/src/providers/java_gradle_groovy.d.ts +1 -1
  37. package/dist/src/providers/java_gradle_kotlin.d.ts +1 -1
  38. package/dist/src/providers/java_maven.d.ts +38 -5
  39. package/dist/src/providers/java_maven.js +261 -8
  40. package/dist/src/providers/javascript_bun.d.ts +22 -0
  41. package/dist/src/providers/javascript_bun.js +141 -0
  42. package/dist/src/providers/javascript_npm.d.ts +19 -0
  43. package/dist/src/providers/javascript_npm.js +61 -1
  44. package/dist/src/providers/javascript_pnpm.d.ts +13 -0
  45. package/dist/src/providers/javascript_pnpm.js +53 -3
  46. package/dist/src/providers/javascript_yarn.d.ts +12 -0
  47. package/dist/src/providers/javascript_yarn.js +75 -2
  48. package/dist/src/providers/manifest.d.ts +2 -0
  49. package/dist/src/providers/manifest.js +22 -4
  50. package/dist/src/providers/marker_evaluator.d.ts +14 -0
  51. package/dist/src/providers/marker_evaluator.js +191 -0
  52. package/dist/src/providers/oci_dockerfile.d.ts +51 -0
  53. package/dist/src/providers/oci_dockerfile.js +177 -0
  54. package/dist/src/providers/processors/yarn_berry_processor.d.ts +6 -2
  55. package/dist/src/providers/processors/yarn_berry_processor.js +91 -7
  56. package/dist/src/providers/processors/yarn_classic_processor.d.ts +6 -2
  57. package/dist/src/providers/processors/yarn_classic_processor.js +8 -6
  58. package/dist/src/providers/python_controller.d.ts +5 -1
  59. package/dist/src/providers/python_controller.js +69 -8
  60. package/dist/src/providers/python_pip.d.ts +5 -0
  61. package/dist/src/providers/python_pip.js +6 -6
  62. package/dist/src/providers/python_pip_pyproject.d.ts +61 -0
  63. package/dist/src/providers/python_pip_pyproject.js +146 -0
  64. package/dist/src/providers/python_poetry.d.ts +98 -0
  65. package/dist/src/providers/python_poetry.js +286 -0
  66. package/dist/src/providers/python_uv.d.ts +46 -0
  67. package/dist/src/providers/python_uv.js +269 -0
  68. package/dist/src/providers/rust_cargo.d.ts +6 -2
  69. package/dist/src/providers/rust_cargo.js +101 -33
  70. package/dist/src/providers/tree-sitter-containerfile.wasm +0 -0
  71. package/dist/src/providers/tree-sitter-gomod.wasm +0 -0
  72. package/dist/src/remediate.d.ts +21 -0
  73. package/dist/src/remediate.js +149 -0
  74. package/dist/src/remediation.d.ts +57 -0
  75. package/dist/src/remediation.js +436 -0
  76. package/dist/src/remediation_report.d.ts +40 -0
  77. package/dist/src/remediation_report.js +159 -0
  78. package/dist/src/sbom.d.ts +25 -1
  79. package/dist/src/sbom.js +23 -2
  80. package/dist/src/tools.d.ts +28 -2
  81. package/dist/src/tools.js +82 -1
  82. package/dist/src/updaters/maven_updater.d.ts +26 -0
  83. package/dist/src/updaters/maven_updater.js +322 -0
  84. package/dist/src/updaters/toml_updater.d.ts +33 -0
  85. package/dist/src/updaters/toml_updater.js +244 -0
  86. package/dist/src/workspace.d.ts +9 -0
  87. package/dist/src/workspace.js +1 -1
  88. package/package.json +34 -26
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Report generator that transforms remediation extractor output into structured
3
+ * markdown for PR bodies, CLI dry-run output, and JSON.
4
+ */
5
+ import { SEVERITY_ORDER } from './remediation.js';
6
+ /**
7
+ * Generates a formatted report from an array of remediation entries.
8
+ *
9
+ * @param {Array<{purl: string, groupId: string, artifactId: string, currentVersion: string,
10
+ * fixedInVersion: string, fixedInPurl: string, provider: string, source: string,
11
+ * advisories: Array<{id: string, url: string}>, severity: string, cves: string[]}>} remediations
12
+ * @param {object} [options]
13
+ * @param {'dependency'|'bundle'} [options.groupBy='dependency'] - grouping strategy
14
+ * @param {'markdown'|'json'} [options.format='markdown'] - output format
15
+ * @param {boolean} [options.dryRun=false] - when true, produces tabular summary
16
+ * @returns {string}
17
+ */
18
+ export function generateReport(remediations, options = {}) {
19
+ const { groupBy = 'dependency', format = 'markdown', dryRun = false } = options;
20
+ if (!remediations || remediations.length === 0) {
21
+ return format === 'json' ? '[]' : 'No remediations found.';
22
+ }
23
+ if (format === 'json') {
24
+ return JSON.stringify(remediations, null, '\t');
25
+ }
26
+ if (dryRun) {
27
+ return generateDryRunReport(remediations);
28
+ }
29
+ if (groupBy === 'bundle') {
30
+ return generateBundledReport(remediations);
31
+ }
32
+ return generatePerDependencyReport(remediations);
33
+ }
34
+ /**
35
+ * Generates a per-dependency markdown report with one section per remediation entry.
36
+ * @param {Array<object>} remediations
37
+ * @returns {string}
38
+ */
39
+ function generatePerDependencyReport(remediations) {
40
+ const sections = remediations.map(rem => {
41
+ const depName = rem.groupId
42
+ ? `${rem.groupId}:${rem.artifactId}`
43
+ : rem.artifactId;
44
+ const lines = [
45
+ `## Security Update: ${depName} ${rem.currentVersion} → ${rem.fixedInVersion}`,
46
+ '',
47
+ `**Provider:** ${rem.provider} | **Source:** ${rem.source}`,
48
+ '',
49
+ ];
50
+ if (rem.cves && rem.cves.length > 0) {
51
+ lines.push('### Vulnerabilities resolved');
52
+ lines.push('');
53
+ lines.push('| CVE | Severity | Advisory |');
54
+ lines.push('| --- | --- | --- |');
55
+ const advisoryLinks = formatAdvisoryLinks(rem.advisories);
56
+ for (const cve of rem.cves) {
57
+ lines.push(`| ${cve} | ${rem.severity} | ${advisoryLinks} |`);
58
+ }
59
+ }
60
+ return lines.join('\n');
61
+ });
62
+ return sections.join('\n\n');
63
+ }
64
+ /**
65
+ * Generates a bundled markdown report grouping all remediations by severity.
66
+ * @param {Array<object>} remediations
67
+ * @returns {string}
68
+ */
69
+ function generateBundledReport(remediations) {
70
+ const lines = ['# Security Update Summary', ''];
71
+ const bySeverity = groupBySeverity(remediations);
72
+ for (const severity of [...SEVERITY_ORDER].reverse()) {
73
+ const group = bySeverity.get(severity);
74
+ if (!group || group.length === 0) {
75
+ continue;
76
+ }
77
+ lines.push(`## ${severity}`);
78
+ lines.push('');
79
+ lines.push('| Dependency | Current | Fixed | Provider | CVEs | Advisory |');
80
+ lines.push('| --- | --- | --- | --- | --- | --- |');
81
+ for (const rem of group) {
82
+ const depName = rem.groupId
83
+ ? `${rem.groupId}:${rem.artifactId}`
84
+ : rem.artifactId;
85
+ const cves = (rem.cves || []).join(', ');
86
+ const advisoryLinks = formatAdvisoryLinks(rem.advisories);
87
+ lines.push(`| ${depName} | ${rem.currentVersion} | ${rem.fixedInVersion}`
88
+ + ` | ${rem.provider} | ${cves} | ${advisoryLinks} |`);
89
+ }
90
+ lines.push('');
91
+ }
92
+ return lines.join('\n').trimEnd();
93
+ }
94
+ /**
95
+ * Generates a tabular dry-run summary of proposed changes.
96
+ * @param {Array<object>} remediations
97
+ * @returns {string}
98
+ */
99
+ function generateDryRunReport(remediations) {
100
+ const lines = [
101
+ 'Proposed dependency updates:',
102
+ '',
103
+ '| Dependency | Current | Fixed | Severity | Provider |',
104
+ '| --- | --- | --- | --- | --- |',
105
+ ];
106
+ for (const rem of remediations) {
107
+ const depName = rem.groupId
108
+ ? `${rem.groupId}:${rem.artifactId}`
109
+ : rem.artifactId;
110
+ lines.push(`| ${depName} | ${rem.currentVersion} | ${rem.fixedInVersion}`
111
+ + ` | ${rem.severity} | ${rem.provider} |`);
112
+ }
113
+ return lines.join('\n');
114
+ }
115
+ /**
116
+ * Groups remediations by their severity.
117
+ * @param {Array<object>} remediations
118
+ * @returns {Map<string, Array<object>>}
119
+ */
120
+ function groupBySeverity(remediations) {
121
+ const map = new Map();
122
+ for (const severity of SEVERITY_ORDER) {
123
+ map.set(severity, []);
124
+ }
125
+ for (const rem of remediations) {
126
+ const sev = rem.severity || 'UNKNOWN';
127
+ if (!map.has(sev)) {
128
+ map.set(sev, []);
129
+ }
130
+ map.get(sev).push(rem);
131
+ }
132
+ return map;
133
+ }
134
+ /**
135
+ * Formats advisory entries into markdown links or plain text.
136
+ * @param {Array<{id: string, url: string}>} advisories
137
+ * @returns {string}
138
+ */
139
+ function formatAdvisoryLinks(advisories) {
140
+ if (!advisories || advisories.length === 0) {
141
+ return '-';
142
+ }
143
+ return advisories
144
+ .map(adv => adv.url ? `[${adv.id}](${adv.url})` : adv.id)
145
+ .join(', ');
146
+ }
147
+ /**
148
+ * Generates a deterministic deduplication key for a remediation entry.
149
+ * Suitable for checking existing PR titles or branch names.
150
+ *
151
+ * @param {object} remediation - a single remediation entry
152
+ * @returns {string} stable key in the form `groupId:artifactId:newVersion`
153
+ */
154
+ export function generateDeduplicationKey(remediation) {
155
+ const group = remediation.groupId || '';
156
+ const artifact = remediation.artifactId || '';
157
+ const version = remediation.fixedInVersion || '';
158
+ return `${group}:${artifact}:${version}`;
159
+ }
@@ -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: any): CycloneDxSbom;
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
@@ -53,6 +70,13 @@ export default class Sbom {
53
70
  * @return {boolean}
54
71
  */
55
72
  checkIfPackageInsideDependsOnList(component: any, name: string): boolean;
73
+ /**
74
+ * Checks if any entry in the dependsOn list of sourceRef starts with the given purl prefix.
75
+ * @param {PackageURL} sourceRef - The source component to check
76
+ * @param {string} purlPrefix - The purl prefix to match (e.g. "pkg:npm/minimist@")
77
+ * @return {boolean}
78
+ */
79
+ checkDependsOnByPurlPrefix(sourceRef: PackageURL, purlPrefix: string): boolean;
56
80
  /** Removes the root component from the sbom
57
81
  */
58
82
  removeRootComponent(): void;
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
@@ -77,6 +89,15 @@ export default class Sbom {
77
89
  checkIfPackageInsideDependsOnList(component, name) {
78
90
  return this.sbomModel.checkIfPackageInsideDependsOnList(component, name);
79
91
  }
92
+ /**
93
+ * Checks if any entry in the dependsOn list of sourceRef starts with the given purl prefix.
94
+ * @param {PackageURL} sourceRef - The source component to check
95
+ * @param {string} purlPrefix - The purl prefix to match (e.g. "pkg:npm/minimist@")
96
+ * @return {boolean}
97
+ */
98
+ checkDependsOnByPurlPrefix(sourceRef, purlPrefix) {
99
+ return this.sbomModel.checkDependsOnByPurlPrefix(sourceRef, purlPrefix);
100
+ }
80
101
  /** Removes the root component from the sbom
81
102
  */
82
103
  removeRootComponent() {
@@ -61,6 +61,32 @@ export function toPurlFromString(strPurl: any): PackageURL | null;
61
61
  * @param {string} cwd - directory for which to find the root of the git repository.
62
62
  */
63
63
  export function getGitRootDir(cwd: string): string | undefined;
64
+ /**
65
+ * Normalize a filesystem path, lowercasing on Windows for case-insensitive comparison.
66
+ *
67
+ * @param {string} thePath
68
+ * @returns {string}
69
+ */
70
+ export function normalizePath(thePath: string): string;
71
+ /**
72
+ * Walk up from `startDir` to `repoRoot` looking for an executable wrapper script.
73
+ *
74
+ * @param {string} startDir - Absolute directory to start from
75
+ * @param {string} wrapperName - Wrapper filename (e.g. `mvnw`, `gradlew`)
76
+ * @param {string} [repoRoot] - Stop boundary (defaults to git root or filesystem root)
77
+ * @returns {string | undefined}
78
+ */
79
+ export function traverseForWrapper(startDir: string, wrapperName: string, repoRoot?: string): string | undefined;
80
+ /**
81
+ * Resolve a build-tool binary, preferring a wrapper when configured.
82
+ *
83
+ * @param {string} globalBinary - Global binary name (e.g. `mvn`, `gradle`)
84
+ * @param {string} localWrapper - Wrapper filename (e.g. `mvnw`, `gradlew.bat`)
85
+ * @param {string} startDir - Directory from which to start the wrapper search
86
+ * @param {import('./index.js').Options} [opts={}]
87
+ * @returns {string} Path to the resolved binary
88
+ */
89
+ export function resolveBinary(globalBinary: string, localWrapper: string, startDir: string, opts?: import("./index.js").Options): string;
64
90
  /** this method invokes command string in a process in a synchronous way.
65
91
  * @param {string} bin - the command to be invoked
66
92
  * @param {Array<string>} args - the args to pass to the binary
@@ -74,13 +100,13 @@ export function invokeCommand(bin: string, args: Array<string>, opts?: import("c
74
100
  * @param {import("index.js").Options} opts - The trustify DA options that may contain proxy configuration
75
101
  * @returns {RequestInit} The fetch options with proxy agent if applicable
76
102
  */
77
- export function addProxyAgent(options: RequestInit, opts: import("index.js").Options): RequestInit;
103
+ export function addProxyAgent(options: RequestInit, opts: any): RequestInit;
78
104
  /**
79
105
  * Utility function for fetching vendor tokens
80
106
  * @param {import("index.js").Options} [opts={}] - optional various options to pass along the application
81
107
  * @returns {{}}
82
108
  */
83
- export function getTokenHeaders(opts?: import("index.js").Options): {};
109
+ export function getTokenHeaders(opts?: any): {};
84
110
  export const RegexNotToBeLogged: RegExp;
85
111
  export const TRUSTIFY_DA_TOKEN_HEADER: "trust-da-token";
86
112
  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";
@@ -40,6 +42,28 @@ export function getCustom(key, def = null, opts = {}) {
40
42
  }
41
43
  return key in process.env ? process.env[key] : key in opts && typeof opts[key] === 'string' ? opts[key] : def;
42
44
  }
45
+ /**
46
+ * Validates that an executable path does not use directory traversal or relative segments.
47
+ * @param {string} binPath - The executable path to validate.
48
+ * @returns {string} The validated path.
49
+ * @throws {Error} If the path contains '..' segments or is a relative path with separators.
50
+ */
51
+ function validateExecutablePath(binPath) {
52
+ if (typeof binPath !== 'string' || binPath.length === 0) {
53
+ throw new Error('Executable path rejected: expected a non-empty string');
54
+ }
55
+ if (binPath.startsWith('./') || binPath.startsWith('.\\')) {
56
+ throw new Error(`Executable path rejected: relative paths starting with './' are not allowed: ${binPath}`);
57
+ }
58
+ const segments = binPath.split(/[/\\]/);
59
+ if (segments.includes('..')) {
60
+ throw new Error(`Executable path rejected: path contains directory traversal segment (..): ${binPath}`);
61
+ }
62
+ if ((binPath.includes('/') || binPath.includes('\\')) && !path.isAbsolute(binPath)) {
63
+ throw new Error(`Executable path rejected: relative paths are not allowed, use an absolute path or a bare command name: ${binPath}`);
64
+ }
65
+ return binPath;
66
+ }
43
67
  /**
44
68
  * Utility function for looking up custom variable for a binary path.
45
69
  * Will look in the environment variables (1) or in opts (2) for a key with TRUSTIFY_DA_x_PATH, x is an
@@ -51,7 +75,8 @@ export function getCustom(key, def = null, opts = {}) {
51
75
  * original name supplied
52
76
  */
53
77
  export function getCustomPath(name, opts = {}) {
54
- return getCustom(`TRUSTIFY_DA_${name.toUpperCase()}_PATH`, name, opts);
78
+ const resolvedPath = getCustom(`TRUSTIFY_DA_${name.toUpperCase()}_PATH`, name, opts);
79
+ return validateExecutablePath(resolvedPath);
55
80
  }
56
81
  /**
57
82
  * Utility function for determining whether wrappers for build tools such as gradlew/mvnw should be
@@ -128,6 +153,62 @@ export function getGitRootDir(cwd) {
128
153
  return undefined;
129
154
  }
130
155
  }
156
+ /**
157
+ * Normalize a filesystem path, lowercasing on Windows for case-insensitive comparison.
158
+ *
159
+ * @param {string} thePath
160
+ * @returns {string}
161
+ */
162
+ export function normalizePath(thePath) {
163
+ const normalized = path.resolve(thePath).normalize();
164
+ return process.platform === 'win32' ? normalized.toLowerCase() : normalized;
165
+ }
166
+ /**
167
+ * Walk up from `startDir` to `repoRoot` looking for an executable wrapper script.
168
+ *
169
+ * @param {string} startDir - Absolute directory to start from
170
+ * @param {string} wrapperName - Wrapper filename (e.g. `mvnw`, `gradlew`)
171
+ * @param {string} [repoRoot] - Stop boundary (defaults to git root or filesystem root)
172
+ * @returns {string | undefined}
173
+ */
174
+ export function traverseForWrapper(startDir, wrapperName, repoRoot = undefined) {
175
+ const currentDir = normalizePath(startDir);
176
+ repoRoot = repoRoot || getGitRootDir(currentDir) || path.parse(currentDir).root;
177
+ const wrapperPath = path.join(currentDir, wrapperName);
178
+ try {
179
+ fs.accessSync(wrapperPath, fs.constants.X_OK);
180
+ return wrapperPath;
181
+ }
182
+ catch {
183
+ const rootDir = path.parse(currentDir).root;
184
+ if (currentDir === repoRoot || currentDir === rootDir) {
185
+ return undefined;
186
+ }
187
+ const parentDir = path.dirname(currentDir);
188
+ if (parentDir === currentDir || parentDir === rootDir) {
189
+ return undefined;
190
+ }
191
+ return traverseForWrapper(parentDir, wrapperName, repoRoot);
192
+ }
193
+ }
194
+ /**
195
+ * Resolve a build-tool binary, preferring a wrapper when configured.
196
+ *
197
+ * @param {string} globalBinary - Global binary name (e.g. `mvn`, `gradle`)
198
+ * @param {string} localWrapper - Wrapper filename (e.g. `mvnw`, `gradlew.bat`)
199
+ * @param {string} startDir - Directory from which to start the wrapper search
200
+ * @param {import('./index.js').Options} [opts={}]
201
+ * @returns {string} Path to the resolved binary
202
+ */
203
+ export function resolveBinary(globalBinary, localWrapper, startDir, opts = {}) {
204
+ if (getWrapperPreference(globalBinary, opts)) {
205
+ const wrapper = traverseForWrapper(startDir, localWrapper);
206
+ if (wrapper !== undefined) {
207
+ return wrapper;
208
+ }
209
+ }
210
+ return getCustomPath(globalBinary, opts);
211
+ }
131
212
  /** this method invokes command string in a process in a synchronous way.
132
213
  * @param {string} bin - the command to be invoked
133
214
  * @param {Array<string>} args - the args to pass to the binary
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Updates dependency versions in a Maven pom.xml while preserving file formatting.
3
+ *
4
+ * Uses `fast-xml-parser` to understand the XML structure (dependencies and properties),
5
+ * then performs position-based string splice to replace version strings without altering
6
+ * any other formatting, comments, whitespace, or indentation.
7
+ *
8
+ * Supports `${property}` indirection: when a dependency's `<version>` is a property
9
+ * reference, the updater resolves the property chain (including recursive references)
10
+ * and updates the terminal property value in `<properties>` instead.
11
+ *
12
+ * @param {string} pomContent - the raw pom.xml file content
13
+ * @param {Array<{groupId: string, artifactId: string, newVersion: string}>} versionChanges -
14
+ * list of version changes to apply
15
+ * @returns {{content: string, applied: Array, skipped: Array}} the updated content and
16
+ * lists of applied and skipped changes
17
+ */
18
+ export function updateMavenVersions(pomContent: string, versionChanges: Array<{
19
+ groupId: string;
20
+ artifactId: string;
21
+ newVersion: string;
22
+ }>): {
23
+ content: string;
24
+ applied: any[];
25
+ skipped: any[];
26
+ };