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

推荐订阅源

D
DataBreaches.Net
F
Fortinet All Blogs
D
Docker
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
罗磊的独立博客
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
J
Java Code Geeks
T
The Blog of Author Tim Ferriss
U
Unit 42
N
Netflix TechBlog - Medium
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
云风的 BLOG
云风的 BLOG
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Stack Overflow Blog
Stack Overflow Blog
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Proofpoint News Feed
G
Google Developers Blog
H
Help Net Security

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(qqbot): bound token response bodies · openclaw/opencl...
vincentkoc · 2026-06-19 · via Recent Commits to openclaw:main

File tree

  • extensions/qqbot/src/engine/api

Original file line numberDiff line numberDiff line change

@@ -21,6 +21,33 @@ function mockGuardedTokenResponse(body: BodyInit, init?: ResponseInit): ReturnTy

2121

return release;

2222

}

2323
24+

function cancelTrackedResponse(

25+

text: string,

26+

init: ResponseInit,

27+

): {

28+

release: ReturnType<typeof vi.fn>;

29+

response: Response;

30+

wasCanceled: () => boolean;

31+

} {

32+

let canceled = false;

33+

const stream = new ReadableStream<Uint8Array>({

34+

start(controller) {

35+

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

36+

},

37+

cancel() {

38+

canceled = true;

39+

},

40+

});

41+

const release = vi.fn(async () => {});

42+

const response = new Response(stream, init);

43+

fetchWithSsrFGuardMock.mockResolvedValueOnce({ response, release });

44+

return {

45+

release,

46+

response,

47+

wasCanceled: () => canceled,

48+

};

49+

}

50+
2451

describe("QQBot token manager", () => {

2552

beforeEach(() => {

2653

fetchWithSsrFGuardMock.mockReset();

@@ -59,6 +86,25 @@ describe("QQBot token manager", () => {

5986

expect(release).toHaveBeenCalledTimes(1);

6087

});

6188
89+

it("bounds access token responses without using response.text()", async () => {

90+

const logger = { debug: vi.fn(), info: vi.fn(), error: vi.fn() };

91+

const tracked = cancelTrackedResponse(`${"qqbot token unavailable ".repeat(1024)}tail`, {

92+

status: 503,

93+

headers: { "content-type": "text/plain" },

94+

});

95+

const textSpy = vi.spyOn(tracked.response, "text").mockRejectedValue(new Error("unbounded"));

96+
97+

await expect(new TokenManager({ logger }).getAccessToken("app-id", "secret")).rejects.toThrow(

98+

"QQBot access_token response was malformed JSON",

99+

);

100+
101+

expect(tracked.wasCanceled()).toBe(true);

102+

expect(textSpy).not.toHaveBeenCalled();

103+

expect(tracked.release).toHaveBeenCalledTimes(1);

104+

expect(logger.debug.mock.calls.join("\n")).toContain("qqbot token unavailable");

105+

expect(logger.debug.mock.calls.join("\n")).not.toContain("tail");

106+

});

107+
62108

it("passes the RFC2544 SSRF allowance to the token fetch (regression for #88984)", async () => {

63109

mockGuardedTokenResponse('{"access_token":"token-1","expires_in":7200}', {

64110

status: 200,

Original file line numberDiff line numberDiff line change

@@ -12,12 +12,14 @@ import {

1212

resolveExpiresAtMsFromDurationSeconds,

1313

resolveTimestampMsToIsoString,

1414

} from "openclaw/plugin-sdk/number-runtime";

15+

import { readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";

1516

import { fetchWithSsrFGuard, type SsrFPolicy } from "openclaw/plugin-sdk/ssrf-runtime";

1617

import type { EngineLogger } from "../types.js";

1718

import { formatErrorMessage } from "../utils/format.js";

1819
1920

const TOKEN_URL = "https://bots.qq.com/app/getAppAccessToken";

2021

const DEFAULT_TOKEN_EXPIRES_IN_SECONDS = 7200;

22+

const QQBOT_TOKEN_RESPONSE_LIMIT_BYTES = 8 * 1024;

2123
2224

/**

2325

* Host-scoped SSRF policy for the QQ Bot token endpoint.

@@ -279,7 +281,7 @@ export class TokenManager {

279281
280282

let rawBody: string;

281283

try {

282-

rawBody = await response.text();

284+

rawBody = await readResponseTextLimited(response, QQBOT_TOKEN_RESPONSE_LIMIT_BYTES);

283285

} catch (err) {

284286

throw new Error(`Failed to read access_token response: ${formatErrorMessage(err)}`, {

285287

cause: err,