Skip to content

Commit

Permalink
appsec: avoid nil dereference (#2773)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc authored Jan 23, 2024
1 parent 84606eb commit 4b8e6cd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/appsec/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,15 @@ 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())
remoteAddrNormalized = r.RemoteAddr
} 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()
Expand Down

0 comments on commit 4b8e6cd

Please sign in to comment.