maka-agent 0.2.0-dev.64.20260929 → 0.2.0-dev.67.20261002
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/LICENSE +1 -1
- package/THIRD_PARTY_NOTICES.txt +3 -3
- package/dist/pi-tui-runner.js +26 -29
- package/dist/tui-copy-catalog.js +9 -9
- package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/settings.js +2 -2
- package/node_modules/@maka/core/dist/tool-ledger-scanner.js +53 -150
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +8 -1
- package/node_modules/@maka/runtime/dist/conversation-copy.js +6 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +17 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +25 -40
- package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +79 -13
- package/node_modules/@maka/runtime/dist/stream-graph-projection.js +64 -0
- package/node_modules/@maka/runtime/dist/stream-graph-read-model.js +138 -20
- package/node_modules/@maka/runtime/dist/tool-availability.js +10 -3
- package/node_modules/@maka/runtime-host/dist/candidate-entry.js +15 -0
- package/node_modules/@maka/runtime-host/dist/candidate-startup-failure.js +5 -0
- package/node_modules/@maka/runtime-host/dist/client/session-catalog-summary.js +1 -0
- package/node_modules/@maka/runtime-host/dist/client/startup-error.js +5 -0
- package/node_modules/@maka/runtime-host/dist/protocol/agent-graph.js +46 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +14 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +12 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-retirement.js +46 -10
- package/node_modules/@maka/runtime-host/dist/protocol/storage-usage.js +155 -0
- package/node_modules/@maka/runtime-host/dist/server/agent-graph-coordinator.js +23 -0
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +5 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +27 -6
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +112 -36
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +27 -1
- package/node_modules/@maka/runtime-host/dist/server/storage-usage-coordinator.js +67 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-inspection-tool.js +208 -0
- package/node_modules/@maka/storage/dist/git-worktree-child-executor.js +3 -1
- package/node_modules/@maka/storage/dist/operational-state-store.js +0 -13
- package/node_modules/@maka/storage/dist/session-store.js +9 -6
- package/node_modules/@maka/storage/dist/sqlite-file-set.js +22 -0
- package/node_modules/@maka/storage/dist/sqlite-long-term-memory-store.js +1 -3
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +10 -260
- package/node_modules/@maka/storage/dist/sqlite-session-catalog-query.js +1 -0
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +18 -6
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +28 -6
- package/node_modules/@maka/storage/dist/storage-footprint.js +239 -0
- package/node_modules/@maka/storage/dist/storage-writer-composition.js +10 -1
- package/node_modules/axios/CHANGELOG.md +62 -0
- package/node_modules/axios/README.md +297 -5
- package/node_modules/axios/dist/axios.js +728 -170
- package/node_modules/axios/dist/axios.min.js +3 -3
- package/node_modules/axios/dist/browser/axios.cjs +871 -188
- package/node_modules/axios/dist/esm/axios.js +871 -188
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/node/axios.cjs +1037 -225
- package/node_modules/axios/lib/adapters/fetch.js +64 -11
- package/node_modules/axios/lib/adapters/http.js +140 -67
- package/node_modules/axios/lib/adapters/xhr.js +52 -3
- package/node_modules/axios/lib/core/Axios.js +43 -20
- package/node_modules/axios/lib/core/AxiosError.js +33 -2
- package/node_modules/axios/lib/core/AxiosHeaders.js +124 -1
- package/node_modules/axios/lib/core/InterceptorManager.js +107 -8
- package/node_modules/axios/lib/core/buildFullPath.js +41 -15
- package/node_modules/axios/lib/core/dispatchRequest.js +8 -2
- package/node_modules/axios/lib/core/mergeConfig.js +19 -4
- package/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/axios/lib/core/setFormDataHeaders.js +27 -0
- package/node_modules/axios/lib/defaults/index.js +2 -1
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +12 -1
- package/node_modules/axios/lib/helpers/combineURLs.js +11 -3
- package/node_modules/axios/lib/helpers/composeSignals.js +12 -1
- package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +115 -54
- package/node_modules/axios/lib/helpers/formDataToJSON.js +11 -5
- package/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
- package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +5 -3
- package/node_modules/axios/lib/helpers/progressEventReducer.js +4 -4
- package/node_modules/axios/lib/helpers/resolveConfig.js +5 -17
- package/node_modules/axios/lib/helpers/shouldBypassProxy.js +300 -5
- package/node_modules/axios/lib/helpers/throttle.js +3 -2
- package/node_modules/axios/lib/helpers/toFormData.js +17 -23
- package/node_modules/axios/lib/platform/node/classes/Buffer.js +11 -0
- package/node_modules/axios/lib/utils.js +151 -18
- package/node_modules/axios/package.json +21 -19
- package/node_modules/brace-expansion/dist/commonjs/index.js +69 -25
- package/node_modules/brace-expansion/dist/esm/index.js +68 -24
- package/node_modules/brace-expansion/package.json +2 -1
- package/node_modules/fast-uri/index.js +10 -6
- package/node_modules/fast-uri/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axios",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "Promise based HTTP client for the browser and node.js",
|
|
5
5
|
"main": "./dist/node/axios.cjs",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -51,12 +51,14 @@
|
|
|
51
51
|
"./dist/node/axios.cjs": "./dist/browser/axios.cjs",
|
|
52
52
|
"./lib/adapters/http.js": "./lib/helpers/null.js",
|
|
53
53
|
"./lib/platform/node/index.js": "./lib/platform/browser/index.js",
|
|
54
|
+
"./lib/platform/node/classes/Buffer.js": "./lib/helpers/null.js",
|
|
54
55
|
"./lib/platform/node/classes/FormData.js": "./lib/helpers/null.js"
|
|
55
56
|
},
|
|
56
57
|
"react-native": {
|
|
57
58
|
"./dist/node/axios.cjs": "./dist/browser/axios.cjs",
|
|
58
59
|
"./lib/adapters/http.js": "./lib/helpers/null.js",
|
|
59
60
|
"./lib/platform/node/index.js": "./lib/platform/browser/index.js",
|
|
61
|
+
"./lib/platform/node/classes/Buffer.js": "./lib/helpers/null.js",
|
|
60
62
|
"./lib/platform/node/classes/FormData.js": "./lib/helpers/null.js"
|
|
61
63
|
},
|
|
62
64
|
"repository": {
|
|
@@ -114,7 +116,7 @@
|
|
|
114
116
|
"dist/node/axios.cjs"
|
|
115
117
|
],
|
|
116
118
|
"scripts": {
|
|
117
|
-
"build": "gulp clear && cross-env NODE_ENV=production rollup -c
|
|
119
|
+
"build": "gulp clear && cross-env NODE_ENV=production rollup -c",
|
|
118
120
|
"version": "npm run build && git add package.json",
|
|
119
121
|
"preversion": "gulp version",
|
|
120
122
|
"test": "npm run test:vitest",
|
|
@@ -138,50 +140,50 @@
|
|
|
138
140
|
},
|
|
139
141
|
"dependencies": {
|
|
140
142
|
"follow-redirects": "^1.16.0",
|
|
141
|
-
"form-data": "^4.0.
|
|
143
|
+
"form-data": "^4.0.6",
|
|
142
144
|
"https-proxy-agent": "^5.0.1",
|
|
143
145
|
"proxy-from-env": "^2.1.0"
|
|
144
146
|
},
|
|
145
147
|
"devDependencies": {
|
|
146
148
|
"@babel/core": "^7.29.0",
|
|
147
149
|
"@babel/preset-env": "^7.29.5",
|
|
148
|
-
"@commitlint/cli": "^21.0
|
|
149
|
-
"@commitlint/config-conventional": "^21.0
|
|
150
|
+
"@commitlint/cli": "^21.2.0",
|
|
151
|
+
"@commitlint/config-conventional": "^21.2.0",
|
|
150
152
|
"@eslint/js": "^10.0.1",
|
|
151
153
|
"@rollup/plugin-alias": "^6.0.0",
|
|
152
|
-
"@rollup/plugin-babel": "^7.
|
|
153
|
-
"@rollup/plugin-commonjs": "^29.0.
|
|
154
|
+
"@rollup/plugin-babel": "^7.1.0",
|
|
155
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
154
156
|
"@rollup/plugin-json": "^6.1.0",
|
|
155
157
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
156
158
|
"@rollup/plugin-terser": "^1.0.0",
|
|
157
|
-
"@vitest/browser": "^4.1.
|
|
158
|
-
"@vitest/browser-playwright": "^4.1.
|
|
159
|
+
"@vitest/browser": "^4.1.9",
|
|
160
|
+
"@vitest/browser-playwright": "^4.1.9",
|
|
159
161
|
"abortcontroller-polyfill": "^1.7.8",
|
|
160
|
-
"acorn": "^8.
|
|
161
|
-
"body-parser": "^2.
|
|
162
|
+
"acorn": "^8.17.0",
|
|
163
|
+
"body-parser": "^2.3.0",
|
|
162
164
|
"chalk": "^5.6.2",
|
|
163
165
|
"cross-env": "^10.1.0",
|
|
164
166
|
"dev-null": "^0.1.1",
|
|
165
|
-
"eslint": "^10.
|
|
167
|
+
"eslint": "^10.6.0",
|
|
166
168
|
"express": "^5.2.1",
|
|
167
169
|
"formdata-node": "^6.0.3",
|
|
168
170
|
"formidable": "^3.5.4",
|
|
169
|
-
"fs-extra": "^11.3.
|
|
171
|
+
"fs-extra": "^11.3.6",
|
|
170
172
|
"get-stream": "^9.0.1",
|
|
171
|
-
"globals": "^17.
|
|
173
|
+
"globals": "^17.7.0",
|
|
172
174
|
"gulp": "^5.0.1",
|
|
173
175
|
"husky": "^9.1.7",
|
|
174
|
-
"lint-staged": "^17.0.
|
|
176
|
+
"lint-staged": "^17.0.8",
|
|
175
177
|
"minimist": "^1.2.8",
|
|
176
|
-
"multer": "^2.
|
|
177
|
-
"playwright": "^1.
|
|
178
|
-
"prettier": "^3.
|
|
178
|
+
"multer": "^2.2.0",
|
|
179
|
+
"playwright": "^1.61.1",
|
|
180
|
+
"prettier": "^3.9.4",
|
|
179
181
|
"rollup": "^4.60.4",
|
|
180
182
|
"rollup-plugin-bundle-size": "^1.0.3",
|
|
181
183
|
"selfsigned": "^5.5.0",
|
|
182
184
|
"stream-throttle": "^0.1.3",
|
|
183
185
|
"typescript": "^5.9.3",
|
|
184
|
-
"vitest": "^4.1.
|
|
186
|
+
"vitest": "^4.1.9"
|
|
185
187
|
},
|
|
186
188
|
"commitlint": {
|
|
187
189
|
"rules": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EXPANSION_MAX_LENGTH = exports.EXPANSION_MAX = void 0;
|
|
3
|
+
exports.EXPANSION_MAX_REWRITES = exports.EXPANSION_MAX_DEPTH = exports.EXPANSION_MAX_LENGTH = exports.EXPANSION_MAX = void 0;
|
|
4
4
|
exports.expand = expand;
|
|
5
5
|
const balanced_match_1 = require("balanced-match");
|
|
6
6
|
const escSlash = '\0SLASH' + Math.random() + '\0';
|
|
@@ -30,6 +30,24 @@ exports.EXPANSION_MAX = 100_000;
|
|
|
30
30
|
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
|
31
31
|
// characters) so legitimate input is unaffected.
|
|
32
32
|
exports.EXPANSION_MAX_LENGTH = 4_000_000;
|
|
33
|
+
// `expand_` recurses once per level of brace *nesting* - both when expanding a
|
|
34
|
+
// set's comma members and when re-wrapping a set whose body is a single part.
|
|
35
|
+
// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
|
|
36
|
+
// level per chained group), which left nesting depth unbounded: about 3,100
|
|
37
|
+
// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
|
|
38
|
+
// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
|
|
39
|
+
// will follow nesting. It sits far above any realistic pattern and well below
|
|
40
|
+
// the depth at which the stack runs out.
|
|
41
|
+
exports.EXPANSION_MAX_DEPTH = 1_000;
|
|
42
|
+
// Bash keeps a quirk where a brace group followed by a comma set still expands
|
|
43
|
+
// (`{a},b}`). The parser implements it by rewriting the string and restarting
|
|
44
|
+
// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`
|
|
45
|
+
// full passes over a string that itself grows by one `escClose` sentinel each
|
|
46
|
+
// time - quadratic in `n`, with a ~26x constant from the sentinel's length.
|
|
47
|
+
// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27
|
|
48
|
+
// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many
|
|
49
|
+
// times the scan may restart. Real `{a},b}` input needs a handful.
|
|
50
|
+
exports.EXPANSION_MAX_REWRITES = 1_000;
|
|
33
51
|
function numeric(str) {
|
|
34
52
|
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
|
35
53
|
}
|
|
@@ -49,37 +67,52 @@ function unescapeBraces(str) {
|
|
|
49
67
|
.replace(escCommaPattern, ',')
|
|
50
68
|
.replace(escPeriodPattern, '.');
|
|
51
69
|
}
|
|
70
|
+
// Like `target.push(...items)` but doesn't overflow the stack
|
|
71
|
+
function pushAll(target, items) {
|
|
72
|
+
for (let i = 0; i < items.length; i++) {
|
|
73
|
+
target.push(items[i]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
52
76
|
/**
|
|
53
77
|
* Basically just str.split(","), but handling cases
|
|
54
78
|
* where we have nested braced sections, which should be
|
|
55
79
|
* treated as individual members, like {a,{b,c},d}
|
|
56
80
|
*/
|
|
57
81
|
function parseCommaParts(str) {
|
|
58
|
-
if (!str) {
|
|
59
|
-
return [''];
|
|
60
|
-
}
|
|
61
82
|
const parts = [];
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
// Walk the brace groups iteratively. Recursing on `post` once per group let a
|
|
84
|
+
// chain of them exhaust the stack - the parsing-side counterpart to
|
|
85
|
+
// the `expand_` overflow fixed for CVE-2026-14257, and not something `max` or
|
|
86
|
+
// `maxLength` can bound, since it happens before expansion.
|
|
87
|
+
//
|
|
88
|
+
// The part the next chunk continues
|
|
89
|
+
let carry = '';
|
|
90
|
+
for (;;) {
|
|
91
|
+
const m = (0, balanced_match_1.balanced)('{', '}', str);
|
|
92
|
+
if (!m) {
|
|
93
|
+
const tail = str.split(',');
|
|
94
|
+
tail[0] = carry + tail[0];
|
|
95
|
+
pushAll(parts, tail);
|
|
96
|
+
return parts;
|
|
97
|
+
}
|
|
98
|
+
const { pre, body, post } = m;
|
|
99
|
+
const p = pre.split(',');
|
|
100
|
+
p[0] = carry + p[0];
|
|
101
|
+
p[p.length - 1] += '{' + body + '}';
|
|
102
|
+
if (!post.length) {
|
|
103
|
+
pushAll(parts, p);
|
|
104
|
+
return parts;
|
|
105
|
+
}
|
|
106
|
+
carry = p.pop();
|
|
107
|
+
pushAll(parts, p);
|
|
108
|
+
str = post;
|
|
74
109
|
}
|
|
75
|
-
parts.push.apply(parts, p);
|
|
76
|
-
return parts;
|
|
77
110
|
}
|
|
78
111
|
function expand(str, options = {}) {
|
|
79
112
|
if (!str) {
|
|
80
113
|
return [];
|
|
81
114
|
}
|
|
82
|
-
const { max = exports.EXPANSION_MAX, maxLength = exports.EXPANSION_MAX_LENGTH } = options;
|
|
115
|
+
const { max = exports.EXPANSION_MAX, maxLength = exports.EXPANSION_MAX_LENGTH, maxDepth = exports.EXPANSION_MAX_DEPTH, maxRewrites = exports.EXPANSION_MAX_REWRITES, } = options;
|
|
83
116
|
// I don't know why Bash 4.3 does this, but it does.
|
|
84
117
|
// Anything starting with {} will have the first two bytes preserved
|
|
85
118
|
// but *only* at the top level, so {},a}b will not expand to anything,
|
|
@@ -89,7 +122,7 @@ function expand(str, options = {}) {
|
|
|
89
122
|
if (str.slice(0, 2) === '{}') {
|
|
90
123
|
str = '\\{\\}' + str.slice(2);
|
|
91
124
|
}
|
|
92
|
-
return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
|
125
|
+
return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
|
93
126
|
}
|
|
94
127
|
function embrace(str) {
|
|
95
128
|
return '{' + str + '}';
|
|
@@ -184,7 +217,13 @@ function expandSequence(body, isAlphaSequence, max, maxLength) {
|
|
|
184
217
|
}
|
|
185
218
|
return N;
|
|
186
219
|
}
|
|
187
|
-
function expand_(str, max, maxLength, isTop) {
|
|
220
|
+
function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|
221
|
+
// Too deeply nested to keep following: treat the rest as literal, the same
|
|
222
|
+
// way a group that cannot expand is already handled. Truncating rather than
|
|
223
|
+
// throwing keeps `expand` total, matching `max` and `maxLength`.
|
|
224
|
+
if (depth > maxDepth) {
|
|
225
|
+
return [str];
|
|
226
|
+
}
|
|
188
227
|
// Consume the string's top-level brace groups left to right, threading a
|
|
189
228
|
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
|
190
229
|
// rather than recursing on `m.post` once per group - keeps the native stack
|
|
@@ -196,6 +235,9 @@ function expand_(str, max, maxLength, isTop) {
|
|
|
196
235
|
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
|
197
236
|
// is on the final strings, so it is applied to whichever `combine` produces
|
|
198
237
|
// them (the one with no brace set left in the tail).
|
|
238
|
+
// How many times the `{a},b}` rewrite below has restarted the scan. Each pass
|
|
239
|
+
// re-reads the whole string, so leaving this unbounded is quadratic.
|
|
240
|
+
let rewrites = 0;
|
|
199
241
|
let dropEmpties = false;
|
|
200
242
|
let firstGroup = true;
|
|
201
243
|
for (;;) {
|
|
@@ -220,7 +262,8 @@ function expand_(str, max, maxLength, isTop) {
|
|
|
220
262
|
const isOptions = m.body.indexOf(',') >= 0;
|
|
221
263
|
if (!isSequence && !isOptions) {
|
|
222
264
|
// {a},b}
|
|
223
|
-
if (m.post.match(/,(?!,).*\}/)) {
|
|
265
|
+
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
|
266
|
+
rewrites++;
|
|
224
267
|
str = m.pre + '{' + m.body + escClose + m.post;
|
|
225
268
|
isTop = true;
|
|
226
269
|
continue;
|
|
@@ -240,7 +283,7 @@ function expand_(str, max, maxLength, isTop) {
|
|
|
240
283
|
let n = parseCommaParts(m.body);
|
|
241
284
|
if (n.length === 1 && n[0] !== undefined) {
|
|
242
285
|
// x{{a,b}}y ==> x{a}y x{b}y
|
|
243
|
-
n = expand_(n[0], max, maxLength, false).map(embrace);
|
|
286
|
+
n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
|
244
287
|
//XXX is this necessary? Can't seem to hit it in tests.
|
|
245
288
|
/* c8 ignore start */
|
|
246
289
|
if (n.length === 1) {
|
|
@@ -266,12 +309,13 @@ function expand_(str, max, maxLength, isTop) {
|
|
|
266
309
|
values = [];
|
|
267
310
|
let valuesLength = 0;
|
|
268
311
|
outer: for (let j = 0; j < n.length; j++) {
|
|
269
|
-
const expanded = expand_(n[j], max, maxLength, false);
|
|
312
|
+
const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
|
|
270
313
|
for (let k = 0; k < expanded.length; k++) {
|
|
271
314
|
const v = expanded[k];
|
|
272
315
|
if (dropsEmpties && !v)
|
|
273
316
|
continue;
|
|
274
|
-
if (values.length >= max ||
|
|
317
|
+
if (values.length >= max ||
|
|
318
|
+
valuesLength + v.length > maxLength) {
|
|
275
319
|
break outer;
|
|
276
320
|
}
|
|
277
321
|
values.push(v);
|
|
@@ -26,6 +26,24 @@ export const EXPANSION_MAX = 100_000;
|
|
|
26
26
|
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
|
27
27
|
// characters) so legitimate input is unaffected.
|
|
28
28
|
export const EXPANSION_MAX_LENGTH = 4_000_000;
|
|
29
|
+
// `expand_` recurses once per level of brace *nesting* - both when expanding a
|
|
30
|
+
// set's comma members and when re-wrapping a set whose body is a single part.
|
|
31
|
+
// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
|
|
32
|
+
// level per chained group), which left nesting depth unbounded: about 3,100
|
|
33
|
+
// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
|
|
34
|
+
// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
|
|
35
|
+
// will follow nesting. It sits far above any realistic pattern and well below
|
|
36
|
+
// the depth at which the stack runs out.
|
|
37
|
+
export const EXPANSION_MAX_DEPTH = 1_000;
|
|
38
|
+
// Bash keeps a quirk where a brace group followed by a comma set still expands
|
|
39
|
+
// (`{a},b}`). The parser implements it by rewriting the string and restarting
|
|
40
|
+
// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`
|
|
41
|
+
// full passes over a string that itself grows by one `escClose` sentinel each
|
|
42
|
+
// time - quadratic in `n`, with a ~26x constant from the sentinel's length.
|
|
43
|
+
// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27
|
|
44
|
+
// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many
|
|
45
|
+
// times the scan may restart. Real `{a},b}` input needs a handful.
|
|
46
|
+
export const EXPANSION_MAX_REWRITES = 1_000;
|
|
29
47
|
function numeric(str) {
|
|
30
48
|
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
|
31
49
|
}
|
|
@@ -45,37 +63,52 @@ function unescapeBraces(str) {
|
|
|
45
63
|
.replace(escCommaPattern, ',')
|
|
46
64
|
.replace(escPeriodPattern, '.');
|
|
47
65
|
}
|
|
66
|
+
// Like `target.push(...items)` but doesn't overflow the stack
|
|
67
|
+
function pushAll(target, items) {
|
|
68
|
+
for (let i = 0; i < items.length; i++) {
|
|
69
|
+
target.push(items[i]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
48
72
|
/**
|
|
49
73
|
* Basically just str.split(","), but handling cases
|
|
50
74
|
* where we have nested braced sections, which should be
|
|
51
75
|
* treated as individual members, like {a,{b,c},d}
|
|
52
76
|
*/
|
|
53
77
|
function parseCommaParts(str) {
|
|
54
|
-
if (!str) {
|
|
55
|
-
return [''];
|
|
56
|
-
}
|
|
57
78
|
const parts = [];
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
79
|
+
// Walk the brace groups iteratively. Recursing on `post` once per group let a
|
|
80
|
+
// chain of them exhaust the stack - the parsing-side counterpart to
|
|
81
|
+
// the `expand_` overflow fixed for CVE-2026-14257, and not something `max` or
|
|
82
|
+
// `maxLength` can bound, since it happens before expansion.
|
|
83
|
+
//
|
|
84
|
+
// The part the next chunk continues
|
|
85
|
+
let carry = '';
|
|
86
|
+
for (;;) {
|
|
87
|
+
const m = balanced('{', '}', str);
|
|
88
|
+
if (!m) {
|
|
89
|
+
const tail = str.split(',');
|
|
90
|
+
tail[0] = carry + tail[0];
|
|
91
|
+
pushAll(parts, tail);
|
|
92
|
+
return parts;
|
|
93
|
+
}
|
|
94
|
+
const { pre, body, post } = m;
|
|
95
|
+
const p = pre.split(',');
|
|
96
|
+
p[0] = carry + p[0];
|
|
97
|
+
p[p.length - 1] += '{' + body + '}';
|
|
98
|
+
if (!post.length) {
|
|
99
|
+
pushAll(parts, p);
|
|
100
|
+
return parts;
|
|
101
|
+
}
|
|
102
|
+
carry = p.pop();
|
|
103
|
+
pushAll(parts, p);
|
|
104
|
+
str = post;
|
|
70
105
|
}
|
|
71
|
-
parts.push.apply(parts, p);
|
|
72
|
-
return parts;
|
|
73
106
|
}
|
|
74
107
|
export function expand(str, options = {}) {
|
|
75
108
|
if (!str) {
|
|
76
109
|
return [];
|
|
77
110
|
}
|
|
78
|
-
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options;
|
|
111
|
+
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES, } = options;
|
|
79
112
|
// I don't know why Bash 4.3 does this, but it does.
|
|
80
113
|
// Anything starting with {} will have the first two bytes preserved
|
|
81
114
|
// but *only* at the top level, so {},a}b will not expand to anything,
|
|
@@ -85,7 +118,7 @@ export function expand(str, options = {}) {
|
|
|
85
118
|
if (str.slice(0, 2) === '{}') {
|
|
86
119
|
str = '\\{\\}' + str.slice(2);
|
|
87
120
|
}
|
|
88
|
-
return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
|
121
|
+
return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
|
89
122
|
}
|
|
90
123
|
function embrace(str) {
|
|
91
124
|
return '{' + str + '}';
|
|
@@ -180,7 +213,13 @@ function expandSequence(body, isAlphaSequence, max, maxLength) {
|
|
|
180
213
|
}
|
|
181
214
|
return N;
|
|
182
215
|
}
|
|
183
|
-
function expand_(str, max, maxLength, isTop) {
|
|
216
|
+
function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|
217
|
+
// Too deeply nested to keep following: treat the rest as literal, the same
|
|
218
|
+
// way a group that cannot expand is already handled. Truncating rather than
|
|
219
|
+
// throwing keeps `expand` total, matching `max` and `maxLength`.
|
|
220
|
+
if (depth > maxDepth) {
|
|
221
|
+
return [str];
|
|
222
|
+
}
|
|
184
223
|
// Consume the string's top-level brace groups left to right, threading a
|
|
185
224
|
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
|
186
225
|
// rather than recursing on `m.post` once per group - keeps the native stack
|
|
@@ -192,6 +231,9 @@ function expand_(str, max, maxLength, isTop) {
|
|
|
192
231
|
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
|
193
232
|
// is on the final strings, so it is applied to whichever `combine` produces
|
|
194
233
|
// them (the one with no brace set left in the tail).
|
|
234
|
+
// How many times the `{a},b}` rewrite below has restarted the scan. Each pass
|
|
235
|
+
// re-reads the whole string, so leaving this unbounded is quadratic.
|
|
236
|
+
let rewrites = 0;
|
|
195
237
|
let dropEmpties = false;
|
|
196
238
|
let firstGroup = true;
|
|
197
239
|
for (;;) {
|
|
@@ -216,7 +258,8 @@ function expand_(str, max, maxLength, isTop) {
|
|
|
216
258
|
const isOptions = m.body.indexOf(',') >= 0;
|
|
217
259
|
if (!isSequence && !isOptions) {
|
|
218
260
|
// {a},b}
|
|
219
|
-
if (m.post.match(/,(?!,).*\}/)) {
|
|
261
|
+
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
|
262
|
+
rewrites++;
|
|
220
263
|
str = m.pre + '{' + m.body + escClose + m.post;
|
|
221
264
|
isTop = true;
|
|
222
265
|
continue;
|
|
@@ -236,7 +279,7 @@ function expand_(str, max, maxLength, isTop) {
|
|
|
236
279
|
let n = parseCommaParts(m.body);
|
|
237
280
|
if (n.length === 1 && n[0] !== undefined) {
|
|
238
281
|
// x{{a,b}}y ==> x{a}y x{b}y
|
|
239
|
-
n = expand_(n[0], max, maxLength, false).map(embrace);
|
|
282
|
+
n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
|
240
283
|
//XXX is this necessary? Can't seem to hit it in tests.
|
|
241
284
|
/* c8 ignore start */
|
|
242
285
|
if (n.length === 1) {
|
|
@@ -262,12 +305,13 @@ function expand_(str, max, maxLength, isTop) {
|
|
|
262
305
|
values = [];
|
|
263
306
|
let valuesLength = 0;
|
|
264
307
|
outer: for (let j = 0; j < n.length; j++) {
|
|
265
|
-
const expanded = expand_(n[j], max, maxLength, false);
|
|
308
|
+
const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
|
|
266
309
|
for (let k = 0; k < expanded.length; k++) {
|
|
267
310
|
const v = expanded[k];
|
|
268
311
|
if (dropsEmpties && !v)
|
|
269
312
|
continue;
|
|
270
|
-
if (values.length >= max ||
|
|
313
|
+
if (values.length >= max ||
|
|
314
|
+
valuesLength + v.length > maxLength) {
|
|
271
315
|
break outer;
|
|
272
316
|
}
|
|
273
317
|
values.push(v);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brace-expansion",
|
|
3
3
|
"description": "Brace expansion as known from sh/bash",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.12",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
7
7
|
],
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"test": "tap",
|
|
30
30
|
"snap": "tap",
|
|
31
31
|
"format": "prettier --write .",
|
|
32
|
+
"format:check": "prettier --check .",
|
|
32
33
|
"benchmark": "node benchmark/index.js",
|
|
33
34
|
"typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts"
|
|
34
35
|
},
|
|
@@ -526,13 +526,17 @@ function parseWithStatus (uri, opts) {
|
|
|
526
526
|
malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP)
|
|
527
527
|
}
|
|
528
528
|
|
|
529
|
-
if (
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
529
|
+
if (uri.indexOf('%') !== -1 && parsed.host !== undefined && !malformedIPLiteral) {
|
|
530
|
+
let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true)
|
|
531
|
+
if (!isIP) {
|
|
532
|
+
// Fold reg-name case after decoding unreserved octets. The second
|
|
533
|
+
// pass only restores uppercase hex in escapes that remain encoded.
|
|
534
|
+
host = normalizePercentEncoding(host.toLowerCase())
|
|
535
535
|
}
|
|
536
|
+
parsed.host = reescapeHostDelimiters(host, isIP)
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
if (!schemeHandler || (schemeHandler && !schemeHandler.skipNormalize)) {
|
|
536
540
|
if (parsed.path) {
|
|
537
541
|
parsed.path = normalizePathEncoding(parsed.path)
|
|
538
542
|
}
|