Files
tamabox/.workbuddy/memory/2026-09-08.md
T
tamakyi e3e59e7c69 chore: baseline snapshot before moderation-strictness feature
Repo .git was damaged (refs/ missing, index truncated, object store near-empty).
Repaired via git init (rebuilt refs), stale index preserved as .git/index.corrupt-20260910.bak,
then full worktree committed as a rollback baseline.
2026-09-10 10:56:27 +08:00

20 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 安全告警邮件增加 IP 网络归属(2026-09-08)
- 需求:autoban 批量扫描告警邮件中展示来源 IP 的云厂商/CDN 归属(用户提到"类似 cloudranger"),选定方案 A:`projectdiscovery/cdncheck v1.3.0`(MIT,离线签名,零外部请求)。
- 新增 `internal/security/ipinfo`:`Lookup(ip) (label, proxied)`,依次查 CDN→WAF→Cloud,错误折叠为"识别失败"标签,不中断告警链路;缩写映射 aws→AWS 等。
- `mail.SendSecurityAlertMail` 增加 `provider`/`proxied` 参数;`route.go` SendAlert 闭包注入 lookup;模板加「网络归属」行 + 命中代理网络时的红色提示块。
- 验证:全模块类型检查 + 相关包测试通过(s3.go 磁盘换桩法);smoke 实测 1.1.1.1→Cloudflare(WAF)、52.95.255.1→AWS(云厂商)。
- 新增回归测试:`internal/mail/mail_alert_test.go`(模板渲染含 proxy_hint 条件分支)。
- 教训(重要):本机 Windows + go1.25.5 下 `-overlay` 行为异常(静默不生效 / "deleted in overlay"),**overlay 不可靠;本地验证用磁盘换桩法**:`cp dev/s3stub/s3_stub.go internal/storage/s3.go`(先备份)→ build/test → 还原。chai2010/webp 是 cgo 库,用户生产编译在 Linux,无需本地真编译。
- `go mod tidy` 顺带升级了部分共享依赖(lipgloss 0.13、xid 1.5、testify 1.11 等),全量构建+测试通过。
- dev/overlay.json 现指向 dev/s3stub/s3_stub.go(旧值指向已删除的 Downloads 副本,已过时)。
## autoban 线上触发实测(box-dev-api.337845818.best,2026-09-08 13:38)
- 基线:/ → 200;敏感路径 → 302(业务跳转,但会计入统计)。
- 60s 窗口内连发 18 个敏感路径:前 ~9 个 302,第 ~10 个起全部 403;封禁后连首页也 403 "403 Forbidden"(中间件先于业务路由,全站拦截)。
- ⚠️ 触发点 ≈ 9~10 次,不是配置的 15:疑似部署侧仍是默认阈值(DefaultThresholdSensitive=10)。需检查服务器 conf/app.ini [security] ban_threshold_sensitive = 15 是否落盘并重启服务。
- 本次触发应已发出一封告警邮件(每 IP 仅一次),可借机验收新的「网络归属」字段。
- 本机出口 IP 已被临时封禁(默认 15 分钟自动解除),期间再测会 403。