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

Update init.go #5282

Closed
wants to merge 1 commit into from
Closed
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
28 changes: 21 additions & 7 deletions pkg/js/compiler/init.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package compiler

import (
"log"
"github.com/projectdiscovery/nuclei/v3/pkg/types"
)

Expand All @@ -16,18 +17,31 @@ var (

// Init initializes the javascript protocol
func Init(opts *types.Options) error {
// Validate the provided timeout
if opts.Timeout < 10 {
// keep existing 10s timeout
return nil
log.Println("Provided timeout too low, using default 10s timeout")
opts.Timeout = 10
}

// Validate the provided concurrency
if opts.JsConcurrency < 100 {
// 100 is reasonable default
log.Println("Provided JS concurrency too low, setting to default 100")
opts.JsConcurrency = 100
}
// we have dialer timeout set to 10s so js needs to be at least
// 15s to return the actual error if not it will be a dialer timeout

// Calculate and set the JsProtocolTimeout
JsProtocolTimeout = int(float64(opts.Timeout) * JsTimeoutMultiplier)
PoolingJsVmConcurrency = opts.JsConcurrency
PoolingJsVmConcurrency -= NonPoolingVMConcurrency

// Adjust PoolingJsVmConcurrency based on NonPoolingVMConcurrency
PoolingJsVmConcurrency = opts.JsConcurrency - NonPoolingVMConcurrency
if PoolingJsVmConcurrency < 0 {
log.Println("Adjusted PoolingJsVmConcurrency to minimum value 0")
PoolingJsVmConcurrency = 0
}

log.Printf("JS Protocol Timeout set to %d seconds\n", JsProtocolTimeout)
log.Printf("Pooling JS VM Concurrency set to %d\n", PoolingJsVmConcurrency)
log.Printf("Non-Pooling JS VM Concurrency set to %d\n", NonPoolingVMConcurrency)

return nil
}
Loading