feat: fixed bug due to parallel auto setting in http (#4992)

* feat: fixed bug due to parallel auto setting in http

* increased threshold

---------

Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>
dev
Ice3man 2024-04-08 16:04:57 +05:30 committed by GitHub
parent b86fcb5546
commit a844e6f7ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 1 deletions

View File

@ -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"
)
@ -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
@ -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)
}