fix(slack): stop leaking bot token into /api/auth.test request body (… · openclaw/openclaw@fbc12e0
xcoulon
·
2026-06-19
·
via Recent Commits to openclaw:main
File tree
extensions/slack/src/monitor
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Slack tests cover auth.test token handling during provider boot. |
| 2 | +import { beforeEach, describe, expect, it } from "vitest"; |
| 3 | +import { |
| 4 | +getSlackClient, |
| 5 | +resetSlackTestState, |
| 6 | +startSlackMonitor, |
| 7 | +stopSlackMonitor, |
| 8 | +} from "../monitor.test-helpers.js"; |
| 9 | + |
| 10 | +const { monitorSlackProvider } = await import("./provider.js"); |
| 11 | + |
| 12 | +beforeEach(() => { |
| 13 | +resetSlackTestState(); |
| 14 | +}); |
| 15 | + |
| 16 | +describe("auth.test boot call", () => { |
| 17 | +it("does not pass the bot token in the call arguments", async () => { |
| 18 | +const monitor = startSlackMonitor(monitorSlackProvider); |
| 19 | +await stopSlackMonitor(monitor); |
| 20 | + |
| 21 | +const client = getSlackClient(); |
| 22 | +expect(client.auth.test).toHaveBeenCalledTimes(1); |
| 23 | +// The SDK serializes every property from the call argument into the POST |
| 24 | +// body. Passing { token } would leak the bot token into the request |
| 25 | +// payload alongside the Authorization header. |
| 26 | +const firstArg = client.auth.test.mock.calls[0]?.[0] as Record<string, unknown> | undefined; |
| 27 | +if (firstArg != null) { |
| 28 | +expect(firstArg).not.toHaveProperty("token"); |
| 29 | +} |
| 30 | +}); |
| 31 | +}); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -296,7 +296,7 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) {
|
296 | 296 | let authTestFailed = false; |
297 | 297 | let authTestError: string | undefined; |
298 | 298 | try { |
299 | | -const auth = await app.client.auth.test({ token: botToken }); |
| 299 | +const auth = await app.client.auth.test(); |
300 | 300 | botUserId = auth.user_id ?? ""; |
301 | 301 | botId = (auth as { bot_id?: string }).bot_id ?? ""; |
302 | 302 | teamId = auth.team_id ?? ""; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。