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

推荐订阅源

爱范儿
爱范儿
博客园_首页
U
Unit 42
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
MongoDB | Blog
MongoDB | Blog
美团技术团队
H
Help Net Security
G
Google Developers Blog
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
aimingoo的专栏
aimingoo的专栏
Google DeepMind News
Google DeepMind News
J
Java Code Geeks
M
MIT News - Artificial intelligence
腾讯CDC
IT之家
IT之家
Vercel News
Vercel News
C
Check Point Blog
博客园 - 三生石上(FineUI控件)
Last Week in AI
Last Week in AI
I
InfoQ
博客园 - 司徒正美
A
About on SuperTechFans

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(ui): order live chat items by timestamp (#81016) · op...
akrimm702 · 2026-05-14 · via Recent Commits to openclaw:main

@@ -1,6 +1,7 @@

11

import crypto from "node:crypto";

22

import { afterAll, beforeAll, describe, expect, test, vi } from "vitest";

33

import { WebSocket } from "ws";

4+

import { writeConfigFile } from "../config/config.js";

45

import {

56

deriveDeviceIdFromPublicKey,

67

type DeviceIdentity,

@@ -174,7 +175,17 @@ describe("node.invoke approval bypass", () => {

174175

let port: number;

175176176177

beforeAll(async () => {

177-

const started = await startServerWithClient("secret", { controlUiEnabled: true });

178+

await writeConfigFile({

179+

gateway: {

180+

nodes: {

181+

pairing: { autoApproveCidrs: ["127.0.0.1/32", "::1/128"] },

182+

allowCommands: ["system.run", "system.run.prepare", "system.which"],

183+

},

184+

},

185+

});

186+

const started = await startServerWithClient("secret", {

187+

controlUiEnabled: true,

188+

});

178189

server = started.server;

179190

port = started.port;

180191

started.ws.close();

@@ -186,12 +197,19 @@ describe("node.invoke approval bypass", () => {

186197187198

const approveAllPendingPairings = async () => {

188199

const { approveDevicePairing, listDevicePairing } = await import("../infra/device-pairing.js");

189-

const list = await listDevicePairing();

190-

for (const pending of list.pending) {

200+

const { approveNodePairing, listNodePairing } = await import("../infra/node-pairing.js");

201+

const deviceList = await listDevicePairing();

202+

for (const pending of deviceList.pending) {

191203

await approveDevicePairing(pending.requestId, {

192204

callerScopes: pending.scopes ?? ["operator.admin"],

193205

});

194206

}

207+

const nodeList = await listNodePairing();

208+

for (const pending of nodeList.pending) {

209+

await approveNodePairing(pending.requestId, {

210+

callerScopes: ["operator.admin"],

211+

});

212+

}

195213

};

196214197215

const connectOperatorWithRetry = async (

@@ -299,67 +317,75 @@ describe("node.invoke approval bypass", () => {

299317

deviceIdentity?: DeviceIdentity,

300318

commands: string[] = ["system.run"],

301319

) => {

302-

let readyResolve: (() => void) | null = null;

303-

const ready = new Promise<void>((resolve) => {

304-

readyResolve = resolve;

305-

});

306-307320

const resolvedDeviceIdentity = deviceIdentity ?? createDeviceIdentity();

308-

const client = new GatewayClient({

309-

url: `ws://127.0.0.1:${port}`,

310-

// Keep challenge timeout realistic in tests; 0 maps to a 250ms timeout and can

311-

// trigger reconnect backoff loops under load.

312-

connectChallengeTimeoutMs: 2_000,

313-

token: "secret",

314-

role: "node",

315-

clientName: GATEWAY_CLIENT_NAMES.NODE_HOST,

316-

clientVersion: "1.0.0",

317-

platform: "linux",

318-

mode: GATEWAY_CLIENT_MODES.NODE,

319-

scopes: [],

320-

commands,

321-

deviceIdentity: resolvedDeviceIdentity,

322-

onHelloOk: () => readyResolve?.(),

323-

onEvent: (evt) => {

324-

if (evt.event !== "node.invoke.request") {

325-

return;

326-

}

327-

onInvoke(evt.payload);

328-

const payload = evt.payload as {

329-

id?: string;

330-

nodeId?: string;

331-

};

332-

const id = typeof payload?.id === "string" ? payload.id : "";

333-

const nodeId = typeof payload?.nodeId === "string" ? payload.nodeId : "";

334-

if (!id || !nodeId) {

335-

return;

321+322+

const startNodeClient = async () => {

323+

let readyResolve: (() => void) | null = null;

324+

const ready = new Promise<void>((resolve) => {

325+

readyResolve = resolve;

326+

});

327+

const client = new GatewayClient({

328+

url: `ws://127.0.0.1:${port}`,

329+

// Keep challenge timeout realistic in tests; 0 maps to a 250ms timeout and can

330+

// trigger reconnect backoff loops under load.

331+

connectChallengeTimeoutMs: 2_000,

332+

token: "secret",

333+

role: "node",

334+

clientName: GATEWAY_CLIENT_NAMES.NODE_HOST,

335+

clientVersion: "1.0.0",

336+

platform: "linux",

337+

mode: GATEWAY_CLIENT_MODES.NODE,

338+

scopes: [],

339+

caps: ["system"],

340+

commands,

341+

deviceIdentity: resolvedDeviceIdentity,

342+

onHelloOk: () => readyResolve?.(),

343+

onEvent: (evt) => {

344+

if (evt.event !== "node.invoke.request") {

345+

return;

346+

}

347+

onInvoke(evt.payload);

348+

const payload = evt.payload as {

349+

id?: string;

350+

nodeId?: string;

351+

};

352+

const id = typeof payload?.id === "string" ? payload.id : "";

353+

const nodeId = typeof payload?.nodeId === "string" ? payload.nodeId : "";

354+

if (!id || !nodeId) {

355+

return;

356+

}

357+

void client.request("node.invoke.result", {

358+

id,

359+

nodeId,

360+

ok: true,

361+

payloadJSON: JSON.stringify({ ok: true }),

362+

});

363+

},

364+

});

365+

client.start();

366+

let timer: NodeJS.Timeout | undefined;

367+

try {

368+

await Promise.race([

369+

ready,

370+

new Promise<never>((_, reject) => {

371+

timer = setTimeout(

372+

() => reject(new Error("timeout waiting for node to connect")),

373+

NODE_CONNECT_TIMEOUT_MS,

374+

);

375+

}),

376+

]);

377+

} finally {

378+

if (timer) {

379+

clearTimeout(timer);

336380

}

337-

void client.request("node.invoke.result", {

338-

id,

339-

nodeId,

340-

ok: true,

341-

payloadJSON: JSON.stringify({ ok: true }),

342-

});

343-

},

344-

});

345-

client.start();

346-

let timer: NodeJS.Timeout | undefined;

347-

try {

348-

await Promise.race([

349-

ready,

350-

new Promise<never>((_, reject) => {

351-

timer = setTimeout(

352-

() => reject(new Error("timeout waiting for node to connect")),

353-

NODE_CONNECT_TIMEOUT_MS,

354-

);

355-

}),

356-

]);

357-

} finally {

358-

if (timer) {

359-

clearTimeout(timer);

360381

}

361-

}

362-

return client;

382+

return client;

383+

};

384+385+

const pendingClient = await startNodeClient();

386+

await approveAllPendingPairings();

387+

pendingClient.stop();

388+

return await startNodeClient();

363389

};

364390365391

test("rejects malformed/forbidden node.invoke payloads before forwarding", async () => {