Ensure unqualified program names are present on PATH before executing them.

This commit is contained in:
Chris Gavin 2020-11-18 21:14:45 +00:00
parent dc80b016b6
commit 726cfc8441
No known key found for this signature in database
GPG key ID: 07F950B80C27E4DA
25 changed files with 228 additions and 47 deletions

9
lib/init.js generated
View file

@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const toolrunnner = __importStar(require("@actions/exec/lib/toolrunner"));
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
const analysisPaths = __importStar(require("./analysis-paths"));
const codeql_1 = require("./codeql");
const configUtils = __importStar(require("./config-utils"));
@ -116,7 +117,7 @@ async function injectWindowsTracer(processName, processLevel, config, codeql, tr
}
const injectTracerPath = path.join(config.tempDir, "inject-tracer.ps1");
fs.writeFileSync(injectTracerPath, script);
await new toolrunnner.ToolRunner("powershell", [
await new toolrunnner.ToolRunner(await safeWhich.safeWhich("powershell"), [
"-ExecutionPolicy",
"Bypass",
"-file",
@ -132,9 +133,7 @@ async function installPythonDeps(codeql, logger) {
if (process.env["ImageOS"] !== undefined) {
try {
if (process.platform === "win32") {
await new toolrunnner.ToolRunner("powershell", [
path.join(scriptsFolder, "install_tools.ps1"),
]).exec();
await new toolrunnner.ToolRunner(await safeWhich.safeWhich("powershell"), [path.join(scriptsFolder, "install_tools.ps1")]).exec();
}
else {
await new toolrunnner.ToolRunner(path.join(scriptsFolder, "install_tools.sh")).exec();
@ -152,7 +151,7 @@ async function installPythonDeps(codeql, logger) {
try {
const script = "auto_install_packages.py";
if (process.platform === "win32") {
await new toolrunnner.ToolRunner("py", [
await new toolrunnner.ToolRunner(await safeWhich.safeWhich("py"), [
"-3",
path.join(scriptsFolder, script),
path.dirname(codeql.getPath()),