蜜罐告警: 修复去重口径与空收件人短路
审阅蜜罐邮件提醒功能发现的问题,三项一并修: 1. autoban.alerted 从 map[string]bool(永不过期)改为带时间戳的 map[string]time.Time,冷却期 24h 与蜜罐侧对齐。cleanup 里清理过期项, 长期盯防同一来源不再漏掉后续攻击活动(此前一生只报一次)。 2. 蜜罐告警在 security_alert_email 为空时短路:route.go 注入 sendAlert 前判空,收件人缺失置 nil,避免每次凭据提交白做 SMTP 拨号 + 刷 Warn。 3. 强化 security_alert_email 的配置警示(蜜罐邮件含明文密码, 必须是个人邮箱、禁群组/分发列表)。
This commit is contained in:
@@ -227,8 +227,12 @@ func New() *flamego.Flame {
|
||||
hph := newHoneypotHandler(hp, ab, db.Honeypots, credStore)
|
||||
// 蜜罐告警:只有真的提交了凭据才发(纯路径探测没有取证价值),且每个 IP 只发一次。
|
||||
// 收件人复用 security_alert_email,不新增配置项。
|
||||
hph.sendAlert = func(a mail.HoneypotAlert) error {
|
||||
return mail.SendHoneypotAlertMail(a)
|
||||
// 收件人为空时把 sendAlert 置 nil —— alert() 里 `h.sendAlert == nil` 会直接短路,
|
||||
// 避免「蜜罐开着但没配收件人」时每次凭据提交都白做一次 SMTP 拨号并留一堆 Warn 日志。
|
||||
if strings.TrimSpace(conf.Security.SecurityAlertEmail) != "" {
|
||||
hph.sendAlert = func(a mail.HoneypotAlert) error {
|
||||
return mail.SendHoneypotAlertMail(a)
|
||||
}
|
||||
}
|
||||
|
||||
templateFS, err := template.EmbedFS(templates.FS, ".", []string{".html"})
|
||||
|
||||
Reference in New Issue
Block a user