fix(slack): skip monitor startup for disabled accounts [AI-assisted]#30592
Conversation
Greptile SummaryThis PR adds an early guard in Changes Made:
Impact:
Confidence Score: 5/5
Last reviewed commit: d5b8b06 |
d5b8b06 to
f32876b
Compare
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🔵 Indefinite await when Slack account disabled and abortSignal missing (startup hang/DoS)
DescriptionIn
Vulnerable code: if (!account.enabled) {
runtime.log?.(`[${account.accountId}] slack account disabled; monitor startup skipped`);
if (opts.abortSignal?.aborted) {
return;
}
await new Promise<void>((resolve) => {
opts.abortSignal?.addEventListener("abort", () => resolve(), { once: true });
});
return;
}Call-site review in this repo shows some callers pass an abort signal (tests and the Slack plugin gateway), but the exported API still allows usage without one, and RecommendationAvoid awaiting a Promise that cannot resolve. Safer patterns:
if (!account.enabled) {
runtime.log?.(`[${account.accountId}] slack account disabled; monitor startup skipped`);
return;
}
if (!account.enabled) {
runtime.log?.(`[${account.accountId}] slack account disabled; monitor startup skipped`);
const signal = opts.abortSignal;
if (!signal) return; // no way to be aborted
if (signal.aborted) return;
await new Promise<void>((resolve) => {
signal.addEventListener("abort", () => resolve(), { once: true });
});
return;
}Optionally factor this into a helper like Analyzed PR: #30592 at commit |
|
PR #30592 - fix(slack): skip monitor startup for disabled accounts [AI-assisted] (#30592) Merged via squash.
Thanks @liuxiaopai-ai! |
…penclaw#30592) thanks @liuxiaopai-ai Cherry-pick of upstream 265b22c.
…penclaw#30592) thanks @liuxiaopai-ai Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…penclaw#30592) thanks @liuxiaopai-ai Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…penclaw#30592) thanks @liuxiaopai-ai Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…penclaw#30592) thanks @liuxiaopai-ai Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…penclaw#30592) thanks @liuxiaopai-ai Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…penclaw#30592) thanks @liuxiaopai-ai Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…penclaw#30592) thanks @liuxiaopai-ai Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…penclaw#30592) thanks @liuxiaopai-ai Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…penclaw#30592) thanks @liuxiaopai-ai Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…penclaw#30592) thanks @liuxiaopai-ai Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…penclaw#30592) thanks @liuxiaopai-ai Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…penclaw#30592) thanks @liuxiaopai-ai Cherry-pick of upstream 265b22c.
…penclaw#30592) thanks @liuxiaopai-ai Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit 265b22c)
…penclaw#30592) thanks @liuxiaopai-ai (#1419) Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini (cherry picked from commit 265b22c) Co-authored-by: Mark L <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
Summary
Describe the problem and fix in 2–5 bullets:
channels.slack.enabled=false, causing unwanted websocket activity.monitorSlackProviderthat skips startup when resolved account is disabled and waits only for abort; added regression test asserting noauth.testcall and no handler registration.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
enabled=falseno longer starts socket monitor even if tokens are still present in config.Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
channels.slack.enabled=false, socket mode with tokens presentSteps
enabled=falseand valid-lookingbotToken/appToken.Expected
Actual
Evidence
Attach at least one:
Failing test/log before + passing after
Trace/log snippets
Screenshot/recording
Perf numbers (if relevant)
pnpm oxfmt --check src/slack/monitor/provider.ts src/slack/monitor.tool-result.test.ts CHANGELOG.mdpnpm oxlint --type-aware src/slack/monitor/provider.ts src/slack/monitor.tool-result.test.tspnpm vitest src/slack/monitor.tool-result.test.tsHuman Verification (required)
What you personally verified (not just CI), and how:
auth.testor register event handlers.Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
src/slack/monitor/provider.tsguard block.Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.account.enabledonly; existing enabled-account tests continue to pass.