mirror of
https://github.com/actions/setup-java.git
synced 2026-09-09 20:24:21 +02:00
Fix import-safe checks when scripts are run from a path with symlinks (#1265)
* Fix import-safe checks when scripts are run from a path with symlinks In v6, setup-java was made "import-safe" to facilitate testing. This prevents setup-java & cleanup-java from doing anything when their sources get imported. This works fine in the general case, but actually invoking the script (`node setup-java/index.js`) when the path to the script contains symlinks led to the script incorrectly believing it was imported, and refuse to actually run. To fix this, we pass `process.argv[1]` through `fs.realpathSync`, which resolves symlinks in the path. Fixes #1264 * Preserve import safety when resolving symlink entrypoints Share entrypoint detection between setup and cleanup, handle non-file entrypoints safely, and normalize both paths for preserved symlinks. Add real-process regression coverage and rebuild action bundles. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 831c32f2-a275-45bd-a92b-c387372a1554 * Update js-yaml to fix merge-source denial of service Bump the transitive development dependency from 3.15.1 to 3.15.2 to address GHSA-2883-xcg3-v3hh without changing dependency ranges or CI checks. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 831c32f2-a275-45bd-a92b-c387372a1554 --------- Co-authored-by: Bruno Borges <brborges@microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 831c32f2-a275-45bd-a92b-c387372a1554
This commit is contained in:
co-authored by
Copilot App
Bruno Borges
parent
0781fc6af3
commit
134912a529
Vendored
+26
-1
@@ -36354,6 +36354,30 @@ function configureProblemMatcher(matcherPath) {
|
||||
|
||||
// EXTERNAL MODULE: ./src/toolchain-ids.ts
|
||||
var toolchain_ids = __nccwpck_require__(7083);
|
||||
;// CONCATENATED MODULE: ./src/is-main-module.ts
|
||||
|
||||
|
||||
function isMainModule(moduleUrl) {
|
||||
const entrypoint = process.argv[1];
|
||||
if (!entrypoint || entrypoint === '-') {
|
||||
return false;
|
||||
}
|
||||
let entrypointPath;
|
||||
try {
|
||||
entrypointPath = external_fs_default().realpathSync(entrypoint);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error &&
|
||||
'code' in error &&
|
||||
(error.code === 'ENOENT' || error.code === 'ENOTDIR')) {
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
// Resolve both paths for runtimes using --preserve-symlinks-main.
|
||||
return entrypointPath === external_fs_default().realpathSync((0,external_url_.fileURLToPath)(moduleUrl));
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./src/setup-java.ts
|
||||
|
||||
|
||||
@@ -36364,6 +36388,7 @@ var toolchain_ids = __nccwpck_require__(7083);
|
||||
|
||||
|
||||
|
||||
|
||||
async function run() {
|
||||
const versions = setup_java_core/* getMultilineInput */.q3(constants/* INPUT_JAVA_VERSION */.QM);
|
||||
let distributionName = setup_java_core/* getInput */.V4(constants/* INPUT_DISTRIBUTION */.g_);
|
||||
@@ -36480,7 +36505,7 @@ async function validateCacheInput(cache) {
|
||||
function settle(promise) {
|
||||
return promise.then(value => ({ status: 'fulfilled', value }), reason => ({ status: 'rejected', reason }));
|
||||
}
|
||||
if (process.argv[1] === (0,external_url_.fileURLToPath)(import.meta.url)) {
|
||||
if (isMainModule(import.meta.url)) {
|
||||
run();
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user