From 6d2ab3f9b8271864aca087ebfdf28ef187292f17 Mon Sep 17 00:00:00 2001 From: mmatur Date: Thu, 27 Aug 2026 16:37:26 +0200 Subject: [PATCH] fix: log the plugin archive hash mismatches --- pkg/handlers/module.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/handlers/module.go b/pkg/handlers/module.go index 6dbf444..5baf056 100644 --- a/pkg/handlers/module.go +++ b/pkg/handlers/module.go @@ -71,7 +71,9 @@ func (h Handlers) Download(rw http.ResponseWriter, req *http.Request) { attributes = append(attributes, attribute.String("module.sum", sum)) ph, errH := h.store.GetHashByName(ctx, pluginName, version) - if errH != nil { + + switch { + case errH != nil: span.RecordError(errH) if !errors.As(errH, &db.NotFoundError{}) { @@ -80,14 +82,17 @@ func (h Handlers) Download(rw http.ResponseWriter, req *http.Request) { return } - } else if ph.Hash == sum { + + case ph.Hash == sum: rw.WriteHeader(http.StatusNotModified) return + + default: + logger.Warn().Str("recorded_hash", ph.Hash).Str("client_hash", sum).Msg("Plugin archive hash mismatch") } span.AddEvent("module.download", trace.WithAttributes(attributes...)) - logger.Error().Msgf("Someone is trying to hack the archive: %v", sum) } span.SetAttributes(attributes...) @@ -579,6 +584,8 @@ func (h Handlers) Validate(rw http.ResponseWriter, req *http.Request) { return } + logger.Warn().Str("recorded_hash", ph.Hash).Str("client_hash", headerSum).Msg("Plugin archive hash mismatch") + rw.WriteHeader(http.StatusNotFound) }