From 8a74242450af43ced1b810c2da1eba8319285fbc Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Mon, 17 Mar 2025 01:16:27 -0400 Subject: cmd/anubis: remove theoretical nil pointer deference panic This won't actually happen in real life, but the code paths might change so we should be somewhat defensive. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- cmd/anubis/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/anubis/main.go b/cmd/anubis/main.go index 683fd7a..de0a592 100644 --- a/cmd/anubis/main.go +++ b/cmd/anubis/main.go @@ -287,6 +287,11 @@ func (s *Server) maybeReverseProxy(w http.ResponseWriter, r *http.Request) { case config.RuleDeny: clearCookie(w) lg.Info("explicit deny") + if rule == nil { + lg.Error("rule is nil, cannot calculate checksum") + templ.Handler(base("Oh noes!", errorPage("Other internal server error (contact the admin)")), templ.WithStatus(http.StatusInternalServerError)).ServeHTTP(w, r) + return + } hash, err := rule.Hash() if err != nil { lg.Error("can't calculate checksum of rule", "err", err) -- cgit v1.2.3