@bigbinary/eslint-plugin-neeto 1.13.2 → 2.0.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.
- package/dist/index.js +558 -130
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -286,7 +286,7 @@
|
|
|
286
286
|
}
|
|
287
287
|
});
|
|
288
288
|
|
|
289
|
-
var version = "1.13.
|
|
289
|
+
var version = "1.13.2";
|
|
290
290
|
var packageJson = {
|
|
291
291
|
version: version};
|
|
292
292
|
|
|
@@ -3656,68 +3656,256 @@
|
|
|
3656
3656
|
|
|
3657
3657
|
var braceExpansion = expandTop;
|
|
3658
3658
|
|
|
3659
|
-
var escSlash = '\0SLASH'+Math.random()+'\0';
|
|
3660
|
-
var escOpen = '\0OPEN'+Math.random()+'\0';
|
|
3661
|
-
var escClose = '\0CLOSE'+Math.random()+'\0';
|
|
3662
|
-
var escComma = '\0COMMA'+Math.random()+'\0';
|
|
3663
|
-
var escPeriod = '\0PERIOD'+Math.random()+'\0';
|
|
3659
|
+
var escSlash = '\0SLASH' + Math.random().toFixed(16) + '\0';
|
|
3660
|
+
var escOpen = '\0OPEN' + Math.random().toFixed(16) + '\0';
|
|
3661
|
+
var escClose = '\0CLOSE' + Math.random().toFixed(16) + '\0';
|
|
3662
|
+
var escComma = '\0COMMA' + Math.random().toFixed(16) + '\0';
|
|
3663
|
+
var escPeriod = '\0PERIOD' + Math.random().toFixed(16) + '\0';
|
|
3664
|
+
|
|
3665
|
+
var EXPANSION_MAX = 100000;
|
|
3666
|
+
|
|
3667
|
+
// `EXPANSION_MAX` caps the *number* of expansions, but not their length. An
|
|
3668
|
+
// input like `'{a,b}'.repeat(1500)` stays under that count - its output is
|
|
3669
|
+
// truncated to 100k results - while making every result ~1500 characters
|
|
3670
|
+
// long. The result set, and the intermediate arrays built while combining
|
|
3671
|
+
// brace sets, then grow large enough to exhaust memory and crash the process
|
|
3672
|
+
// (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of
|
|
3673
|
+
// characters the accumulator may hold at any point, so memory stays flat no
|
|
3674
|
+
// matter how many brace groups are chained. The limit sits well above any
|
|
3675
|
+
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
|
3676
|
+
// characters) so legitimate input is unaffected.
|
|
3677
|
+
var EXPANSION_MAX_LENGTH = 4000000;
|
|
3678
|
+
|
|
3679
|
+
// `expand` recurses once per level of brace *nesting* - both when expanding a
|
|
3680
|
+
// set's comma members and when re-wrapping a set whose body is a single part.
|
|
3681
|
+
// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
|
|
3682
|
+
// level per chained group), which left nesting depth unbounded: about 3,100
|
|
3683
|
+
// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
|
|
3684
|
+
// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
|
|
3685
|
+
// will follow nesting. It sits far above any realistic pattern and well below
|
|
3686
|
+
// the depth at which the stack runs out.
|
|
3687
|
+
var EXPANSION_MAX_DEPTH = 1000;
|
|
3688
|
+
|
|
3689
|
+
// Bash keeps a quirk where a brace group followed by a comma set still expands
|
|
3690
|
+
// (`{a},b}`). The parser implements it by rewriting the string and restarting
|
|
3691
|
+
// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`
|
|
3692
|
+
// full passes over a string that itself grows by one `escClose` sentinel each
|
|
3693
|
+
// time - quadratic in `n`, with a ~26x constant from the sentinel's length.
|
|
3694
|
+
// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27
|
|
3695
|
+
// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many
|
|
3696
|
+
// times the scan may restart. Real `{a},b}` input needs a handful.
|
|
3697
|
+
var EXPANSION_MAX_REWRITES = 1000;
|
|
3698
|
+
|
|
3699
|
+
// `EXPANSION_MAX_STEPS` bounds the work one `expandTop` call does, which `max`,
|
|
3700
|
+
// `maxLength` and `maxDepth` don't: nested sets are rescanned at every level
|
|
3701
|
+
// and chained groups each rebuild up to `max` results, so 2KB of input could
|
|
3702
|
+
// block the event loop for over 30 seconds. Each character scanned, result
|
|
3703
|
+
// built and sequence value generated is a step, and each `expand` call costs
|
|
3704
|
+
// `CALL_STEPS` more. Past the budget, the set being expanded and everything
|
|
3705
|
+
// after it stay literal. A glob needs a few hundred steps, and nesting all the
|
|
3706
|
+
// way to `EXPANSION_MAX_DEPTH` about 4M.
|
|
3707
|
+
var EXPANSION_MAX_STEPS = 20000000;
|
|
3708
|
+
|
|
3709
|
+
// What one `expand` call costs on top of what it scans and builds. Setting
|
|
3710
|
+
// one up takes about as long as scanning 16 characters, and a set whose
|
|
3711
|
+
// results are wrapped to be expanded again makes one call per result, each
|
|
3712
|
+
// scanning and building next to nothing: 64KB of
|
|
3713
|
+
// `('{{' + ','.repeat(316) + '}{' + ','.repeat(316) + '}}').repeat(n)` made
|
|
3714
|
+
// 4M such calls, which spent the budget three times as slowly as anything
|
|
3715
|
+
// else.
|
|
3716
|
+
var CALL_STEPS = 16;
|
|
3664
3717
|
|
|
3665
3718
|
function numeric(str) {
|
|
3666
|
-
return parseInt(str, 10) == str
|
|
3667
|
-
? parseInt(str, 10)
|
|
3668
|
-
: str.charCodeAt(0);
|
|
3719
|
+
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0)
|
|
3669
3720
|
}
|
|
3670
3721
|
|
|
3671
3722
|
function escapeBraces(str) {
|
|
3672
|
-
return str
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3723
|
+
return str
|
|
3724
|
+
.split('\\\\')
|
|
3725
|
+
.join(escSlash)
|
|
3726
|
+
.split('\\{')
|
|
3727
|
+
.join(escOpen)
|
|
3728
|
+
.split('\\}')
|
|
3729
|
+
.join(escClose)
|
|
3730
|
+
.split('\\,')
|
|
3731
|
+
.join(escComma)
|
|
3732
|
+
.split('\\.')
|
|
3733
|
+
.join(escPeriod)
|
|
3677
3734
|
}
|
|
3678
3735
|
|
|
3679
3736
|
function unescapeBraces(str) {
|
|
3680
|
-
return str
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3737
|
+
return str
|
|
3738
|
+
.split(escSlash)
|
|
3739
|
+
.join('\\')
|
|
3740
|
+
.split(escOpen)
|
|
3741
|
+
.join('{')
|
|
3742
|
+
.split(escClose)
|
|
3743
|
+
.join('}')
|
|
3744
|
+
.split(escComma)
|
|
3745
|
+
.join(',')
|
|
3746
|
+
.split(escPeriod)
|
|
3747
|
+
.join('.')
|
|
3685
3748
|
}
|
|
3686
3749
|
|
|
3750
|
+
// Like `target.push(...items)` but doesn't overflow the stack
|
|
3751
|
+
function pushAll(target, items) {
|
|
3752
|
+
for (var i = 0; i < items.length; i++) {
|
|
3753
|
+
target.push(items[i]);
|
|
3754
|
+
}
|
|
3755
|
+
}
|
|
3756
|
+
|
|
3757
|
+
// `budget` is `{ remaining }`, one counter shared by every level and group of
|
|
3758
|
+
// an `expandTop` call, so the bound holds for the call as a whole.
|
|
3759
|
+
//
|
|
3760
|
+
// `balanced`, run on `masked` (see `maskUnmatchedOpens`), sliced from `str`
|
|
3761
|
+
// and charged for the characters it walks: up to the group's `}`, or the
|
|
3762
|
+
// whole string when there is no match or unmatched `{` come first, which
|
|
3763
|
+
// `unmatched` then flags for masking. Once a call overdraws the budget, it
|
|
3764
|
+
// and every later one return undefined, so the rest stays literal.
|
|
3765
|
+
function balancedWithBudget(str, masked, budget) {
|
|
3766
|
+
if (budget.remaining < 0) {
|
|
3767
|
+
return undefined
|
|
3768
|
+
}
|
|
3769
|
+
var r = balanced.range('{', '}', masked);
|
|
3770
|
+
var unmatched = r !== undefined && masked.indexOf('{') < r[0];
|
|
3771
|
+
budget.remaining -= r && !unmatched ? r[1] + 1 : str.length;
|
|
3772
|
+
if (!r || budget.remaining < 0) {
|
|
3773
|
+
return undefined
|
|
3774
|
+
}
|
|
3775
|
+
return {
|
|
3776
|
+
end: r[1],
|
|
3777
|
+
pre: str.slice(0, r[0]),
|
|
3778
|
+
body: str.slice(r[0] + 1, r[1]),
|
|
3779
|
+
post: str.slice(r[1] + 1),
|
|
3780
|
+
unmatched: unmatched,
|
|
3781
|
+
}
|
|
3782
|
+
}
|
|
3783
|
+
|
|
3784
|
+
// `masked` with every `{` that has no matching `}` swapped for a `\0`, which
|
|
3785
|
+
// keeps the length, so a scan of it still lines up with the string it was
|
|
3786
|
+
// made from. Such a `{` is literal either way, but `balanced` only learns that
|
|
3787
|
+
// one is unmatched by reading to the end of the string, so with one at the
|
|
3788
|
+
// head of every group (`'{a,{b,c}'.repeat(n)`) each scan read the rest of the
|
|
3789
|
+
// input. That was quadratic, and once the step budget charged for it, it ran
|
|
3790
|
+
// out partway through and left the rest literal. A scan of the masked copy
|
|
3791
|
+
// stops at the group's `}`. It is one pass, charged as such.
|
|
3792
|
+
function maskUnmatchedOpens(masked, budget) {
|
|
3793
|
+
budget.remaining -= masked.length;
|
|
3794
|
+
var open = [];
|
|
3795
|
+
for (var i = 0; i < masked.length; i++) {
|
|
3796
|
+
var c = masked.charCodeAt(i);
|
|
3797
|
+
if (c === 0x7b) {
|
|
3798
|
+
open.push(i);
|
|
3799
|
+
} else if (c === 0x7d && open.length) {
|
|
3800
|
+
open.pop();
|
|
3801
|
+
}
|
|
3802
|
+
}
|
|
3803
|
+
var out = '';
|
|
3804
|
+
var last = 0;
|
|
3805
|
+
for (var j = 0; j < open.length; j++) {
|
|
3806
|
+
out += masked.slice(last, open[j]) + '\0';
|
|
3807
|
+
last = open[j] + 1;
|
|
3808
|
+
}
|
|
3809
|
+
return out + masked.slice(last)
|
|
3810
|
+
}
|
|
3811
|
+
|
|
3812
|
+
// Whether `str` has a `,` not followed by another `,`, with a `}` after it on
|
|
3813
|
+
// the same line - what `/,(?!,).*\}/.test(str)` asks, answered in one pass from
|
|
3814
|
+
// the end. The regex tries every `,` and backtracks through the rest of its
|
|
3815
|
+
// line from each, which is quadratic, and the `{a},b}` rewrite asks again on
|
|
3816
|
+
// every pass. Like a scan, it is charged for the whole string and refused if
|
|
3817
|
+
// that overdraws the budget.
|
|
3818
|
+
function commaSetFollows(str, budget) {
|
|
3819
|
+
budget.remaining -= str.length;
|
|
3820
|
+
if (budget.remaining < 0) {
|
|
3821
|
+
return false
|
|
3822
|
+
}
|
|
3823
|
+
// Whether a `}` follows the current position before the line ends
|
|
3824
|
+
var close = false;
|
|
3825
|
+
for (var i = str.length - 1; i >= 0; i--) {
|
|
3826
|
+
var c = str.charCodeAt(i);
|
|
3827
|
+
if (c === 0x7d) {
|
|
3828
|
+
close = true;
|
|
3829
|
+
} else if (c === 0x0a || c === 0x0d || c === 0x2028 || c === 0x2029) {
|
|
3830
|
+
// A line terminator, which `.` does not match
|
|
3831
|
+
close = false;
|
|
3832
|
+
} else if (c === 0x2c && close && str.charCodeAt(i + 1) !== 0x2c) {
|
|
3833
|
+
return true
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
return false
|
|
3837
|
+
}
|
|
3687
3838
|
|
|
3688
3839
|
// Basically just str.split(","), but handling cases
|
|
3689
3840
|
// where we have nested braced sections, which should be
|
|
3690
3841
|
// treated as individual members, like {a,{b,c},d}
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3842
|
+
//
|
|
3843
|
+
// Returns `undefined` if the step budget runs out before the whole set is
|
|
3844
|
+
// split, since splitting what is left on every comma would tear apart the
|
|
3845
|
+
// nested sets it still holds.
|
|
3846
|
+
function parseCommaParts(str, budget) {
|
|
3695
3847
|
var parts = [];
|
|
3696
|
-
var m = balanced('{', '}', str);
|
|
3697
3848
|
|
|
3698
|
-
|
|
3699
|
-
|
|
3849
|
+
// Walk the brace groups iteratively. Recursing on `post` once per group let a
|
|
3850
|
+
// chain of them exhaust the stack - the parsing-side counterpart to
|
|
3851
|
+
// the `expand` overflow fixed for CVE-2026-14257, and not something `max` or
|
|
3852
|
+
// `maxLength` can bound, since it happens before expansion.
|
|
3853
|
+
//
|
|
3854
|
+
// The part the next chunk continues
|
|
3855
|
+
var carry = '';
|
|
3700
3856
|
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
var p = pre.split(',');
|
|
3857
|
+
for (;;) {
|
|
3858
|
+
// A set's body holds no unmatched `{`, so there is nothing to mask.
|
|
3859
|
+
var m = balancedWithBudget(str, str, budget);
|
|
3705
3860
|
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3861
|
+
if (budget.remaining < 0) {
|
|
3862
|
+
return undefined
|
|
3863
|
+
}
|
|
3864
|
+
|
|
3865
|
+
if (!m) {
|
|
3866
|
+
var tail = str.split(',');
|
|
3867
|
+
tail[0] = carry + tail[0];
|
|
3868
|
+
pushAll(parts, tail);
|
|
3869
|
+
return parts
|
|
3870
|
+
}
|
|
3871
|
+
|
|
3872
|
+
var pre = m.pre;
|
|
3873
|
+
var body = m.body;
|
|
3874
|
+
var post = m.post;
|
|
3875
|
+
var p = pre.split(',');
|
|
3876
|
+
|
|
3877
|
+
p[0] = carry + p[0];
|
|
3878
|
+
p[p.length - 1] += '{' + body + '}';
|
|
3879
|
+
|
|
3880
|
+
if (!post.length) {
|
|
3881
|
+
pushAll(parts, p);
|
|
3882
|
+
return parts
|
|
3883
|
+
}
|
|
3712
3884
|
|
|
3713
|
-
|
|
3885
|
+
carry = p.pop();
|
|
3886
|
+
pushAll(parts, p);
|
|
3887
|
+
str = post;
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3714
3890
|
|
|
3715
|
-
|
|
3891
|
+
// An option that is left out or null, or that is NaN, gets its default. Every
|
|
3892
|
+
// comparison against NaN is false, so a NaN bound would never be reached:
|
|
3893
|
+
// `{ maxSteps: NaN }` let 15KB of input block the event loop for 16 seconds,
|
|
3894
|
+
// and `{ maxDepth: NaN }` overflowed the stack again (CVE-2026-102278). Pass
|
|
3895
|
+
// `Infinity` to lift a bound.
|
|
3896
|
+
function bound(value, fallback) {
|
|
3897
|
+
return value == null || isNaN(value) ? fallback : value
|
|
3716
3898
|
}
|
|
3717
3899
|
|
|
3718
|
-
function expandTop(str) {
|
|
3719
|
-
if (!str)
|
|
3720
|
-
|
|
3900
|
+
function expandTop(str, options) {
|
|
3901
|
+
if (!str) return []
|
|
3902
|
+
|
|
3903
|
+
options = options || {};
|
|
3904
|
+
var max = bound(options.max, EXPANSION_MAX);
|
|
3905
|
+
var maxLength = bound(options.maxLength, EXPANSION_MAX_LENGTH);
|
|
3906
|
+
var maxDepth = bound(options.maxDepth, EXPANSION_MAX_DEPTH);
|
|
3907
|
+
var maxRewrites = bound(options.maxRewrites, EXPANSION_MAX_REWRITES);
|
|
3908
|
+
var maxSteps = bound(options.maxSteps, EXPANSION_MAX_STEPS);
|
|
3721
3909
|
|
|
3722
3910
|
// I don't know why Bash 4.3 does this, but it does.
|
|
3723
3911
|
// Anything starting with {} will have the first two bytes preserved
|
|
@@ -3729,130 +3917,373 @@
|
|
|
3729
3917
|
str = '\\{\\}' + str.substr(2);
|
|
3730
3918
|
}
|
|
3731
3919
|
|
|
3732
|
-
return expand(
|
|
3920
|
+
return expand(
|
|
3921
|
+
escapeBraces(str),
|
|
3922
|
+
max,
|
|
3923
|
+
maxLength,
|
|
3924
|
+
maxDepth,
|
|
3925
|
+
0,
|
|
3926
|
+
maxRewrites,
|
|
3927
|
+
{ remaining: maxSteps },
|
|
3928
|
+
true
|
|
3929
|
+
).map(unescapeBraces)
|
|
3733
3930
|
}
|
|
3734
3931
|
|
|
3735
3932
|
function embrace(str) {
|
|
3736
|
-
return '{' + str + '}'
|
|
3933
|
+
return '{' + str + '}'
|
|
3737
3934
|
}
|
|
3738
3935
|
function isPadded(el) {
|
|
3739
|
-
return /^-?0\d/.test(el)
|
|
3936
|
+
return /^-?0\d/.test(el)
|
|
3740
3937
|
}
|
|
3741
3938
|
|
|
3742
3939
|
function lte(i, y) {
|
|
3743
|
-
return i <= y
|
|
3940
|
+
return i <= y
|
|
3744
3941
|
}
|
|
3745
3942
|
function gte(i, y) {
|
|
3746
|
-
return i >= y
|
|
3943
|
+
return i >= y
|
|
3747
3944
|
}
|
|
3748
3945
|
|
|
3749
|
-
|
|
3750
|
-
|
|
3946
|
+
// Build `{ acc[a] + pre + values[v] }` for every combination, capping the
|
|
3947
|
+
// number of results at `max` and the total number of characters at `maxLength`.
|
|
3948
|
+
// This is the one place output grows, so bounding it here keeps the single
|
|
3949
|
+
// accumulator - and therefore memory - flat regardless of how many brace groups
|
|
3950
|
+
// are combined (CVE-2026-14257). Each result built is a step, since `max` and
|
|
3951
|
+
// `maxLength` bound one combination, not how many brace groups are combined.
|
|
3952
|
+
function combine(acc, pre, values, max, maxLength, dropEmpties, budget) {
|
|
3953
|
+
var out = [];
|
|
3954
|
+
var length = 0;
|
|
3955
|
+
// Bash drops empty results at the top level, and they don't count against
|
|
3956
|
+
// `max`, so `max` bounds the number of *kept* results. Only an empty
|
|
3957
|
+
// `acc[a] + pre` can make one, so for those the empty values are skipped
|
|
3958
|
+
// without being visited. Visiting them one at a time let a set of empties
|
|
3959
|
+
// cost `acc.length * values.length` while keeping nothing.
|
|
3960
|
+
var nonEmpty;
|
|
3961
|
+
outer: for (var a = 0; a < acc.length; a++) {
|
|
3962
|
+
var prefix = acc[a] + pre;
|
|
3963
|
+
var vs = values;
|
|
3964
|
+
if (dropEmpties && !prefix) {
|
|
3965
|
+
if (!nonEmpty) nonEmpty = values.filter(Boolean);
|
|
3966
|
+
vs = nonEmpty;
|
|
3967
|
+
}
|
|
3968
|
+
for (var v = 0; v < vs.length; v++) {
|
|
3969
|
+
if (out.length >= max) break outer
|
|
3970
|
+
var expansion = prefix + vs[v];
|
|
3971
|
+
if (length + expansion.length > maxLength) break outer
|
|
3972
|
+
out.push(expansion);
|
|
3973
|
+
length += expansion.length;
|
|
3974
|
+
}
|
|
3975
|
+
}
|
|
3976
|
+
budget.remaining -= out.length;
|
|
3977
|
+
return out
|
|
3978
|
+
}
|
|
3751
3979
|
|
|
3752
|
-
|
|
3753
|
-
|
|
3980
|
+
// The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)
|
|
3981
|
+
// sequence body, or `undefined` if the step budget runs out generating them.
|
|
3982
|
+
function expandSequence(body, isAlphaSequence, max, maxLength, budget) {
|
|
3983
|
+
var n = body.split(/\.\./);
|
|
3984
|
+
var N = [];
|
|
3985
|
+
// A sequence body always splits into two or three parts, but the compiler
|
|
3986
|
+
// can't know that.
|
|
3987
|
+
/* c8 ignore start */
|
|
3988
|
+
if (n[0] === undefined || n[1] === undefined) {
|
|
3989
|
+
return N
|
|
3990
|
+
}
|
|
3991
|
+
/* c8 ignore stop */
|
|
3992
|
+
var x = numeric(n[0]);
|
|
3993
|
+
var y = numeric(n[1]);
|
|
3994
|
+
var width = Math.max(n[0].length, n[1].length);
|
|
3995
|
+
var incr =
|
|
3996
|
+
n.length === 3 && n[2] !== undefined ?
|
|
3997
|
+
Math.max(Math.abs(numeric(n[2])), 1)
|
|
3998
|
+
: 1;
|
|
3999
|
+
var test = lte;
|
|
4000
|
+
var reverse = y < x;
|
|
4001
|
+
if (reverse) {
|
|
4002
|
+
incr *= -1;
|
|
4003
|
+
test = gte;
|
|
4004
|
+
}
|
|
4005
|
+
var pad = n.some(isPadded);
|
|
4006
|
+
// A padded value is built a character at a time to `width`, which the input
|
|
4007
|
+
// sets, so it costs one step per character: 64KB of
|
|
4008
|
+
// `('{' + '0'.repeat(100) + '..99999}').repeat(n)` took 7 seconds charged
|
|
4009
|
+
// one step per value.
|
|
4010
|
+
var cost = pad ? width : 1;
|
|
4011
|
+
|
|
4012
|
+
var length = 0;
|
|
4013
|
+
for (var i = x; test(i, y) && N.length < max; i += incr) {
|
|
4014
|
+
// Each value is a step. `max` and `maxLength` bound one sequence, but a
|
|
4015
|
+
// chain of them still generated up to `max` values each, however few
|
|
4016
|
+
// combining could keep.
|
|
4017
|
+
budget.remaining -= cost;
|
|
4018
|
+
if (budget.remaining < 0) {
|
|
4019
|
+
return undefined
|
|
4020
|
+
}
|
|
4021
|
+
var c;
|
|
4022
|
+
if (isAlphaSequence) {
|
|
4023
|
+
c = String.fromCharCode(i);
|
|
4024
|
+
if (c === '\\') {
|
|
4025
|
+
c = '';
|
|
4026
|
+
}
|
|
4027
|
+
} else {
|
|
4028
|
+
c = String(i);
|
|
4029
|
+
if (pad) {
|
|
4030
|
+
var need = width - c.length;
|
|
4031
|
+
if (need > 0) {
|
|
4032
|
+
var z = new Array(need + 1).join('0');
|
|
4033
|
+
if (i < 0) {
|
|
4034
|
+
c = '-' + z + c.slice(1);
|
|
4035
|
+
} else {
|
|
4036
|
+
c = z + c;
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
if (length + c.length > maxLength) break
|
|
4042
|
+
N.push(c);
|
|
4043
|
+
length += c.length;
|
|
4044
|
+
}
|
|
4045
|
+
return N
|
|
4046
|
+
}
|
|
3754
4047
|
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
4048
|
+
function expand(
|
|
4049
|
+
str,
|
|
4050
|
+
max,
|
|
4051
|
+
maxLength,
|
|
4052
|
+
maxDepth,
|
|
4053
|
+
depth,
|
|
4054
|
+
maxRewrites,
|
|
4055
|
+
budget,
|
|
4056
|
+
isTop
|
|
4057
|
+
) {
|
|
4058
|
+
// An overdraft here makes the first scan refuse, so `str` stays literal.
|
|
4059
|
+
budget.remaining -= CALL_STEPS;
|
|
4060
|
+
|
|
4061
|
+
// Too deeply nested to keep following: treat the rest as literal, the same
|
|
4062
|
+
// way a group that cannot expand is already handled. Truncating rather than
|
|
4063
|
+
// throwing keeps expansion total, matching `max` and `maxLength`.
|
|
4064
|
+
if (depth > maxDepth) {
|
|
4065
|
+
return [str]
|
|
4066
|
+
}
|
|
4067
|
+
|
|
4068
|
+
// Consume the string's top-level brace groups left to right, threading a
|
|
4069
|
+
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
|
4070
|
+
// rather than recursing on `m.post` once per group - keeps the native stack
|
|
4071
|
+
// depth constant, so deeply chained input (`'{a,b}'.repeat(3000)`) can no
|
|
4072
|
+
// longer overflow the stack, and leaves a single accumulator whose size
|
|
4073
|
+
// `maxLength` bounds directly (CVE-2026-14257).
|
|
4074
|
+
var acc = [''];
|
|
4075
|
+
|
|
4076
|
+
// Bash drops empty results, but only when the *first* top-level group is a
|
|
4077
|
+
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
|
4078
|
+
// is on the final strings, so it is applied to whichever `combine` produces
|
|
4079
|
+
// them (the one with no brace set left in the tail).
|
|
4080
|
+
// How many times the `{a},b}` rewrite below has restarted the scan. Each pass
|
|
4081
|
+
// re-reads the whole string, so leaving this unbounded is quadratic.
|
|
4082
|
+
var rewrites = 0;
|
|
4083
|
+
var dropEmpties = false;
|
|
4084
|
+
var firstGroup = true;
|
|
4085
|
+
// `str` with its unmatched `{` masked, once a scan has run into them
|
|
4086
|
+
var masked = str;
|
|
4087
|
+
|
|
4088
|
+
for (;;) {
|
|
4089
|
+
const m = balancedWithBudget(str, masked, budget);
|
|
4090
|
+
|
|
4091
|
+
// No brace set left, or no step budget left to look for one: the rest of
|
|
4092
|
+
// the string is literal.
|
|
4093
|
+
if (!m) {
|
|
4094
|
+
return combine(acc, str, [''], max, maxLength, dropEmpties, budget)
|
|
4095
|
+
}
|
|
4096
|
+
if (m.unmatched) {
|
|
4097
|
+
masked = maskUnmatchedOpens(masked, budget);
|
|
4098
|
+
}
|
|
4099
|
+
|
|
4100
|
+
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
|
4101
|
+
const pre = m.pre;
|
|
4102
|
+
|
|
4103
|
+
// This set and the rest of the string, literal: for a set that cannot
|
|
4104
|
+
// expand, and for one the step budget runs out on. Once it is overdrawn,
|
|
4105
|
+
// every set still being expanded, at every level, stays literal like this -
|
|
4106
|
+
// otherwise each level above would go on combining, and wrapping and
|
|
4107
|
+
// expanding again, results the budget was too small for.
|
|
4108
|
+
var literal = function () {
|
|
4109
|
+
return combine(
|
|
4110
|
+
acc,
|
|
4111
|
+
pre + '{' + m.body + '}' + m.post,
|
|
4112
|
+
[''],
|
|
4113
|
+
max,
|
|
4114
|
+
maxLength,
|
|
4115
|
+
dropEmpties,
|
|
4116
|
+
budget
|
|
4117
|
+
)
|
|
4118
|
+
};
|
|
3760
4119
|
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
4120
|
+
if (/\$$/.test(pre)) {
|
|
4121
|
+
acc = combine(
|
|
4122
|
+
acc,
|
|
4123
|
+
pre + '{' + m.body + '}',
|
|
4124
|
+
[''],
|
|
4125
|
+
max,
|
|
4126
|
+
maxLength,
|
|
4127
|
+
dropEmpties && !m.post.length,
|
|
4128
|
+
budget
|
|
4129
|
+
);
|
|
4130
|
+
firstGroup = false;
|
|
4131
|
+
if (!m.post.length) break
|
|
4132
|
+
str = m.post;
|
|
4133
|
+
masked = masked.slice(m.end + 1);
|
|
4134
|
+
continue
|
|
3765
4135
|
}
|
|
3766
|
-
|
|
4136
|
+
|
|
3767
4137
|
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
3768
|
-
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(
|
|
4138
|
+
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(
|
|
4139
|
+
m.body
|
|
4140
|
+
);
|
|
3769
4141
|
var isSequence = isNumericSequence || isAlphaSequence;
|
|
3770
4142
|
var isOptions = m.body.indexOf(',') >= 0;
|
|
3771
4143
|
if (!isSequence && !isOptions) {
|
|
3772
4144
|
// {a},b}
|
|
3773
|
-
if (m.post
|
|
4145
|
+
if (rewrites < maxRewrites && commaSetFollows(m.post, budget)) {
|
|
4146
|
+
rewrites++;
|
|
3774
4147
|
str = m.pre + '{' + m.body + escClose + m.post;
|
|
3775
|
-
|
|
4148
|
+
// Taking a `}` away never gives an unmatched `{` a partner, so what
|
|
4149
|
+
// is masked stays unmatched. The `{` it closed can be left without
|
|
4150
|
+
// one, and the next scan masks it.
|
|
4151
|
+
masked =
|
|
4152
|
+
masked.slice(0, m.end) + escClose + masked.slice(m.end + 1);
|
|
4153
|
+
isTop = true;
|
|
4154
|
+
continue
|
|
3776
4155
|
}
|
|
3777
|
-
|
|
4156
|
+
// Nothing here expands, so the whole remaining string is literal.
|
|
4157
|
+
return literal()
|
|
3778
4158
|
}
|
|
3779
4159
|
|
|
3780
|
-
|
|
4160
|
+
if (firstGroup) {
|
|
4161
|
+
dropEmpties = isTop && !isSequence;
|
|
4162
|
+
firstGroup = false;
|
|
4163
|
+
}
|
|
4164
|
+
|
|
4165
|
+
var values;
|
|
3781
4166
|
if (isSequence) {
|
|
3782
|
-
|
|
4167
|
+
values = expandSequence(
|
|
4168
|
+
m.body,
|
|
4169
|
+
isAlphaSequence,
|
|
4170
|
+
max,
|
|
4171
|
+
maxLength,
|
|
4172
|
+
budget
|
|
4173
|
+
);
|
|
4174
|
+
if (!values) {
|
|
4175
|
+
return literal()
|
|
4176
|
+
}
|
|
3783
4177
|
} else {
|
|
3784
|
-
n = parseCommaParts(m.body);
|
|
3785
|
-
|
|
4178
|
+
var n = parseCommaParts(m.body, budget);
|
|
4179
|
+
// The step budget ran out partway through the set.
|
|
4180
|
+
if (!n) {
|
|
4181
|
+
return literal()
|
|
4182
|
+
}
|
|
4183
|
+
if (n.length === 1 && n[0] !== undefined) {
|
|
3786
4184
|
// x{{a,b}}y ==> x{a}y x{b}y
|
|
3787
|
-
n = expand(
|
|
4185
|
+
n = expand(
|
|
4186
|
+
n[0],
|
|
4187
|
+
max,
|
|
4188
|
+
maxLength,
|
|
4189
|
+
maxDepth,
|
|
4190
|
+
depth + 1,
|
|
4191
|
+
maxRewrites,
|
|
4192
|
+
budget,
|
|
4193
|
+
false
|
|
4194
|
+
).map(embrace);
|
|
4195
|
+
// The step budget ran out expanding the set's only part.
|
|
4196
|
+
if (budget.remaining < 0) {
|
|
4197
|
+
return literal()
|
|
4198
|
+
}
|
|
4199
|
+
//XXX is this necessary? Can't seem to hit it in tests.
|
|
4200
|
+
/* c8 ignore start */
|
|
3788
4201
|
if (n.length === 1) {
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
4202
|
+
var single = combine(
|
|
4203
|
+
acc,
|
|
4204
|
+
pre + n[0],
|
|
4205
|
+
[''],
|
|
4206
|
+
max,
|
|
4207
|
+
maxLength,
|
|
4208
|
+
dropEmpties && !m.post.length,
|
|
4209
|
+
budget
|
|
4210
|
+
);
|
|
4211
|
+
if (budget.remaining < 0) {
|
|
4212
|
+
return literal()
|
|
4213
|
+
}
|
|
4214
|
+
acc = single;
|
|
4215
|
+
if (!m.post.length) break
|
|
4216
|
+
str = m.post;
|
|
4217
|
+
masked = masked.slice(m.end + 1);
|
|
4218
|
+
continue
|
|
3792
4219
|
}
|
|
4220
|
+
/* c8 ignore stop */
|
|
3793
4221
|
}
|
|
3794
|
-
}
|
|
3795
|
-
|
|
3796
|
-
// at this point, n is the parts, and we know it's not a comma set
|
|
3797
|
-
// with a single entry.
|
|
3798
|
-
var N;
|
|
3799
4222
|
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
incr *= -1;
|
|
3811
|
-
test = gte;
|
|
4223
|
+
// Values that `combine` is going to drop as empty produce no result, so
|
|
4224
|
+
// they must not count against `max` - otherwise `{a,,b}` with `max: 2`
|
|
4225
|
+
// would stop at `['a', '']` and yield one result instead of two. Skipping
|
|
4226
|
+
// them outright keeps `values` bounded while leaving `max` a bound on
|
|
4227
|
+
// *kept* results.
|
|
4228
|
+
var dropsEmpties = dropEmpties && !m.post.length && !pre;
|
|
4229
|
+
for (var d = 0; dropsEmpties && d < acc.length; d++) {
|
|
4230
|
+
if (acc[d]) {
|
|
4231
|
+
dropsEmpties = false;
|
|
4232
|
+
}
|
|
3812
4233
|
}
|
|
3813
|
-
var pad = n.some(isPadded);
|
|
3814
4234
|
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
for (var
|
|
3818
|
-
var
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
4235
|
+
values = [];
|
|
4236
|
+
var valuesLength = 0;
|
|
4237
|
+
outer: for (var j = 0; j < n.length; j++) {
|
|
4238
|
+
var expanded = expand(
|
|
4239
|
+
n[j],
|
|
4240
|
+
max,
|
|
4241
|
+
maxLength,
|
|
4242
|
+
maxDepth,
|
|
4243
|
+
depth + 1,
|
|
4244
|
+
maxRewrites,
|
|
4245
|
+
budget,
|
|
4246
|
+
false
|
|
4247
|
+
);
|
|
4248
|
+
// The step budget ran out expanding a member.
|
|
4249
|
+
if (budget.remaining < 0) {
|
|
4250
|
+
return literal()
|
|
4251
|
+
}
|
|
4252
|
+
for (var k = 0; k < expanded.length; k++) {
|
|
4253
|
+
var v = expanded[k];
|
|
4254
|
+
if (dropsEmpties && !v) continue
|
|
4255
|
+
if (
|
|
4256
|
+
values.length >= max ||
|
|
4257
|
+
valuesLength + v.length > maxLength
|
|
4258
|
+
) {
|
|
4259
|
+
break outer
|
|
3834
4260
|
}
|
|
4261
|
+
values.push(v);
|
|
4262
|
+
valuesLength += v.length;
|
|
3835
4263
|
}
|
|
3836
|
-
N.push(c);
|
|
3837
|
-
}
|
|
3838
|
-
} else {
|
|
3839
|
-
N = [];
|
|
3840
|
-
|
|
3841
|
-
for (var j = 0; j < n.length; j++) {
|
|
3842
|
-
N.push.apply(N, expand(n[j], false));
|
|
3843
4264
|
}
|
|
3844
4265
|
}
|
|
3845
4266
|
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
4267
|
+
var next = combine(
|
|
4268
|
+
acc,
|
|
4269
|
+
pre,
|
|
4270
|
+
values,
|
|
4271
|
+
max,
|
|
4272
|
+
maxLength,
|
|
4273
|
+
dropEmpties && !m.post.length,
|
|
4274
|
+
budget
|
|
4275
|
+
);
|
|
4276
|
+
// The step budget ran out combining the set's values in.
|
|
4277
|
+
if (budget.remaining < 0) {
|
|
4278
|
+
return literal()
|
|
3852
4279
|
}
|
|
4280
|
+
acc = next;
|
|
4281
|
+
if (!m.post.length) break
|
|
4282
|
+
str = m.post;
|
|
4283
|
+
masked = masked.slice(m.end + 1);
|
|
3853
4284
|
}
|
|
3854
4285
|
|
|
3855
|
-
return
|
|
4286
|
+
return acc
|
|
3856
4287
|
}
|
|
3857
4288
|
|
|
3858
4289
|
const minimatch = (p, pattern, options = {}) => {
|
|
@@ -4257,8 +4688,8 @@
|
|
|
4257
4688
|
}
|
|
4258
4689
|
}
|
|
4259
4690
|
const head = pattern.slice(patternIndex, firstgs);
|
|
4260
|
-
const body = pattern.slice(firstgs + 1, lastgs);
|
|
4261
|
-
const tail = pattern.slice(lastgs + 1);
|
|
4691
|
+
const body = partial ? pattern.slice(firstgs + 1) : pattern.slice(firstgs + 1, lastgs);
|
|
4692
|
+
const tail = partial ? [] : pattern.slice(lastgs + 1);
|
|
4262
4693
|
// check the head
|
|
4263
4694
|
if (head.length) {
|
|
4264
4695
|
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
|
@@ -4300,7 +4731,7 @@
|
|
|
4300
4731
|
return false;
|
|
4301
4732
|
}
|
|
4302
4733
|
}
|
|
4303
|
-
return sawSome;
|
|
4734
|
+
return partial || sawSome;
|
|
4304
4735
|
}
|
|
4305
4736
|
// split body into segments at each GLOBSTAR
|
|
4306
4737
|
const bodySegments = [[[], 0]];
|
|
@@ -4361,7 +4792,7 @@
|
|
|
4361
4792
|
}
|
|
4362
4793
|
fileIndex++;
|
|
4363
4794
|
}
|
|
4364
|
-
return null;
|
|
4795
|
+
return partial || null;
|
|
4365
4796
|
}
|
|
4366
4797
|
_matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
4367
4798
|
let fi;
|
|
@@ -6097,7 +6528,6 @@
|
|
|
6097
6528
|
type: TYPES.BINARY_EXPRESSION,
|
|
6098
6529
|
operator: operators.compare // ===, !==
|
|
6099
6530
|
};
|
|
6100
|
-
|
|
6101
6531
|
return neetoCist.matches(binaryExpressionPattern, expression) && (neetoCist.matches(pattern, expression.left) || neetoCist.matches(pattern, expression.right));
|
|
6102
6532
|
};
|
|
6103
6533
|
const logicalExpressionPattern = {
|
|
@@ -9997,7 +10427,6 @@
|
|
|
9997
10427
|
if (!validateBaseUrlConstant(context, baseUrlDeclarator, programNode)) {
|
|
9998
10428
|
return; // Stop further checks if base URL is invalid.
|
|
9999
10429
|
}
|
|
10000
|
-
|
|
10001
10430
|
for (const declarator of topLevelDeclarations) {
|
|
10002
10431
|
if (declarator.id.name === HELP_DOCS_BASE_URL_CONSTANT_NAME) {
|
|
10003
10432
|
// Check for the old, incorrect URL format first for base constant.
|
|
@@ -10008,7 +10437,6 @@
|
|
|
10008
10437
|
});
|
|
10009
10438
|
return; // Report this error and stop, as it's a format issue.
|
|
10010
10439
|
}
|
|
10011
|
-
|
|
10012
10440
|
continue;
|
|
10013
10441
|
}
|
|
10014
10442
|
if (declarator.id.type !== TYPES.IDENTIFIER) continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/eslint-plugin-neeto",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"scripts": {
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@babel/core": "^7.
|
|
33
|
+
"@babel/core": "^7.29.6",
|
|
34
34
|
"@babel/eslint-parser": "^7.27.5",
|
|
35
35
|
"@babel/plugin-transform-runtime": "^7.19.1",
|
|
36
36
|
"@babel/preset-env": "7.17.10",
|
|
37
37
|
"@babel/preset-react": "7.16.7",
|
|
38
38
|
"@babel/preset-typescript": "^7.18.6",
|
|
39
|
-
"@babel/runtime": "^7.
|
|
39
|
+
"@babel/runtime": "^7.26.10",
|
|
40
40
|
"@bigbinary/babel-preset-neeto": "^1.0.3",
|
|
41
41
|
"@bigbinary/eslint-plugin-neeto": "^1.7.2",
|
|
42
42
|
"@bigbinary/neeto-cist": "^1.0.3",
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
74
74
|
"globals": "^16.0.0",
|
|
75
75
|
"husky": "7.0.4",
|
|
76
|
-
"i18next": "
|
|
76
|
+
"i18next": "26.3.4",
|
|
77
77
|
"jest": "27.5.1",
|
|
78
78
|
"lint-staged": "12.4.1",
|
|
79
|
-
"minimatch": "^6.2.
|
|
79
|
+
"minimatch": "^6.2.3",
|
|
80
80
|
"mock-fs": "^5.2.0",
|
|
81
81
|
"prettier": "2.6.2",
|
|
82
82
|
"ramda": "0.29.0",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"@bigbinary/neeto-cist": "^1.0.3",
|
|
92
92
|
"@bigbinary/neeto-commons-frontend": "4.13.38",
|
|
93
93
|
"eslint": "^9.25.1",
|
|
94
|
-
"i18next": "
|
|
94
|
+
"i18next": "26.3.4",
|
|
95
95
|
"ramda": "0.29.0"
|
|
96
96
|
}
|
|
97
97
|
}
|