fix(security): align QQBot log sanitizer with CodeQL

Aligns QQBot debug log newline removal with the CodeQL js/log-injection sanitizer model to close alert 232.
This commit is contained in:
Vincent Koc
2026-04-30 01:10:26 -07:00
committed by GitHub
parent 914287642d
commit f31311d104

View File

@@ -42,20 +42,20 @@ function formatDebugLogArgs(args: unknown[]): string {
/** Debug-level log; only outputs when QQBOT_DEBUG is enabled. */
export function debugLog(...args: unknown[]): void {
if (isDebug()) {
console.log(formatDebugLogArgs(args).replace(/[\r\n]/g, " "));
console.log(formatDebugLogArgs(args).replace(/\n|\r/g, ""));
}
}
/** Debug-level warning; only outputs when QQBOT_DEBUG is enabled. */
export function debugWarn(...args: unknown[]): void {
if (isDebug()) {
console.warn(formatDebugLogArgs(args).replace(/[\r\n]/g, " "));
console.warn(formatDebugLogArgs(args).replace(/\n|\r/g, ""));
}
}
/** Debug-level error; only outputs when QQBOT_DEBUG is enabled. */
export function debugError(...args: unknown[]): void {
if (isDebug()) {
console.error(formatDebugLogArgs(args).replace(/[\r\n]/g, " "));
console.error(formatDebugLogArgs(args).replace(/\n|\r/g, ""));
}
}