From 0eb9e845dd381928fb9773fc61cd91909e20630f Mon Sep 17 00:00:00 2001 From: liufumingren Date: Sat, 15 Aug 2026 20:10:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(inbox):=20=E5=87=BD=E6=95=B0=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=89=8D=E6=8C=89=E7=BE=A4=E7=B1=BB=E5=9E=8B=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E5=8F=AF=E7=94=A8=E6=80=A7=EF=BC=8C=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E8=B4=A7=E4=B8=BB=E7=BE=A4=E8=B6=8A=E6=9D=83=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=BF=AB=E9=80=92=E7=BE=A4=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/inbox/functions.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/service/inbox/functions.js b/app/service/inbox/functions.js index 0861745..d09c7cd 100644 --- a/app/service/inbox/functions.js +++ b/app/service/inbox/functions.js @@ -3831,6 +3831,24 @@ class InboxFunctionsService extends Service { }; } + // 群类型权限过滤:按当前群的活跃分组校验函数可用性, + // 防止货主群调用快递群专属函数(如 handleExpressFeedback)等越权调用。 + // 无 groups 服务的场景(单元测试直接实例化)跳过校验,由调用方保证上下文。 + const groupsSvc = this.ctx.service && this.ctx.service.inbox && this.ctx.service.inbox.groups; + if (groupsSvc && typeof groupsSvc.isFunctionAvailable === 'function') { + const activeGroups = groupsSvc.resolveActiveGroups(); + if (!groupsSvc.isFunctionAvailable(def, activeGroups)) { + this.ctx.logger.warn( + `[inbox functions] 越权调用被拦截: ${name} ` + + `groups=${(def.groups || []).join(',')} active=${activeGroups.join(',')}` + ); + return { + success: false, + error: `函数 ${name} 在当前群类型下不可用,请通过对应类型的群发起`, + }; + } + } + try { const result = await def.handler(params); return result && typeof result === 'object' ? result : { success: true, data: result };