mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:11:23 +00:00
fix(security): harden account-key handling against prototype pollution
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
import type { ChannelId } from "../channels/plugins/types.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { findFenceSpanAt, isSafeFenceBreak, parseFenceSpans } from "../markdown/fences.js";
|
||||
import { resolveAccountEntry } from "../routing/account-lookup.js";
|
||||
import { normalizeAccountId } from "../routing/session-key.js";
|
||||
import { chunkTextByBreakResolver } from "../shared/text-chunking.js";
|
||||
import { INTERNAL_MESSAGE_CHANNEL } from "../utils/message-channel.js";
|
||||
@@ -39,17 +40,10 @@ function resolveChunkLimitForProvider(
|
||||
const normalizedAccountId = normalizeAccountId(accountId);
|
||||
const accounts = cfgSection.accounts;
|
||||
if (accounts && typeof accounts === "object") {
|
||||
const direct = accounts[normalizedAccountId];
|
||||
const direct = resolveAccountEntry(accounts, normalizedAccountId);
|
||||
if (typeof direct?.textChunkLimit === "number") {
|
||||
return direct.textChunkLimit;
|
||||
}
|
||||
const matchKey = Object.keys(accounts).find(
|
||||
(key) => key.toLowerCase() === normalizedAccountId.toLowerCase(),
|
||||
);
|
||||
const match = matchKey ? accounts[matchKey] : undefined;
|
||||
if (typeof match?.textChunkLimit === "number") {
|
||||
return match.textChunkLimit;
|
||||
}
|
||||
}
|
||||
return cfgSection.textChunkLimit;
|
||||
}
|
||||
@@ -89,17 +83,10 @@ function resolveChunkModeForProvider(
|
||||
const normalizedAccountId = normalizeAccountId(accountId);
|
||||
const accounts = cfgSection.accounts;
|
||||
if (accounts && typeof accounts === "object") {
|
||||
const direct = accounts[normalizedAccountId];
|
||||
const direct = resolveAccountEntry(accounts, normalizedAccountId);
|
||||
if (direct?.chunkMode) {
|
||||
return direct.chunkMode;
|
||||
}
|
||||
const matchKey = Object.keys(accounts).find(
|
||||
(key) => key.toLowerCase() === normalizedAccountId.toLowerCase(),
|
||||
);
|
||||
const match = matchKey ? accounts[matchKey] : undefined;
|
||||
if (match?.chunkMode) {
|
||||
return match.chunkMode;
|
||||
}
|
||||
}
|
||||
return cfgSection.chunkMode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user