diff --git a/common/fileutil/fileutil.go b/common/fileutil/fileutil.go index 994587a42..24ba53f99 100644 --- a/common/fileutil/fileutil.go +++ b/common/fileutil/fileutil.go @@ -52,7 +52,7 @@ func ListFilesWithPattern(rootpattern string) ([]string, error) { if len(files) == 0 { return nil, errors.New("no files found") } - return files, err + return files, nil } // FileNameIsGlob check if the filanem is a pattern diff --git a/common/hashes/jarm/jarmhash.go b/common/hashes/jarm/jarmhash.go index 5b45656ba..d96f1ad23 100644 --- a/common/hashes/jarm/jarmhash.go +++ b/common/hashes/jarm/jarmhash.go @@ -75,8 +75,11 @@ func Jarm(dialer *fastdialer.Dialer, host string, duration int) string { return "" } t.Host = u.Hostname() - port, _ := strconv.Atoi(u.Port()) - t.Port = port + if portStr := u.Port(); portStr != "" { + if p, err := strconv.Atoi(portStr); err == nil { + t.Port = p + } + } } if t.Port == 0 { t.Port = defaultPort diff --git a/common/httpx/httpx.go b/common/httpx/httpx.go index b38fdf591..15c567f06 100644 --- a/common/httpx/httpx.go +++ b/common/httpx/httpx.go @@ -293,7 +293,7 @@ get_response: respbody, err = DecodeData(respbody, httpresp.Header) if err != nil && !shouldIgnoreBodyErrors { - return nil, closeErr + return nil, err } respbodystr := string(respbody) @@ -307,8 +307,9 @@ get_response: if resp.ContentLength <= 0 { // check if it's in the header and convert to int if contentLength, ok := resp.Headers["Content-Length"]; ok && len(contentLength) > 0 { - contentLengthInt, _ := strconv.Atoi(contentLength[0]) - resp.ContentLength = contentLengthInt + if contentLengthInt, err := strconv.Atoi(contentLength[0]); err == nil { + resp.ContentLength = contentLengthInt + } } // if we have a body, then use the number of bytes in the body if the length is still zero diff --git a/runner/runner.go b/runner/runner.go index af9db5661..352e4c74c 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -125,7 +125,7 @@ func (r *Runner) IsInterrupted() bool { } // picked based on try-fail but it seems to close to one it's used https://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html#c1992 -var hammingDistanceThreshold int = 22 +const hammingDistanceThreshold = 22 // regex for stripping ANSI codes var ansiRegex = regexp.MustCompile(`\x1b\[[0-9;]*m`) @@ -2204,7 +2204,12 @@ retry: pipeline := false if scanopts.Pipeline { - port, _ := strconv.Atoi(URL.Port()) + port := 0 + if portStr := URL.Port(); portStr != "" { + if p, err := strconv.Atoi(portStr); err == nil { + port = p + } + } r.ratelimiter.Take() pipeline = hp.SupportPipeline(protocol, method, URL.Host, port) if pipeline {