From 9e0b5898a54fdac6a4d5c5d102e7c20850191939 Mon Sep 17 00:00:00 2001 From: a squid <34890855+squi-ddy@users.noreply.github.com> Date: Tue, 27 Feb 2024 11:43:56 +0800 Subject: [PATCH 1/3] check for uuid collisions --- bot/src/cogs/ms_auth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/src/cogs/ms_auth.py b/bot/src/cogs/ms_auth.py index 32c97b2..1cd4e69 100644 --- a/bot/src/cogs/ms_auth.py +++ b/bot/src/cogs/ms_auth.py @@ -146,7 +146,8 @@ async def get_real_ms_auth_link(self, data) -> Optional[Union[str, Literal[False return self.auth_flows.get(state, (0, 0, {}))[2].get("auth_uri") def get_ms_auth_link(self, member_id: int) -> str: - state = uuid.uuid4().hex + while (state := uuid.uuid4().hex) in self.auth_flows: + pass auth_flow = self.application.initiate_auth_code_flow( scopes=["User.Read"], From 72c712ebac2f5b614d247a06a138ed00a359e29d Mon Sep 17 00:00:00 2001 From: a squid <34890855+squi-ddy@users.noreply.github.com> Date: Tue, 27 Feb 2024 11:45:53 +0800 Subject: [PATCH 2/3] collisions in ui_helper --- bot/src/cogs/ui_helper.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bot/src/cogs/ui_helper.py b/bot/src/cogs/ui_helper.py index d6ba97a..280e9a3 100644 --- a/bot/src/cogs/ui_helper.py +++ b/bot/src/cogs/ui_helper.py @@ -53,12 +53,14 @@ def register_callback(self, callback_name: str, callback: ButtonCallbackFactory) self.callbacks[callback_name] = callback def get_button(self, callback_name: str, callback_args: Collection[Any], **kwargs) -> Button: - button_id = uuid.uuid4().hex + while (button_id := uuid.uuid4().hex) in self.pending: + pass + + self.pending[button_id] = (callback_name, callback_args) + kwargs["custom_id"] = button_id button = Button(**kwargs) - self.pending[button_id] = (callback_name, callback_args) - return button @Cog.listener() From 8d034194e579bb710e40190f7c0d2ded8f1caad2 Mon Sep 17 00:00:00 2001 From: a squid <34890855+squi-ddy@users.noreply.github.com> Date: Tue, 27 Feb 2024 11:46:44 +0800 Subject: [PATCH 3/3] collisions in github_auth --- bot/src/cogs/github_auth.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bot/src/cogs/github_auth.py b/bot/src/cogs/github_auth.py index bb3e479..1e09e31 100644 --- a/bot/src/cogs/github_auth.py +++ b/bot/src/cogs/github_auth.py @@ -63,7 +63,9 @@ async def verify(self, interaction: Interaction) -> None: return await send_error(interaction, "You have already linked your GitHub account!", ephemeral=True) # generate auth flow - state = uuid.uuid4().hex + while (state := uuid.uuid4().hex) in self.github_auth_flows: + pass + github_link = f"https://github.com/login/oauth/authorize?client_id={config.github_client_id}&state={state}" # add to pending auth flows