snyk 1.1071.0 → 1.1072.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.
@@ -2633,10 +2633,10 @@ module.exports = flatten;
2633
2633
  module.exports = minimatch
2634
2634
  minimatch.Minimatch = Minimatch
2635
2635
 
2636
- var path = { sep: '/' }
2637
- try {
2638
- path = __webpack_require__(85622)
2639
- } catch (er) {}
2636
+ var path = (function () { try { return __webpack_require__(85622) } catch (e) {}}()) || {
2637
+ sep: '/'
2638
+ }
2639
+ minimatch.sep = path.sep
2640
2640
 
2641
2641
  var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
2642
2642
  var expand = __webpack_require__(3644)
@@ -2688,43 +2688,64 @@ function filter (pattern, options) {
2688
2688
  }
2689
2689
 
2690
2690
  function ext (a, b) {
2691
- a = a || {}
2692
2691
  b = b || {}
2693
2692
  var t = {}
2694
- Object.keys(b).forEach(function (k) {
2695
- t[k] = b[k]
2696
- })
2697
2693
  Object.keys(a).forEach(function (k) {
2698
2694
  t[k] = a[k]
2699
2695
  })
2696
+ Object.keys(b).forEach(function (k) {
2697
+ t[k] = b[k]
2698
+ })
2700
2699
  return t
2701
2700
  }
2702
2701
 
2703
2702
  minimatch.defaults = function (def) {
2704
- if (!def || !Object.keys(def).length) return minimatch
2703
+ if (!def || typeof def !== 'object' || !Object.keys(def).length) {
2704
+ return minimatch
2705
+ }
2705
2706
 
2706
2707
  var orig = minimatch
2707
2708
 
2708
2709
  var m = function minimatch (p, pattern, options) {
2709
- return orig.minimatch(p, pattern, ext(def, options))
2710
+ return orig(p, pattern, ext(def, options))
2710
2711
  }
2711
2712
 
2712
2713
  m.Minimatch = function Minimatch (pattern, options) {
2713
2714
  return new orig.Minimatch(pattern, ext(def, options))
2714
2715
  }
2716
+ m.Minimatch.defaults = function defaults (options) {
2717
+ return orig.defaults(ext(def, options)).Minimatch
2718
+ }
2719
+
2720
+ m.filter = function filter (pattern, options) {
2721
+ return orig.filter(pattern, ext(def, options))
2722
+ }
2723
+
2724
+ m.defaults = function defaults (options) {
2725
+ return orig.defaults(ext(def, options))
2726
+ }
2727
+
2728
+ m.makeRe = function makeRe (pattern, options) {
2729
+ return orig.makeRe(pattern, ext(def, options))
2730
+ }
2731
+
2732
+ m.braceExpand = function braceExpand (pattern, options) {
2733
+ return orig.braceExpand(pattern, ext(def, options))
2734
+ }
2735
+
2736
+ m.match = function (list, pattern, options) {
2737
+ return orig.match(list, pattern, ext(def, options))
2738
+ }
2715
2739
 
2716
2740
  return m
2717
2741
  }
2718
2742
 
2719
2743
  Minimatch.defaults = function (def) {
2720
- if (!def || !Object.keys(def).length) return Minimatch
2721
2744
  return minimatch.defaults(def).Minimatch
2722
2745
  }
2723
2746
 
2724
2747
  function minimatch (p, pattern, options) {
2725
- if (typeof pattern !== 'string') {
2726
- throw new TypeError('glob pattern string required')
2727
- }
2748
+ assertValidPattern(pattern)
2728
2749
 
2729
2750
  if (!options) options = {}
2730
2751
 
@@ -2733,9 +2754,6 @@ function minimatch (p, pattern, options) {
2733
2754
  return false
2734
2755
  }
2735
2756
 
2736
- // "" only matches ""
2737
- if (pattern.trim() === '') return p === ''
2738
-
2739
2757
  return new Minimatch(pattern, options).match(p)
2740
2758
  }
2741
2759
 
@@ -2744,15 +2762,14 @@ function Minimatch (pattern, options) {
2744
2762
  return new Minimatch(pattern, options)
2745
2763
  }
2746
2764
 
2747
- if (typeof pattern !== 'string') {
2748
- throw new TypeError('glob pattern string required')
2749
- }
2765
+ assertValidPattern(pattern)
2750
2766
 
2751
2767
  if (!options) options = {}
2768
+
2752
2769
  pattern = pattern.trim()
2753
2770
 
2754
2771
  // windows support: need to use /, not \
2755
- if (path.sep !== '/') {
2772
+ if (!options.allowWindowsEscape && path.sep !== '/') {
2756
2773
  pattern = pattern.split(path.sep).join('/')
2757
2774
  }
2758
2775
 
@@ -2763,6 +2780,7 @@ function Minimatch (pattern, options) {
2763
2780
  this.negate = false
2764
2781
  this.comment = false
2765
2782
  this.empty = false
2783
+ this.partial = !!options.partial
2766
2784
 
2767
2785
  // make the set of regexps etc.
2768
2786
  this.make()
@@ -2772,9 +2790,6 @@ Minimatch.prototype.debug = function () {}
2772
2790
 
2773
2791
  Minimatch.prototype.make = make
2774
2792
  function make () {
2775
- // don't do it more than once.
2776
- if (this._made) return
2777
-
2778
2793
  var pattern = this.pattern
2779
2794
  var options = this.options
2780
2795
 
@@ -2794,7 +2809,7 @@ function make () {
2794
2809
  // step 2: expand braces
2795
2810
  var set = this.globSet = this.braceExpand()
2796
2811
 
2797
- if (options.debug) this.debug = console.error
2812
+ if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
2798
2813
 
2799
2814
  this.debug(this.pattern, set)
2800
2815
 
@@ -2874,12 +2889,11 @@ function braceExpand (pattern, options) {
2874
2889
  pattern = typeof pattern === 'undefined'
2875
2890
  ? this.pattern : pattern
2876
2891
 
2877
- if (typeof pattern === 'undefined') {
2878
- throw new TypeError('undefined pattern')
2879
- }
2892
+ assertValidPattern(pattern)
2880
2893
 
2881
- if (options.nobrace ||
2882
- !pattern.match(/\{.*\}/)) {
2894
+ // Thanks to Yeting Li <https://github.com/yetingli> for
2895
+ // improving this regexp to avoid a ReDOS vulnerability.
2896
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
2883
2897
  // shortcut. no need to expand.
2884
2898
  return [pattern]
2885
2899
  }
@@ -2887,6 +2901,17 @@ function braceExpand (pattern, options) {
2887
2901
  return expand(pattern)
2888
2902
  }
2889
2903
 
2904
+ var MAX_PATTERN_LENGTH = 1024 * 64
2905
+ var assertValidPattern = function (pattern) {
2906
+ if (typeof pattern !== 'string') {
2907
+ throw new TypeError('invalid pattern')
2908
+ }
2909
+
2910
+ if (pattern.length > MAX_PATTERN_LENGTH) {
2911
+ throw new TypeError('pattern is too long')
2912
+ }
2913
+ }
2914
+
2890
2915
  // parse a component of the expanded set.
2891
2916
  // At this point, no pattern may contain "/" in it
2892
2917
  // so we're going to return a 2d array, where each entry is the full
@@ -2901,14 +2926,17 @@ function braceExpand (pattern, options) {
2901
2926
  Minimatch.prototype.parse = parse
2902
2927
  var SUBPARSE = {}
2903
2928
  function parse (pattern, isSub) {
2904
- if (pattern.length > 1024 * 64) {
2905
- throw new TypeError('pattern is too long')
2906
- }
2929
+ assertValidPattern(pattern)
2907
2930
 
2908
2931
  var options = this.options
2909
2932
 
2910
2933
  // shortcuts
2911
- if (!options.noglobstar && pattern === '**') return GLOBSTAR
2934
+ if (pattern === '**') {
2935
+ if (!options.noglobstar)
2936
+ return GLOBSTAR
2937
+ else
2938
+ pattern = '*'
2939
+ }
2912
2940
  if (pattern === '') return ''
2913
2941
 
2914
2942
  var re = ''
@@ -2964,10 +2992,12 @@ function parse (pattern, isSub) {
2964
2992
  }
2965
2993
 
2966
2994
  switch (c) {
2967
- case '/':
2995
+ /* istanbul ignore next */
2996
+ case '/': {
2968
2997
  // completely not allowed, even escaped.
2969
2998
  // Should already be path-split by now.
2970
2999
  return false
3000
+ }
2971
3001
 
2972
3002
  case '\\':
2973
3003
  clearStateChar()
@@ -3086,25 +3116,23 @@ function parse (pattern, isSub) {
3086
3116
 
3087
3117
  // handle the case where we left a class open.
3088
3118
  // "[z-a]" is valid, equivalent to "\[z-a\]"
3089
- if (inClass) {
3090
- // split where the last [ was, make sure we don't have
3091
- // an invalid re. if so, re-walk the contents of the
3092
- // would-be class to re-translate any characters that
3093
- // were passed through as-is
3094
- // TODO: It would probably be faster to determine this
3095
- // without a try/catch and a new RegExp, but it's tricky
3096
- // to do safely. For now, this is safe and works.
3097
- var cs = pattern.substring(classStart + 1, i)
3098
- try {
3099
- RegExp('[' + cs + ']')
3100
- } catch (er) {
3101
- // not a valid class!
3102
- var sp = this.parse(cs, SUBPARSE)
3103
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
3104
- hasMagic = hasMagic || sp[1]
3105
- inClass = false
3106
- continue
3107
- }
3119
+ // split where the last [ was, make sure we don't have
3120
+ // an invalid re. if so, re-walk the contents of the
3121
+ // would-be class to re-translate any characters that
3122
+ // were passed through as-is
3123
+ // TODO: It would probably be faster to determine this
3124
+ // without a try/catch and a new RegExp, but it's tricky
3125
+ // to do safely. For now, this is safe and works.
3126
+ var cs = pattern.substring(classStart + 1, i)
3127
+ try {
3128
+ RegExp('[' + cs + ']')
3129
+ } catch (er) {
3130
+ // not a valid class!
3131
+ var sp = this.parse(cs, SUBPARSE)
3132
+ re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
3133
+ hasMagic = hasMagic || sp[1]
3134
+ inClass = false
3135
+ continue
3108
3136
  }
3109
3137
 
3110
3138
  // finish up the class.
@@ -3188,9 +3216,7 @@ function parse (pattern, isSub) {
3188
3216
  // something that could conceivably capture a dot
3189
3217
  var addPatternStart = false
3190
3218
  switch (re.charAt(0)) {
3191
- case '.':
3192
- case '[':
3193
- case '(': addPatternStart = true
3219
+ case '[': case '.': case '(': addPatternStart = true
3194
3220
  }
3195
3221
 
3196
3222
  // Hack to work around lack of negative lookbehind in JS
@@ -3252,7 +3278,7 @@ function parse (pattern, isSub) {
3252
3278
  var flags = options.nocase ? 'i' : ''
3253
3279
  try {
3254
3280
  var regExp = new RegExp('^' + re + '$', flags)
3255
- } catch (er) {
3281
+ } catch (er) /* istanbul ignore next - should be impossible */ {
3256
3282
  // If it was an invalid regular expression, then it can't match
3257
3283
  // anything. This trick looks for a character after the end of
3258
3284
  // the string, which is of course impossible, except in multi-line
@@ -3310,7 +3336,7 @@ function makeRe () {
3310
3336
 
3311
3337
  try {
3312
3338
  this.regexp = new RegExp(re, flags)
3313
- } catch (ex) {
3339
+ } catch (ex) /* istanbul ignore next - should be impossible */ {
3314
3340
  this.regexp = false
3315
3341
  }
3316
3342
  return this.regexp
@@ -3328,8 +3354,8 @@ minimatch.match = function (list, pattern, options) {
3328
3354
  return list
3329
3355
  }
3330
3356
 
3331
- Minimatch.prototype.match = match
3332
- function match (f, partial) {
3357
+ Minimatch.prototype.match = function match (f, partial) {
3358
+ if (typeof partial === 'undefined') partial = this.partial
3333
3359
  this.debug('match', f, this.pattern)
3334
3360
  // short-circuit in the case of busted things.
3335
3361
  // comments, etc.
@@ -3411,6 +3437,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
3411
3437
 
3412
3438
  // should be impossible.
3413
3439
  // some invalid regexp stuff in the set.
3440
+ /* istanbul ignore if */
3414
3441
  if (p === false) return false
3415
3442
 
3416
3443
  if (p === GLOBSTAR) {
@@ -3484,6 +3511,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
3484
3511
  // no match was found.
3485
3512
  // However, in partial mode, we can't say this is necessarily over.
3486
3513
  // If there's more *pattern* left, then
3514
+ /* istanbul ignore if */
3487
3515
  if (partial) {
3488
3516
  // ran out of file
3489
3517
  this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
@@ -3497,11 +3525,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
3497
3525
  // patterns with magic have been turned into regexps.
3498
3526
  var hit
3499
3527
  if (typeof p === 'string') {
3500
- if (options.nocase) {
3501
- hit = f.toLowerCase() === p.toLowerCase()
3502
- } else {
3503
- hit = f === p
3504
- }
3528
+ hit = f === p
3505
3529
  this.debug('string match', p, f, hit)
3506
3530
  } else {
3507
3531
  hit = f.match(p)
@@ -3532,16 +3556,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
3532
3556
  // this is ok if we're doing the match as part of
3533
3557
  // a glob fs traversal.
3534
3558
  return partial
3535
- } else if (pi === pl) {
3559
+ } else /* istanbul ignore else */ if (pi === pl) {
3536
3560
  // ran out of pattern, still have file left.
3537
3561
  // this is only acceptable if we're on the very last
3538
3562
  // empty segment of a file with a trailing slash.
3539
3563
  // a/* should match a/b/
3540
- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
3541
- return emptyFileEnd
3564
+ return (fi === fl - 1) && (file[fi] === '')
3542
3565
  }
3543
3566
 
3544
3567
  // should be unreachable.
3568
+ /* istanbul ignore next */
3545
3569
  throw new Error('wtf?')
3546
3570
  }
3547
3571