cdk8s-plus-32 2.5.80 → 2.5.81
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/.jsii +2 -2
- package/lib/api-resource.js +2 -2
- package/lib/base.js +2 -2
- package/lib/config-map.js +1 -1
- package/lib/container.js +6 -6
- package/lib/cron-job.js +1 -1
- package/lib/daemon-set.js +1 -1
- package/lib/deployment.js +3 -3
- package/lib/handler.js +1 -1
- package/lib/horizontal-pod-autoscaler.js +4 -4
- package/lib/imports/k8s.js +156 -156
- package/lib/ingress.js +2 -2
- package/lib/job.js +1 -1
- package/lib/namespace.js +2 -2
- package/lib/network-policy.js +3 -3
- package/lib/pod.js +16 -16
- package/lib/probe.js +1 -1
- package/lib/pv.js +4 -4
- package/lib/pvc.js +1 -1
- package/lib/role-binding.js +4 -4
- package/lib/role.js +2 -2
- package/lib/secret.js +6 -6
- package/lib/service-account.js +1 -1
- package/lib/service.js +1 -1
- package/lib/stateful-set.js +2 -2
- package/lib/volume.js +1 -1
- package/lib/workload.js +2 -2
- package/node_modules/brace-expansion/.tap/coverage/8b906b8c-e21f-40b5-8c0d-214d8c2682c5.json +757 -0
- package/node_modules/brace-expansion/.tap/processinfo/8b906b8c-e21f-40b5-8c0d-214d8c2682c5.json +719 -0
- package/node_modules/brace-expansion/ADVISORY-CVE-2026-14257.md +107 -0
- package/node_modules/brace-expansion/dist/commonjs/index.d.ts +8 -0
- package/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/brace-expansion/dist/commonjs/index.js +263 -0
- package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -0
- package/node_modules/brace-expansion/dist/commonjs/package.json +3 -0
- package/node_modules/brace-expansion/dist/esm/index.d.ts +8 -0
- package/node_modules/brace-expansion/dist/esm/index.d.ts.map +1 -0
- package/node_modules/brace-expansion/dist/esm/index.js +259 -0
- package/node_modules/brace-expansion/dist/esm/index.js.map +1 -0
- package/node_modules/brace-expansion/dist/esm/package.json +3 -0
- package/node_modules/brace-expansion/index.js +29 -17
- package/node_modules/brace-expansion/package.json +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { balanced } from 'balanced-match';
|
|
2
|
+
const escSlash = '\0SLASH' + Math.random() + '\0';
|
|
3
|
+
const escOpen = '\0OPEN' + Math.random() + '\0';
|
|
4
|
+
const escClose = '\0CLOSE' + Math.random() + '\0';
|
|
5
|
+
const escComma = '\0COMMA' + Math.random() + '\0';
|
|
6
|
+
const escPeriod = '\0PERIOD' + Math.random() + '\0';
|
|
7
|
+
const escSlashPattern = new RegExp(escSlash, 'g');
|
|
8
|
+
const escOpenPattern = new RegExp(escOpen, 'g');
|
|
9
|
+
const escClosePattern = new RegExp(escClose, 'g');
|
|
10
|
+
const escCommaPattern = new RegExp(escComma, 'g');
|
|
11
|
+
const escPeriodPattern = new RegExp(escPeriod, 'g');
|
|
12
|
+
const slashPattern = /\\\\/g;
|
|
13
|
+
const openPattern = /\\{/g;
|
|
14
|
+
const closePattern = /\\}/g;
|
|
15
|
+
const commaPattern = /\\,/g;
|
|
16
|
+
const periodPattern = /\\\./g;
|
|
17
|
+
export const EXPANSION_MAX = 100_000;
|
|
18
|
+
// `EXPANSION_MAX` caps the *number* of expansions, but not their length. An
|
|
19
|
+
// input like `'{a,b}'.repeat(1500)` stays under that count - its output is
|
|
20
|
+
// truncated to 100k results - while making every result ~1500 characters
|
|
21
|
+
// long. The result set, and the intermediate arrays built while combining
|
|
22
|
+
// brace sets, then grow large enough to exhaust memory and crash the process
|
|
23
|
+
// (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of
|
|
24
|
+
// characters the accumulator may hold at any point, so memory stays flat no
|
|
25
|
+
// matter how many brace groups are chained. The limit sits well above any
|
|
26
|
+
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
|
27
|
+
// characters) so legitimate input is unaffected.
|
|
28
|
+
export const EXPANSION_MAX_LENGTH = 4_000_000;
|
|
29
|
+
function numeric(str) {
|
|
30
|
+
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
|
31
|
+
}
|
|
32
|
+
function escapeBraces(str) {
|
|
33
|
+
return str
|
|
34
|
+
.replace(slashPattern, escSlash)
|
|
35
|
+
.replace(openPattern, escOpen)
|
|
36
|
+
.replace(closePattern, escClose)
|
|
37
|
+
.replace(commaPattern, escComma)
|
|
38
|
+
.replace(periodPattern, escPeriod);
|
|
39
|
+
}
|
|
40
|
+
function unescapeBraces(str) {
|
|
41
|
+
return str
|
|
42
|
+
.replace(escSlashPattern, '\\')
|
|
43
|
+
.replace(escOpenPattern, '{')
|
|
44
|
+
.replace(escClosePattern, '}')
|
|
45
|
+
.replace(escCommaPattern, ',')
|
|
46
|
+
.replace(escPeriodPattern, '.');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Basically just str.split(","), but handling cases
|
|
50
|
+
* where we have nested braced sections, which should be
|
|
51
|
+
* treated as individual members, like {a,{b,c},d}
|
|
52
|
+
*/
|
|
53
|
+
function parseCommaParts(str) {
|
|
54
|
+
if (!str) {
|
|
55
|
+
return [''];
|
|
56
|
+
}
|
|
57
|
+
const parts = [];
|
|
58
|
+
const m = balanced('{', '}', str);
|
|
59
|
+
if (!m) {
|
|
60
|
+
return str.split(',');
|
|
61
|
+
}
|
|
62
|
+
const { pre, body, post } = m;
|
|
63
|
+
const p = pre.split(',');
|
|
64
|
+
p[p.length - 1] += '{' + body + '}';
|
|
65
|
+
const postParts = parseCommaParts(post);
|
|
66
|
+
if (post.length) {
|
|
67
|
+
;
|
|
68
|
+
p[p.length - 1] += postParts.shift();
|
|
69
|
+
p.push.apply(p, postParts);
|
|
70
|
+
}
|
|
71
|
+
parts.push.apply(parts, p);
|
|
72
|
+
return parts;
|
|
73
|
+
}
|
|
74
|
+
export function expand(str, options = {}) {
|
|
75
|
+
if (!str) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options;
|
|
79
|
+
// I don't know why Bash 4.3 does this, but it does.
|
|
80
|
+
// Anything starting with {} will have the first two bytes preserved
|
|
81
|
+
// but *only* at the top level, so {},a}b will not expand to anything,
|
|
82
|
+
// but a{},b}c will be expanded to [a}c,abc].
|
|
83
|
+
// One could argue that this is a bug in Bash, but since the goal of
|
|
84
|
+
// this module is to match Bash's rules, we escape a leading {}
|
|
85
|
+
if (str.slice(0, 2) === '{}') {
|
|
86
|
+
str = '\\{\\}' + str.slice(2);
|
|
87
|
+
}
|
|
88
|
+
return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
|
89
|
+
}
|
|
90
|
+
function embrace(str) {
|
|
91
|
+
return '{' + str + '}';
|
|
92
|
+
}
|
|
93
|
+
function isPadded(el) {
|
|
94
|
+
return /^-?0\d/.test(el);
|
|
95
|
+
}
|
|
96
|
+
function lte(i, y) {
|
|
97
|
+
return i <= y;
|
|
98
|
+
}
|
|
99
|
+
function gte(i, y) {
|
|
100
|
+
return i >= y;
|
|
101
|
+
}
|
|
102
|
+
// Build `{ acc[a] + pre + values[v] }` for every combination, capping the
|
|
103
|
+
// number of results at `max` and the total number of characters at `maxLength`.
|
|
104
|
+
// This is the one place output grows, so bounding it here keeps the single
|
|
105
|
+
// accumulator - and therefore memory - flat regardless of how many brace groups
|
|
106
|
+
// are combined (CVE-2026-14257).
|
|
107
|
+
function combine(acc, pre, values, max, maxLength, dropEmpties) {
|
|
108
|
+
const out = [];
|
|
109
|
+
let length = 0;
|
|
110
|
+
for (let a = 0; a < acc.length; a++) {
|
|
111
|
+
for (let v = 0; v < values.length; v++) {
|
|
112
|
+
if (out.length >= max)
|
|
113
|
+
return out;
|
|
114
|
+
const expansion = acc[a] + pre + values[v];
|
|
115
|
+
// Bash drops empty results at the top level. Skip them before they count
|
|
116
|
+
// against `max`, so `max` bounds the number of *kept* results.
|
|
117
|
+
if (dropEmpties && !expansion)
|
|
118
|
+
continue;
|
|
119
|
+
if (length + expansion.length > maxLength)
|
|
120
|
+
return out;
|
|
121
|
+
out.push(expansion);
|
|
122
|
+
length += expansion.length;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
// The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)
|
|
128
|
+
// sequence body.
|
|
129
|
+
function expandSequence(body, isAlphaSequence, max) {
|
|
130
|
+
const n = body.split(/\.\./);
|
|
131
|
+
const N = [];
|
|
132
|
+
// A sequence body always splits into two or three parts, but the compiler
|
|
133
|
+
// can't know that.
|
|
134
|
+
/* c8 ignore start */
|
|
135
|
+
if (n[0] === undefined || n[1] === undefined) {
|
|
136
|
+
return N;
|
|
137
|
+
}
|
|
138
|
+
/* c8 ignore stop */
|
|
139
|
+
const x = numeric(n[0]);
|
|
140
|
+
const y = numeric(n[1]);
|
|
141
|
+
const width = Math.max(n[0].length, n[1].length);
|
|
142
|
+
let incr = n.length === 3 && n[2] !== undefined ?
|
|
143
|
+
Math.max(Math.abs(numeric(n[2])), 1)
|
|
144
|
+
: 1;
|
|
145
|
+
let test = lte;
|
|
146
|
+
const reverse = y < x;
|
|
147
|
+
if (reverse) {
|
|
148
|
+
incr *= -1;
|
|
149
|
+
test = gte;
|
|
150
|
+
}
|
|
151
|
+
const pad = n.some(isPadded);
|
|
152
|
+
for (let i = x; test(i, y) && N.length < max; i += incr) {
|
|
153
|
+
let c;
|
|
154
|
+
if (isAlphaSequence) {
|
|
155
|
+
c = String.fromCharCode(i);
|
|
156
|
+
if (c === '\\') {
|
|
157
|
+
c = '';
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
c = String(i);
|
|
162
|
+
if (pad) {
|
|
163
|
+
const need = width - c.length;
|
|
164
|
+
if (need > 0) {
|
|
165
|
+
const z = new Array(need + 1).join('0');
|
|
166
|
+
if (i < 0) {
|
|
167
|
+
c = '-' + z + c.slice(1);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
c = z + c;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
N.push(c);
|
|
176
|
+
}
|
|
177
|
+
return N;
|
|
178
|
+
}
|
|
179
|
+
function expand_(str, max, maxLength, isTop) {
|
|
180
|
+
// Consume the string's top-level brace groups left to right, threading a
|
|
181
|
+
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
|
182
|
+
// rather than recursing on `m.post` once per group - keeps the native stack
|
|
183
|
+
// depth constant, so deeply chained input (`'{a,b}'.repeat(3000)`) can no
|
|
184
|
+
// longer overflow the stack, and leaves a single accumulator whose size
|
|
185
|
+
// `maxLength` bounds directly (CVE-2026-14257).
|
|
186
|
+
let acc = [''];
|
|
187
|
+
// Bash drops empty results, but only when the *first* top-level group is a
|
|
188
|
+
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
|
189
|
+
// is on the final strings, so it is applied to whichever `combine` produces
|
|
190
|
+
// them (the one with no brace set left in the tail).
|
|
191
|
+
let dropEmpties = false;
|
|
192
|
+
let firstGroup = true;
|
|
193
|
+
for (;;) {
|
|
194
|
+
const m = balanced('{', '}', str);
|
|
195
|
+
// No brace set left: the rest of the string is literal.
|
|
196
|
+
if (!m) {
|
|
197
|
+
return combine(acc, str, [''], max, maxLength, dropEmpties);
|
|
198
|
+
}
|
|
199
|
+
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
|
200
|
+
const pre = m.pre;
|
|
201
|
+
if (/\$$/.test(pre)) {
|
|
202
|
+
acc = combine(acc, pre + '{' + m.body + '}', [''], max, maxLength, dropEmpties && !m.post.length);
|
|
203
|
+
firstGroup = false;
|
|
204
|
+
if (!m.post.length)
|
|
205
|
+
break;
|
|
206
|
+
str = m.post;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
210
|
+
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
211
|
+
const isSequence = isNumericSequence || isAlphaSequence;
|
|
212
|
+
const isOptions = m.body.indexOf(',') >= 0;
|
|
213
|
+
if (!isSequence && !isOptions) {
|
|
214
|
+
// {a},b}
|
|
215
|
+
if (m.post.match(/,(?!,).*\}/)) {
|
|
216
|
+
str = m.pre + '{' + m.body + escClose + m.post;
|
|
217
|
+
isTop = true;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
// Nothing here expands, so the whole remaining string is literal.
|
|
221
|
+
return combine(acc, pre + '{' + m.body + '}' + m.post, [''], max, maxLength, dropEmpties);
|
|
222
|
+
}
|
|
223
|
+
if (firstGroup) {
|
|
224
|
+
dropEmpties = isTop && !isSequence;
|
|
225
|
+
firstGroup = false;
|
|
226
|
+
}
|
|
227
|
+
let values;
|
|
228
|
+
if (isSequence) {
|
|
229
|
+
values = expandSequence(m.body, isAlphaSequence, max);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
let n = parseCommaParts(m.body);
|
|
233
|
+
if (n.length === 1 && n[0] !== undefined) {
|
|
234
|
+
// x{{a,b}}y ==> x{a}y x{b}y
|
|
235
|
+
n = expand_(n[0], max, maxLength, false).map(embrace);
|
|
236
|
+
//XXX is this necessary? Can't seem to hit it in tests.
|
|
237
|
+
/* c8 ignore start */
|
|
238
|
+
if (n.length === 1) {
|
|
239
|
+
acc = combine(acc, pre + n[0], [''], max, maxLength, dropEmpties && !m.post.length);
|
|
240
|
+
if (!m.post.length)
|
|
241
|
+
break;
|
|
242
|
+
str = m.post;
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
/* c8 ignore stop */
|
|
246
|
+
}
|
|
247
|
+
values = [];
|
|
248
|
+
for (let j = 0; j < n.length; j++) {
|
|
249
|
+
values.push.apply(values, expand_(n[j], max, maxLength, false));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
|
|
253
|
+
if (!m.post.length)
|
|
254
|
+
break;
|
|
255
|
+
str = m.post;
|
|
256
|
+
}
|
|
257
|
+
return acc;
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAA;AACjD,MAAM,OAAO,GAAG,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAA;AAC/C,MAAM,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAA;AACjD,MAAM,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAA;AACjD,MAAM,SAAS,GAAG,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAA;AACnD,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjD,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;AAC/C,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjD,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjD,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;AACnD,MAAM,YAAY,GAAG,OAAO,CAAA;AAC5B,MAAM,WAAW,GAAG,MAAM,CAAA;AAC1B,MAAM,YAAY,GAAG,MAAM,CAAA;AAC3B,MAAM,YAAY,GA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D;gBACvD,qBAAqB;gBACrB,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACnB,GAAG,GAAG,OAAO,CACX,GAAG,EACH,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EACV,CAAC,EAAE,CAAC,EACJ,GAAG,EACH,SAAS,EACT,WAAW,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAC9B,CAAA;oBACD,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM;wBAAE,MAAK;oBACzB,GAAG,GAAG,CAAC,CAAC,IAAI,CAAA;oBACZ,SAAQ;gBACV,CAAC;gBACD,oBAAoB;YACtB,CAAC;YAED,MAAM,GAAG,EAAE,CAAA;YACX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAClC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAW,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAA;YAC3E,CAAC;QACH,CAAC;QAED,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC9E,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM;YAAE,MAAK;QACzB,GAAG,GAAG,CAAC,CAAC,IAAI,CAAA;IACd,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import { balanced } from 'balanced-match'\n\nconst escSlash = '\\0SLASH' + Math.random() + '\\0'\nconst escOpen = '\\0OPEN' + Math.random() + '\\0'\nconst escClose = '\\0CLOSE' + Math.random() + '\\0'\nconst escComma = '\\0COMMA' + Math.random() + '\\0'\nconst escPeriod = '\\0PERIOD' + Math.random() + '\\0'\nconst escSlashPattern = new RegExp(escSlash, 'g')\nconst escOpenPattern = new RegExp(escOpen, 'g')\nconst escClosePattern = new RegExp(escClose, 'g')\nconst escCommaPattern = new RegExp(escComma, 'g')\nconst escPeriodPattern = new RegExp(escPeriod, 'g')\nconst slashPattern = /\\\\\\\\/g\nconst openPattern = /\\\\{/g\nconst closePattern = /\\\\}/g\nconst commaPattern = /\\\\,/g\nconst periodPattern = /\\\\\\./g\n\nexport const EXPANSION_MAX = 100_000\n\n// `EXPANSION_MAX` caps the *number* of expansions, but not their length. An\n// input like `'{a,b}'.repeat(1500)` stays under that count - its output is\n// truncated to 100k results - while making every result ~1500 characters\n// long. The result set, and the intermediate arrays built while combining\n// brace sets, then grow large enough to exhaust memory and crash the process\n// (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of\n// characters the accumulator may hold at any point, so memory stays flat no\n// matter how many brace groups are chained. The limit sits well above any\n// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M\n// characters) so legitimate input is unaffected.\nexport const EXPANSION_MAX_LENGTH = 4_000_000\n\nfunction numeric(str: string) {\n return !isNaN(str as any) ? parseInt(str, 10) : str.charCodeAt(0)\n}\n\nfunction escapeBraces(str: string) {\n return str\n .replace(slashPattern, escSlash)\n .replace(openPattern, escOpen)\n .replace(closePattern, escClose)\n .replace(commaPattern, escComma)\n .replace(periodPattern, escPeriod)\n}\n\nfunction unescapeBraces(str: string) {\n return str\n .replace(escSlashPattern, '\\\\')\n .replace(escOpenPattern, '{')\n .replace(escClosePattern, '}')\n .replace(escCommaPattern, ',')\n .replace(escPeriodPattern, '.')\n}\n\n/**\n * Basically just str.split(\",\"), but handling cases\n * where we have nested braced sections, which should be\n * treated as individual members, like {a,{b,c},d}\n */\nfunction parseCommaParts(str: string) {\n if (!str) {\n return ['']\n }\n\n const parts: string[] = []\n const m = balanced('{', '}', str)\n\n if (!m) {\n return str.split(',')\n }\n\n const { pre, body, post } = m\n const p = pre.split(',')\n\n p[p.length - 1] += '{' + body + '}'\n const postParts = parseCommaParts(post)\n if (post.length) {\n ;(p[p.length - 1] as string) += postParts.shift()\n p.push.apply(p, postParts)\n }\n\n parts.push.apply(parts, p)\n\n return parts\n}\n\nexport type BraceExpansionOptions = {\n max?: number\n maxLength?: number\n}\n\nexport function expand(str: string, options: BraceExpansionOptions = {}) {\n if (!str) {\n return []\n }\n\n const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options\n\n // I don't know why Bash 4.3 does this, but it does.\n // Anything starting with {} will have the first two bytes preserved\n // but *only* at the top level, so {},a}b will not expand to anything,\n // but a{},b}c will be expanded to [a}c,abc].\n // One could argue that this is a bug in Bash, but since the goal of\n // this module is to match Bash's rules, we escape a leading {}\n if (str.slice(0, 2) === '{}') {\n str = '\\\\{\\\\}' + str.slice(2)\n }\n\n return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces)\n}\n\nfunction embrace(str: string) {\n return '{' + str + '}'\n}\n\nfunction isPadded(el: string) {\n return /^-?0\\d/.test(el)\n}\n\nfunction lte(i: number, y: number) {\n return i <= y\n}\n\nfunction gte(i: number, y: number) {\n return i >= y\n}\n\n// Build `{ acc[a] + pre + values[v] }` for every combination, capping the\n// number of results at `max` and the total number of characters at `maxLength`.\n// This is the one place output grows, so bounding it here keeps the single\n// accumulator - and therefore memory - flat regardless of how many brace groups\n// are combined (CVE-2026-14257).\nfunction combine(\n acc: string[],\n pre: string,\n values: string[],\n max: number,\n maxLength: number,\n dropEmpties: boolean,\n): string[] {\n const out: string[] = []\n let length = 0\n for (let a = 0; a < acc.length; a++) {\n for (let v = 0; v < values.length; v++) {\n if (out.length >= max) return out\n const expansion = (acc[a] as string) + pre + values[v]\n // Bash drops empty results at the top level. Skip them before they count\n // against `max`, so `max` bounds the number of *kept* results.\n if (dropEmpties && !expansion) continue\n if (length + expansion.length > maxLength) return out\n out.push(expansion)\n length += expansion.length\n }\n }\n return out\n}\n\n// The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)\n// sequence body.\nfunction expandSequence(\n body: string,\n isAlphaSequence: boolean,\n max: number,\n): string[] {\n const n = body.split(/\\.\\./)\n const N: string[] = []\n // A sequence body always splits into two or three parts, but the compiler\n // can't know that.\n /* c8 ignore start */\n if (n[0] === undefined || n[1] === undefined) {\n return N\n }\n /* c8 ignore stop */\n const x = numeric(n[0])\n const y = numeric(n[1])\n const width = Math.max(n[0].length, n[1].length)\n let incr =\n n.length === 3 && n[2] !== undefined ?\n Math.max(Math.abs(numeric(n[2])), 1)\n : 1\n let test = lte\n const reverse = y < x\n if (reverse) {\n incr *= -1\n test = gte\n }\n const pad = n.some(isPadded)\n\n for (let i = x; test(i, y) && N.length < max; i += incr) {\n let c\n if (isAlphaSequence) {\n c = String.fromCharCode(i)\n if (c === '\\\\') {\n c = ''\n }\n } else {\n c = String(i)\n if (pad) {\n const need = width - c.length\n if (need > 0) {\n const z = new Array(need + 1).join('0')\n if (i < 0) {\n c = '-' + z + c.slice(1)\n } else {\n c = z + c\n }\n }\n }\n }\n N.push(c)\n }\n return N\n}\n\nfunction expand_(\n str: string,\n max: number,\n maxLength: number,\n isTop: boolean,\n): string[] {\n // Consume the string's top-level brace groups left to right, threading a\n // running set of combined prefixes (`acc`). Expanding the tail iteratively -\n // rather than recursing on `m.post` once per group - keeps the native stack\n // depth constant, so deeply chained input (`'{a,b}'.repeat(3000)`) can no\n // longer overflow the stack, and leaves a single accumulator whose size\n // `maxLength` bounds directly (CVE-2026-14257).\n let acc: string[] = ['']\n\n // Bash drops empty results, but only when the *first* top-level group is a\n // comma set - a sequence like `{a..\\}` may legitimately yield ''. The drop\n // is on the final strings, so it is applied to whichever `combine` produces\n // them (the one with no brace set left in the tail).\n let dropEmpties = false\n let firstGroup = true\n\n for (;;) {\n const m = balanced('{', '}', str)\n\n // No brace set left: the rest of the string is literal.\n if (!m) {\n return combine(acc, str, [''], max, maxLength, dropEmpties)\n }\n\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n const pre = m.pre\n\n if (/\\$$/.test(pre)) {\n acc = combine(\n acc,\n pre + '{' + m.body + '}',\n [''],\n max,\n maxLength,\n dropEmpties && !m.post.length,\n )\n firstGroup = false\n if (!m.post.length) break\n str = m.post\n continue\n }\n\n const isNumericSequence = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(m.body)\n const isAlphaSequence = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(\n m.body,\n )\n const isSequence = isNumericSequence || isAlphaSequence\n const isOptions = m.body.indexOf(',') >= 0\n if (!isSequence && !isOptions) {\n // {a},b}\n if (m.post.match(/,(?!,).*\\}/)) {\n str = m.pre + '{' + m.body + escClose + m.post\n isTop = true\n continue\n }\n // Nothing here expands, so the whole remaining string is literal.\n return combine(\n acc,\n pre + '{' + m.body + '}' + m.post,\n [''],\n max,\n maxLength,\n dropEmpties,\n )\n }\n\n if (firstGroup) {\n dropEmpties = isTop && !isSequence\n firstGroup = false\n }\n\n let values: string[]\n if (isSequence) {\n values = expandSequence(m.body, isAlphaSequence, max)\n } else {\n let n = parseCommaParts(m.body)\n if (n.length === 1 && n[0] !== undefined) {\n // x{{a,b}}y ==> x{a}y x{b}y\n n = expand_(n[0], max, maxLength, false).map(embrace)\n //XXX is this necessary? Can't seem to hit it in tests.\n /* c8 ignore start */\n if (n.length === 1) {\n acc = combine(\n acc,\n pre + n[0],\n [''],\n max,\n maxLength,\n dropEmpties && !m.post.length,\n )\n if (!m.post.length) break\n str = m.post\n continue\n }\n /* c8 ignore stop */\n }\n\n values = []\n for (let j = 0; j < n.length; j++) {\n values.push.apply(values, expand_(n[j] as string, max, maxLength, false))\n }\n }\n\n acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length)\n if (!m.post.length) break\n str = m.post\n }\n\n return acc\n}\n"]}
|
|
@@ -98,21 +98,26 @@ function gte(i, y) {
|
|
|
98
98
|
function expand(str, max, isTop) {
|
|
99
99
|
var expansions = [];
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
101
|
+
// The `{a},b}` rewrite below restarts expansion on a rewritten string with
|
|
102
|
+
// the same `max` and `isTop = true`. Loop instead of recursing so a long run
|
|
103
|
+
// of non-expanding `{}` groups can't exhaust the call stack.
|
|
104
|
+
for (;;) {
|
|
105
|
+
const m = balanced('{', '}', str)
|
|
106
|
+
if (!m) return [str]
|
|
107
|
+
|
|
108
|
+
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
|
109
|
+
const pre = m.pre
|
|
110
|
+
|
|
111
|
+
if (/\$$/.test(m.pre)) {
|
|
112
|
+
const post =
|
|
113
|
+
m.post.length ? expand(m.post, max, false) : ['']
|
|
114
|
+
for (let k = 0; k < post.length && k < max; k++) {
|
|
115
|
+
const expansion = pre + '{' + m.body + '}' + post[k]
|
|
116
|
+
expansions.push(expansion)
|
|
117
|
+
}
|
|
118
|
+
return expansions
|
|
114
119
|
}
|
|
115
|
-
|
|
120
|
+
|
|
116
121
|
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
117
122
|
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
118
123
|
var isSequence = isNumericSequence || isAlphaSequence;
|
|
@@ -121,11 +126,18 @@ function expand(str, max, isTop) {
|
|
|
121
126
|
// {a},b}
|
|
122
127
|
if (m.post.match(/,(?!,).*\}/)) {
|
|
123
128
|
str = m.pre + '{' + m.body + escClose + m.post;
|
|
124
|
-
|
|
129
|
+
isTop = true;
|
|
130
|
+
continue;
|
|
125
131
|
}
|
|
126
132
|
return [str];
|
|
127
133
|
}
|
|
128
134
|
|
|
135
|
+
// Only expand post once we know this brace set actually expands. Computing
|
|
136
|
+
// it before the early returns above expanded post a second time on every
|
|
137
|
+
// non-expanding `{}`, which is what made inputs like `a{},{},{}...` blow up
|
|
138
|
+
// exponentially.
|
|
139
|
+
const post =
|
|
140
|
+
m.post.length ? expand(m.post, max, false) : ['']
|
|
129
141
|
var n;
|
|
130
142
|
if (isSequence) {
|
|
131
143
|
n = m.body.split(/\.\./);
|
|
@@ -199,7 +211,7 @@ function expand(str, max, isTop) {
|
|
|
199
211
|
expansions.push(expansion);
|
|
200
212
|
}
|
|
201
213
|
}
|
|
202
|
-
}
|
|
203
214
|
|
|
204
|
-
|
|
215
|
+
return expansions;
|
|
216
|
+
}
|
|
205
217
|
}
|
package/package.json
CHANGED
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"organization": false
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@cdk8s/projen-common": "^0.1.
|
|
50
|
+
"@cdk8s/projen-common": "^0.1.4",
|
|
51
51
|
"@stylistic/eslint-plugin": "^2",
|
|
52
52
|
"@types/jest": "^27",
|
|
53
53
|
"@types/node": "^18",
|
|
54
54
|
"@typescript-eslint/eslint-plugin": "^8",
|
|
55
55
|
"@typescript-eslint/parser": "^8",
|
|
56
|
-
"cdk8s": "2.70.
|
|
57
|
-
"cdk8s-cli": "^2.207.
|
|
56
|
+
"cdk8s": "2.70.83",
|
|
57
|
+
"cdk8s-cli": "^2.207.39",
|
|
58
58
|
"commit-and-tag-version": "^12",
|
|
59
59
|
"constructs": "10.3.0",
|
|
60
60
|
"eslint": "^9",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"publishConfig": {
|
|
105
105
|
"access": "public"
|
|
106
106
|
},
|
|
107
|
-
"version": "2.5.
|
|
107
|
+
"version": "2.5.81",
|
|
108
108
|
"jest": {
|
|
109
109
|
"coverageProvider": "v8",
|
|
110
110
|
"testMatch": [
|