From 4b8e6cd780af96840c5bc8f021795cec132a381e Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Tue, 23 Jan 2024 09:32:41 +0100 Subject: [PATCH] appsec: avoid nil dereference (#2773) --- pkg/appsec/request.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/appsec/request.go b/pkg/appsec/request.go index f244cee9cb0..6d472e8afae 100644 --- a/pkg/appsec/request.go +++ b/pkg/appsec/request.go @@ -329,7 +329,7 @@ func NewParsedRequestFromRequest(r *http.Request, logger *logrus.Entry) (ParsedR return ParsedRequest{}, fmt.Errorf("unable to parse url '%s': %s", clientURI, err) } - remoteAddrNormalized := "" + var remoteAddrNormalized string host, _, err := net.SplitHostPort(r.RemoteAddr) if err != nil { log.Errorf("Invalid appsec remote IP source %v: %s", r.RemoteAddr, err.Error()) @@ -337,7 +337,7 @@ func NewParsedRequestFromRequest(r *http.Request, logger *logrus.Entry) (ParsedR } else { ip := net.ParseIP(host) if ip == nil { - log.Errorf("Invalid appsec remote IP address source %v: %s", r.RemoteAddr, err.Error()) + log.Errorf("Invalid appsec remote IP address source %v", r.RemoteAddr) remoteAddrNormalized = r.RemoteAddr } else { remoteAddrNormalized = ip.String()