mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 17:24:32 +00:00
fix: enforce strict allowlist across pairing stores (#23017)
This commit is contained in:
committed by
GitHub
parent
617e38cec0
commit
0bd9f0d4ac
@@ -56,6 +56,7 @@ export const normalizeAllowFrom = (list?: Array<string | number>): NormalizedAll
|
||||
export const normalizeAllowFromWithStore = (params: {
|
||||
allowFrom?: Array<string | number>;
|
||||
storeAllowFrom?: string[];
|
||||
dmPolicy?: string;
|
||||
}): NormalizedAllowFrom => normalizeAllowFrom(mergeAllowFromSources(params));
|
||||
|
||||
export const isSenderAllowed = (params: {
|
||||
|
||||
@@ -794,6 +794,7 @@ export const registerTelegramHandlers = ({
|
||||
const groupAllowContext = await resolveTelegramGroupAllowFromContext({
|
||||
chatId,
|
||||
accountId,
|
||||
dmPolicy: telegramCfg.dmPolicy ?? "pairing",
|
||||
isForum,
|
||||
messageThreadId,
|
||||
groupAllowFrom,
|
||||
@@ -807,11 +808,12 @@ export const registerTelegramHandlers = ({
|
||||
effectiveGroupAllow,
|
||||
hasGroupAllowOverride,
|
||||
} = groupAllowContext;
|
||||
const dmPolicy = telegramCfg.dmPolicy ?? "pairing";
|
||||
const effectiveDmAllow = normalizeAllowFromWithStore({
|
||||
allowFrom: telegramCfg.allowFrom,
|
||||
storeAllowFrom,
|
||||
dmPolicy,
|
||||
});
|
||||
const dmPolicy = telegramCfg.dmPolicy ?? "pairing";
|
||||
const senderId = callback.from?.id ? String(callback.from.id) : "";
|
||||
const senderUsername = callback.from?.username ?? "";
|
||||
if (
|
||||
@@ -1089,6 +1091,7 @@ export const registerTelegramHandlers = ({
|
||||
const groupAllowContext = await resolveTelegramGroupAllowFromContext({
|
||||
chatId: event.chatId,
|
||||
accountId,
|
||||
dmPolicy: telegramCfg.dmPolicy ?? "pairing",
|
||||
isForum: event.isForum,
|
||||
messageThreadId: event.messageThreadId,
|
||||
groupAllowFrom,
|
||||
|
||||
@@ -197,11 +197,12 @@ export const buildTelegramMessageContext = async ({
|
||||
: null;
|
||||
const sessionKey = threadKeys?.sessionKey ?? baseSessionKey;
|
||||
const mentionRegexes = buildMentionRegexes(cfg, route.agentId);
|
||||
const effectiveDmAllow = normalizeAllowFromWithStore({ allowFrom, storeAllowFrom });
|
||||
const effectiveDmAllow = normalizeAllowFromWithStore({ allowFrom, storeAllowFrom, dmPolicy });
|
||||
const groupAllowOverride = firstDefined(topicConfig?.allowFrom, groupConfig?.allowFrom);
|
||||
const effectiveGroupAllow = normalizeAllowFromWithStore({
|
||||
allowFrom: groupAllowOverride ?? groupAllowFrom,
|
||||
storeAllowFrom,
|
||||
dmPolicy,
|
||||
});
|
||||
const hasGroupAllowOverride = typeof groupAllowOverride !== "undefined";
|
||||
const senderId = msg.from?.id ? String(msg.from.id) : "";
|
||||
|
||||
@@ -167,6 +167,7 @@ async function resolveTelegramCommandAuth(params: {
|
||||
const groupAllowContext = await resolveTelegramGroupAllowFromContext({
|
||||
chatId,
|
||||
accountId,
|
||||
dmPolicy: telegramCfg.dmPolicy ?? "pairing",
|
||||
isForum,
|
||||
messageThreadId,
|
||||
groupAllowFrom,
|
||||
@@ -251,6 +252,7 @@ async function resolveTelegramCommandAuth(params: {
|
||||
const dmAllow = normalizeAllowFromWithStore({
|
||||
allowFrom: allowFrom,
|
||||
storeAllowFrom,
|
||||
dmPolicy: telegramCfg.dmPolicy ?? "pairing",
|
||||
});
|
||||
const senderAllowed = isSenderAllowed({
|
||||
allow: dmAllow,
|
||||
|
||||
@@ -20,6 +20,7 @@ export type TelegramThreadSpec = {
|
||||
export async function resolveTelegramGroupAllowFromContext(params: {
|
||||
chatId: string | number;
|
||||
accountId?: string;
|
||||
dmPolicy?: string;
|
||||
isForum?: boolean;
|
||||
messageThreadId?: number | null;
|
||||
groupAllowFrom?: Array<string | number>;
|
||||
@@ -53,6 +54,7 @@ export async function resolveTelegramGroupAllowFromContext(params: {
|
||||
const effectiveGroupAllow = normalizeAllowFromWithStore({
|
||||
allowFrom: groupAllowOverride ?? params.groupAllowFrom,
|
||||
storeAllowFrom,
|
||||
dmPolicy: params.dmPolicy,
|
||||
});
|
||||
const hasGroupAllowOverride = typeof groupAllowOverride !== "undefined";
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user