2024-01-18 04:39:15 +05:30
|
|
|
package compiler
|
|
|
|
|
|
2024-05-25 00:29:04 +05:30
|
|
|
import (
|
|
|
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/types"
|
|
|
|
|
)
|
2024-01-18 04:39:15 +05:30
|
|
|
|
|
|
|
|
// jsprotocolInit
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
// Per Execution Javascript timeout in seconds
|
2024-02-02 02:22:04 +05:30
|
|
|
JsProtocolTimeout = 10
|
|
|
|
|
PoolingJsVmConcurrency = 100
|
|
|
|
|
NonPoolingVMConcurrency = 20
|
2024-05-25 00:29:04 +05:30
|
|
|
JsTimeoutMultiplier = 1.5
|
2024-01-18 04:39:15 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Init initializes the javascript protocol
|
|
|
|
|
func Init(opts *types.Options) error {
|
|
|
|
|
if opts.Timeout < 10 {
|
|
|
|
|
// keep existing 10s timeout
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2024-01-31 01:59:49 +05:30
|
|
|
if opts.JsConcurrency < 100 {
|
|
|
|
|
// 100 is reasonable default
|
|
|
|
|
opts.JsConcurrency = 100
|
|
|
|
|
}
|
2024-05-25 00:29:04 +05:30
|
|
|
// 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
|
|
|
|
|
JsProtocolTimeout = int(float64(opts.Timeout) * JsTimeoutMultiplier)
|
2024-02-02 02:22:04 +05:30
|
|
|
PoolingJsVmConcurrency = opts.JsConcurrency
|
|
|
|
|
PoolingJsVmConcurrency -= NonPoolingVMConcurrency
|
2024-01-18 04:39:15 +05:30
|
|
|
return nil
|
|
|
|
|
}
|