diff --git a/modules/http/scanner.go b/modules/http/scanner.go index a124b306..b63aba3c 100644 --- a/modules/http/scanner.go +++ b/modules/http/scanner.go @@ -388,6 +388,12 @@ func redirectsToLocalhost(host string) bool { // the redirectToLocalhost and MaxRedirects config func (scan *scan) getCheckRedirect() func(*http.Request, *http.Response, []*http.Request) error { return func(req *http.Request, res *http.Response, via []*http.Request) error { + if scan.scanner.config.MaxRedirects == 0 { + return nil + } + if len(via) > scan.scanner.config.MaxRedirects { + return ErrTooManyRedirects + } if !scan.scanner.config.FollowLocalhostRedirects && redirectsToLocalhost(req.URL.Hostname()) { return ErrRedirLocalhost } @@ -413,10 +419,6 @@ func (scan *scan) getCheckRedirect() func(*http.Request, *http.Response, []*http } } - if len(via) > scan.scanner.config.MaxRedirects { - return ErrTooManyRedirects - } - return nil } }