Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pkg/protocols/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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 @@ -416,7 +417,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 @@ -443,3 +448,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)
}
Loading