Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/protocols/common/protocolstate/js.go
2073 views
1
package protocolstate
2
3
import (
4
"github.com/Mzack9999/goja"
5
"github.com/Mzack9999/goja/parser"
6
"github.com/projectdiscovery/gologger"
7
)
8
9
// NewJSRuntime returns a new javascript runtime
10
// with defaults set
11
// i.e sourcemap parsing is disabled by default
12
func NewJSRuntime() *goja.Runtime {
13
vm := goja.New()
14
vm.SetParserOptions(parser.WithDisableSourceMaps)
15
// disable eval by default
16
if err := vm.Set("eval", "undefined"); err != nil {
17
gologger.Error().Msgf("could not set eval to undefined: %s", err)
18
}
19
return vm
20
}
21
22