Skip to content

Commit

Permalink
feat: fixed bug due to parallel auto setting in http (#4992)
Browse files Browse the repository at this point in the history
* feat: fixed bug due to parallel auto setting in http

* increased threshold

---------

Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>
  • Loading branch information
Ice3man543 and ehsandeep authored Apr 8, 2024
1 parent b86fcb5 commit a844e6f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/protocols/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
httputil "github.com/projectdiscovery/nuclei/v3/pkg/protocols/utils/http"
"github.com/projectdiscovery/rawhttp"
"github.com/projectdiscovery/retryablehttp-go"
"github.com/projectdiscovery/utils/env"
fileutil "github.com/projectdiscovery/utils/file"
)

Expand Down Expand Up @@ -440,7 +441,11 @@ func (request *Request) Compile(options *protocols.ExecutorOptions) error {
request.Threads = protocolstate.GuardThreadsOrDefault(request.Threads)
}
// if we have payloads, adjust threads if none specified
request.Threads = options.GetThreadsForNPayloadRequests(request.Requests(), request.Threads)
// We only do this in case we have more payload requests than the
// specified concurrency threshold.
if request.generator.NewIterator().Total() > PayloadAutoConcurrencyThreshold {
request.Threads = options.GetThreadsForNPayloadRequests(request.Requests(), request.Threads)
}
}

return nil
Expand All @@ -467,3 +472,11 @@ func (request *Request) Requests() int {
}
return len(request.Path)
}

// PayloadAutoConcurrencyThreshold is the threshold for auto adjusting concurrency
// for payloads in a template.
var PayloadAutoConcurrencyThreshold int

func init() {
PayloadAutoConcurrencyThreshold = env.GetEnvOrDefault[int]("NUCLEI_PAYLOAD_AUTO_CONCURRENCY_THRESHOLD", 100)
}

0 comments on commit a844e6f

Please sign in to comment.