From 0bd36c52679e0718e534ab195869c8cd842def73 Mon Sep 17 00:00:00 2001 From: Jeff Cody Date: Fri, 28 Feb 2020 13:56:18 -0500 Subject: [PATCH] modules/http: Add option to suppress errors when max redirects exceeded (#253) If the --max-redirects value is exceeded, we return SCAN_APPLICATION_ERROR with "Too many redirect" as the error message. Add an option to suppress this error, and return success even if we exceed the maximum specified number of redirects. --- modules/http/scanner.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/http/scanner.go b/modules/http/scanner.go index f4947e22..65d9605b 100644 --- a/modules/http/scanner.go +++ b/modules/http/scanner.go @@ -53,6 +53,9 @@ type Flags struct { // UseHTTPS causes the first request to be over TLS, without requiring a // redirect to HTTPS. It does not change the port used for the connection. UseHTTPS bool `long:"use-https" description:"Perform an HTTPS connection on the initial host"` + + // RedirectsSucceed causes the ErrTooManRedirects error to be suppressed + RedirectsSucceed bool `long:"redirects-succeed" description:"Redirects are always a success, even if max-redirects is exceeded"` } // A Results object is returned by the HTTP module's Scanner.Scan() @@ -354,6 +357,9 @@ func (scan *scan) Grab() *zgrab2.ScanError { case ErrRedirLocalhost: break case ErrTooManyRedirects: + if scan.scanner.config.RedirectsSucceed { + return nil + } return zgrab2.NewScanError(zgrab2.SCAN_APPLICATION_ERROR, err) default: return zgrab2.DetectScanError(err)