From 51feaf021c22c1f6dfa431aaa7a5f426ff272f53 Mon Sep 17 00:00:00 2001 From: Juan Font Date: Fri, 26 Jul 2024 16:26:24 +0000 Subject: [PATCH] Fix bug with wrong file --- auth_log.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/auth_log.go b/auth_log.go index f270bfb..bc0d2d3 100644 --- a/auth_log.go +++ b/auth_log.go @@ -10,7 +10,7 @@ import ( ) func (s *GitLabLogStreamer) readAuthLogFile() error { - content, err := os.ReadFile(s.cfg.AuditLogPath) + content, err := os.ReadFile(s.cfg.AuthLogPath) if err != nil { return err } @@ -40,6 +40,11 @@ func (s *GitLabLogStreamer) readAuthLogFile() error { return err } + if len(newEvents) == 0 { + log.Warn(). + Msg("No new auth events to forward, but a full read was requested") + } + err = s.forwardNewAuthEvents(newEvents) if err != nil { return err @@ -53,7 +58,7 @@ func (s *GitLabLogStreamer) forwardNewAuthEvents(authEvents []*AuthEvent) error log.Info(). Int("events", len(authEvents)). Str("endpoint", s.cfg.AuditLogForwardingEndpoint). - Msgf("Forwarding %d auth events to HTTP endpoint") + Msgf("Forwarding auth events to HTTP endpoint") err := s.forwardNewAuthEventsHTTP(authEvents) if err != nil { log.Warn(). @@ -106,7 +111,6 @@ func (s *GitLabLogStreamer) processNewAuthEvents(authEvents []*AuthEvent) ([]*Au func (s *GitLabLogStreamer) parseAuthEvent(line string) (*AuthEvent, error) { authEvent := &AuthEvent{} - err := json.Unmarshal([]byte(line), authEvent) if err != nil { return nil, err