8d26c46323
feat(bot): use runtime api for bot data
2026-06-20 18:20:40 +08:00
c62ac37611
review: fix critical/medium bugs in 4 plugins (round 2)
...
group_horse_racing:
- settle_race: rewrite with 7 bug fixes (race condition, draw double-credit, empty participants, etc.)
- models.py: reorder fields for correct defaults, add indexes
- message_service: add logger import
danding_points:
- api.py: add finally blocks to 3 methods (add_points, get_history, get_leaderboard)
- database.py: add finally block to get_user_balance
chatai:
- __init__.py: deprecated API→asyncio.to_thread, deduplicate logging, taskkill filter for safety
- screenshot.py: XSS protection with bleach on HTML content
- requirements.txt: add bleach dependency
danding_qqpush:
- api.py L13: fix self-referencing _renderer NameError crash
- api.py: lazy singleton pattern via _get_renderer() instead of per-request ImageRenderer
- __init__.py: mask Token in log output (security)
All 34 tests pass.
2026-05-10 00:30:22 +08:00
fd2fd90f05
refactor: extract admin check helper & harden room_store JSON parsing
...
- Extract duplicated admin/owner check from race.py into shared._is_admin_or_owner()
- Add try/except around JSON.loads in room_store.load_rooms for corrupted data resilience
- Use .get() for safer dict access in room deserialization
2026-05-09 23:37:55 +08:00
c01338f496
refactor(plugins): comprehensive code review - ~35 fixes across 14 plugins
...
Phase 1 - Plugin code review (14/14 plugins):
- Security: 3x token leak in print→logger.debug, Bearer prefix handling
- Bug: bare except→specific exceptions, HorseState type safety, sync→async
- Critical: response_model undefined, route dead code, sync blocking event loop
- Quality: 11x print()→logger, variable name shadowing, consistent logging
Phase 2 - Deep analysis:
- Fix: payout int truncation→max(1, round(amount*odds))
- Fix: room_store get_lock race condition→dict.setdefault()
- Verify: data_manager f-string SQL is safe (uses ? placeholders)
Infrastructure: review reports generated for all plugins.
2026-05-09 23:22:28 +08:00
a952760cf8
fix: break circular import in horse racing commands
...
Extract shared.py from commands/__init__.py to break circular dependency:
- shared.py: shared variables/services/helper functions
- access.py: get_scope/check_access/get_event_id (canonical source)
- __init__.py: re-exports from shared.py for backward compat
- register/bet/race/help: import from .shared instead of package
2026-05-02 15:38:34 +08:00