Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Outbound: at Full access, Send without asking also sends code runs without a card

AdityaUmaleeec0e6117817
diff --git a/server/outbound-hold.test.ts b/server/outbound-hold.test.ts
index 537b1dd2ae..e9aa5233df 100644
--- a/server/outbound-hold.test.ts
+++ b/server/outbound-hold.test.ts
@@ -182,13 +182,19 @@ describe("Full access with no sending rule of its own", () => {
expect(allowing.appended).toEqual([]);
});
- it("sends a call it cannot inspect without a card, while Send without asking still asks for one", async () => {
+ it("at Full access sends a call it cannot inspect without a card, with no rule or Send without asking", async () => {
const held = setup(bot(undefined));
for (let sent = 0; sent < 30; sent++) await expect(send(held, { fullAccess: true, opaque: true })).resolves.toEqual({ ok: true, approved: false });
expect(held.appended).toEqual([]);
+ const allowingFull = setup(bot({ policy: "allow" }));
+ await expect(send(allowingFull, { fullAccess: true, opaque: true })).resolves.toEqual({ ok: true, approved: false });
+ expect(allowingFull.appended).toEqual([]);
+ });
+
+ it("below Full access, Send without asking still asks before a call it cannot inspect", async () => {
const allowing = setup(bot({ policy: "allow" }));
- const pending = allowing.hold.hold({ ...allowing.input, opaque: true, fullAccess: true, active: () => true });
+ const pending = allowing.hold.hold({ ...allowing.input, opaque: true, fullAccess: false, active: () => true });
expect(allowing.appended).toHaveLength(1);
allowing.outboundRequests.resolve({ threadId: "t1", requestId: allowing.appended[0].message.card!.requestId as string, behavior: "deny" });
await expect(pending).resolves.toMatchObject({ ok: false });
diff --git a/server/outbound-hold.ts b/server/outbound-hold.ts
index 4ef369762d..fe69ec78af 100644
--- a/server/outbound-hold.ts
+++ b/server/outbound-hold.ts
@@ -32,7 +32,8 @@ export type OutboundHoldAnswer = { ok: true; approved: boolean } | { ok: false;
* sending rule of its own sends without asking; a stored rule is kept exactly as set. */
function sendsWithoutAsking(rule: OutboundPolicy | undefined, fullAccess: boolean, opaque: boolean): "full-access" | "allow" | null {
if (fullAccess && rule === undefined) return "full-access";
- return (rule ?? DEFAULT_OUTBOUND_POLICY).policy === "allow" && !opaque ? "allow" : null;
+ // A call it cannot inspect (code run) goes out under "allow" only at Full access, as it would with no rule.
+ return (rule ?? DEFAULT_OUTBOUND_POLICY).policy === "allow" && (!opaque || fullAccess) ? "allow" : null;
}
export interface OutboundHold {
diff --git a/server/trust-controls.e2e.test.ts b/server/trust-controls.e2e.test.ts
index 1e1c410882..66310e76b1 100644
--- a/server/trust-controls.e2e.test.ts
+++ b/server/trust-controls.e2e.test.ts
@@ -202,14 +202,13 @@ it("honors outbound approval and Send without asking at Full access, and still r
expect((await relay(token, "SLACK_SEND_MESSAGE", { channel: "fixture", text: "Sent without asking" })).body.result.isError).not.toBe(true);
expect((await relay(token, "GMAIL_SEND_EMAIL", { to: "[email protected]" })).body.result.isError).not.toBe(true);
expect((await cards(b.threadId)).filter(row => row.card?.outboundRequest)).toHaveLength(cardCount);
- const opaque = relay(token, "COMPOSIO_REMOTE_WORKBENCH", { code_to_execute: "print(1)" });
- const opaqueCard = await pending(b.threadId);
- await api("POST", `/api/threads/${b.threadId}/respond`, { requestId: opaqueCard.card.requestId, behavior: "deny" });
- expect((await opaque).body.result.isError).toBe(true);
- expect(relayed).toHaveLength(before + 3);
+ // A code run goes out without a card too, as it does at Full access with no rule.
+ expect((await relay(token, "COMPOSIO_REMOTE_WORKBENCH", { code_to_execute: "print(1)" })).body.result.isError).not.toBe(true);
+ expect((await cards(b.threadId)).filter(row => row.card?.outboundRequest)).toHaveLength(cardCount);
+ expect(relayed).toHaveLength(before + 4);
await api("PATCH", `/api/bots/${b.id}`, { connectorScopes: { apps: { gmail: "read" } } });
expect((await relay(token, "GMAIL_SEND_EMAIL")).body.result.isError).toBe(true);
- expect(relayed).toHaveLength(before + 3);
+ expect(relayed).toHaveLength(before + 4);
});
it("honors Ask every time at Full access before the first send for any prompt language", async () => {