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.6 KiB
1.6 KiB
damo_balance 评审报告
修复前问题清单 (5项)
| # | 严重度 | 问题 | 文件 |
|---|---|---|---|
| 1 | 致命 | 明文硬编码账号密码 xsllovemlj/xsl1314520mlj |
AccountSpider.py:main + init.py |
| 2 | 致命 | 模块级 spider = AccountSpider() 共享session,多用户并发冲突 |
init.py |
| 3 | 高 | input() 阻塞等待验证码,nonebot环境下必死 |
AccountSpider.py:24 |
| 4 | 中 | 硬编码绝对路径 /bot/danding-bot/... 移动即崩 |
AccountSpider.py:22 |
| 5 | 中 | 爬虫调用无错误处理,state = response.text 可能无余额标签 |
AccountSpider.py/commands |
修复内容
AccountSpider.py
- 移除明文密码,
main()改用环境变量DAMO_USERNAME/DAMO_PASSWORD __init__接受save_dir参数,移除硬编码路径- 移除
input()函数,get_verification_code()直接返回图片字节 - 加
osimport
init.py
- 移除全局
spider实例,改为 handler 内创建并通过state["spider"]传递 - 凭证从环境变量读取,未配置时提示用户
- 所有 API 调用加
try/except+logger.error错误处理 state.get("spider")安全取值,空时提示重新发送
安全建议(未自动修改)
- 建议将环境变量替换为 nonebot
.env配置文件 - 验证码图片建议用 base64 内联发送后立即删除临时文件
验证
- 无明文密码残留
- 无 global spider
- state 传递 spider 实例
- env var 读取凭证
- 错误处理覆盖所有 API 调用
代码质量总结
安全问题修复后评级:B (从 D- 提升)