snyk 1.1058.0 → 1.1060.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:
@@ -142597,9 +142729,8 @@ class GoBinary {
142597
142729
  if (event_loop_spinner_1.eventLoopSpinner.isStarving()) {
142598
142730
  await event_loop_spinner_1.eventLoopSpinner.spin();
142599
142731
  }
142600
- const version = module.snykNormalisedVersion();
142601
- const nodeId = `${pkg}@${version}`;
142602
- goModulesDepGraph.addPkgNode({ name: pkg, version }, nodeId);
142732
+ const nodeId = `${pkg}@${module.version}`;
142733
+ goModulesDepGraph.addPkgNode({ name: pkg, version: module.version }, nodeId);
142603
142734
  goModulesDepGraph.connectDep(goModulesDepGraph.rootNodeId, nodeId);
142604
142735
  }
142605
142736
  }
@@ -142949,16 +143080,6 @@ class GoModule {
142949
143080
  fullName() {
142950
143081
  return this.name + "@" + this.version;
142951
143082
  }
142952
- snykNormalisedVersion() {
142953
- // Versions in Go have leading 'v'
142954
- let version = this.version.substring(1);
142955
- // In versions with hash, we only care about hash
142956
- // v0.0.0-20200905004654-be1d3432aa8f => #be1d3432aa8f
142957
- version = version.includes("-")
142958
- ? `#${version.substring(version.lastIndexOf("-") + 1)}`
142959
- : version;
142960
- return version;
142961
- }
142962
143083
  }
142963
143084
  exports.GoModule = GoModule;
142964
143085
  //# sourceMappingURL=go-module.js.map
@@ -160606,7 +160727,7 @@ exports.findChildren = findChildren;
160606
160727
  "use strict";
160607
160728
 
160608
160729
  Object.defineProperty(exports, "__esModule", ({ value: true }));
160609
- exports.exportsForTests = exports.formatArgWithWhiteSpace = exports.processProjectsInExtractedJSON = exports.inspect = exports.debugLog = void 0;
160730
+ exports.exportsForTests = exports.processProjectsInExtractedJSON = exports.inspect = exports.debugLog = void 0;
160610
160731
  const os = __webpack_require__(12087);
160611
160732
  const fs = __webpack_require__(35747);
160612
160733
  const path = __webpack_require__(85622);
@@ -160634,8 +160755,6 @@ function debugLog(s) {
160634
160755
  logger(s);
160635
160756
  }
160636
160757
  exports.debugLog = debugLog;
160637
- const isWin = /^win/.test(os.platform());
160638
- const quot = isWin ? '"' : "'";
160639
160758
  const cannotResolveVariantMarkers = [
160640
160759
  'Cannot choose between the following',
160641
160760
  'Could not select value from candidates',
@@ -160656,6 +160775,7 @@ async function inspect(root, targetFile, options, snykHttpClient) {
160656
160775
  let subProject = options.subProject;
160657
160776
  if (subProject) {
160658
160777
  subProject = subProject.trim();
160778
+ options.subProject = subProject;
160659
160779
  }
160660
160780
  const plugin = {
160661
160781
  name: 'bundled:gradle',
@@ -161042,13 +161162,6 @@ function getCommand(root, targetFile) {
161042
161162
  }
161043
161163
  return 'gradle';
161044
161164
  }
161045
- function formatArgWithWhiteSpace(arg) {
161046
- if (/\s/.test(arg)) {
161047
- return quot + arg + quot;
161048
- }
161049
- return arg;
161050
- }
161051
- exports.formatArgWithWhiteSpace = formatArgWithWhiteSpace;
161052
161165
  function buildArgs(root, targetFile, initGradlePath, options) {
161053
161166
  const args = [];
161054
161167
  const taskName = options.gradleNormalizeDeps
@@ -161056,22 +161169,22 @@ function buildArgs(root, targetFile, initGradlePath, options) {
161056
161169
  : 'snykResolvedDepsJson';
161057
161170
  args.push(taskName, '-q');
161058
161171
  if (targetFile) {
161059
- if (!fs.existsSync(path.resolve(root, targetFile))) {
161060
- throw new Error('File not found: "' + targetFile + '"');
161172
+ const resolvedTargetFilePath = path.resolve(root, targetFile);
161173
+ if (!fs.existsSync(resolvedTargetFilePath)) {
161174
+ throw new Error('File not found: "' + resolvedTargetFilePath + '"');
161061
161175
  }
161062
161176
  args.push('--build-file');
161063
- const formattedTargetFile = formatArgWithWhiteSpace(targetFile);
161064
- args.push(formattedTargetFile);
161177
+ args.push(resolvedTargetFilePath);
161065
161178
  }
161066
161179
  // Arguments to init script are supplied as properties: https://stackoverflow.com/a/48370451
161067
161180
  if (options['configuration-matching']) {
161068
- args.push(`-Pconfiguration=${quot}${options['configuration-matching']}${quot}`);
161181
+ args.push(`-Pconfiguration=${options['configuration-matching']}`);
161069
161182
  }
161070
161183
  if (options['configuration-attributes']) {
161071
- args.push(`-PconfAttr=${quot}${options['configuration-attributes']}${quot}`);
161184
+ args.push(`-PconfAttr=${options['configuration-attributes']}`);
161072
161185
  }
161073
161186
  if (options.initScript) {
161074
- const formattedInitScript = formatArgWithWhiteSpace(path.resolve(options.initScript));
161187
+ const formattedInitScript = path.resolve(options.initScript);
161075
161188
  args.push('--init-script', formattedInitScript);
161076
161189
  }
161077
161190
  if (!options.daemon) {
@@ -161088,7 +161201,7 @@ function buildArgs(root, targetFile, initGradlePath, options) {
161088
161201
  if (!cli_interface_1.legacyPlugin.isMultiSubProject(options)) {
161089
161202
  args.push('-PonlySubProject=' + (options.subProject || '.'));
161090
161203
  }
161091
- args.push('-I ' + initGradlePath);
161204
+ args.push('-I', initGradlePath);
161092
161205
  if (options.args) {
161093
161206
  args.push(...options.args);
161094
161207
  }
@@ -161097,14 +161210,14 @@ function buildArgs(root, targetFile, initGradlePath, options) {
161097
161210
  // but we are handling it to support the legacy setups.
161098
161211
  args.forEach((a, i) => {
161099
161212
  // Transform --configuration=foo
161100
- args[i] = a.replace(/^--configuration[= ]([a-zA-Z_]+)/, `-Pconfiguration=${quot}^$1$$${quot}`);
161213
+ args[i] = a.replace(/^--configuration[= ]([a-zA-Z_]+)/, `-Pconfiguration=^$1$$`);
161101
161214
  // Transform --configuration foo
161102
161215
  if (a === '--configuration') {
161103
- args[i] = `-Pconfiguration=${quot}^${args[i + 1]}$${quot}`;
161216
+ args[i] = `-Pconfiguration=^${args[i + 1]}$`;
161104
161217
  args[i + 1] = '';
161105
161218
  }
161106
161219
  });
161107
- return args;
161220
+ return args.filter(Boolean);
161108
161221
  }
161109
161222
  exports.exportsForTests = {
161110
161223
  buildArgs,
@@ -161179,6 +161292,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
161179
161292
  exports.execute = void 0;
161180
161293
  const childProcess = __webpack_require__(63129);
161181
161294
  const debugModule = __webpack_require__(15158);
161295
+ const shescape_1 = __webpack_require__(79114);
161182
161296
  const debugLogging = debugModule('snyk-gradle-plugin');
161183
161297
  // Executes a subprocess. Resolves successfully with stdout contents if the exit code is 0.
161184
161298
  function execute(command, args, options, perLineCallback) {
@@ -161186,6 +161300,7 @@ function execute(command, args, options, perLineCallback) {
161186
161300
  if (options && options.cwd) {
161187
161301
  spawnOptions.cwd = options.cwd;
161188
161302
  }
161303
+ args = (0, shescape_1.quoteAll)(args, spawnOptions);
161189
161304
  return new Promise((resolve, reject) => {
161190
161305
  let stdout = '';
161191
161306
  let stderr = '';
@@ -237043,6 +237158,838 @@ function extend() {
237043
237158
  }
237044
237159
 
237045
237160
 
237161
+ /***/ }),
237162
+
237163
+ /***/ 79114:
237164
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
237165
+
237166
+ "use strict";
237167
+
237168
+
237169
+ var os = __webpack_require__(12087);
237170
+ var process = __webpack_require__(61765);
237171
+ var fs = __webpack_require__(35747);
237172
+ var path = __webpack_require__(85622);
237173
+ var which = __webpack_require__(53267);
237174
+
237175
+ function _interopNamespaceDefault(e) {
237176
+ var n = Object.create(null);
237177
+ if (e) {
237178
+ Object.keys(e).forEach(function (k) {
237179
+ if (k !== 'default') {
237180
+ var d = Object.getOwnPropertyDescriptor(e, k);
237181
+ Object.defineProperty(n, k, d.get ? d : {
237182
+ enumerable: true,
237183
+ get: function () { return e[k]; }
237184
+ });
237185
+ }
237186
+ });
237187
+ }
237188
+ n.default = e;
237189
+ return Object.freeze(n);
237190
+ }
237191
+
237192
+ var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
237193
+ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
237194
+
237195
+ /**
237196
+ * @overview Provides functionality related to working with executables.
237197
+ * @license MPL-2.0
237198
+ */
237199
+
237200
+ /**
237201
+ * Resolves the location of an executable given an arbitrary valid string
237202
+ * representation of that executable.
237203
+ *
237204
+ * To obtain the location of the executable this function (if necessary):
237205
+ * - Expands the provided string to a absolute path.
237206
+ * - Follows symbolic links.
237207
+ *
237208
+ * @param {object} args The arguments for this function.
237209
+ * @param {string} args.executable A string representation of the executable.
237210
+ * @param {object} deps The dependencies for this function.
237211
+ * @param {Function} deps.exists A function to check if a file exists.
237212
+ * @param {Function} deps.readlink A function to resolve (sym)links.
237213
+ * @param {Function} deps.which A function to perform a `which(1)`-like lookup.
237214
+ * @returns {string} The full path to the binary of the executable.
237215
+ * @throws {Error} If the `deps` aren't provided.
237216
+ */
237217
+ function resolveExecutable({ executable }, { exists, readlink, which }) {
237218
+ if (readlink === undefined || which === undefined) {
237219
+ throw new Error();
237220
+ }
237221
+
237222
+ try {
237223
+ executable = which(executable);
237224
+ } catch (_) {
237225
+ // For backwards compatibility return the executable even if its location
237226
+ // cannot be obtained
237227
+ return executable;
237228
+ }
237229
+
237230
+ if (!exists(executable)) {
237231
+ // For backwards compatibility return the executable even if there exists no
237232
+ // file at the specified path
237233
+ return executable;
237234
+ }
237235
+
237236
+ try {
237237
+ executable = readlink(executable);
237238
+ } catch (_) {
237239
+ // An error will be thrown if the executable is not a (sym)link, this is not
237240
+ // a problem so the error is ignored
237241
+ }
237242
+
237243
+ return executable;
237244
+ }
237245
+
237246
+ /**
237247
+ * @overview Provides an API to consistently escape or quote shell arguments
237248
+ * across platforms.
237249
+ * @license MPL-2.0
237250
+ */
237251
+
237252
+ /**
237253
+ * The error message for incorrect parameter types.
237254
+ *
237255
+ * @constant
237256
+ * @type {string}
237257
+ */
237258
+ const typeError =
237259
+ "Shescape requires strings or values that can be converted into a string using .toString()";
237260
+
237261
+ /**
237262
+ * The `typeof` value of functions.
237263
+ *
237264
+ * @constant
237265
+ * @type {string}
237266
+ */
237267
+ const typeofFunction = "function";
237268
+
237269
+ /**
237270
+ * The `typeof` value of strings.
237271
+ *
237272
+ * @constant
237273
+ * @type {string}
237274
+ */
237275
+ const typeofString = "string";
237276
+
237277
+ /**
237278
+ * Checks if a value is a string.
237279
+ *
237280
+ * @param {any} value The value of interest.
237281
+ * @returns {boolean} `true` if `value` is a string, `false` otherwise.
237282
+ */
237283
+ function isString(value) {
237284
+ return typeof value === typeofString;
237285
+ }
237286
+
237287
+ /**
237288
+ * Checks if a value can be converted into a string.
237289
+ *
237290
+ * @param {any} value The value of interest.
237291
+ * @returns {boolean} `true` if `value` is stringable, `false` otherwise.
237292
+ */
237293
+ function isStringable(value) {
237294
+ if (value === undefined || value === null) {
237295
+ return false;
237296
+ }
237297
+
237298
+ if (typeof value.toString !== typeofFunction) {
237299
+ return false;
237300
+ }
237301
+
237302
+ const str = value.toString();
237303
+ return isString(str);
237304
+ }
237305
+
237306
+ /**
237307
+ * Merges any number of objects into a single object.
237308
+ *
237309
+ * Note: the values of objects appearing later in the list of arguments take
237310
+ * precedence when merging.
237311
+ *
237312
+ * @param {...object} objects The objects to merge.
237313
+ * @returns {object} The merged object.
237314
+ */
237315
+ function mergeObjects(...objects) {
237316
+ const baseObject = Object.create(null);
237317
+ const mergedObjects = Object.assign(baseObject, ...objects);
237318
+ return mergedObjects;
237319
+ }
237320
+
237321
+ /**
237322
+ * Parses arguments provided to {@link escapeShellArg} or {@link quoteShellArg}.
237323
+ *
237324
+ * @param {object} args The arguments for this function.
237325
+ * @param {string} args.arg The argument to escape.
237326
+ * @param {object} args.options The options for escaping `arg`.
237327
+ * @param {string} [args.options.shell] The shell to escape `arg` for.
237328
+ * @param {boolean} [args.options.interpolation] Is interpolation enabled.
237329
+ * @param {boolean} [args.options.quoted] Is `arg` being quoted.
237330
+ * @param {object} args.process The `process` values.
237331
+ * @param {object} args.process.env The environment variables.
237332
+ * @param {object} deps The dependencies for this function.
237333
+ * @param {Function} deps.getDefaultShell Get the default shell for the system.
237334
+ * @param {Function} deps.getShellName Get the name of a shell.
237335
+ * @returns {object} The parsed arguments.
237336
+ */
237337
+ function parseArgs(
237338
+ { arg, options: { interpolation, quoted, shell }, process: { env } },
237339
+ { getDefaultShell, getShellName }
237340
+ ) {
237341
+ interpolation = interpolation ? true : false;
237342
+ shell = isString(shell) ? shell : getDefaultShell({ env });
237343
+
237344
+ const shellName = getShellName({ shell }, { resolveExecutable });
237345
+ return { arg, interpolation, quoted, shellName };
237346
+ }
237347
+
237348
+ /**
237349
+ * Escapes an argument for the given shell.
237350
+ *
237351
+ * @param {object} args The arguments for this function.
237352
+ * @param {string} args.arg The argument to escape.
237353
+ * @param {boolean} args.interpolation Is interpolation enabled.
237354
+ * @param {boolean} args.quoted Is `arg` being quoted.
237355
+ * @param {string} args.shellName The name of the shell to escape `arg` for.
237356
+ * @param {object} deps The dependencies for this function.
237357
+ * @param {Function} deps.getEscapeFunction Get the escape function for a shell.
237358
+ * @returns {string} The escaped argument.
237359
+ * @throws {TypeError} The argument to escape is not stringable.
237360
+ */
237361
+ function escape$1(
237362
+ { arg, interpolation, quoted, shellName },
237363
+ { getEscapeFunction }
237364
+ ) {
237365
+ if (!isStringable(arg)) {
237366
+ throw new TypeError(typeError);
237367
+ }
237368
+
237369
+ const argAsString = arg.toString();
237370
+ const escape = getEscapeFunction(shellName);
237371
+ const escapedArg = escape(argAsString, interpolation, quoted);
237372
+ return escapedArg;
237373
+ }
237374
+
237375
+ /**
237376
+ * Quotes and escape an argument for the given shell.
237377
+ *
237378
+ * @param {object} args The arguments for this function.
237379
+ * @param {string} args.arg The argument to escape.
237380
+ * @param {string} args.shellName The name of the shell to escape `arg` for.
237381
+ * @param {object} deps The dependencies for this function.
237382
+ * @param {Function} deps.getEscapeFunction Get the escape function for a shell.
237383
+ * @param {Function} deps.getQuoteFunction Get the quote function for a shell.
237384
+ * @returns {string} The quoted and escaped argument.
237385
+ * @throws {TypeError} The argument to escape is not stringable.
237386
+ */
237387
+ function quote$1({ arg, shellName }, { getEscapeFunction, getQuoteFunction }) {
237388
+ const escapedArg = escape$1(
237389
+ { arg, interpolation: false, quoted: true, shellName },
237390
+ { getEscapeFunction }
237391
+ );
237392
+ const quote = getQuoteFunction(shellName);
237393
+ const escapedAndQuotedArg = quote(escapedArg);
237394
+ return escapedAndQuotedArg;
237395
+ }
237396
+
237397
+ /**
237398
+ * Escapes an argument for the given shell.
237399
+ *
237400
+ * @param {object} args The arguments for this function.
237401
+ * @param {string} args.arg The argument to escape.
237402
+ * @param {object} args.options The options for escaping `arg`.
237403
+ * @param {object} args.process The `process` values.
237404
+ * @param {object} deps The dependencies for this function.
237405
+ * @param {Function} deps.getDefaultShell Get the default shell for the system.
237406
+ * @param {Function} deps.getEscapeFunction Get an escape function for a shell.
237407
+ * @param {Function} deps.getShellName Get the name of a shell.
237408
+ * @returns {string} The escaped argument.
237409
+ */
237410
+ function escapeShellArg({ arg, options, process }, deps) {
237411
+ options = mergeObjects(options, { quoted: false });
237412
+ const escapeArgs = parseArgs({ arg, options, process }, deps);
237413
+ return escape$1(escapeArgs, deps);
237414
+ }
237415
+
237416
+ /**
237417
+ * Quotes and escape an argument for the given shell.
237418
+ *
237419
+ * @param {object} args The arguments for this function.
237420
+ * @param {string} args.arg The argument to escape.
237421
+ * @param {object} args.options The options for escaping `arg`.
237422
+ * @param {string} [args.options.shell] The shell to escape `arg` for.
237423
+ * @param {object} args.process The `process` values.
237424
+ * @param {object} args.process.env The environment variables.
237425
+ * @param {object} deps The dependencies for this function.
237426
+ * @param {Function} deps.getDefaultShell Get the default shell for the system.
237427
+ * @param {Function} deps.getEscapeFunction Get an escape function for a shell.
237428
+ * @param {Function} deps.getQuoteFunction Get a quote function for a shell.
237429
+ * @param {Function} deps.getShellName Get the name of a shell.
237430
+ * @returns {string} The quoted and escaped argument.
237431
+ */
237432
+ function quoteShellArg(args, deps) {
237433
+ const quoteArgs = parseArgs(args, deps);
237434
+ return quote$1(quoteArgs, deps);
237435
+ }
237436
+
237437
+ /**
237438
+ * @overview Provides functionality specifically for Unix systems.
237439
+ * @license MPL-2.0
237440
+ */
237441
+
237442
+ /**
237443
+ * The name of the Bourne-again shell (Bash) binary.
237444
+ *
237445
+ * @constant
237446
+ * @type {string}
237447
+ */
237448
+ const binBash = "bash";
237449
+
237450
+ /**
237451
+ * The name of the Debian Almquist shell (Dash) binary.
237452
+ *
237453
+ * @constant
237454
+ * @type {string}
237455
+ */
237456
+ const binDash = "dash";
237457
+
237458
+ /**
237459
+ * The name of the Z shell (Zsh) binary.
237460
+ *
237461
+ * @constant
237462
+ * @type {string}
237463
+ */
237464
+ const binZsh = "zsh";
237465
+
237466
+ /**
237467
+ * Escapes a shell argument for use in Bash(-like shells).
237468
+ *
237469
+ * @param {string} arg The argument to escape.
237470
+ * @param {boolean} interpolation Is interpolation enabled.
237471
+ * @param {boolean} quoted Is `arg` being quoted.
237472
+ * @returns {string} The escaped argument.
237473
+ */
237474
+ function escapeArgBash(arg, interpolation, quoted) {
237475
+ let result = arg.replace(/[\0\u0008\u001B\u009B]/gu, "");
237476
+
237477
+ if (interpolation) {
237478
+ result = result
237479
+ .replace(/\\/gu, "\\\\")
237480
+ .replace(/\n/gu, " ")
237481
+ .replace(/(^|\s)([#~])/gu, "$1\\$2")
237482
+ .replace(/(["$&'()*;<>?`{|])/gu, "\\$1")
237483
+ .replace(/(?<=[:=])(~)(?=[\s+\-/0:=]|$)/gu, "\\$1");
237484
+ } else if (quoted) {
237485
+ result = result.replace(/'/gu, `'\\''`);
237486
+ }
237487
+
237488
+ result = result.replace(/\r(?!\n)/gu, "");
237489
+
237490
+ return result;
237491
+ }
237492
+
237493
+ /**
237494
+ * Escapes a shell argument for use in Dash.
237495
+ *
237496
+ * @param {string} arg The argument to escape.
237497
+ * @param {boolean} interpolation Is interpolation enabled.
237498
+ * @param {boolean} quoted Is `arg` being quoted.
237499
+ * @returns {string} The escaped argument.
237500
+ */
237501
+ function escapeArgDash(arg, interpolation, quoted) {
237502
+ let result = arg.replace(/[\0\u0008\u001B\u009B]/gu, "");
237503
+
237504
+ if (interpolation) {
237505
+ result = result
237506
+ .replace(/\\/gu, "\\\\")
237507
+ .replace(/\n/gu, " ")
237508
+ .replace(/(^|\s)([#~])/gu, "$1\\$2")
237509
+ .replace(/(["$&'()*;<>?`|])/gu, "\\$1");
237510
+ } else if (quoted) {
237511
+ result = result.replace(/'/gu, `'\\''`);
237512
+ }
237513
+
237514
+ result = result.replace(/\r(?!\n)/gu, "");
237515
+
237516
+ return result;
237517
+ }
237518
+
237519
+ /**
237520
+ * Escapes a shell argument for use in Zsh.
237521
+ *
237522
+ * @param {string} arg The argument to escape.
237523
+ * @param {boolean} interpolation Is interpolation enabled.
237524
+ * @param {boolean} quoted Is `arg` being quoted.
237525
+ * @returns {string} The escaped argument.
237526
+ */
237527
+ function escapeArgZsh(arg, interpolation, quoted) {
237528
+ let result = arg.replace(/[\0\u0008\u001B\u009B]/gu, "");
237529
+
237530
+ if (interpolation) {
237531
+ result = result
237532
+ .replace(/\\/gu, "\\\\")
237533
+ .replace(/\n/gu, " ")
237534
+ .replace(/(^|\s)([#=~])/gu, "$1\\$2")
237535
+ .replace(/(["$&'()*;<>?[\]`{|}])/gu, "\\$1");
237536
+ } else if (quoted) {
237537
+ result = result.replace(/'/gu, `'\\''`);
237538
+ }
237539
+
237540
+ result = result.replace(/\r(?!\n)/gu, "");
237541
+
237542
+ return result;
237543
+ }
237544
+
237545
+ /**
237546
+ * Quotes an argument for use in a Unix shell.
237547
+ *
237548
+ * @param {string} arg The argument to quote.
237549
+ * @returns {string} The quoted argument.
237550
+ */
237551
+ function quoteArg$1(arg) {
237552
+ return `'${arg}'`;
237553
+ }
237554
+
237555
+ /**
237556
+ * Returns the basename of a directory or file path on a Unix system.
237557
+ *
237558
+ * @param {string} fullPath A Unix-style directory or file path.
237559
+ * @returns {string} The basename of `fullPath`.
237560
+ */
237561
+ function getBasename$1(fullPath) {
237562
+ return path__namespace.basename(fullPath);
237563
+ }
237564
+
237565
+ /**
237566
+ * Returns the default shell for Unix systems.
237567
+ *
237568
+ * For more information, see `options.shell` in:
237569
+ * https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback.
237570
+ *
237571
+ * @returns {string} The default shell.
237572
+ */
237573
+ function getDefaultShell$1() {
237574
+ return "/bin/sh";
237575
+ }
237576
+
237577
+ /**
237578
+ * Returns a function to escape arguments for use in a particular shell.
237579
+ *
237580
+ * @param {string} shellName The name of a Unix shell.
237581
+ * @returns {Function?} A function to escape arguments for use in the shell.
237582
+ */
237583
+ function getEscapeFunction$1(shellName) {
237584
+ switch (shellName) {
237585
+ case binBash:
237586
+ return escapeArgBash;
237587
+ case binDash:
237588
+ return escapeArgDash;
237589
+ case binZsh:
237590
+ return escapeArgZsh;
237591
+ default:
237592
+ return null;
237593
+ }
237594
+ }
237595
+
237596
+ /**
237597
+ * Returns a function to quote arguments for use in a particular shell.
237598
+ *
237599
+ * @param {string} shellName The name of a Unix shell.
237600
+ * @returns {Function?} A function to quote arguments for use in the shell.
237601
+ */
237602
+ function getQuoteFunction$1(shellName) {
237603
+ switch (shellName) {
237604
+ case binBash:
237605
+ case binDash:
237606
+ case binZsh:
237607
+ return quoteArg$1;
237608
+ default:
237609
+ return null;
237610
+ }
237611
+ }
237612
+
237613
+ /**
237614
+ * Determines the name of the shell identified by a file path or file name.
237615
+ *
237616
+ * @param {object} args The arguments for this function.
237617
+ * @param {string} args.shell The name or path of the shell.
237618
+ * @param {object} deps The dependencies for this function.
237619
+ * @param {Function} deps.resolveExecutable Resolve the path to an executable.
237620
+ * @returns {string} The shell name.
237621
+ */
237622
+ function getShellName$1({ shell }, { resolveExecutable }) {
237623
+ shell = resolveExecutable(
237624
+ { executable: shell },
237625
+ { exists: fs__namespace.existsSync, readlink: fs__namespace.readlinkSync, which: which.sync }
237626
+ );
237627
+
237628
+ const shellName = getBasename$1(shell);
237629
+ if (getEscapeFunction$1(shellName) === null) {
237630
+ return binBash;
237631
+ }
237632
+
237633
+ return shellName;
237634
+ }
237635
+
237636
+ var unix = /*#__PURE__*/Object.freeze({
237637
+ __proto__: null,
237638
+ getDefaultShell: getDefaultShell$1,
237639
+ getEscapeFunction: getEscapeFunction$1,
237640
+ getQuoteFunction: getQuoteFunction$1,
237641
+ getShellName: getShellName$1
237642
+ });
237643
+
237644
+ /**
237645
+ * @overview Provides functionality specifically for Windows systems.
237646
+ * @license MPL-2.0
237647
+ */
237648
+
237649
+ /**
237650
+ * The name of the Windows Command Prompt binary.
237651
+ *
237652
+ * @constant
237653
+ * @type {string}
237654
+ */
237655
+ const binCmd = "cmd.exe";
237656
+
237657
+ /**
237658
+ * The name of the Windows PowerShell binary.
237659
+ *
237660
+ * @constant
237661
+ * @type {string}
237662
+ */
237663
+ const binPowerShell = "powershell.exe";
237664
+
237665
+ /**
237666
+ * Escapes a shell argument for use in Windows Command Prompt.
237667
+ *
237668
+ * @param {string} arg The argument to escape.
237669
+ * @param {boolean} interpolation Is interpolation enabled.
237670
+ * @param {boolean} quoted Is `arg` being quoted.
237671
+ * @returns {string} The escaped argument.
237672
+ */
237673
+ function escapeArgCmd(arg, interpolation, quoted) {
237674
+ let result = arg
237675
+ .replace(/[\0\u0008\u001B\u009B]/gu, "")
237676
+ .replace(/\r?\n|\r/gu, " ");
237677
+
237678
+ if (interpolation) {
237679
+ result = result.replace(/\^/gu, "^^").replace(/(["&<>|])/gu, "^$1");
237680
+ } else if (quoted) {
237681
+ result = result.replace(/"/gu, `""`);
237682
+ }
237683
+
237684
+ return result;
237685
+ }
237686
+
237687
+ /**
237688
+ * Escapes a shell argument for use in Windows PowerShell.
237689
+ *
237690
+ * @param {string} arg The argument to escape.
237691
+ * @param {boolean} interpolation Is interpolation enabled.
237692
+ * @param {boolean} quoted Is `arg` being quoted.
237693
+ * @returns {string} The escaped argument.
237694
+ */
237695
+ function escapeArgPowerShell(arg, interpolation, quoted) {
237696
+ let result = arg
237697
+ .replace(/[\0\u0008\u001B\u009B]/gu, "")
237698
+ .replace(/`/gu, "``")
237699
+ .replace(/\$/gu, "`$$")
237700
+ .replace(/\r(?!\n)/gu, "");
237701
+
237702
+ if (interpolation) {
237703
+ result = result
237704
+ .replace(/\r?\n|\r/gu, " ")
237705
+ .replace(/(^|[\s\u0085])([*1-6]?)(>)/gu, "$1$2`$3")
237706
+ .replace(/(^|[\s\u0085])([#\-:<@\]])/gu, "$1`$2")
237707
+ .replace(/(["&'(),;{|}‘’‚‛“”„])/gu, "`$1");
237708
+ } else if (quoted) {
237709
+ result = result.replace(/(["“”„])/gu, "$1$1");
237710
+ }
237711
+
237712
+ return result;
237713
+ }
237714
+
237715
+ /**
237716
+ * Quotes an argument for use in a Windows shell.
237717
+ *
237718
+ * @param {string} arg The argument to quote.
237719
+ * @returns {string} The quoted argument.
237720
+ */
237721
+ function quoteArg(arg) {
237722
+ return `"${arg}"`;
237723
+ }
237724
+
237725
+ /**
237726
+ * Returns the basename of a directory or file path on a Windows system.
237727
+ *
237728
+ * @param {string} fullPath A Windows-style directory or file path.
237729
+ * @returns {string} The basename of `fullPath`.
237730
+ */
237731
+ function getBasename(fullPath) {
237732
+ return path__namespace.win32.basename(fullPath);
237733
+ }
237734
+
237735
+ /**
237736
+ * Returns the default shell for Windows systems.
237737
+ *
237738
+ * For more information, see:
237739
+ * https://nodejs.org/api/child_process.html#default-windows-shell.
237740
+ *
237741
+ * @param {object} args The arguments for this function.
237742
+ * @param {object} args.env The environment variables.
237743
+ * @param {string} [args.env.ComSpec] The %COMSPEC% value.
237744
+ * @returns {string} The default shell.
237745
+ */
237746
+ function getDefaultShell({ env: { ComSpec } }) {
237747
+ if (ComSpec !== undefined) {
237748
+ return ComSpec;
237749
+ }
237750
+
237751
+ return binCmd;
237752
+ }
237753
+
237754
+ /**
237755
+ * Returns a function to escape arguments for use in a particular shell.
237756
+ *
237757
+ * @param {string} shellName The name of a Windows shell.
237758
+ * @returns {Function?} A function to escape arguments for use in the shell.
237759
+ */
237760
+ function getEscapeFunction(shellName) {
237761
+ switch (shellName) {
237762
+ case binCmd:
237763
+ return escapeArgCmd;
237764
+ case binPowerShell:
237765
+ return escapeArgPowerShell;
237766
+ default:
237767
+ return null;
237768
+ }
237769
+ }
237770
+
237771
+ /**
237772
+ * Returns a function to quote arguments for use in a particular shell.
237773
+ *
237774
+ * @param {string} shellName The name of a Windows shell.
237775
+ * @returns {Function?} A function to quote arguments for use in the shell.
237776
+ */
237777
+ function getQuoteFunction(shellName) {
237778
+ switch (shellName) {
237779
+ case binCmd:
237780
+ case binPowerShell:
237781
+ return quoteArg;
237782
+ default:
237783
+ return null;
237784
+ }
237785
+ }
237786
+
237787
+ /**
237788
+ * Determines the name of the shell identified by a file path or file name.
237789
+ *
237790
+ * @param {object} args The arguments for this function.
237791
+ * @param {string} args.shell The name or path of the shell.
237792
+ * @param {object} deps The dependencies for this function.
237793
+ * @param {Function} deps.resolveExecutable Resolve the path to an executable.
237794
+ * @returns {string} The shell name.
237795
+ */
237796
+ function getShellName({ shell }, { resolveExecutable }) {
237797
+ shell = resolveExecutable(
237798
+ { executable: shell },
237799
+ { exists: fs__namespace.existsSync, readlink: fs__namespace.readlinkSync, which: which.sync }
237800
+ );
237801
+
237802
+ const shellName = getBasename(shell);
237803
+ if (getEscapeFunction(shellName) === null) {
237804
+ return binCmd;
237805
+ }
237806
+
237807
+ return shellName;
237808
+ }
237809
+
237810
+ var win = /*#__PURE__*/Object.freeze({
237811
+ __proto__: null,
237812
+ getDefaultShell: getDefaultShell,
237813
+ getEscapeFunction: getEscapeFunction,
237814
+ getQuoteFunction: getQuoteFunction,
237815
+ getShellName: getShellName
237816
+ });
237817
+
237818
+ /**
237819
+ * @overview Provides functionality related to getting the platform module for
237820
+ * the current system.
237821
+ * @license MPL-2.0
237822
+ */
237823
+
237824
+ /**
237825
+ * The string identifying the OS type Cygwin.
237826
+ *
237827
+ * @constant
237828
+ * @type {string}
237829
+ */
237830
+ const cygwin = "cygwin";
237831
+
237832
+ /**
237833
+ * The string identifying the OS type MSYS.
237834
+ *
237835
+ * @constant
237836
+ * @type {string}
237837
+ */
237838
+ const msys = "msys";
237839
+
237840
+ /**
237841
+ * The string identifying Windows platforms.
237842
+ *
237843
+ * @constant
237844
+ * @type {string}
237845
+ */
237846
+ const win32 = "win32";
237847
+
237848
+ /**
237849
+ * Checks if the current system is a Windows system.
237850
+ *
237851
+ * @param {object} args The arguments for this function.
237852
+ * @param {Object<string, string>} args.env The environment variables.
237853
+ * @param {string} args.platform The `os.platform()` value.
237854
+ * @returns {boolean} `true` if the system is Windows, `false` otherwise.
237855
+ */
237856
+ function isWindow({ env, platform }) {
237857
+ return env.OSTYPE === cygwin || env.OSTYPE === msys || platform === win32;
237858
+ }
237859
+
237860
+ /**
237861
+ * Returns all helper functions for a specific system.
237862
+ *
237863
+ * @param {object} args The arguments for this function.
237864
+ * @param {Object<string, string>} args.env The environment variables.
237865
+ * @param {string} args.platform The `os.platform()` value.
237866
+ * @returns {object} The helper functions for the current system.
237867
+ */
237868
+ function getHelpersByPlatform(args) {
237869
+ if (isWindow(args)) {
237870
+ return win;
237871
+ }
237872
+
237873
+ return unix;
237874
+ }
237875
+
237876
+ /**
237877
+ * A simple shell escape package. Use it to escape user-controlled inputs to
237878
+ * shell commands to prevent shell injection.
237879
+ *
237880
+ * @example
237881
+ * import cp from "child_process";
237882
+ * import * as shescape from "shescape";
237883
+ * cp.spawn("command", shescape.escapeAll(userInput), options);
237884
+ * @overview Entrypoint for the package.
237885
+ * @module shescape
237886
+ * @version 1.6.1
237887
+ * @license MPL-2.0
237888
+ */
237889
+
237890
+ /**
237891
+ * Get the helper functions for the current platform.
237892
+ *
237893
+ * @returns {object} The helper functions for the current platform.
237894
+ */
237895
+ function getPlatformHelpers() {
237896
+ const platform = os.platform();
237897
+ const helpers = getHelpersByPlatform({ env: process.env, platform });
237898
+ return helpers;
237899
+ }
237900
+
237901
+ /**
237902
+ * Converts the provided value into an array if it is not already an array and
237903
+ * returns the array.
237904
+ *
237905
+ * @param {Array | any} x The value to convert to an array if necessary.
237906
+ * @returns {Array} An array containing `x` or `x` itself.
237907
+ */
237908
+ function toArrayIfNecessary(x) {
237909
+ return Array.isArray(x) ? x : [x];
237910
+ }
237911
+
237912
+ /**
237913
+ * Take a single value, the argument, and escape any dangerous characters.
237914
+ *
237915
+ * Non-string inputs will be converted to strings using a `toString()` method.
237916
+ *
237917
+ * @param {string} arg The argument to escape.
237918
+ * @param {object} [options] The escape options.
237919
+ * @param {boolean} [options.interpolation=false] Is interpolation enabled.
237920
+ * @param {boolean | string} [options.shell] The shell to escape for.
237921
+ * @returns {string} The escaped argument.
237922
+ * @throws {TypeError} The argument is not stringable.
237923
+ * @since 0.1.0
237924
+ */
237925
+ function escape(arg, options = {}) {
237926
+ const helpers = getPlatformHelpers();
237927
+ return escapeShellArg({ arg, options, process }, helpers);
237928
+ }
237929
+
237930
+ /**
237931
+ * Take a array of values, the arguments, and escape any dangerous characters in
237932
+ * every argument.
237933
+ *
237934
+ * Non-array inputs will be converted to one-value arrays and non-string values
237935
+ * will be converted to strings using a `toString()` method.
237936
+ *
237937
+ * @param {string[]} args The arguments to escape.
237938
+ * @param {object} [options] The escape options.
237939
+ * @param {boolean} [options.interpolation=false] Is interpolation enabled.
237940
+ * @param {boolean | string} [options.shell] The shell to escape for.
237941
+ * @returns {string[]} The escaped arguments.
237942
+ * @throws {TypeError} One of the arguments is not stringable.
237943
+ * @since 1.1.0
237944
+ */
237945
+ function escapeAll(args, options = {}) {
237946
+ args = toArrayIfNecessary(args);
237947
+ return args.map((arg) => escape(arg, options));
237948
+ }
237949
+
237950
+ /**
237951
+ * Take a single value, the argument, put OS-specific quotes around it and
237952
+ * escape any dangerous characters.
237953
+ *
237954
+ * Non-string inputs will be converted to strings using a `toString()` method.
237955
+ *
237956
+ * @param {string} arg The argument to quote and escape.
237957
+ * @param {object} [options] The escape and quote options.
237958
+ * @param {boolean | string} [options.shell] The shell to escape for.
237959
+ * @returns {string} The quoted and escaped argument.
237960
+ * @throws {TypeError} The argument is not stringable.
237961
+ * @since 0.3.0
237962
+ */
237963
+ function quote(arg, options = {}) {
237964
+ const helpers = getPlatformHelpers();
237965
+ return quoteShellArg({ arg, options, process }, helpers);
237966
+ }
237967
+
237968
+ /**
237969
+ * Take an array of values, the arguments, put OS-specific quotes around every
237970
+ * argument and escape any dangerous characters in every argument.
237971
+ *
237972
+ * Non-array inputs will be converted to one-value arrays and non-string values
237973
+ * will be converted to strings using a `toString()` method.
237974
+ *
237975
+ * @param {string[]} args The arguments to quote and escape.
237976
+ * @param {object} [options] The escape and quote options.
237977
+ * @param {boolean | string} [options.shell] The shell to escape for.
237978
+ * @returns {string[]} The quoted and escaped arguments.
237979
+ * @throws {TypeError} One of the arguments is not stringable.
237980
+ * @since 0.4.0
237981
+ */
237982
+ function quoteAll(args, options = {}) {
237983
+ args = toArrayIfNecessary(args);
237984
+ return args.map((arg) => quote(arg, options));
237985
+ }
237986
+
237987
+ exports.escape = escape;
237988
+ exports.escapeAll = escapeAll;
237989
+ exports.quote = quote;
237990
+ exports.quoteAll = quoteAll;
237991
+
237992
+
237046
237993
  /***/ }),
237047
237994
 
237048
237995
  /***/ 53966: