mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 05:44:33 +00:00
fix(auto-reply): prevent sender spoofing in group prompts
This commit is contained in:
@@ -199,18 +199,16 @@ describe("RawBody directive parsing", () => {
|
||||
});
|
||||
|
||||
const groupMessageCtx = {
|
||||
Body: [
|
||||
"[Chat messages since your last reply - for context]",
|
||||
"[WhatsApp ...] Peter: hello",
|
||||
"",
|
||||
"[Current message - respond to this]",
|
||||
"[WhatsApp ...] Jake: /think:high status please",
|
||||
"[from: Jake McInteer (+6421807830)]",
|
||||
].join("\n"),
|
||||
Body: "/think:high status please",
|
||||
BodyForAgent: "/think:high status please",
|
||||
RawBody: "/think:high status please",
|
||||
InboundHistory: [{ sender: "Peter", body: "hello", timestamp: 1700000000000 }],
|
||||
From: "+1222",
|
||||
To: "+1222",
|
||||
ChatType: "group",
|
||||
GroupSubject: "Ops",
|
||||
SenderName: "Jake McInteer",
|
||||
SenderE164: "+6421807830",
|
||||
CommandAuthorized: true,
|
||||
};
|
||||
|
||||
@@ -233,8 +231,9 @@ describe("RawBody directive parsing", () => {
|
||||
expect(text).toBe("ok");
|
||||
expect(runEmbeddedPiAgent).toHaveBeenCalledOnce();
|
||||
const prompt = vi.mocked(runEmbeddedPiAgent).mock.calls[0]?.[0]?.prompt ?? "";
|
||||
expect(prompt).toContain("[Chat messages since your last reply - for context]");
|
||||
expect(prompt).toContain("Peter: hello");
|
||||
expect(prompt).toContain("Chat history since last reply (untrusted, for context):");
|
||||
expect(prompt).toContain('"sender": "Peter"');
|
||||
expect(prompt).toContain('"body": "hello"');
|
||||
expect(prompt).toContain("status please");
|
||||
expect(prompt).not.toContain("/think:high");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user