Skip to content

Commit

Permalink
modules/http: Add option to suppress errors when max redirects exceed…
Browse files Browse the repository at this point in the history
…ed (#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.
  • Loading branch information
codyprime committed Feb 28, 2020
1 parent 909643c commit 0bd36c5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/http/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0bd36c5

Please sign in to comment.