新增:安全告警邮件展示来源 IP 网络归属(CDN/云厂商/WAF)
- 新增 internal/security/ipinfo:基于 projectdiscovery/cdncheck v1.3.0 (离线指纹、零外部请求)识别来源 IP 归属,识别失败折叠为展示标签, 不中断告警链路 - autoban 告警回调注入归属识别;告警邮件新增「网络归属」行, 命中 CDN/代理网络时提示「封禁可能无法拦截真实来源」 - 新增邮件模板渲染回归测试 internal/mail/mail_alert_test.go - dev/s3stub:webp(cgo) 本地类型检查桩,替换 s3.go 做全模块编译验证, 生产 Linux 构建不受影响;dev/overlay.json 指向该桩 - go mod tidy 顺带升级共享依赖(lipgloss/xid/testify 等), 全模块类型检查与相关包测试通过
This commit is contained in:
+13
-5
@@ -94,12 +94,20 @@ func SendNewVoteSubmissionMail(email, voteTitle string, voteID uint) error {
|
||||
}
|
||||
|
||||
// SendSecurityAlertMail 发送安全告警:检测到疑似批量扫描/探测并触发自动封禁时通知管理员。
|
||||
func SendSecurityAlertMail(ip string, samplePaths []string, durationMinutes int) error {
|
||||
// provider 为来源 IP 的网络归属标签(见 internal/security/ipinfo),proxied 表示
|
||||
// IP 属于 CDN/WAF/代理网络(此时封禁出口 IP 可能无法拦截真实攻击者,邮件中额外提示)。
|
||||
func SendSecurityAlertMail(ip, provider string, proxied bool, samplePaths []string, durationMinutes int) error {
|
||||
proxyHint := ""
|
||||
if proxied {
|
||||
proxyHint = "1"
|
||||
}
|
||||
params := map[string]string{
|
||||
"ip": ip,
|
||||
"paths": strings.Join(samplePaths, "、"),
|
||||
"duration": fmt.Sprintf("%d", durationMinutes),
|
||||
"time": time.Now().Format("2006-01-02 15:04:05"),
|
||||
"ip": ip,
|
||||
"provider": provider,
|
||||
"proxy_hint": proxyHint,
|
||||
"paths": strings.Join(samplePaths, "、"),
|
||||
"duration": fmt.Sprintf("%d", durationMinutes),
|
||||
"time": time.Now().Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
return sendTemplateMail(conf.Security.SecurityAlertEmail, "【狼的提问箱】检测到疑似批量扫描,已自动封禁 IP", templates.FS, "mail/security-alert.html", params)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user