From 01bb2f089122027aea11c56abd3982ba32efe02f Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 29 Aug 2025 18:55:51 +0000 Subject: [PATCH 1/3] [utils.ts] replace exec with execFile --- src/lib/util/utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/util/utils.ts b/src/lib/util/utils.ts index 96fddd8a..ec613d05 100644 --- a/src/lib/util/utils.ts +++ b/src/lib/util/utils.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -import { execSync } from "child_process" +import { execFileSync } from "child_process" import * as fs from "fs" import * as YAML from "js-yaml" import * as jsonPointer from "json-pointer" @@ -421,8 +421,8 @@ export function gitClone(url: string, directory: string) { } try { - const cmd = `git clone ${url} ${directory}` - execSync(cmd, { encoding: "utf8" }) + const [file, args] = ["git", ["clone", url, directory]] + execFileSync(file, args, { encoding: "utf8" }) } catch (err) { throw new Error(`An error occurred while cloning git repository: ${util.inspect(err, { depth: null })}.`) } From 4829f58d214657baad59bb2077365bf49ecff431 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 29 Aug 2025 19:10:17 +0000 Subject: [PATCH 2/3] [openApiDiff.ts] Use execFile for dotnet --- src/lib/validators/openApiDiff.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/validators/openApiDiff.ts b/src/lib/validators/openApiDiff.ts index 24197078..94b7cb4d 100644 --- a/src/lib/validators/openApiDiff.ts +++ b/src/lib/validators/openApiDiff.ts @@ -18,7 +18,7 @@ import { ResolveSwagger } from "../util/resolveSwagger" import { pathToJsonPointer } from "../util/utils" const _ = require("lodash") -const exec = util.promisify(child_process.exec) +const execFile = util.promisify(child_process.execFile) export type Options = { readonly consoleLogLevel?: unknown @@ -319,10 +319,10 @@ export class OpenApiDiff { throw new Error(`File "${newSwagger}" not found.`) } - const cmd = `${this.dotNetPath()} ${this.openApiDiffDllPath()} -o ${oldSwagger} -n ${newSwagger}` + const [file, args] = [this.dotNetPath(), [this.openApiDiffDllPath(), "-o", oldSwagger, "-n", newSwagger]]; - log.debug(`Executing: "${cmd}"`) - const { stdout } = await exec(cmd, { encoding: "utf8", maxBuffer: 1024 * 1024 * 64 }) + log.debug(`Executing: "${file} ${args.join(' ')}"`) + const { stdout } = await execFile(file, args, { encoding: "utf8", maxBuffer: 1024 * 1024 * 64 }) const resultJson = JSON.parse(stdout) as Messages const updatedJson = resultJson.map(message => ({ From b17108dbb5e6948c886076e97dd40d71648f5140 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 29 Aug 2025 21:41:27 +0000 Subject: [PATCH 3/3] Revert "[openApiDiff.ts] Use execFile for dotnet" This reverts commit 4829f58d214657baad59bb2077365bf49ecff431. --- src/lib/validators/openApiDiff.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/validators/openApiDiff.ts b/src/lib/validators/openApiDiff.ts index 94b7cb4d..24197078 100644 --- a/src/lib/validators/openApiDiff.ts +++ b/src/lib/validators/openApiDiff.ts @@ -18,7 +18,7 @@ import { ResolveSwagger } from "../util/resolveSwagger" import { pathToJsonPointer } from "../util/utils" const _ = require("lodash") -const execFile = util.promisify(child_process.execFile) +const exec = util.promisify(child_process.exec) export type Options = { readonly consoleLogLevel?: unknown @@ -319,10 +319,10 @@ export class OpenApiDiff { throw new Error(`File "${newSwagger}" not found.`) } - const [file, args] = [this.dotNetPath(), [this.openApiDiffDllPath(), "-o", oldSwagger, "-n", newSwagger]]; + const cmd = `${this.dotNetPath()} ${this.openApiDiffDllPath()} -o ${oldSwagger} -n ${newSwagger}` - log.debug(`Executing: "${file} ${args.join(' ')}"`) - const { stdout } = await execFile(file, args, { encoding: "utf8", maxBuffer: 1024 * 1024 * 64 }) + log.debug(`Executing: "${cmd}"`) + const { stdout } = await exec(cmd, { encoding: "utf8", maxBuffer: 1024 * 1024 * 64 }) const resultJson = JSON.parse(stdout) as Messages const updatedJson = resultJson.map(message => ({