The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(slack): slash commands obey allowed_channels and ignored_channels, like messages
John Paul Solivab37659177849
diff --git a/plugins/platforms/slack/adapter.py b/plugins/platforms/slack/adapter.pyindex 48294ada58d..c5145a4e424 100644--- a/plugins/platforms/slack/adapter.py+++ b/plugins/platforms/slack/adapter.py@@ -6052,6 +6052,16 @@ class SlackAdapter(BasePlatformAdapter):self._remember_channel_team(channel_id, team_id)text = self._slash_command_text(command)thread_id = self._slash_thread_id(command)+ # The message path's channel gates (_prefilter_inbound, _channel_gate_allows): ignored+ # channels are never touched, and outside allowed_channels only a 1:1 DM is answered. By id+ # alone, so no lookup can drop a control command.+ if self._is_ignored_channel(channel_id):+ logger.debug("[Slack] Ignoring slash command in ignored channel: %s", channel_id)+ return+ allowed_channels = self._slack_allowed_channels()+ if allowed_channels and not str(channel_id).startswith("D") and channel_id not in allowed_channels:+ logger.debug("[Slack] Ignoring slash command in non-allowed channel: %s", channel_id)+ returnis_dm = str(channel_id).startswith("D")if is_dm and self._slack_disable_dms():logger.info(diff --git a/tests/gateway/test_slack.py b/tests/gateway/test_slack.pyindex fe2c8ed13e4..ab696cbbbd1 100644--- a/tests/gateway/test_slack.py+++ b/tests/gateway/test_slack.py@@ -249,6 +249,24 @@ class TestSlashCommandSessionIsolation:assert event.source.user_id == "U123"assert event.source.scope_id == "T123"+ @pytest.mark.asyncio+ @pytest.mark.parametrize("channel_id, extra, dispatched", [+ ("C999", {"allowed_channels": "C123"}, False), # outside allowed_channels+ ("G123", {"allowed_channels": "C123"}, False), # an MPIM obeys channel gating too+ ("D123", {"allowed_channels": "C123"}, True), # a 1:1 DM is exempt+ ("C123", {"allowed_channels": "C123"}, True),+ ("C123", {"ignored_channels": "C123"}, False), # ignored channels are never touched+ ])+ async def test_slash_command_obeys_message_channel_gates(+ self, adapter, channel_id, extra, dispatched):+ """allowed_channels / ignored_channels gate a slash command like a message in the same+ conversation: every conversation but a 1:1 DM."""+ adapter.config.extra.update(extra)+ await adapter._handle_slash_command(+ {"text": "hello", "user_id": "U123", "channel_id": channel_id, "team_id": "T123"})++ assert adapter.handle_message.await_count == (1 if dispatched else 0)+class TestSlackWorkspaceCollisionIsolation:@pytest.mark.asyncio