Skip to content

Commit edddb07

Browse files
authored
fix(qqbot): preserve framework command authorization (#77453)
* fix(qqbot): preserve framework command authorization * Add changelog entry for PR #77453
1 parent dff437a commit edddb07

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ Docs: https://docs.openclaw.ai
207207
- TUI: replace the stale-response watchdog notice with plain user-facing copy so stalled replies no longer surface backend or streaming internals. (#77120) Thanks @davemorin.
208208
- Security/Windows: validate `SystemRoot`/`WINDIR` env values through the Windows install-root validator and add them to the dangerous-host-env policy when resolving `icacls.exe`/`whoami.exe` for `openclaw security audit`, so workspace `.env` overrides and bare command names cannot redirect Windows ACL helpers to attacker-controlled binaries. (#74458) Thanks @mmaps.
209209
- Security/Windows: pin Windows registry-probe `reg.exe` resolution to the canonical Windows install root in install-root probing, so `SystemRoot`/`WINDIR` env overrides cannot redirect registry queries during Windows host detection. (#74454) Thanks @mmaps.
210+
- QQBot: preserve the framework command authorization decision when converting framework command contexts into engine slash command contexts, so downstream slash handlers see `commandAuthorized` matching the channel's resolved `isAuthorizedSender` instead of a hardcoded `true`. (#77453) Thanks @drobison00.
210211

211212
## 2026.5.3-1
212213

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
2+
import type { PluginCommandContext } from "openclaw/plugin-sdk/plugin-entry";
3+
import { describe, expect, it } from "vitest";
4+
import { buildFrameworkSlashContext } from "./framework-context-adapter.js";
5+
6+
function createCommandContext(isAuthorizedSender: boolean): PluginCommandContext {
7+
return {
8+
senderId: "SENDER_OPENID",
9+
channel: "qqbot",
10+
isAuthorizedSender,
11+
args: "on",
12+
commandBody: "/bot-streaming on",
13+
config: {} as OpenClawConfig,
14+
from: "qqbot:c2c:SENDER_OPENID",
15+
requestConversationBinding: async () => undefined,
16+
detachConversationBinding: async () => ({ removed: false }),
17+
getCurrentConversationBinding: async () => null,
18+
} as unknown as PluginCommandContext;
19+
}
20+
21+
describe("buildFrameworkSlashContext", () => {
22+
it("preserves the framework authorization decision in the slash context", () => {
23+
const authorized = buildFrameworkSlashContext({
24+
ctx: createCommandContext(true),
25+
account: {
26+
accountId: "default",
27+
enabled: true,
28+
appId: "app",
29+
clientSecret: "secret",
30+
secretSource: "config",
31+
markdownSupport: true,
32+
config: {},
33+
},
34+
from: { msgType: "c2c", targetType: "c2c", targetId: "SENDER_OPENID" },
35+
commandName: "bot-streaming",
36+
});
37+
const unauthorized = buildFrameworkSlashContext({
38+
ctx: createCommandContext(false),
39+
account: {
40+
accountId: "default",
41+
enabled: true,
42+
appId: "app",
43+
clientSecret: "secret",
44+
secretSource: "config",
45+
markdownSupport: true,
46+
config: {},
47+
},
48+
from: { msgType: "c2c", targetType: "c2c", targetId: "SENDER_OPENID" },
49+
commandName: "bot-streaming",
50+
});
51+
52+
expect(authorized.commandAuthorized).toBe(true);
53+
expect(unauthorized.commandAuthorized).toBe(false);
54+
});
55+
});

extensions/qqbot/src/bridge/commands/framework-context-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function buildFrameworkSlashContext({
5454
accountId: account.accountId,
5555
appId: account.appId,
5656
accountConfig: account.config as unknown as Record<string, unknown>,
57-
commandAuthorized: true,
57+
commandAuthorized: ctx.isAuthorizedSender,
5858
queueSnapshot: { ...DEFAULT_QUEUE_SNAPSHOT },
5959
};
6060
}

0 commit comments

Comments
 (0)