Files
SafeLine/management/webserver/model/db_patch_1_4_0.go
T
Binbim b8788c239e
MCP Docker / build-and-push (push) Has been cancelled
feat: SafeLine CE 9.3.9 with pro features
- Remove telemetry: disabled all phone-home (installation notify, false positives, behavior tracking, upgrade tips)
- Version branding: removed 'ce-' prefix, product name changed to '长亭雷池 WAF'
- Detection engine enhancement: strict preset enables all 17 modules with aggressive configs
- Multi-user RBAC: admin/operator/viewer roles with password + TOTP 2FA
- Rate limiting: nginx limit_req per website (RPS, burst, action)
- JS Challenge: browser fingerprint verification page with cookie-based bypass
- Security fixes: removed InsecureSkipVerify, hardcoded credentials, NO_AUTH backdoor
2026-07-04 07:59:04 +08:00

39 lines
928 B
Go

package model
import (
"strings"
"chaitin.cn/dev/go/errors"
"gorm.io/gorm"
)
type sqlResult struct {
Ids string `json:"ids"`
}
func DBPatch140(tx *gorm.DB) error {
if !tx.Migrator().HasTable(&SystemStatistics{}) {
return nil
}
var result []sqlResult
//SELECT string_agg(id::text, ',') as ids FROM mgt_system_statistics GROUP BY (type, website, created_at) HAVING COUNT(*) > 1) as tmp
res := tx.Model(&SystemStatistics{}).Select("string_agg(id::text, ',') as ids").Group("type, website, created_at").Having("COUNT(*) > 1").Find(&result)
if res.Error != nil {
return errors.Wrap(res.Error, "Failed to select data")
}
if len(result) <= 0 {
return nil
}
var deleteIds []string
for _, s := range result {
tmpIds := strings.Split(s.Ids, ",")
deleteIds = append(deleteIds, tmpIds...)
}
deleteRes := tx.Delete(&SystemStatistics{}, deleteIds)
return errors.Wrap(deleteRes.Error, "Failed to delete")
}