Skip to content

Commit b0a8909

Browse files
authored
fix(feishu): fix group policy enforcement gaps (#25439)
- Respect groupConfig.enabled flag (was parsed but never enforced) - Fix misleading log: group allowlist rejection now logs group ID and policy instead of sender open_id
1 parent 8818464 commit b0a8909

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

extensions/feishu/src/bot.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,38 @@ describe("handleFeishuMessage command authorization", () => {
554554
expect(mockDispatchReplyFromConfig).not.toHaveBeenCalled();
555555
});
556556

557+
it("drops message when groupConfig.enabled is false", async () => {
558+
const cfg: ClawdbotConfig = {
559+
channels: {
560+
feishu: {
561+
groups: {
562+
"oc-disabled-group": {
563+
enabled: false,
564+
},
565+
},
566+
},
567+
},
568+
} as ClawdbotConfig;
569+
570+
const event: FeishuMessageEvent = {
571+
sender: {
572+
sender_id: { open_id: "ou-sender" },
573+
},
574+
message: {
575+
message_id: "msg-disabled-group",
576+
chat_id: "oc-disabled-group",
577+
chat_type: "group",
578+
message_type: "text",
579+
content: JSON.stringify({ text: "hello" }),
580+
},
581+
};
582+
583+
await dispatchMessage({ cfg, event });
584+
585+
expect(mockFinalizeInboundContext).not.toHaveBeenCalled();
586+
expect(mockDispatchReplyFromConfig).not.toHaveBeenCalled();
587+
});
588+
557589
it("uses video file_key (not thumbnail image_key) for inbound video download", async () => {
558590
mockShouldComputeCommandAuthorized.mockReturnValue(false);
559591

extensions/feishu/src/bot.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,10 @@ export async function handleFeishuMessage(params: {
742742
const useAccessGroups = cfg.commands?.useAccessGroups !== false;
743743

744744
if (isGroup) {
745+
if (groupConfig?.enabled === false) {
746+
log(`feishu[${account.accountId}]: group ${ctx.chatId} is disabled`);
747+
return;
748+
}
745749
const defaultGroupPolicy = resolveDefaultGroupPolicy(cfg);
746750
const { groupPolicy, providerMissingFallbackApplied } = resolveOpenProviderRuntimeGroupPolicy({
747751
providerConfigPresent: cfg.channels?.feishu !== undefined,
@@ -766,7 +770,9 @@ export async function handleFeishuMessage(params: {
766770
});
767771

768772
if (!groupAllowed) {
769-
log(`feishu[${account.accountId}]: sender ${ctx.senderOpenId} not in group allowlist`);
773+
log(
774+
`feishu[${account.accountId}]: group ${ctx.chatId} not in groupAllowFrom (groupPolicy=${groupPolicy})`,
775+
);
770776
return;
771777
}
772778

0 commit comments

Comments
 (0)