惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
D
Docker
GbyAI
GbyAI
宝玉的分享
宝玉的分享
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Vercel News
Vercel News
博客园_首页
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
S
SegmentFault 最新的问题
Microsoft Security Blog
Microsoft Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
V
V2EX
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
IT之家
IT之家
Apple Machine Learning Research
Apple Machine Learning Research
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(matrix): bound non-raw JSON response body in transpor...
Alix-007 · 2026-06-24 · via Recent Commits to openclaw:main

@@ -195,6 +195,142 @@ describe("performMatrixRequest", () => {

195195

"MockAgent",

196196

);

197197

});

198+199+

it("rejects oversized JSON responses via content-length before buffering the body", async () => {

200+

const arrayBuffer = vi.fn(async () => new ArrayBuffer(0));

201+

stubRuntimeFetch(

202+

vi.fn(

203+

async () =>

204+

({

205+

ok: true,

206+

status: 200,

207+

headers: new Headers({

208+

"content-type": "application/json",

209+

"content-length": String(16 * 1024 * 1024),

210+

}),

211+

arrayBuffer,

212+

}) as unknown as Response,

213+

),

214+

);

215+216+

await expect(

217+

performMatrixRequest({

218+

homeserver: "http://127.0.0.1:8008",

219+

accessToken: "token",

220+

method: "GET",

221+

endpoint: "/_matrix/client/v3/account/whoami",

222+

timeoutMs: 5000,

223+

maxBytes: 1024,

224+

ssrfPolicy: { allowPrivateNetwork: true },

225+

}),

226+

).rejects.toThrow("Matrix JSON response exceeds configured size limit");

227+

expect(arrayBuffer).not.toHaveBeenCalled();

228+

});

229+230+

it("applies streaming byte limits when JSON responses omit content-length", async () => {

231+

const chunk = new Uint8Array(768);

232+

const stream = new ReadableStream<Uint8Array>({

233+

start(controller) {

234+

controller.enqueue(chunk);

235+

controller.enqueue(chunk);

236+

controller.close();

237+

},

238+

});

239+

stubRuntimeFetch(

240+

vi.fn(

241+

async () =>

242+

new Response(stream, {

243+

status: 200,

244+

headers: { "content-type": "application/json" },

245+

}),

246+

),

247+

);

248+249+

await expect(

250+

performMatrixRequest({

251+

homeserver: "http://127.0.0.1:8008",

252+

accessToken: "token",

253+

method: "GET",

254+

endpoint: "/_matrix/client/v3/account/whoami",

255+

timeoutMs: 5000,

256+

maxBytes: 1024,

257+

ssrfPolicy: { allowPrivateNetwork: true },

258+

}),

259+

).rejects.toThrow(

260+

"Matrix JSON response exceeds configured size limit (1536 bytes > 1024 bytes)",

261+

);

262+

});

263+264+

it("uses the configured idle-timeout error for stalled JSON downloads", async () => {

265+

vi.useFakeTimers();

266+

try {

267+

const stream = new ReadableStream<Uint8Array>({

268+

start(controller) {

269+

controller.enqueue(new Uint8Array([1, 2, 3]));

270+

},

271+

});

272+

stubRuntimeFetch(

273+

vi.fn(

274+

async () =>

275+

new Response(stream, {

276+

status: 200,

277+

headers: { "content-type": "application/json" },

278+

}),

279+

),

280+

);

281+282+

const requestPromise = performMatrixRequest({

283+

homeserver: "http://127.0.0.1:8008",

284+

accessToken: "token",

285+

method: "GET",

286+

endpoint: "/_matrix/client/v3/account/whoami",

287+

timeoutMs: 5000,

288+

maxBytes: 1024,

289+

readIdleTimeoutMs: 50,

290+

ssrfPolicy: { allowPrivateNetwork: true },

291+

});

292+293+

const rejection = expect(requestPromise).rejects.toThrow(

294+

"Matrix media download stalled: no data received for 50ms",

295+

);

296+

await vi.advanceTimersByTimeAsync(60);

297+

await rejection;

298+

} finally {

299+

vi.useRealTimers();

300+

}

301+

}, 5_000);

302+303+

it("returns full JSON bodies that stay under the byte limit", async () => {

304+

const payload = JSON.stringify({ ok: true, items: [1, 2, 3] });

305+

const stream = new ReadableStream<Uint8Array>({

306+

start(controller) {

307+

controller.enqueue(new TextEncoder().encode(payload));

308+

controller.close();

309+

},

310+

});

311+

stubRuntimeFetch(

312+

vi.fn(

313+

async () =>

314+

new Response(stream, {

315+

status: 200,

316+

headers: { "content-type": "application/json" },

317+

}),

318+

),

319+

);

320+321+

const result = await performMatrixRequest({

322+

homeserver: "http://127.0.0.1:8008",

323+

accessToken: "token",

324+

method: "GET",

325+

endpoint: "/_matrix/client/v3/account/whoami",

326+

timeoutMs: 5000,

327+

maxBytes: 1024,

328+

ssrfPolicy: { allowPrivateNetwork: true },

329+

});

330+331+

expect(result.text).toBe(payload);

332+

expect(result.buffer.toString("utf8")).toBe(payload);

333+

});

198334

});

199335200336

describe("createMatrixGuardedFetch", () => {