Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix: audit bot tool permission changes
Locksley Lennox1339ad21b157
diff --git a/server/admin-activity.test.ts b/server/admin-activity.test.tsindex a41cfd0bba..0f73112804 100644--- a/server/admin-activity.test.ts+++ b/server/admin-activity.test.ts@@ -259,3 +259,13 @@ describe("the Activity view", () => {expect(csv).toContain(",'=cmd|' /C calc'!A0,");});});++it("records explicit tool selection and connected-app permission changes", () => {+ const before = botAuditSnapshot({ id: "b" });+ const after = botAuditSnapshot({ id: "b", toolScope: { allow: ["native:read"] }, connectorScopes: { apps: { gmail: "read" } }, connectorTools: { gmail: { tools: ["GMAIL_FETCH_EMAILS"] } } });+ const rows = botChangeRows({ id: "b" }, before, after);+ expect(rows.flatMap(row => row.changed).sort()).toEqual(["connectorScopes", "connectorTools", "toolScope"]);+ const reset = botChangeRows({ id: "b" }, after, before);+ expect(reset.flatMap(row => row.changed).sort()).toEqual(["connectorScopes", "connectorTools", "toolScope"]);+ expect(botChangeRows({ id: "b" }, after, after)).toEqual([]);+});diff --git a/server/admin-activity.ts b/server/admin-activity.tsindex a223a961e4..203d92d254 100644--- a/server/admin-activity.ts+++ b/server/admin-activity.ts@@ -224,7 +224,7 @@ export function configChangeRows(before: unknown, after: unknown): Array<Omit<Ad/** What a bot may do, where, and who may see it; display fields (colour, unread, pins) are not audited. */export const BOT_AUDIT_FIELDS = [- "approvalMode", "autoApprove", "alwaysAllow", "computer", "cloudBackend", "autoStartVps", "vpsAlias",+ "approvalMode", "autoApprove", "alwaysAllow", "toolScope", "connectorScopes", "connectorTools", "computer", "cloudBackend", "autoStartVps", "vpsAlias","cwd", "composio", "browser", "browserProfile", "mcpServers", "chiefOfStaff", "managedSections", "section","parkDirectMessages", "hidden", "modelSelection", "helperModel", "visibility",] as const;diff --git a/server/tool-permission-audit.e2e.test.ts b/server/tool-permission-audit.e2e.test.tsnew file mode 100644index 0000000000..d024e43e60--- /dev/null+++ b/server/tool-permission-audit.e2e.test.ts@@ -0,0 +1,22 @@+import { expect, it } from "vitest";+import { launchVerificationServer, runControlOmb } from "../scripts/control-omb.ts";+import { readAdminActivityRange } from "./admin-activity.ts";++it("records tool permission changes through the bot settings API", async () => {+ const fixture = await launchVerificationServer();+ try {+ const { bot } = await runControlOmb(["new-bot", "--name", "Permission audit fixture", "--url", fixture.info.url]) as { bot: { id: string } };+ expect((await fetch(`${fixture.info.url}/api/auth/pairing`, { method: "POST", headers: { "content-type": "application/json", origin: fixture.info.url }, body: JSON.stringify({ label: "Audit sharing fixture", scopes: ["client"] }) })).status).toBe(200);+ const patch = async (body: unknown) => fetch(`${fixture.info.url}/api/bots/${bot.id}`, {+ method: "PATCH", headers: { "content-type": "application/json", origin: fixture.info.url }, body: JSON.stringify(body),+ });+ expect((await patch({ toolScope: { allow: ["native:read"] }, connectorScopes: { apps: { gmail: "read" } }, connectorTools: { gmail: { tools: ["GMAIL_FETCH_EMAILS"] } } })).status).toBe(200);+ const rows = () => readAdminActivityRange(fixture.info.dataDir, { from: new Date(Date.now() - 60_000), to: new Date(Date.now() + 60_000) }).filter(row => row.changed?.includes("toolScope"));+ await expect.poll(() => rows().length).toBe(1);+ expect(rows()[0]!.changed).toEqual(expect.arrayContaining(["toolScope", "connectorScopes", "connectorTools"]));+ expect((await patch({ title: "Unrelated display edit" })).status).toBe(200);+ expect(rows()).toHaveLength(1);+ expect((await patch({ toolScope: null, connectorScopes: null, connectorTools: null })).status).toBe(200);+ await expect.poll(() => rows().length).toBe(2);+ } finally { await fixture.close(); }+}, 60_000);