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

推荐订阅源

IT之家
IT之家
腾讯CDC
博客园 - Franky
S
SegmentFault 最新的问题
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
J
Java Code Geeks
Y
Y Combinator Blog
Engineering at Meta
Engineering at Meta
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
I
InfoQ
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
B
Blog RSS Feed
博客园 - 叶小钗
博客园_首页
有赞技术团队
有赞技术团队
雷峰网
雷峰网
量子位
小众软件
小众软件
月光博客
月光博客
U
Unit 42
D
DataBreaches.Net

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: keep session history redaction forced · openclaw/ope...
steipete · 2026-04-28 · via Recent Commits to openclaw:main

@@ -0,0 +1,86 @@

1+

import fs from "node:fs";

2+

import os from "node:os";

3+

import path from "node:path";

4+

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

5+

import type { callGateway as gatewayCall } from "../../gateway/call.js";

6+7+

type CallGatewayRequest = Parameters<typeof gatewayCall>[0];

8+9+

let createSessionsHistoryTool: typeof import("./sessions-history-tool.js").createSessionsHistoryTool;

10+

let previousConfigPath: string | undefined;

11+

let tempDir: string | undefined;

12+13+

function useLoggingConfig(name: string, logging: Record<string, unknown>): void {

14+

if (!tempDir) {

15+

throw new Error("tempDir not initialized");

16+

}

17+

const configPath = path.join(tempDir, name);

18+

fs.writeFileSync(configPath, `${JSON.stringify({ logging })}\n`, "utf8");

19+

process.env.OPENCLAW_CONFIG_PATH = configPath;

20+

}

21+22+

function createHistoryToolWithMessage(content: string) {

23+

return createSessionsHistoryTool({

24+

config: {},

25+

callGateway: async <T = Record<string, unknown>>(request: CallGatewayRequest): Promise<T> => {

26+

if (request.method === "chat.history") {

27+

return {

28+

messages: [

29+

{

30+

role: "user",

31+

content,

32+

},

33+

],

34+

} as T;

35+

}

36+

return {} as T;

37+

},

38+

});

39+

}

40+41+

describe("sessions_history redaction", () => {

42+

beforeAll(async () => {

43+

previousConfigPath = process.env.OPENCLAW_CONFIG_PATH;

44+

tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-sessions-history-redact-"));

45+

useLoggingConfig("redaction-off.json", { redactSensitive: "off" });

46+

({ createSessionsHistoryTool } = await import("./sessions-history-tool.js"));

47+

});

48+49+

afterAll(() => {

50+

if (previousConfigPath === undefined) {

51+

delete process.env.OPENCLAW_CONFIG_PATH;

52+

} else {

53+

process.env.OPENCLAW_CONFIG_PATH = previousConfigPath;

54+

}

55+

if (tempDir) {

56+

fs.rmSync(tempDir, { recursive: true, force: true });

57+

}

58+

});

59+60+

it("redacts recalled session text even when log redaction is disabled", async () => {

61+

useLoggingConfig("redaction-off.json", { redactSensitive: "off" });

62+

const tool = createHistoryToolWithMessage("OPENROUTER_API_KEY=sk-or-v1-abcdef0123456789");

63+64+

const result = await tool.execute("call-1", { sessionKey: "main" });

65+

const serialized = JSON.stringify(result.details);

66+67+

expect(serialized).not.toContain("sk-or-v1-abcdef0123456789");

68+

expect(serialized).toContain("OPENROUTER_API_KEY=");

69+

expect(result.details).toMatchObject({ contentRedacted: true });

70+

});

71+72+

it("applies custom redaction patterns to recalled session text", async () => {

73+

useLoggingConfig("custom-patterns.json", {

74+

redactSensitive: "off",

75+

redactPatterns: [String.raw`\binternal-ticket-[A-Za-z0-9]+\b`],

76+

});

77+

const tool = createHistoryToolWithMessage("follow up on internal-ticket-AbC12345");

78+79+

const result = await tool.execute("call-1", { sessionKey: "main" });

80+

const serialized = JSON.stringify(result.details);

81+82+

expect(serialized).not.toContain("internal-ticket-AbC12345");

83+

expect(serialized).toContain("intern");

84+

expect(result.details).toMatchObject({ contentRedacted: true });

85+

});

86+

});