Skip to content

Commit 6cb82ea

Browse files
authored
fix: require owner for trajectory export (#97840)
1 parent 738b2be commit 6cb82ea

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/auto-reply/reply/commands-info.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ describe("info command handlers", () => {
133133
});
134134
});
135135

136-
it("only lets owners export trajectory bundles", async () => {
136+
it("ignores trajectory export requests from unauthorized senders", async () => {
137137
const params = buildInfoParams("/export-trajectory", {
138138
commands: { text: true },
139139
} as OpenClawConfig);
@@ -145,6 +145,18 @@ describe("info command handlers", () => {
145145
expect(buildExportTrajectoryCommandReplyMock).not.toHaveBeenCalled();
146146
});
147147

148+
it("blocks authorized non-owners from exporting trajectory bundles", async () => {
149+
const params = buildInfoParams("/export-trajectory", {
150+
commands: { text: true },
151+
} as OpenClawConfig);
152+
params.command.senderIsOwner = false;
153+
154+
const result = await handleExportTrajectoryCommand(params, true);
155+
156+
expect(result).toEqual({ shouldContinue: false });
157+
expect(buildExportTrajectoryCommandReplyMock).not.toHaveBeenCalled();
158+
});
159+
148160
it("returns sender details for /whoami", async () => {
149161
const result = await handleWhoamiCommand(
150162
buildInfoParams(

src/auto-reply/reply/commands-info.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from "../status.js";
1616
import { buildThreadingToolContext } from "./agent-runner-utils.js";
1717
import { resolveChannelAccountId } from "./channel-context.js";
18-
import { rejectUnauthorizedCommand } from "./command-gates.js";
18+
import { rejectNonOwnerCommand, rejectUnauthorizedCommand } from "./command-gates.js";
1919
import { buildExportSessionReply } from "./commands-export-session.js";
2020
import { buildExportTrajectoryCommandReply } from "./commands-export-trajectory.js";
2121
import { buildStatusPluginsReply, buildStatusReply } from "./commands-status.js";
@@ -348,5 +348,9 @@ export const handleExportTrajectoryCommand: CommandHandler = async (params, allo
348348
if (unauthorized) {
349349
return unauthorized;
350350
}
351+
const nonOwner = rejectNonOwnerCommand(params, "/export-trajectory");
352+
if (nonOwner) {
353+
return nonOwner;
354+
}
351355
return { shouldContinue: false, reply: await buildExportTrajectoryCommandReply(params) };
352356
};

0 commit comments

Comments
 (0)