fix(security): emit QQBot debug logs as sanitized lines · openclaw/openclaw@77f904d
vincentkoc
·
2026-04-30
·
via Recent Commits to openclaw:main
File tree
extensions/qqbot/src/engine/utils
| Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,6 @@ describe("QQBot debug logging", () => {
|
23 | 23 | |
24 | 24 | debugLog("prefix", "line one\nline two"); |
25 | 25 | |
26 | | -expect(logSpy).toHaveBeenCalledWith("prefix", "line one line two"); |
| 26 | +expect(logSpy).toHaveBeenCalledWith("prefix line one line two"); |
27 | 27 | }); |
28 | 28 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -35,27 +35,27 @@ export function sanitizeDebugLogValue(value: unknown): string {
|
35 | 35 | return `${sanitized.slice(0, MAX_LOG_VALUE_CHARS)}...`; |
36 | 36 | } |
37 | 37 | |
38 | | -function sanitizeDebugLogArgs(args: unknown[]): string[] { |
39 | | -return args.map(sanitizeDebugLogValue); |
| 38 | +function formatDebugLogArgs(args: unknown[]): string { |
| 39 | +return args.map(sanitizeDebugLogValue).join(" "); |
40 | 40 | } |
41 | 41 | |
42 | 42 | /** Debug-level log; only outputs when QQBOT_DEBUG is enabled. */ |
43 | 43 | export function debugLog(...args: unknown[]): void { |
44 | 44 | if (isDebug()) { |
45 | | -console.log(...sanitizeDebugLogArgs(args)); |
| 45 | +console.log(formatDebugLogArgs(args).replace(/[\r\n]/g, " ")); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** Debug-level warning; only outputs when QQBOT_DEBUG is enabled. */ |
50 | 50 | export function debugWarn(...args: unknown[]): void { |
51 | 51 | if (isDebug()) { |
52 | | -console.warn(...sanitizeDebugLogArgs(args)); |
| 52 | +console.warn(formatDebugLogArgs(args).replace(/[\r\n]/g, " ")); |
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | 56 | /** Debug-level error; only outputs when QQBOT_DEBUG is enabled. */ |
57 | 57 | export function debugError(...args: unknown[]): void { |
58 | 58 | if (isDebug()) { |
59 | | -console.error(...sanitizeDebugLogArgs(args)); |
| 59 | +console.error(formatDebugLogArgs(args).replace(/[\r\n]/g, " ")); |
60 | 60 | } |
61 | 61 | } |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。