Fix: Security collector debug logging + backend rebuild needed

This commit is contained in:
cynfo3000 2026-03-04 23:35:21 +01:00
parent 772a1fd7a6
commit a60a91bff8

View File

@ -3,6 +3,7 @@ package collector
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"log"
"os" "os"
"os/exec" "os/exec"
"regexp" "regexp"
@ -72,7 +73,12 @@ func CollectSecurity() *SecurityData {
seen := make(map[string]bool) seen := make(map[string]bool)
for _, path := range logFiles { for _, path := range logFiles {
events := parseAuditLog(path) events, err := parseAuditLog(path)
if err != nil {
log.Printf("Security: %s: %v", path, err)
continue
}
log.Printf("Security: %s: %d events", path, len(events))
for _, e := range events { for _, e := range events {
key := e.Timestamp + e.User + e.Source + e.Port + e.Status key := e.Timestamp + e.User + e.Source + e.Port + e.Status
if !seen[key] { if !seen[key] {
@ -118,10 +124,10 @@ func CollectSecurity() *SecurityData {
return data return data
} }
func parseAuditLog(path string) []LoginEvent { func parseAuditLog(path string) ([]LoginEvent, error) {
f, err := os.Open(path) f, err := os.Open(path)
if err != nil { if err != nil {
return nil return nil, err
} }
defer f.Close() defer f.Close()
@ -166,7 +172,7 @@ func parseAuditLog(path string) []LoginEvent {
} }
} }
return events return events, nil
} }
func extractTimestamp(line string) string { func extractTimestamp(line string) string {