取消独立配置审计并将配置结果写入运行日志
Security Checks / security (push) Waiting to run

This commit is contained in:
xuans committed 2026-09-09 01:46:30 +08:00
1 parent 42a173f742
commit ae224649f3
25 files changed
+291 -313

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
package config
import (
"context"
log "github.com/sirupsen/logrus"
)
// RuntimeConfigLogWriter 复用运行日志记录配置结果,不生成独立审计文件或数据库记录。
// 只保留定位操作需要的元数据,不输出配置值、凭据、用户名称或完整变更载荷。
type RuntimeConfigLogWriter struct{}
func (RuntimeConfigLogWriter) WriteConfigAudit(_ context.Context, event ConfigAuditEvent) error {
event, err := normalizeAuditEvent(event)
if err != nil {
return err
}
action := map[ConfigOperation]string{
ConfigOperationUpdate: "保存配置",
ConfigOperationRollback: "回滚配置",
ConfigOperationMigration: "迁移配置",
}[event.Operation]
entry := log.WithFields(log.Fields{
"operation": event.Operation,
"section": event.Section,
"actorId": event.ActorID,
"fromGeneration": event.FromGeneration,
"toGeneration": event.ToGeneration,
"result": event.Result,
})
if event.Result == "failure" {
entry.Warn(action + "失败")
} else {
entry.Info(action + "成功")
}
return nil
}