chore(security): replace silent exception swallowing across handlers

This commit is contained in:
kavore
2026-02-08 21:30:39 +03:00
parent 199c7797f5
commit da03510a92
16 changed files with 322 additions and 316 deletions
+4 -4
View File
@@ -46,8 +46,8 @@ async def show_ads_menu(callback: types.CallbackQuery, settings: Settings, i18n_
await callback.message.edit_text(text, reply_markup=reply_markup)
try:
await callback.answer()
except Exception:
pass
except Exception as exc:
logging.debug("Suppressed exception in bot/handlers/admin/ads.py: %s", exc)
@router.callback_query(F.data.startswith("admin_ads:page:"))
@@ -262,8 +262,8 @@ async def ads_create_start(callback: types.CallbackQuery, state: FSMContext, set
await callback.message.edit_text(_("admin_ads_create_source_prompt"))
try:
await callback.answer()
except Exception:
pass
except Exception as exc:
logging.debug("Suppressed exception in bot/handlers/admin/ads.py: %s", exc)
@router.message(
+2 -2
View File
@@ -171,8 +171,8 @@ async def change_broadcast_target_handler(
current_lang, i18n, target=new_target
),
)
except Exception:
pass
except Exception as exc:
logging.debug("Suppressed exception in bot/handlers/admin/broadcast.py: %s", exc)
await callback.answer()
+2 -2
View File
@@ -1,5 +1,5 @@
import logging
import random
import secrets
import string
import csv
import io
@@ -56,7 +56,7 @@ async def create_bulk_promo_prompt_handler(callback: types.CallbackQuery,
def generate_unique_promo_code(length: int = 8) -> str:
"""Generate a unique random promo code"""
characters = string.ascii_uppercase + string.digits
return ''.join(random.choice(characters) for _ in range(length))
return ''.join(secrets.choice(characters) for _ in range(length))
# Step 1: Process quantity