Files
DanDingNoneBot/review_reports/command_list_review.md
Mr.Xia 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

1.2 KiB
Raw Permalink Blame History

command_list 评审报告

修复前问题清单 (4项)

# 严重度 问题 文件
1 致命 check_user and fullmatch(...) — Python对truthy callable用and返回右侧,权限检查被完全绕过 command_list.py:17
2 __plugin_meta__ = Config 应为PluginMetadata实例 init.py:4
3 random.uniform(1,2) sleep无功能意义 command_list.py:46
4 config.py的字段从未被任何代码引用 config.py

修复内容

  1. 重写权限检查为Rule(_check_user) & fullmatch(...),确保_check_user作为Rule执行而非truthy短路
  2. 移除random依赖
  3. 移除无用sleep

严重问题说明

致命级权限绕过check_user and fullmatch(...) 中,check_user是一个async函数对象truthyPython的and运算符会直接返回右侧fullmatch(...)的结果,完全跳过权限检查。所有用户都能使用该命令。

验证

  • Rule(_check_user) & fullmatch(...) 语法正确
  • 移除random依赖
  • 插件列表排序输出
  • 异常处理

代码质量总结

__init__.pyconfig.py结构有问题(meta=Config),但不影响运行。核心逻辑修复后评级:B