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

推荐订阅源

J
Java Code Geeks
F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
D
DataBreaches.Net
Stack Overflow Blog
Stack Overflow Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
B
Blog RSS Feed
I
InfoQ
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
H
Help Net Security
L
LangChain Blog
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
aimingoo的专栏
aimingoo的专栏

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(gateway): redact credential-bearing diagnostics · ope...
vincentkoc · 2026-05-17 · via Recent Commits to openclaw:main

@@ -4,13 +4,21 @@ import type { DeviceIdentity } from "../infra/device-identity.js";

44

import { captureEnv } from "../test-utils/env.js";

55

import { MIN_CLIENT_PROTOCOL_VERSION, PROTOCOL_VERSION } from "./protocol/index.js";

667+

type MockLoggingConfig = {

8+

redactPatterns?: string[];

9+

redactSensitive?: "off" | "tools";

10+

};

11+712

const wsInstances = vi.hoisted((): MockWebSocket[] => []);

813

const wsConstructorObservers = vi.hoisted((): Array<(url: string, options: unknown) => void> => []);

914

const clearDeviceAuthTokenMock = vi.hoisted(() => vi.fn());

1015

const loadDeviceAuthTokenMock = vi.hoisted(() => vi.fn());

1116

const storeDeviceAuthTokenMock = vi.hoisted(() => vi.fn());

1217

const logDebugMock = vi.hoisted(() => vi.fn());

1318

const logErrorMock = vi.hoisted(() => vi.fn());

19+

const readLoggingConfigMock = vi.hoisted(() =>

20+

vi.fn<() => MockLoggingConfig | undefined>(() => undefined),

21+

);

1422

const {

1523

installGlobalProxyMock,

1624

proxylineRegisterBypassMock,

@@ -167,6 +175,15 @@ vi.mock("../logger.js", async () => {

167175

};

168176

});

169177178+

vi.mock("../logging/config.js", async () => {

179+

const actual =

180+

await vi.importActual<typeof import("../logging/config.js")>("../logging/config.js");

181+

return {

182+

...actual,

183+

readLoggingConfig: () => readLoggingConfigMock(),

184+

};

185+

});

186+170187

type GatewayClientModule = typeof import("./client.js");

171188

type GatewayClientInstance = InstanceType<GatewayClientModule["GatewayClient"]>;

172189

@@ -820,6 +837,8 @@ describe("GatewayClient connect auth payload", () => {

820837

clearDeviceAuthTokenMock.mockReset();

821838

loadDeviceAuthTokenMock.mockReset();

822839

storeDeviceAuthTokenMock.mockReset();

840+

readLoggingConfigMock.mockReset();

841+

readLoggingConfigMock.mockReturnValue(undefined);

823842

logDebugMock.mockClear();

824843

logErrorMock.mockClear();

825844

});

@@ -1067,6 +1086,82 @@ describe("GatewayClient connect auth payload", () => {

10671086

expect(ws.closeCalls).toBe(1);

10681087

});

106910881089+

it("redacts secret-bearing connect failure logs", async () => {

1090+

const client = new GatewayClient({

1091+

url: "ws://127.0.0.1:18789",

1092+

token: "shared-token",

1093+

deviceIdentity: null,

1094+

});

1095+1096+

const { ws, connect } = startClientAndConnect({ client });

1097+

emitConnectFailure(

1098+

ws,

1099+

connect.id,

1100+

{ code: "AUTH_UNAUTHORIZED" },

1101+

"Authorization: Bearer sk-testsecret1234567890abcd wss://user:pass@gateway.example/ws?token=secret-token", // pragma: allowlist secret

1102+

);

1103+1104+

await vi.waitFor(() => {

1105+

expect(logErrorMock).toHaveBeenCalledWith(expect.stringContaining("gateway connect failed:"));

1106+

});

1107+

const logged = String(logErrorMock.mock.calls.at(-1)?.[0] ?? "");

1108+

expect(logged).toContain("Authorization: Bearer");

1109+

expect(logged).not.toContain("sk-testsecret1234567890abcd");

1110+

expect(logged).not.toContain("user:pass");

1111+

expect(logged).not.toContain("secret-token");

1112+

client.stop();

1113+

});

1114+1115+

it("preserves trailing diagnostics after redacted connect failure URL query params", async () => {

1116+

const client = new GatewayClient({

1117+

url: "ws://127.0.0.1:18789",

1118+

token: "shared-token",

1119+

deviceIdentity: null,

1120+

});

1121+1122+

const { ws, connect } = startClientAndConnect({ client });

1123+

emitConnectFailure(

1124+

ws,

1125+

connect.id,

1126+

{ code: "AUTH_UNAUTHORIZED" },

1127+

"wss://gateway.example/ws?token=secret-token failed with 401 from remote gateway", // pragma: allowlist secret

1128+

);

1129+1130+

await vi.waitFor(() => {

1131+

expect(logErrorMock).toHaveBeenCalledWith(expect.stringContaining("gateway connect failed:"));

1132+

});

1133+

const logged = String(logErrorMock.mock.calls.at(-1)?.[0] ?? "");

1134+

expect(logged).toContain("wss://gateway.example/ws?token=*** failed with 401");

1135+

expect(logged).toContain("from remote gateway");

1136+

expect(logged).not.toContain("secret-token");

1137+

client.stop();

1138+

});

1139+1140+

it("forces secret redaction for connect failure logs when general log redaction is off", async () => {

1141+

readLoggingConfigMock.mockReturnValue({ redactSensitive: "off" });

1142+

const client = new GatewayClient({

1143+

url: "ws://127.0.0.1:18789",

1144+

token: "shared-token",

1145+

deviceIdentity: null,

1146+

});

1147+1148+

const { ws, connect } = startClientAndConnect({ client });

1149+

emitConnectFailure(

1150+

ws,

1151+

connect.id,

1152+

{ code: "AUTH_UNAUTHORIZED" },

1153+

"Authorization: Bearer sk-disabledredaction1234567890abcd", // pragma: allowlist secret

1154+

);

1155+1156+

await vi.waitFor(() => {

1157+

expect(logErrorMock).toHaveBeenCalledWith(expect.stringContaining("gateway connect failed:"));

1158+

});

1159+

const logged = String(logErrorMock.mock.calls.at(-1)?.[0] ?? "");

1160+

expect(logged).toContain("Authorization: Bearer");

1161+

expect(logged).not.toContain("sk-disabledredaction1234567890abcd");

1162+

client.stop();

1163+

});

1164+10701165

it("uses explicit shared password and does not inject stored device token", () => {

10711166

loadDeviceAuthTokenMock.mockReturnValue({ token: "stored-device-token" });

10721167

const client = new GatewayClient({