From e957998bd96931b88a09b0b22577a26d27e14bc2 Mon Sep 17 00:00:00 2001 From: Kurt von Laven Date: Sat, 22 Oct 2022 10:40:06 -0700 Subject: [PATCH] Don't add literal double quote characters to filenames (#1984) * Remove unnecessary spawnSync options. The detached option defaults to false, and the cwd option defaults to the current working directory, so there is no need to specify them. * Don't retrieve spawnRes properties individually. This isn't necessary and gives the misleading impression that stdout and stderr may contain something. They cannot since the Docker image is run with stdio: "inherit", meaning the stdio and stderr streams are passed through to/from the mega-linter-runner process and hence aren't captured. * Don't add literal " character to filenames (#1942) The extra quotes caused MegaLinter to fail to find the first and last files in the list on non-Windows platforms, because the first has a literal double quote character prepended to it, and the last has one appended to it. Stop passing Windows arguments verbatim to eliminate the need for the quotes on Windows. Co-authored-by: nvuillam --- CHANGELOG.md | 1 + mega-linter-runner/lib/runner.js | 11 ++--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0329df28083..20e99dca264 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-linter.yml file, or with `oxsecurity/megalinter:beta` docker image - New [cupcake flavor](https://oxsecurity.github.io/megalinter/beta/flavors/cupcake/#readme) with 78 instead of 108 linters +- Don't add literal double quote character to filenames in mega-linter-runner ([#1942](https://github.com/oxsecurity/megalinter/issues/1942)). - Remove default npm-groovy-lint extra arguments ([#1872](https://github.com/oxsecurity/megalinter/issues/1872)) - Linter versions upgrades diff --git a/mega-linter-runner/lib/runner.js b/mega-linter-runner/lib/runner.js index 3654bb56663..79a8da5c369 100644 --- a/mega-linter-runner/lib/runner.js +++ b/mega-linter-runner/lib/runner.js @@ -151,7 +151,7 @@ ERROR: Docker engine has not been found on your system. if ((options._ || []).length > 0) { commandArgs.push( ...["-e"], - `MEGALINTER_FILES_TO_LINT="${options._.join(",")}"` + `MEGALINTER_FILES_TO_LINT=${options._.join(",")}` ); } commandArgs.push(dockerImage); @@ -159,12 +159,9 @@ ERROR: Docker engine has not been found on your system. // Call docker run console.log(`Command: docker ${commandArgs.join(" ")}`); const spawnOptions = { - detached: false, - cwd: process.cwd(), env: Object.assign({}, process.env), stdio: "inherit", windowsHide: true, - windowsVerbatimArguments: true, }; const spawnRes = spawnSync("docker", commandArgs, spawnOptions); // Output json if requested @@ -179,11 +176,7 @@ ERROR: Docker engine has not been found on your system. console.log(JSON.stringify(JSON.parse(jsonRaw))); } } - return { - status: spawnRes.status, - stdout: spawnRes.stdout, - stderr: spawnRes.stderr, - }; + return spawnRes; } isv4(release) {