Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
users: Validate the embedded bot name in its config check.
Niloth Pb2fcdaeb0ed7
diff --git a/zerver/lib/users.py b/zerver/lib/users.pyindex 9ce0f344000..6840f4fd0be 100644--- a/zerver/lib/users.py+++ b/zerver/lib/users.py@@ -170,6 +170,8 @@ def check_valid_embedded_bot_config(service_name: str, config_data: Mapping[str,from zerver.lib.bot_lib import get_bot_handlerbot_handler = get_bot_handler(service_name)+ if bot_handler is None:+ raise JsonableError(_("Invalid embedded bot name."))if not hasattr(bot_handler, "validate_config"):returndiff --git a/zerver/views/users.py b/zerver/views/users.pyindex adc80ceb692..1a1a2c7397e 100644--- a/zerver/views/users.py+++ b/zerver/views/users.py@@ -52,7 +52,6 @@ from zerver.lib.exceptions import (OrganizationAdministratorRequiredError,OrganizationOwnerRequiredError,)-from zerver.lib.integrations import EMBEDDED_BOTSfrom zerver.lib.rate_limiter import (rate_limit_spectator_attachment_access_by_file,should_rate_limit,@@ -672,11 +671,8 @@ def add_bot_backend()form = CreateUserForm({"full_name": full_name, "email": email})- if bot_type == UserProfile.EMBEDDED_BOT:- if not settings.EMBEDDED_BOTS_ENABLED:- raise JsonableError(_("Embedded bots are not enabled."))- if service_name not in [bot.name for bot in EMBEDDED_BOTS]:- raise JsonableError(_("Invalid embedded bot name."))+ if bot_type == UserProfile.EMBEDDED_BOT and not settings.EMBEDDED_BOTS_ENABLED:+ raise JsonableError(_("Embedded bots are not enabled."))if not form.is_valid(): # nocoverage# coverage note: The similar block above covers the most