mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 21:51:24 +00:00
fix(security): make allowFrom id-only by default with dangerous name opt-in (#24907)
* fix(channels): default allowFrom to id-only; add dangerous name opt-in * docs(security): align channel allowFrom docs with id-only default
This commit is contained in:
committed by
GitHub
parent
41b0568b35
commit
cfa44ea6b4
@@ -184,7 +184,7 @@ describe("discord allowlist helpers", () => {
|
||||
expect(normalizeDiscordSlug("Dev__Chat")).toBe("dev-chat");
|
||||
});
|
||||
|
||||
it("matches ids or names", () => {
|
||||
it("matches ids by default and names only when enabled", () => {
|
||||
const allow = normalizeDiscordAllowList(
|
||||
["123", "steipete", "Friends of OpenClaw"],
|
||||
["discord:", "user:", "guild:", "channel:"],
|
||||
@@ -194,8 +194,12 @@ describe("discord allowlist helpers", () => {
|
||||
throw new Error("Expected allow list to be normalized");
|
||||
}
|
||||
expect(allowListMatches(allow, { id: "123" })).toBe(true);
|
||||
expect(allowListMatches(allow, { name: "steipete" })).toBe(true);
|
||||
expect(allowListMatches(allow, { name: "friends-of-openclaw" })).toBe(true);
|
||||
expect(allowListMatches(allow, { name: "steipete" })).toBe(false);
|
||||
expect(allowListMatches(allow, { name: "friends-of-openclaw" })).toBe(false);
|
||||
expect(allowListMatches(allow, { name: "steipete" }, { allowNameMatching: true })).toBe(true);
|
||||
expect(
|
||||
allowListMatches(allow, { name: "friends-of-openclaw" }, { allowNameMatching: true }),
|
||||
).toBe(true);
|
||||
expect(allowListMatches(allow, { name: "other" })).toBe(false);
|
||||
});
|
||||
|
||||
@@ -750,6 +754,31 @@ describe("discord reaction notification gating", () => {
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "allowlist mode does not match usernames by default",
|
||||
input: {
|
||||
mode: "allowlist" as const,
|
||||
botId: "bot-1",
|
||||
messageAuthorId: "user-1",
|
||||
userId: "999",
|
||||
userName: "trusted-user",
|
||||
allowlist: ["trusted-user"] as string[],
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "allowlist mode matches usernames when explicitly enabled",
|
||||
input: {
|
||||
mode: "allowlist" as const,
|
||||
botId: "bot-1",
|
||||
messageAuthorId: "user-1",
|
||||
userId: "999",
|
||||
userName: "trusted-user",
|
||||
allowlist: ["trusted-user"] as string[],
|
||||
allowNameMatching: true,
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
]);
|
||||
|
||||
for (const testCase of cases) {
|
||||
@@ -870,6 +899,7 @@ function makeReactionClient(options?: {
|
||||
|
||||
function makeReactionListenerParams(overrides?: {
|
||||
botUserId?: string;
|
||||
allowNameMatching?: boolean;
|
||||
guildEntries?: Record<string, DiscordGuildEntryResolved>;
|
||||
}) {
|
||||
return {
|
||||
@@ -877,6 +907,7 @@ function makeReactionListenerParams(overrides?: {
|
||||
accountId: "acc-1",
|
||||
runtime: {} as import("../runtime.js").RuntimeEnv,
|
||||
botUserId: overrides?.botUserId ?? "bot-1",
|
||||
allowNameMatching: overrides?.allowNameMatching ?? false,
|
||||
guildEntries: overrides?.guildEntries,
|
||||
logger: {
|
||||
info: vi.fn(),
|
||||
|
||||
@@ -237,6 +237,7 @@ async function ensureGuildComponentMemberAllowed(params: {
|
||||
replyOpts: { ephemeral?: boolean };
|
||||
componentLabel: string;
|
||||
unauthorizedReply: string;
|
||||
allowNameMatching: boolean;
|
||||
}): Promise<boolean> {
|
||||
const {
|
||||
interaction,
|
||||
@@ -275,6 +276,7 @@ async function ensureGuildComponentMemberAllowed(params: {
|
||||
name: user.username,
|
||||
tag: user.discriminator ? `${user.username}#${user.discriminator}` : undefined,
|
||||
},
|
||||
allowNameMatching: params.allowNameMatching,
|
||||
});
|
||||
if (memberAllowed) {
|
||||
return true;
|
||||
@@ -299,6 +301,7 @@ async function ensureComponentUserAllowed(params: {
|
||||
replyOpts: { ephemeral?: boolean };
|
||||
componentLabel: string;
|
||||
unauthorizedReply: string;
|
||||
allowNameMatching: boolean;
|
||||
}): Promise<boolean> {
|
||||
const allowList = normalizeDiscordAllowList(params.entry.allowedUsers, [
|
||||
"discord:",
|
||||
@@ -315,6 +318,7 @@ async function ensureComponentUserAllowed(params: {
|
||||
name: params.user.username,
|
||||
tag: formatDiscordUserTag(params.user),
|
||||
},
|
||||
allowNameMatching: params.allowNameMatching,
|
||||
});
|
||||
if (match.allowed) {
|
||||
return true;
|
||||
@@ -361,6 +365,7 @@ async function ensureAgentComponentInteractionAllowed(params: {
|
||||
replyOpts: params.replyOpts,
|
||||
componentLabel: params.componentLabel,
|
||||
unauthorizedReply: params.unauthorizedReply,
|
||||
allowNameMatching: params.ctx.discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
});
|
||||
if (!memberAllowed) {
|
||||
return null;
|
||||
@@ -476,6 +481,7 @@ async function ensureDmComponentAuthorized(params: {
|
||||
name: user.username,
|
||||
tag: formatDiscordUserTag(user),
|
||||
},
|
||||
allowNameMatching: ctx.discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
})
|
||||
: { allowed: false };
|
||||
if (allowMatch.allowed) {
|
||||
@@ -778,6 +784,7 @@ async function dispatchDiscordComponentEvent(params: {
|
||||
channelConfig,
|
||||
guildInfo,
|
||||
sender: { id: interactionCtx.user.id, name: interactionCtx.user.username, tag: senderTag },
|
||||
allowNameMatching: ctx.discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
});
|
||||
const storePath = resolveStorePath(ctx.cfg.session?.store, { agentId });
|
||||
const envelopeOptions = resolveEnvelopeFormatOptions(ctx.cfg);
|
||||
@@ -975,6 +982,7 @@ async function handleDiscordComponentEvent(params: {
|
||||
replyOpts,
|
||||
componentLabel: params.componentLabel,
|
||||
unauthorizedReply,
|
||||
allowNameMatching: params.ctx.discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
});
|
||||
if (!memberAllowed) {
|
||||
return;
|
||||
@@ -987,6 +995,7 @@ async function handleDiscordComponentEvent(params: {
|
||||
replyOpts,
|
||||
componentLabel: params.componentLabel,
|
||||
unauthorizedReply,
|
||||
allowNameMatching: params.ctx.discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
});
|
||||
if (!componentAllowed) {
|
||||
return;
|
||||
@@ -1125,6 +1134,7 @@ async function handleDiscordModalTrigger(params: {
|
||||
replyOpts,
|
||||
componentLabel: "form",
|
||||
unauthorizedReply,
|
||||
allowNameMatching: params.ctx.discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
});
|
||||
if (!memberAllowed) {
|
||||
return;
|
||||
@@ -1137,6 +1147,7 @@ async function handleDiscordModalTrigger(params: {
|
||||
replyOpts,
|
||||
componentLabel: "form",
|
||||
unauthorizedReply,
|
||||
allowNameMatching: params.ctx.discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
});
|
||||
if (!componentAllowed) {
|
||||
return;
|
||||
@@ -1572,6 +1583,7 @@ class DiscordComponentModal extends Modal {
|
||||
replyOpts,
|
||||
componentLabel: "form",
|
||||
unauthorizedReply: "You are not authorized to use this form.",
|
||||
allowNameMatching: this.ctx.discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
});
|
||||
if (!memberAllowed) {
|
||||
return;
|
||||
|
||||
@@ -98,6 +98,7 @@ export function normalizeDiscordSlug(value: string) {
|
||||
export function allowListMatches(
|
||||
list: DiscordAllowList,
|
||||
candidate: { id?: string; name?: string; tag?: string },
|
||||
params?: { allowNameMatching?: boolean },
|
||||
) {
|
||||
if (list.allowAll) {
|
||||
return true;
|
||||
@@ -105,12 +106,14 @@ export function allowListMatches(
|
||||
if (candidate.id && list.ids.has(candidate.id)) {
|
||||
return true;
|
||||
}
|
||||
const slug = candidate.name ? normalizeDiscordSlug(candidate.name) : "";
|
||||
if (slug && list.names.has(slug)) {
|
||||
return true;
|
||||
}
|
||||
if (candidate.tag && list.names.has(normalizeDiscordSlug(candidate.tag))) {
|
||||
return true;
|
||||
if (params?.allowNameMatching === true) {
|
||||
const slug = candidate.name ? normalizeDiscordSlug(candidate.name) : "";
|
||||
if (slug && list.names.has(slug)) {
|
||||
return true;
|
||||
}
|
||||
if (candidate.tag && list.names.has(normalizeDiscordSlug(candidate.tag))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -118,6 +121,7 @@ export function allowListMatches(
|
||||
export function resolveDiscordAllowListMatch(params: {
|
||||
allowList: DiscordAllowList;
|
||||
candidate: { id?: string; name?: string; tag?: string };
|
||||
allowNameMatching?: boolean;
|
||||
}): DiscordAllowListMatch {
|
||||
const { allowList, candidate } = params;
|
||||
if (allowList.allowAll) {
|
||||
@@ -126,13 +130,15 @@ export function resolveDiscordAllowListMatch(params: {
|
||||
if (candidate.id && allowList.ids.has(candidate.id)) {
|
||||
return { allowed: true, matchKey: candidate.id, matchSource: "id" };
|
||||
}
|
||||
const nameSlug = candidate.name ? normalizeDiscordSlug(candidate.name) : "";
|
||||
if (nameSlug && allowList.names.has(nameSlug)) {
|
||||
return { allowed: true, matchKey: nameSlug, matchSource: "name" };
|
||||
}
|
||||
const tagSlug = candidate.tag ? normalizeDiscordSlug(candidate.tag) : "";
|
||||
if (tagSlug && allowList.names.has(tagSlug)) {
|
||||
return { allowed: true, matchKey: tagSlug, matchSource: "tag" };
|
||||
if (params.allowNameMatching === true) {
|
||||
const nameSlug = candidate.name ? normalizeDiscordSlug(candidate.name) : "";
|
||||
if (nameSlug && allowList.names.has(nameSlug)) {
|
||||
return { allowed: true, matchKey: nameSlug, matchSource: "name" };
|
||||
}
|
||||
const tagSlug = candidate.tag ? normalizeDiscordSlug(candidate.tag) : "";
|
||||
if (tagSlug && allowList.names.has(tagSlug)) {
|
||||
return { allowed: true, matchKey: tagSlug, matchSource: "tag" };
|
||||
}
|
||||
}
|
||||
return { allowed: false };
|
||||
}
|
||||
@@ -142,16 +148,21 @@ export function resolveDiscordUserAllowed(params: {
|
||||
userId: string;
|
||||
userName?: string;
|
||||
userTag?: string;
|
||||
allowNameMatching?: boolean;
|
||||
}) {
|
||||
const allowList = normalizeDiscordAllowList(params.allowList, ["discord:", "user:", "pk:"]);
|
||||
if (!allowList) {
|
||||
return true;
|
||||
}
|
||||
return allowListMatches(allowList, {
|
||||
id: params.userId,
|
||||
name: params.userName,
|
||||
tag: params.userTag,
|
||||
});
|
||||
return allowListMatches(
|
||||
allowList,
|
||||
{
|
||||
id: params.userId,
|
||||
name: params.userName,
|
||||
tag: params.userTag,
|
||||
},
|
||||
{ allowNameMatching: params.allowNameMatching },
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveDiscordRoleAllowed(params: {
|
||||
@@ -176,6 +187,7 @@ export function resolveDiscordMemberAllowed(params: {
|
||||
userId: string;
|
||||
userName?: string;
|
||||
userTag?: string;
|
||||
allowNameMatching?: boolean;
|
||||
}) {
|
||||
const hasUserRestriction = Array.isArray(params.userAllowList) && params.userAllowList.length > 0;
|
||||
const hasRoleRestriction = Array.isArray(params.roleAllowList) && params.roleAllowList.length > 0;
|
||||
@@ -188,6 +200,7 @@ export function resolveDiscordMemberAllowed(params: {
|
||||
userId: params.userId,
|
||||
userName: params.userName,
|
||||
userTag: params.userTag,
|
||||
allowNameMatching: params.allowNameMatching,
|
||||
})
|
||||
: false;
|
||||
const roleOk = hasRoleRestriction
|
||||
@@ -204,6 +217,7 @@ export function resolveDiscordMemberAccessState(params: {
|
||||
guildInfo?: DiscordGuildEntryResolved | null;
|
||||
memberRoleIds: string[];
|
||||
sender: { id: string; name?: string; tag?: string };
|
||||
allowNameMatching?: boolean;
|
||||
}) {
|
||||
const channelUsers = params.channelConfig?.users ?? params.guildInfo?.users;
|
||||
const channelRoles = params.channelConfig?.roles ?? params.guildInfo?.roles;
|
||||
@@ -217,6 +231,7 @@ export function resolveDiscordMemberAccessState(params: {
|
||||
userId: params.sender.id,
|
||||
userName: params.sender.name,
|
||||
userTag: params.sender.tag,
|
||||
allowNameMatching: params.allowNameMatching,
|
||||
});
|
||||
return { channelUsers, channelRoles, hasAccessRestrictions, memberAllowed } as const;
|
||||
}
|
||||
@@ -225,6 +240,7 @@ export function resolveDiscordOwnerAllowFrom(params: {
|
||||
channelConfig?: DiscordChannelConfigResolved | null;
|
||||
guildInfo?: DiscordGuildEntryResolved | null;
|
||||
sender: { id: string; name?: string; tag?: string };
|
||||
allowNameMatching?: boolean;
|
||||
}): string[] | undefined {
|
||||
const rawAllowList = params.channelConfig?.users ?? params.guildInfo?.users;
|
||||
if (!Array.isArray(rawAllowList) || rawAllowList.length === 0) {
|
||||
@@ -241,6 +257,7 @@ export function resolveDiscordOwnerAllowFrom(params: {
|
||||
name: params.sender.name,
|
||||
tag: params.sender.tag,
|
||||
},
|
||||
allowNameMatching: params.allowNameMatching,
|
||||
});
|
||||
if (!match.allowed || !match.matchKey || match.matchKey === "*") {
|
||||
return undefined;
|
||||
@@ -253,6 +270,7 @@ export function resolveDiscordCommandAuthorized(params: {
|
||||
allowFrom?: string[];
|
||||
guildInfo?: DiscordGuildEntryResolved | null;
|
||||
author: User;
|
||||
allowNameMatching?: boolean;
|
||||
}) {
|
||||
if (!params.isDirectMessage) {
|
||||
return true;
|
||||
@@ -261,11 +279,15 @@ export function resolveDiscordCommandAuthorized(params: {
|
||||
if (!allowList) {
|
||||
return true;
|
||||
}
|
||||
return allowListMatches(allowList, {
|
||||
id: params.author.id,
|
||||
name: params.author.username,
|
||||
tag: formatDiscordUserTag(params.author),
|
||||
});
|
||||
return allowListMatches(
|
||||
allowList,
|
||||
{
|
||||
id: params.author.id,
|
||||
name: params.author.username,
|
||||
tag: formatDiscordUserTag(params.author),
|
||||
},
|
||||
{ allowNameMatching: params.allowNameMatching },
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveDiscordGuildEntry(params: {
|
||||
@@ -501,6 +523,7 @@ export function shouldEmitDiscordReactionNotification(params: {
|
||||
userName?: string;
|
||||
userTag?: string;
|
||||
allowlist?: string[];
|
||||
allowNameMatching?: boolean;
|
||||
}) {
|
||||
const mode = params.mode ?? "own";
|
||||
if (mode === "off") {
|
||||
@@ -517,11 +540,15 @@ export function shouldEmitDiscordReactionNotification(params: {
|
||||
if (!list) {
|
||||
return false;
|
||||
}
|
||||
return allowListMatches(list, {
|
||||
id: params.userId,
|
||||
name: params.userName,
|
||||
tag: params.userTag,
|
||||
});
|
||||
return allowListMatches(
|
||||
list,
|
||||
{
|
||||
id: params.userId,
|
||||
name: params.userName,
|
||||
tag: params.userTag,
|
||||
},
|
||||
{ allowNameMatching: params.allowNameMatching },
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ type DiscordReactionListenerParams = {
|
||||
accountId: string;
|
||||
runtime: RuntimeEnv;
|
||||
botUserId?: string;
|
||||
allowNameMatching: boolean;
|
||||
guildEntries?: Record<string, import("./allow-list.js").DiscordGuildEntryResolved>;
|
||||
logger: Logger;
|
||||
};
|
||||
@@ -178,6 +179,7 @@ async function runDiscordReactionHandler(params: {
|
||||
cfg: params.handlerParams.cfg,
|
||||
accountId: params.handlerParams.accountId,
|
||||
botUserId: params.handlerParams.botUserId,
|
||||
allowNameMatching: params.handlerParams.allowNameMatching,
|
||||
guildEntries: params.handlerParams.guildEntries,
|
||||
logger: params.handlerParams.logger,
|
||||
}),
|
||||
@@ -191,6 +193,7 @@ async function handleDiscordReactionEvent(params: {
|
||||
cfg: LoadedConfig;
|
||||
accountId: string;
|
||||
botUserId?: string;
|
||||
allowNameMatching: boolean;
|
||||
guildEntries?: Record<string, import("./allow-list.js").DiscordGuildEntryResolved>;
|
||||
logger: Logger;
|
||||
}) {
|
||||
@@ -292,6 +295,7 @@ async function handleDiscordReactionEvent(params: {
|
||||
userName: user.username,
|
||||
userTag: formatDiscordUserTag(user),
|
||||
allowlist: guildInfo?.users,
|
||||
allowNameMatching: params.allowNameMatching,
|
||||
});
|
||||
const emitReactionWithAuthor = (message: { author?: User } | null) => {
|
||||
const { baseText } = resolveReactionBase();
|
||||
|
||||
@@ -190,6 +190,7 @@ export async function preflightDiscordMessage(
|
||||
name: sender.name,
|
||||
tag: sender.tag,
|
||||
},
|
||||
allowNameMatching: params.discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
})
|
||||
: { allowed: false };
|
||||
const allowMatchMeta = formatAllowlistMatchMeta(allowMatch);
|
||||
@@ -563,6 +564,7 @@ export async function preflightDiscordMessage(
|
||||
guildInfo,
|
||||
memberRoleIds,
|
||||
sender,
|
||||
allowNameMatching: params.discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
});
|
||||
|
||||
if (!isDirectMessage) {
|
||||
@@ -572,11 +574,15 @@ export async function preflightDiscordMessage(
|
||||
"pk:",
|
||||
]);
|
||||
const ownerOk = ownerAllowList
|
||||
? allowListMatches(ownerAllowList, {
|
||||
id: sender.id,
|
||||
name: sender.name,
|
||||
tag: sender.tag,
|
||||
})
|
||||
? allowListMatches(
|
||||
ownerAllowList,
|
||||
{
|
||||
id: sender.id,
|
||||
name: sender.name,
|
||||
tag: sender.tag,
|
||||
},
|
||||
{ allowNameMatching: params.discordConfig?.dangerouslyAllowNameMatching === true },
|
||||
)
|
||||
: false;
|
||||
const useAccessGroups = params.cfg.commands?.useAccessGroups !== false;
|
||||
const commandGate = resolveControlCommandGate({
|
||||
|
||||
@@ -199,6 +199,7 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext)
|
||||
channelConfig,
|
||||
guildInfo,
|
||||
sender: { id: sender.id, name: sender.name, tag: sender.tag },
|
||||
allowNameMatching: discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
});
|
||||
const storePath = resolveStorePath(cfg.session?.store, {
|
||||
agentId: route.agentId,
|
||||
|
||||
@@ -170,6 +170,7 @@ describe("agent components", () => {
|
||||
const select = createAgentSelectMenu({
|
||||
cfg: createCfg(),
|
||||
accountId: "default",
|
||||
discordConfig: { dangerouslyAllowNameMatching: true } as DiscordAccountConfig,
|
||||
dmPolicy: "allowlist",
|
||||
allowFrom: ["Alice#1234"],
|
||||
});
|
||||
@@ -426,13 +427,20 @@ describe("resolveDiscordOwnerAllowFrom", () => {
|
||||
expect(result).toEqual(["123"]);
|
||||
});
|
||||
|
||||
it("returns the normalized name slug for name matches", () => {
|
||||
const result = resolveDiscordOwnerAllowFrom({
|
||||
it("returns the normalized name slug for name matches only when enabled", () => {
|
||||
const defaultResult = resolveDiscordOwnerAllowFrom({
|
||||
channelConfig: { allowed: true, users: ["Some User"] } as DiscordChannelConfigResolved,
|
||||
sender: { id: "999", name: "Some User" },
|
||||
});
|
||||
expect(defaultResult).toBeUndefined();
|
||||
|
||||
expect(result).toEqual(["some-user"]);
|
||||
const enabledResult = resolveDiscordOwnerAllowFrom({
|
||||
channelConfig: { allowed: true, users: ["Some User"] } as DiscordChannelConfigResolved,
|
||||
sender: { id: "999", name: "Some User" },
|
||||
allowNameMatching: true,
|
||||
});
|
||||
|
||||
expect(enabledResult).toEqual(["some-user"]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1276,11 +1276,15 @@ async function dispatchDiscordCommandInteraction(params: {
|
||||
);
|
||||
const ownerOk =
|
||||
ownerAllowList && user
|
||||
? allowListMatches(ownerAllowList, {
|
||||
id: sender.id,
|
||||
name: sender.name,
|
||||
tag: sender.tag,
|
||||
})
|
||||
? allowListMatches(
|
||||
ownerAllowList,
|
||||
{
|
||||
id: sender.id,
|
||||
name: sender.name,
|
||||
tag: sender.tag,
|
||||
},
|
||||
{ allowNameMatching: discordConfig?.dangerouslyAllowNameMatching === true },
|
||||
)
|
||||
: false;
|
||||
const guildInfo = resolveDiscordGuildEntry({
|
||||
guild: interaction.guild ?? undefined,
|
||||
@@ -1363,11 +1367,15 @@ async function dispatchDiscordCommandInteraction(params: {
|
||||
];
|
||||
const allowList = normalizeDiscordAllowList(effectiveAllowFrom, ["discord:", "user:", "pk:"]);
|
||||
const permitted = allowList
|
||||
? allowListMatches(allowList, {
|
||||
id: sender.id,
|
||||
name: sender.name,
|
||||
tag: sender.tag,
|
||||
})
|
||||
? allowListMatches(
|
||||
allowList,
|
||||
{
|
||||
id: sender.id,
|
||||
name: sender.name,
|
||||
tag: sender.tag,
|
||||
},
|
||||
{ allowNameMatching: discordConfig?.dangerouslyAllowNameMatching === true },
|
||||
)
|
||||
: false;
|
||||
if (!permitted) {
|
||||
commandAuthorized = false;
|
||||
@@ -1404,6 +1412,7 @@ async function dispatchDiscordCommandInteraction(params: {
|
||||
guildInfo,
|
||||
memberRoleIds,
|
||||
sender,
|
||||
allowNameMatching: discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
});
|
||||
const authorizers = useAccessGroups
|
||||
? [
|
||||
@@ -1509,6 +1518,7 @@ async function dispatchDiscordCommandInteraction(params: {
|
||||
channelConfig,
|
||||
guildInfo,
|
||||
sender: { id: sender.id, name: sender.name, tag: sender.tag },
|
||||
allowNameMatching: discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
});
|
||||
const ctxPayload = finalizeInboundContext({
|
||||
Body: prompt,
|
||||
|
||||
@@ -559,6 +559,7 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
|
||||
accountId: account.accountId,
|
||||
runtime,
|
||||
botUserId,
|
||||
allowNameMatching: discordCfg.dangerouslyAllowNameMatching === true,
|
||||
guildEntries,
|
||||
logger,
|
||||
}),
|
||||
@@ -570,6 +571,7 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
|
||||
accountId: account.accountId,
|
||||
runtime,
|
||||
botUserId,
|
||||
allowNameMatching: discordCfg.dangerouslyAllowNameMatching === true,
|
||||
guildEntries,
|
||||
logger,
|
||||
}),
|
||||
|
||||
@@ -156,6 +156,7 @@ async function authorizeVoiceCommand(
|
||||
guildInfo,
|
||||
memberRoleIds,
|
||||
sender,
|
||||
allowNameMatching: params.discordConfig?.dangerouslyAllowNameMatching === true,
|
||||
});
|
||||
|
||||
const ownerAllowList = normalizeDiscordAllowList(
|
||||
@@ -163,11 +164,15 @@ async function authorizeVoiceCommand(
|
||||
["discord:", "user:", "pk:"],
|
||||
);
|
||||
const ownerOk = ownerAllowList
|
||||
? allowListMatches(ownerAllowList, {
|
||||
id: sender.id,
|
||||
name: sender.name,
|
||||
tag: sender.tag,
|
||||
})
|
||||
? allowListMatches(
|
||||
ownerAllowList,
|
||||
{
|
||||
id: sender.id,
|
||||
name: sender.name,
|
||||
tag: sender.tag,
|
||||
},
|
||||
{ allowNameMatching: params.discordConfig?.dangerouslyAllowNameMatching === true },
|
||||
)
|
||||
: false;
|
||||
|
||||
const authorizers = params.useAccessGroups
|
||||
|
||||
Reference in New Issue
Block a user