audit(csv): drop user_id and target_id columns

This commit is contained in:
2026-05-05 08:05:41 +01:00
parent 86fe569ea0
commit deb8b874ca
+12 -12
View File
@@ -172,22 +172,23 @@ func (s *Server) handleUIAuditCSV(w stdhttp.ResponseWriter, r *stdhttp.Request)
cw := csv.NewWriter(w) cw := csv.NewWriter(w)
defer cw.Flush() defer cw.Flush()
_ = cw.Write([]string{"timestamp_utc", "actor", "user", "user_id", "action", "target_kind", "target_id", "target_name", "payload"}) // user_id and target_id are internal ULIDs that carry no meaning
// to anyone reading the CSV — the resolved name (or — for system
// rows / non-host targets) is what an operator wants. The HTML
// page still shows IDs in the Target column for traceability when
// no name is available; the CSV is for human reporting only.
_ = cw.Write([]string{"timestamp_utc", "actor", "user", "action", "target_kind", "target_name", "payload"})
for _, e := range entries { for _, e := range entries {
var uid, uname string var uname string
if e.UserID != nil { if e.UserID != nil {
uid = *e.UserID uname = userNames[*e.UserID]
uname = userNames[uid]
} }
var tk, tid, tname string var tk, tname string
if e.TargetKind != nil { if e.TargetKind != nil {
tk = *e.TargetKind tk = *e.TargetKind
} }
if e.TargetID != nil { if tk == "host" && e.TargetID != nil {
tid = *e.TargetID tname = hostNames[*e.TargetID]
}
if tk == "host" {
tname = hostNames[tid]
} }
payload := "" payload := ""
if len(e.Payload) > 0 { if len(e.Payload) > 0 {
@@ -195,8 +196,7 @@ func (s *Server) handleUIAuditCSV(w stdhttp.ResponseWriter, r *stdhttp.Request)
} }
_ = cw.Write([]string{ _ = cw.Write([]string{
e.TS.UTC().Format("2006-01-02 15:04:05"), e.TS.UTC().Format("2006-01-02 15:04:05"),
e.Actor, uname, uid, e.Action, e.Actor, uname, e.Action, tk, tname, payload,
tk, tid, tname, payload,
}) })
} }
} }