Files
Nexus/docs/changelog/2026-05-22-telegram-sanitize-and-security-tests.md
2026-07-08 22:31:31 +08:00

907 B
Raw Permalink Blame History

Telegram 出站脱敏 + 安全回归测试(F2d-04 / F2f-06

日期: 2026-05-22

F2d-04 — Telegram 脱敏

  • server/infrastructure/telegram/__init__.py:新增 sanitize_external_message(),屏蔽 DB/Redis URL、password、Bearer、密钥片段。
  • send_telegram_system_alert():出站前脱敏 + html.escape
  • send_telegram() 成功日志同样脱敏后再截断。
  • self_monitor.pyRedis/MySQL 失败详情写入 logger.warning(..., exc_info=True)Telegram 仅固定文案。

F2f-06 — 回归测试

tests/test_security_unit.py 扩展至 15 项,覆盖:

  • 危险命令、server_ids JSON 解析、HTTPS callback
  • sanitize_external_message 脱敏与截断
  • JwtAuthMiddleware 401 / 公开路径跳过
  • /api/install//api/auth/logout 公开前缀
  • 安装后 _reject_if_installed() → 403
pytest tests/test_security_unit.py -q