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.
1.2 KiB
1.2 KiB
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 |
修复内容
- 重写权限检查为
Rule(_check_user) & fullmatch(...),确保_check_user作为Rule执行而非truthy短路 - 移除random依赖
- 移除无用sleep
严重问题说明
致命级权限绕过:check_user and fullmatch(...) 中,check_user是一个async函数对象(truthy),Python的and运算符会直接返回右侧fullmatch(...)的结果,完全跳过权限检查。所有用户都能使用该命令。
验证
- Rule(_check_user) & fullmatch(...) 语法正确
- 移除random依赖
- 插件列表排序输出
- 异常处理
代码质量总结
__init__.py和config.py结构有问题(meta=Config),但不影响运行。核心逻辑修复后评级:B