snyk 1.1058.0 → 1.1059.0

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.
@@ -137531,6 +137531,138 @@ module.exports = typeof setImmediate === 'function' ? setImmediate :
137531
137531
  };
137532
137532
 
137533
137533
 
137534
+ /***/ }),
137535
+
137536
+ /***/ 53267:
137537
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
137538
+
137539
+ const isWindows = process.platform === 'win32' ||
137540
+ process.env.OSTYPE === 'cygwin' ||
137541
+ process.env.OSTYPE === 'msys'
137542
+
137543
+ const path = __webpack_require__(85622)
137544
+ const COLON = isWindows ? ';' : ':'
137545
+ const isexe = __webpack_require__(31959)
137546
+
137547
+ const getNotFoundError = (cmd) =>
137548
+ Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })
137549
+
137550
+ const getPathInfo = (cmd, opt) => {
137551
+ const colon = opt.colon || COLON
137552
+
137553
+ // If it has a slash, then we don't bother searching the pathenv.
137554
+ // just check the file itself, and that's it.
137555
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
137556
+ : (
137557
+ [
137558
+ // windows always checks the cwd first
137559
+ ...(isWindows ? [process.cwd()] : []),
137560
+ ...(opt.path || process.env.PATH ||
137561
+ /* istanbul ignore next: very unusual */ '').split(colon),
137562
+ ]
137563
+ )
137564
+ const pathExtExe = isWindows
137565
+ ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
137566
+ : ''
137567
+ const pathExt = isWindows ? pathExtExe.split(colon) : ['']
137568
+
137569
+ if (isWindows) {
137570
+ if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
137571
+ pathExt.unshift('')
137572
+ }
137573
+
137574
+ return {
137575
+ pathEnv,
137576
+ pathExt,
137577
+ pathExtExe,
137578
+ }
137579
+ }
137580
+
137581
+ const which = (cmd, opt, cb) => {
137582
+ if (typeof opt === 'function') {
137583
+ cb = opt
137584
+ opt = {}
137585
+ }
137586
+ if (!opt)
137587
+ opt = {}
137588
+
137589
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
137590
+ const found = []
137591
+
137592
+ const step = i => new Promise((resolve, reject) => {
137593
+ if (i === pathEnv.length)
137594
+ return opt.all && found.length ? resolve(found)
137595
+ : reject(getNotFoundError(cmd))
137596
+
137597
+ const ppRaw = pathEnv[i]
137598
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
137599
+
137600
+ const pCmd = path.join(pathPart, cmd)
137601
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
137602
+ : pCmd
137603
+
137604
+ resolve(subStep(p, i, 0))
137605
+ })
137606
+
137607
+ const subStep = (p, i, ii) => new Promise((resolve, reject) => {
137608
+ if (ii === pathExt.length)
137609
+ return resolve(step(i + 1))
137610
+ const ext = pathExt[ii]
137611
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
137612
+ if (!er && is) {
137613
+ if (opt.all)
137614
+ found.push(p + ext)
137615
+ else
137616
+ return resolve(p + ext)
137617
+ }
137618
+ return resolve(subStep(p, i, ii + 1))
137619
+ })
137620
+ })
137621
+
137622
+ return cb ? step(0).then(res => cb(null, res), cb) : step(0)
137623
+ }
137624
+
137625
+ const whichSync = (cmd, opt) => {
137626
+ opt = opt || {}
137627
+
137628
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
137629
+ const found = []
137630
+
137631
+ for (let i = 0; i < pathEnv.length; i ++) {
137632
+ const ppRaw = pathEnv[i]
137633
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
137634
+
137635
+ const pCmd = path.join(pathPart, cmd)
137636
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
137637
+ : pCmd
137638
+
137639
+ for (let j = 0; j < pathExt.length; j ++) {
137640
+ const cur = p + pathExt[j]
137641
+ try {
137642
+ const is = isexe.sync(cur, { pathExt: pathExtExe })
137643
+ if (is) {
137644
+ if (opt.all)
137645
+ found.push(cur)
137646
+ else
137647
+ return cur
137648
+ }
137649
+ } catch (ex) {}
137650
+ }
137651
+ }
137652
+
137653
+ if (opt.all && found.length)
137654
+ return found
137655
+
137656
+ if (opt.nothrow)
137657
+ return null
137658
+
137659
+ throw getNotFoundError(cmd)
137660
+ }
137661
+
137662
+ module.exports = which
137663
+ which.sync = whichSync
137664
+
137665
+
137534
137666
  /***/ }),
137535
137667
 
137536
137668
  /***/ 83859:
@@ -160606,7 +160738,7 @@ exports.findChildren = findChildren;
160606
160738
  "use strict";
160607
160739
 
160608
160740
  Object.defineProperty(exports, "__esModule", ({ value: true }));
160609
- exports.exportsForTests = exports.formatArgWithWhiteSpace = exports.processProjectsInExtractedJSON = exports.inspect = exports.debugLog = void 0;
160741
+ exports.exportsForTests = exports.processProjectsInExtractedJSON = exports.inspect = exports.debugLog = void 0;
160610
160742
  const os = __webpack_require__(12087);
160611
160743
  const fs = __webpack_require__(35747);
160612
160744
  const path = __webpack_require__(85622);
@@ -160634,8 +160766,6 @@ function debugLog(s) {
160634
160766
  logger(s);
160635
160767
  }
160636
160768
  exports.debugLog = debugLog;
160637
- const isWin = /^win/.test(os.platform());
160638
- const quot = isWin ? '"' : "'";
160639
160769
  const cannotResolveVariantMarkers = [
160640
160770
  'Cannot choose between the following',
160641
160771
  'Could not select value from candidates',
@@ -160656,6 +160786,7 @@ async function inspect(root, targetFile, options, snykHttpClient) {
160656
160786
  let subProject = options.subProject;
160657
160787
  if (subProject) {
160658
160788
  subProject = subProject.trim();
160789
+ options.subProject = subProject;
160659
160790
  }
160660
160791
  const plugin = {
160661
160792
  name: 'bundled:gradle',
@@ -161042,13 +161173,6 @@ function getCommand(root, targetFile) {
161042
161173
  }
161043
161174
  return 'gradle';
161044
161175
  }
161045
- function formatArgWithWhiteSpace(arg) {
161046
- if (/\s/.test(arg)) {
161047
- return quot + arg + quot;
161048
- }
161049
- return arg;
161050
- }
161051
- exports.formatArgWithWhiteSpace = formatArgWithWhiteSpace;
161052
161176
  function buildArgs(root, targetFile, initGradlePath, options) {
161053
161177
  const args = [];
161054
161178
  const taskName = options.gradleNormalizeDeps
@@ -161056,22 +161180,22 @@ function buildArgs(root, targetFile, initGradlePath, options) {
161056
161180
  : 'snykResolvedDepsJson';
161057
161181
  args.push(taskName, '-q');
161058
161182
  if (targetFile) {
161059
- if (!fs.existsSync(path.resolve(root, targetFile))) {
161060
- throw new Error('File not found: "' + targetFile + '"');
161183
+ const resolvedTargetFilePath = path.resolve(root, targetFile);
161184
+ if (!fs.existsSync(resolvedTargetFilePath)) {
161185
+ throw new Error('File not found: "' + resolvedTargetFilePath + '"');
161061
161186
  }
161062
161187
  args.push('--build-file');
161063
- const formattedTargetFile = formatArgWithWhiteSpace(targetFile);
161064
- args.push(formattedTargetFile);
161188
+ args.push(resolvedTargetFilePath);
161065
161189
  }
161066
161190
  // Arguments to init script are supplied as properties: https://stackoverflow.com/a/48370451
161067
161191
  if (options['configuration-matching']) {
161068
- args.push(`-Pconfiguration=${quot}${options['configuration-matching']}${quot}`);
161192
+ args.push(`-Pconfiguration=${options['configuration-matching']}`);
161069
161193
  }
161070
161194
  if (options['configuration-attributes']) {
161071
- args.push(`-PconfAttr=${quot}${options['configuration-attributes']}${quot}`);
161195
+ args.push(`-PconfAttr=${options['configuration-attributes']}`);
161072
161196
  }
161073
161197
  if (options.initScript) {
161074
- const formattedInitScript = formatArgWithWhiteSpace(path.resolve(options.initScript));
161198
+ const formattedInitScript = path.resolve(options.initScript);
161075
161199
  args.push('--init-script', formattedInitScript);
161076
161200
  }
161077
161201
  if (!options.daemon) {
@@ -161088,7 +161212,7 @@ function buildArgs(root, targetFile, initGradlePath, options) {
161088
161212
  if (!cli_interface_1.legacyPlugin.isMultiSubProject(options)) {
161089
161213
  args.push('-PonlySubProject=' + (options.subProject || '.'));
161090
161214
  }
161091
- args.push('-I ' + initGradlePath);
161215
+ args.push('-I', initGradlePath);
161092
161216
  if (options.args) {
161093
161217
  args.push(...options.args);
161094
161218
  }
@@ -161097,14 +161221,14 @@ function buildArgs(root, targetFile, initGradlePath, options) {
161097
161221
  // but we are handling it to support the legacy setups.
161098
161222
  args.forEach((a, i) => {
161099
161223
  // Transform --configuration=foo
161100
- args[i] = a.replace(/^--configuration[= ]([a-zA-Z_]+)/, `-Pconfiguration=${quot}^$1$$${quot}`);
161224
+ args[i] = a.replace(/^--configuration[= ]([a-zA-Z_]+)/, `-Pconfiguration=^$1$$`);
161101
161225
  // Transform --configuration foo
161102
161226
  if (a === '--configuration') {
161103
- args[i] = `-Pconfiguration=${quot}^${args[i + 1]}$${quot}`;
161227
+ args[i] = `-Pconfiguration=^${args[i + 1]}$`;
161104
161228
  args[i + 1] = '';
161105
161229
  }
161106
161230
  });
161107
- return args;
161231
+ return args.filter(Boolean);
161108
161232
  }
161109
161233
  exports.exportsForTests = {
161110
161234
  buildArgs,
@@ -161179,6 +161303,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
161179
161303
  exports.execute = void 0;
161180
161304
  const childProcess = __webpack_require__(63129);
161181
161305
  const debugModule = __webpack_require__(15158);
161306
+ const shescape_1 = __webpack_require__(79114);
161182
161307
  const debugLogging = debugModule('snyk-gradle-plugin');
161183
161308
  // Executes a subprocess. Resolves successfully with stdout contents if the exit code is 0.
161184
161309
  function execute(command, args, options, perLineCallback) {
@@ -161186,6 +161311,7 @@ function execute(command, args, options, perLineCallback) {
161186
161311
  if (options && options.cwd) {
161187
161312
  spawnOptions.cwd = options.cwd;
161188
161313
  }
161314
+ args = (0, shescape_1.quoteAll)(args, spawnOptions);
161189
161315
  return new Promise((resolve, reject) => {
161190
161316
  let stdout = '';
161191
161317
  let stderr = '';
@@ -237043,6 +237169,838 @@ function extend() {
237043
237169
  }
237044
237170
 
237045
237171
 
237172
+ /***/ }),
237173
+
237174
+ /***/ 79114:
237175
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
237176
+
237177
+ "use strict";
237178
+
237179
+
237180
+ var os = __webpack_require__(12087);
237181
+ var process = __webpack_require__(61765);
237182
+ var fs = __webpack_require__(35747);
237183
+ var path = __webpack_require__(85622);
237184
+ var which = __webpack_require__(53267);
237185
+
237186
+ function _interopNamespaceDefault(e) {
237187
+ var n = Object.create(null);
237188
+ if (e) {
237189
+ Object.keys(e).forEach(function (k) {
237190
+ if (k !== 'default') {
237191
+ var d = Object.getOwnPropertyDescriptor(e, k);
237192
+ Object.defineProperty(n, k, d.get ? d : {
237193
+ enumerable: true,
237194
+ get: function () { return e[k]; }
237195
+ });
237196
+ }
237197
+ });
237198
+ }
237199
+ n.default = e;
237200
+ return Object.freeze(n);
237201
+ }
237202
+
237203
+ var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
237204
+ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
237205
+
237206
+ /**
237207
+ * @overview Provides functionality related to working with executables.
237208
+ * @license MPL-2.0
237209
+ */
237210
+
237211
+ /**
237212
+ * Resolves the location of an executable given an arbitrary valid string
237213
+ * representation of that executable.
237214
+ *
237215
+ * To obtain the location of the executable this function (if necessary):
237216
+ * - Expands the provided string to a absolute path.
237217
+ * - Follows symbolic links.
237218
+ *
237219
+ * @param {object} args The arguments for this function.
237220
+ * @param {string} args.executable A string representation of the executable.
237221
+ * @param {object} deps The dependencies for this function.
237222
+ * @param {Function} deps.exists A function to check if a file exists.
237223
+ * @param {Function} deps.readlink A function to resolve (sym)links.
237224
+ * @param {Function} deps.which A function to perform a `which(1)`-like lookup.
237225
+ * @returns {string} The full path to the binary of the executable.
237226
+ * @throws {Error} If the `deps` aren't provided.
237227
+ */
237228
+ function resolveExecutable({ executable }, { exists, readlink, which }) {
237229
+ if (readlink === undefined || which === undefined) {
237230
+ throw new Error();
237231
+ }
237232
+
237233
+ try {
237234
+ executable = which(executable);
237235
+ } catch (_) {
237236
+ // For backwards compatibility return the executable even if its location
237237
+ // cannot be obtained
237238
+ return executable;
237239
+ }
237240
+
237241
+ if (!exists(executable)) {
237242
+ // For backwards compatibility return the executable even if there exists no
237243
+ // file at the specified path
237244
+ return executable;
237245
+ }
237246
+
237247
+ try {
237248
+ executable = readlink(executable);
237249
+ } catch (_) {
237250
+ // An error will be thrown if the executable is not a (sym)link, this is not
237251
+ // a problem so the error is ignored
237252
+ }
237253
+
237254
+ return executable;
237255
+ }
237256
+
237257
+ /**
237258
+ * @overview Provides an API to consistently escape or quote shell arguments
237259
+ * across platforms.
237260
+ * @license MPL-2.0
237261
+ */
237262
+
237263
+ /**
237264
+ * The error message for incorrect parameter types.
237265
+ *
237266
+ * @constant
237267
+ * @type {string}
237268
+ */
237269
+ const typeError =
237270
+ "Shescape requires strings or values that can be converted into a string using .toString()";
237271
+
237272
+ /**
237273
+ * The `typeof` value of functions.
237274
+ *
237275
+ * @constant
237276
+ * @type {string}
237277
+ */
237278
+ const typeofFunction = "function";
237279
+
237280
+ /**
237281
+ * The `typeof` value of strings.
237282
+ *
237283
+ * @constant
237284
+ * @type {string}
237285
+ */
237286
+ const typeofString = "string";
237287
+
237288
+ /**
237289
+ * Checks if a value is a string.
237290
+ *
237291
+ * @param {any} value The value of interest.
237292
+ * @returns {boolean} `true` if `value` is a string, `false` otherwise.
237293
+ */
237294
+ function isString(value) {
237295
+ return typeof value === typeofString;
237296
+ }
237297
+
237298
+ /**
237299
+ * Checks if a value can be converted into a string.
237300
+ *
237301
+ * @param {any} value The value of interest.
237302
+ * @returns {boolean} `true` if `value` is stringable, `false` otherwise.
237303
+ */
237304
+ function isStringable(value) {
237305
+ if (value === undefined || value === null) {
237306
+ return false;
237307
+ }
237308
+
237309
+ if (typeof value.toString !== typeofFunction) {
237310
+ return false;
237311
+ }
237312
+
237313
+ const str = value.toString();
237314
+ return isString(str);
237315
+ }
237316
+
237317
+ /**
237318
+ * Merges any number of objects into a single object.
237319
+ *
237320
+ * Note: the values of objects appearing later in the list of arguments take
237321
+ * precedence when merging.
237322
+ *
237323
+ * @param {...object} objects The objects to merge.
237324
+ * @returns {object} The merged object.
237325
+ */
237326
+ function mergeObjects(...objects) {
237327
+ const baseObject = Object.create(null);
237328
+ const mergedObjects = Object.assign(baseObject, ...objects);
237329
+ return mergedObjects;
237330
+ }
237331
+
237332
+ /**
237333
+ * Parses arguments provided to {@link escapeShellArg} or {@link quoteShellArg}.
237334
+ *
237335
+ * @param {object} args The arguments for this function.
237336
+ * @param {string} args.arg The argument to escape.
237337
+ * @param {object} args.options The options for escaping `arg`.
237338
+ * @param {string} [args.options.shell] The shell to escape `arg` for.
237339
+ * @param {boolean} [args.options.interpolation] Is interpolation enabled.
237340
+ * @param {boolean} [args.options.quoted] Is `arg` being quoted.
237341
+ * @param {object} args.process The `process` values.
237342
+ * @param {object} args.process.env The environment variables.
237343
+ * @param {object} deps The dependencies for this function.
237344
+ * @param {Function} deps.getDefaultShell Get the default shell for the system.
237345
+ * @param {Function} deps.getShellName Get the name of a shell.
237346
+ * @returns {object} The parsed arguments.
237347
+ */
237348
+ function parseArgs(
237349
+ { arg, options: { interpolation, quoted, shell }, process: { env } },
237350
+ { getDefaultShell, getShellName }
237351
+ ) {
237352
+ interpolation = interpolation ? true : false;
237353
+ shell = isString(shell) ? shell : getDefaultShell({ env });
237354
+
237355
+ const shellName = getShellName({ shell }, { resolveExecutable });
237356
+ return { arg, interpolation, quoted, shellName };
237357
+ }
237358
+
237359
+ /**
237360
+ * Escapes an argument for the given shell.
237361
+ *
237362
+ * @param {object} args The arguments for this function.
237363
+ * @param {string} args.arg The argument to escape.
237364
+ * @param {boolean} args.interpolation Is interpolation enabled.
237365
+ * @param {boolean} args.quoted Is `arg` being quoted.
237366
+ * @param {string} args.shellName The name of the shell to escape `arg` for.
237367
+ * @param {object} deps The dependencies for this function.
237368
+ * @param {Function} deps.getEscapeFunction Get the escape function for a shell.
237369
+ * @returns {string} The escaped argument.
237370
+ * @throws {TypeError} The argument to escape is not stringable.
237371
+ */
237372
+ function escape$1(
237373
+ { arg, interpolation, quoted, shellName },
237374
+ { getEscapeFunction }
237375
+ ) {
237376
+ if (!isStringable(arg)) {
237377
+ throw new TypeError(typeError);
237378
+ }
237379
+
237380
+ const argAsString = arg.toString();
237381
+ const escape = getEscapeFunction(shellName);
237382
+ const escapedArg = escape(argAsString, interpolation, quoted);
237383
+ return escapedArg;
237384
+ }
237385
+
237386
+ /**
237387
+ * Quotes and escape an argument for the given shell.
237388
+ *
237389
+ * @param {object} args The arguments for this function.
237390
+ * @param {string} args.arg The argument to escape.
237391
+ * @param {string} args.shellName The name of the shell to escape `arg` for.
237392
+ * @param {object} deps The dependencies for this function.
237393
+ * @param {Function} deps.getEscapeFunction Get the escape function for a shell.
237394
+ * @param {Function} deps.getQuoteFunction Get the quote function for a shell.
237395
+ * @returns {string} The quoted and escaped argument.
237396
+ * @throws {TypeError} The argument to escape is not stringable.
237397
+ */
237398
+ function quote$1({ arg, shellName }, { getEscapeFunction, getQuoteFunction }) {
237399
+ const escapedArg = escape$1(
237400
+ { arg, interpolation: false, quoted: true, shellName },
237401
+ { getEscapeFunction }
237402
+ );
237403
+ const quote = getQuoteFunction(shellName);
237404
+ const escapedAndQuotedArg = quote(escapedArg);
237405
+ return escapedAndQuotedArg;
237406
+ }
237407
+
237408
+ /**
237409
+ * Escapes an argument for the given shell.
237410
+ *
237411
+ * @param {object} args The arguments for this function.
237412
+ * @param {string} args.arg The argument to escape.
237413
+ * @param {object} args.options The options for escaping `arg`.
237414
+ * @param {object} args.process The `process` values.
237415
+ * @param {object} deps The dependencies for this function.
237416
+ * @param {Function} deps.getDefaultShell Get the default shell for the system.
237417
+ * @param {Function} deps.getEscapeFunction Get an escape function for a shell.
237418
+ * @param {Function} deps.getShellName Get the name of a shell.
237419
+ * @returns {string} The escaped argument.
237420
+ */
237421
+ function escapeShellArg({ arg, options, process }, deps) {
237422
+ options = mergeObjects(options, { quoted: false });
237423
+ const escapeArgs = parseArgs({ arg, options, process }, deps);
237424
+ return escape$1(escapeArgs, deps);
237425
+ }
237426
+
237427
+ /**
237428
+ * Quotes and escape an argument for the given shell.
237429
+ *
237430
+ * @param {object} args The arguments for this function.
237431
+ * @param {string} args.arg The argument to escape.
237432
+ * @param {object} args.options The options for escaping `arg`.
237433
+ * @param {string} [args.options.shell] The shell to escape `arg` for.
237434
+ * @param {object} args.process The `process` values.
237435
+ * @param {object} args.process.env The environment variables.
237436
+ * @param {object} deps The dependencies for this function.
237437
+ * @param {Function} deps.getDefaultShell Get the default shell for the system.
237438
+ * @param {Function} deps.getEscapeFunction Get an escape function for a shell.
237439
+ * @param {Function} deps.getQuoteFunction Get a quote function for a shell.
237440
+ * @param {Function} deps.getShellName Get the name of a shell.
237441
+ * @returns {string} The quoted and escaped argument.
237442
+ */
237443
+ function quoteShellArg(args, deps) {
237444
+ const quoteArgs = parseArgs(args, deps);
237445
+ return quote$1(quoteArgs, deps);
237446
+ }
237447
+
237448
+ /**
237449
+ * @overview Provides functionality specifically for Unix systems.
237450
+ * @license MPL-2.0
237451
+ */
237452
+
237453
+ /**
237454
+ * The name of the Bourne-again shell (Bash) binary.
237455
+ *
237456
+ * @constant
237457
+ * @type {string}
237458
+ */
237459
+ const binBash = "bash";
237460
+
237461
+ /**
237462
+ * The name of the Debian Almquist shell (Dash) binary.
237463
+ *
237464
+ * @constant
237465
+ * @type {string}
237466
+ */
237467
+ const binDash = "dash";
237468
+
237469
+ /**
237470
+ * The name of the Z shell (Zsh) binary.
237471
+ *
237472
+ * @constant
237473
+ * @type {string}
237474
+ */
237475
+ const binZsh = "zsh";
237476
+
237477
+ /**
237478
+ * Escapes a shell argument for use in Bash(-like shells).
237479
+ *
237480
+ * @param {string} arg The argument to escape.
237481
+ * @param {boolean} interpolation Is interpolation enabled.
237482
+ * @param {boolean} quoted Is `arg` being quoted.
237483
+ * @returns {string} The escaped argument.
237484
+ */
237485
+ function escapeArgBash(arg, interpolation, quoted) {
237486
+ let result = arg.replace(/[\0\u0008\u001B\u009B]/gu, "");
237487
+
237488
+ if (interpolation) {
237489
+ result = result
237490
+ .replace(/\\/gu, "\\\\")
237491
+ .replace(/\n/gu, " ")
237492
+ .replace(/(^|\s)([#~])/gu, "$1\\$2")
237493
+ .replace(/(["$&'()*;<>?`{|])/gu, "\\$1")
237494
+ .replace(/(?<=[:=])(~)(?=[\s+\-/0:=]|$)/gu, "\\$1");
237495
+ } else if (quoted) {
237496
+ result = result.replace(/'/gu, `'\\''`);
237497
+ }
237498
+
237499
+ result = result.replace(/\r(?!\n)/gu, "");
237500
+
237501
+ return result;
237502
+ }
237503
+
237504
+ /**
237505
+ * Escapes a shell argument for use in Dash.
237506
+ *
237507
+ * @param {string} arg The argument to escape.
237508
+ * @param {boolean} interpolation Is interpolation enabled.
237509
+ * @param {boolean} quoted Is `arg` being quoted.
237510
+ * @returns {string} The escaped argument.
237511
+ */
237512
+ function escapeArgDash(arg, interpolation, quoted) {
237513
+ let result = arg.replace(/[\0\u0008\u001B\u009B]/gu, "");
237514
+
237515
+ if (interpolation) {
237516
+ result = result
237517
+ .replace(/\\/gu, "\\\\")
237518
+ .replace(/\n/gu, " ")
237519
+ .replace(/(^|\s)([#~])/gu, "$1\\$2")
237520
+ .replace(/(["$&'()*;<>?`|])/gu, "\\$1");
237521
+ } else if (quoted) {
237522
+ result = result.replace(/'/gu, `'\\''`);
237523
+ }
237524
+
237525
+ result = result.replace(/\r(?!\n)/gu, "");
237526
+
237527
+ return result;
237528
+ }
237529
+
237530
+ /**
237531
+ * Escapes a shell argument for use in Zsh.
237532
+ *
237533
+ * @param {string} arg The argument to escape.
237534
+ * @param {boolean} interpolation Is interpolation enabled.
237535
+ * @param {boolean} quoted Is `arg` being quoted.
237536
+ * @returns {string} The escaped argument.
237537
+ */
237538
+ function escapeArgZsh(arg, interpolation, quoted) {
237539
+ let result = arg.replace(/[\0\u0008\u001B\u009B]/gu, "");
237540
+
237541
+ if (interpolation) {
237542
+ result = result
237543
+ .replace(/\\/gu, "\\\\")
237544
+ .replace(/\n/gu, " ")
237545
+ .replace(/(^|\s)([#=~])/gu, "$1\\$2")
237546
+ .replace(/(["$&'()*;<>?[\]`{|}])/gu, "\\$1");
237547
+ } else if (quoted) {
237548
+ result = result.replace(/'/gu, `'\\''`);
237549
+ }
237550
+
237551
+ result = result.replace(/\r(?!\n)/gu, "");
237552
+
237553
+ return result;
237554
+ }
237555
+
237556
+ /**
237557
+ * Quotes an argument for use in a Unix shell.
237558
+ *
237559
+ * @param {string} arg The argument to quote.
237560
+ * @returns {string} The quoted argument.
237561
+ */
237562
+ function quoteArg$1(arg) {
237563
+ return `'${arg}'`;
237564
+ }
237565
+
237566
+ /**
237567
+ * Returns the basename of a directory or file path on a Unix system.
237568
+ *
237569
+ * @param {string} fullPath A Unix-style directory or file path.
237570
+ * @returns {string} The basename of `fullPath`.
237571
+ */
237572
+ function getBasename$1(fullPath) {
237573
+ return path__namespace.basename(fullPath);
237574
+ }
237575
+
237576
+ /**
237577
+ * Returns the default shell for Unix systems.
237578
+ *
237579
+ * For more information, see `options.shell` in:
237580
+ * https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback.
237581
+ *
237582
+ * @returns {string} The default shell.
237583
+ */
237584
+ function getDefaultShell$1() {
237585
+ return "/bin/sh";
237586
+ }
237587
+
237588
+ /**
237589
+ * Returns a function to escape arguments for use in a particular shell.
237590
+ *
237591
+ * @param {string} shellName The name of a Unix shell.
237592
+ * @returns {Function?} A function to escape arguments for use in the shell.
237593
+ */
237594
+ function getEscapeFunction$1(shellName) {
237595
+ switch (shellName) {
237596
+ case binBash:
237597
+ return escapeArgBash;
237598
+ case binDash:
237599
+ return escapeArgDash;
237600
+ case binZsh:
237601
+ return escapeArgZsh;
237602
+ default:
237603
+ return null;
237604
+ }
237605
+ }
237606
+
237607
+ /**
237608
+ * Returns a function to quote arguments for use in a particular shell.
237609
+ *
237610
+ * @param {string} shellName The name of a Unix shell.
237611
+ * @returns {Function?} A function to quote arguments for use in the shell.
237612
+ */
237613
+ function getQuoteFunction$1(shellName) {
237614
+ switch (shellName) {
237615
+ case binBash:
237616
+ case binDash:
237617
+ case binZsh:
237618
+ return quoteArg$1;
237619
+ default:
237620
+ return null;
237621
+ }
237622
+ }
237623
+
237624
+ /**
237625
+ * Determines the name of the shell identified by a file path or file name.
237626
+ *
237627
+ * @param {object} args The arguments for this function.
237628
+ * @param {string} args.shell The name or path of the shell.
237629
+ * @param {object} deps The dependencies for this function.
237630
+ * @param {Function} deps.resolveExecutable Resolve the path to an executable.
237631
+ * @returns {string} The shell name.
237632
+ */
237633
+ function getShellName$1({ shell }, { resolveExecutable }) {
237634
+ shell = resolveExecutable(
237635
+ { executable: shell },
237636
+ { exists: fs__namespace.existsSync, readlink: fs__namespace.readlinkSync, which: which.sync }
237637
+ );
237638
+
237639
+ const shellName = getBasename$1(shell);
237640
+ if (getEscapeFunction$1(shellName) === null) {
237641
+ return binBash;
237642
+ }
237643
+
237644
+ return shellName;
237645
+ }
237646
+
237647
+ var unix = /*#__PURE__*/Object.freeze({
237648
+ __proto__: null,
237649
+ getDefaultShell: getDefaultShell$1,
237650
+ getEscapeFunction: getEscapeFunction$1,
237651
+ getQuoteFunction: getQuoteFunction$1,
237652
+ getShellName: getShellName$1
237653
+ });
237654
+
237655
+ /**
237656
+ * @overview Provides functionality specifically for Windows systems.
237657
+ * @license MPL-2.0
237658
+ */
237659
+
237660
+ /**
237661
+ * The name of the Windows Command Prompt binary.
237662
+ *
237663
+ * @constant
237664
+ * @type {string}
237665
+ */
237666
+ const binCmd = "cmd.exe";
237667
+
237668
+ /**
237669
+ * The name of the Windows PowerShell binary.
237670
+ *
237671
+ * @constant
237672
+ * @type {string}
237673
+ */
237674
+ const binPowerShell = "powershell.exe";
237675
+
237676
+ /**
237677
+ * Escapes a shell argument for use in Windows Command Prompt.
237678
+ *
237679
+ * @param {string} arg The argument to escape.
237680
+ * @param {boolean} interpolation Is interpolation enabled.
237681
+ * @param {boolean} quoted Is `arg` being quoted.
237682
+ * @returns {string} The escaped argument.
237683
+ */
237684
+ function escapeArgCmd(arg, interpolation, quoted) {
237685
+ let result = arg
237686
+ .replace(/[\0\u0008\u001B\u009B]/gu, "")
237687
+ .replace(/\r?\n|\r/gu, " ");
237688
+
237689
+ if (interpolation) {
237690
+ result = result.replace(/\^/gu, "^^").replace(/(["&<>|])/gu, "^$1");
237691
+ } else if (quoted) {
237692
+ result = result.replace(/"/gu, `""`);
237693
+ }
237694
+
237695
+ return result;
237696
+ }
237697
+
237698
+ /**
237699
+ * Escapes a shell argument for use in Windows PowerShell.
237700
+ *
237701
+ * @param {string} arg The argument to escape.
237702
+ * @param {boolean} interpolation Is interpolation enabled.
237703
+ * @param {boolean} quoted Is `arg` being quoted.
237704
+ * @returns {string} The escaped argument.
237705
+ */
237706
+ function escapeArgPowerShell(arg, interpolation, quoted) {
237707
+ let result = arg
237708
+ .replace(/[\0\u0008\u001B\u009B]/gu, "")
237709
+ .replace(/`/gu, "``")
237710
+ .replace(/\$/gu, "`$$")
237711
+ .replace(/\r(?!\n)/gu, "");
237712
+
237713
+ if (interpolation) {
237714
+ result = result
237715
+ .replace(/\r?\n|\r/gu, " ")
237716
+ .replace(/(^|[\s\u0085])([*1-6]?)(>)/gu, "$1$2`$3")
237717
+ .replace(/(^|[\s\u0085])([#\-:<@\]])/gu, "$1`$2")
237718
+ .replace(/(["&'(),;{|}‘’‚‛“”„])/gu, "`$1");
237719
+ } else if (quoted) {
237720
+ result = result.replace(/(["“”„])/gu, "$1$1");
237721
+ }
237722
+
237723
+ return result;
237724
+ }
237725
+
237726
+ /**
237727
+ * Quotes an argument for use in a Windows shell.
237728
+ *
237729
+ * @param {string} arg The argument to quote.
237730
+ * @returns {string} The quoted argument.
237731
+ */
237732
+ function quoteArg(arg) {
237733
+ return `"${arg}"`;
237734
+ }
237735
+
237736
+ /**
237737
+ * Returns the basename of a directory or file path on a Windows system.
237738
+ *
237739
+ * @param {string} fullPath A Windows-style directory or file path.
237740
+ * @returns {string} The basename of `fullPath`.
237741
+ */
237742
+ function getBasename(fullPath) {
237743
+ return path__namespace.win32.basename(fullPath);
237744
+ }
237745
+
237746
+ /**
237747
+ * Returns the default shell for Windows systems.
237748
+ *
237749
+ * For more information, see:
237750
+ * https://nodejs.org/api/child_process.html#default-windows-shell.
237751
+ *
237752
+ * @param {object} args The arguments for this function.
237753
+ * @param {object} args.env The environment variables.
237754
+ * @param {string} [args.env.ComSpec] The %COMSPEC% value.
237755
+ * @returns {string} The default shell.
237756
+ */
237757
+ function getDefaultShell({ env: { ComSpec } }) {
237758
+ if (ComSpec !== undefined) {
237759
+ return ComSpec;
237760
+ }
237761
+
237762
+ return binCmd;
237763
+ }
237764
+
237765
+ /**
237766
+ * Returns a function to escape arguments for use in a particular shell.
237767
+ *
237768
+ * @param {string} shellName The name of a Windows shell.
237769
+ * @returns {Function?} A function to escape arguments for use in the shell.
237770
+ */
237771
+ function getEscapeFunction(shellName) {
237772
+ switch (shellName) {
237773
+ case binCmd:
237774
+ return escapeArgCmd;
237775
+ case binPowerShell:
237776
+ return escapeArgPowerShell;
237777
+ default:
237778
+ return null;
237779
+ }
237780
+ }
237781
+
237782
+ /**
237783
+ * Returns a function to quote arguments for use in a particular shell.
237784
+ *
237785
+ * @param {string} shellName The name of a Windows shell.
237786
+ * @returns {Function?} A function to quote arguments for use in the shell.
237787
+ */
237788
+ function getQuoteFunction(shellName) {
237789
+ switch (shellName) {
237790
+ case binCmd:
237791
+ case binPowerShell:
237792
+ return quoteArg;
237793
+ default:
237794
+ return null;
237795
+ }
237796
+ }
237797
+
237798
+ /**
237799
+ * Determines the name of the shell identified by a file path or file name.
237800
+ *
237801
+ * @param {object} args The arguments for this function.
237802
+ * @param {string} args.shell The name or path of the shell.
237803
+ * @param {object} deps The dependencies for this function.
237804
+ * @param {Function} deps.resolveExecutable Resolve the path to an executable.
237805
+ * @returns {string} The shell name.
237806
+ */
237807
+ function getShellName({ shell }, { resolveExecutable }) {
237808
+ shell = resolveExecutable(
237809
+ { executable: shell },
237810
+ { exists: fs__namespace.existsSync, readlink: fs__namespace.readlinkSync, which: which.sync }
237811
+ );
237812
+
237813
+ const shellName = getBasename(shell);
237814
+ if (getEscapeFunction(shellName) === null) {
237815
+ return binCmd;
237816
+ }
237817
+
237818
+ return shellName;
237819
+ }
237820
+
237821
+ var win = /*#__PURE__*/Object.freeze({
237822
+ __proto__: null,
237823
+ getDefaultShell: getDefaultShell,
237824
+ getEscapeFunction: getEscapeFunction,
237825
+ getQuoteFunction: getQuoteFunction,
237826
+ getShellName: getShellName
237827
+ });
237828
+
237829
+ /**
237830
+ * @overview Provides functionality related to getting the platform module for
237831
+ * the current system.
237832
+ * @license MPL-2.0
237833
+ */
237834
+
237835
+ /**
237836
+ * The string identifying the OS type Cygwin.
237837
+ *
237838
+ * @constant
237839
+ * @type {string}
237840
+ */
237841
+ const cygwin = "cygwin";
237842
+
237843
+ /**
237844
+ * The string identifying the OS type MSYS.
237845
+ *
237846
+ * @constant
237847
+ * @type {string}
237848
+ */
237849
+ const msys = "msys";
237850
+
237851
+ /**
237852
+ * The string identifying Windows platforms.
237853
+ *
237854
+ * @constant
237855
+ * @type {string}
237856
+ */
237857
+ const win32 = "win32";
237858
+
237859
+ /**
237860
+ * Checks if the current system is a Windows system.
237861
+ *
237862
+ * @param {object} args The arguments for this function.
237863
+ * @param {Object<string, string>} args.env The environment variables.
237864
+ * @param {string} args.platform The `os.platform()` value.
237865
+ * @returns {boolean} `true` if the system is Windows, `false` otherwise.
237866
+ */
237867
+ function isWindow({ env, platform }) {
237868
+ return env.OSTYPE === cygwin || env.OSTYPE === msys || platform === win32;
237869
+ }
237870
+
237871
+ /**
237872
+ * Returns all helper functions for a specific system.
237873
+ *
237874
+ * @param {object} args The arguments for this function.
237875
+ * @param {Object<string, string>} args.env The environment variables.
237876
+ * @param {string} args.platform The `os.platform()` value.
237877
+ * @returns {object} The helper functions for the current system.
237878
+ */
237879
+ function getHelpersByPlatform(args) {
237880
+ if (isWindow(args)) {
237881
+ return win;
237882
+ }
237883
+
237884
+ return unix;
237885
+ }
237886
+
237887
+ /**
237888
+ * A simple shell escape package. Use it to escape user-controlled inputs to
237889
+ * shell commands to prevent shell injection.
237890
+ *
237891
+ * @example
237892
+ * import cp from "child_process";
237893
+ * import * as shescape from "shescape";
237894
+ * cp.spawn("command", shescape.escapeAll(userInput), options);
237895
+ * @overview Entrypoint for the package.
237896
+ * @module shescape
237897
+ * @version 1.6.1
237898
+ * @license MPL-2.0
237899
+ */
237900
+
237901
+ /**
237902
+ * Get the helper functions for the current platform.
237903
+ *
237904
+ * @returns {object} The helper functions for the current platform.
237905
+ */
237906
+ function getPlatformHelpers() {
237907
+ const platform = os.platform();
237908
+ const helpers = getHelpersByPlatform({ env: process.env, platform });
237909
+ return helpers;
237910
+ }
237911
+
237912
+ /**
237913
+ * Converts the provided value into an array if it is not already an array and
237914
+ * returns the array.
237915
+ *
237916
+ * @param {Array | any} x The value to convert to an array if necessary.
237917
+ * @returns {Array} An array containing `x` or `x` itself.
237918
+ */
237919
+ function toArrayIfNecessary(x) {
237920
+ return Array.isArray(x) ? x : [x];
237921
+ }
237922
+
237923
+ /**
237924
+ * Take a single value, the argument, and escape any dangerous characters.
237925
+ *
237926
+ * Non-string inputs will be converted to strings using a `toString()` method.
237927
+ *
237928
+ * @param {string} arg The argument to escape.
237929
+ * @param {object} [options] The escape options.
237930
+ * @param {boolean} [options.interpolation=false] Is interpolation enabled.
237931
+ * @param {boolean | string} [options.shell] The shell to escape for.
237932
+ * @returns {string} The escaped argument.
237933
+ * @throws {TypeError} The argument is not stringable.
237934
+ * @since 0.1.0
237935
+ */
237936
+ function escape(arg, options = {}) {
237937
+ const helpers = getPlatformHelpers();
237938
+ return escapeShellArg({ arg, options, process }, helpers);
237939
+ }
237940
+
237941
+ /**
237942
+ * Take a array of values, the arguments, and escape any dangerous characters in
237943
+ * every argument.
237944
+ *
237945
+ * Non-array inputs will be converted to one-value arrays and non-string values
237946
+ * will be converted to strings using a `toString()` method.
237947
+ *
237948
+ * @param {string[]} args The arguments to escape.
237949
+ * @param {object} [options] The escape options.
237950
+ * @param {boolean} [options.interpolation=false] Is interpolation enabled.
237951
+ * @param {boolean | string} [options.shell] The shell to escape for.
237952
+ * @returns {string[]} The escaped arguments.
237953
+ * @throws {TypeError} One of the arguments is not stringable.
237954
+ * @since 1.1.0
237955
+ */
237956
+ function escapeAll(args, options = {}) {
237957
+ args = toArrayIfNecessary(args);
237958
+ return args.map((arg) => escape(arg, options));
237959
+ }
237960
+
237961
+ /**
237962
+ * Take a single value, the argument, put OS-specific quotes around it and
237963
+ * escape any dangerous characters.
237964
+ *
237965
+ * Non-string inputs will be converted to strings using a `toString()` method.
237966
+ *
237967
+ * @param {string} arg The argument to quote and escape.
237968
+ * @param {object} [options] The escape and quote options.
237969
+ * @param {boolean | string} [options.shell] The shell to escape for.
237970
+ * @returns {string} The quoted and escaped argument.
237971
+ * @throws {TypeError} The argument is not stringable.
237972
+ * @since 0.3.0
237973
+ */
237974
+ function quote(arg, options = {}) {
237975
+ const helpers = getPlatformHelpers();
237976
+ return quoteShellArg({ arg, options, process }, helpers);
237977
+ }
237978
+
237979
+ /**
237980
+ * Take an array of values, the arguments, put OS-specific quotes around every
237981
+ * argument and escape any dangerous characters in every argument.
237982
+ *
237983
+ * Non-array inputs will be converted to one-value arrays and non-string values
237984
+ * will be converted to strings using a `toString()` method.
237985
+ *
237986
+ * @param {string[]} args The arguments to quote and escape.
237987
+ * @param {object} [options] The escape and quote options.
237988
+ * @param {boolean | string} [options.shell] The shell to escape for.
237989
+ * @returns {string[]} The quoted and escaped arguments.
237990
+ * @throws {TypeError} One of the arguments is not stringable.
237991
+ * @since 0.4.0
237992
+ */
237993
+ function quoteAll(args, options = {}) {
237994
+ args = toArrayIfNecessary(args);
237995
+ return args.map((arg) => quote(arg, options));
237996
+ }
237997
+
237998
+ exports.escape = escape;
237999
+ exports.escapeAll = escapeAll;
238000
+ exports.quote = quote;
238001
+ exports.quoteAll = quoteAll;
238002
+
238003
+
237046
238004
  /***/ }),
237047
238005
 
237048
238006
  /***/ 53966: