MCPcopy Create free account
hub / github.com/Adaptix-Framework/AdaptixC2 / NewScriptEngine

Function NewScriptEngine

AdaptixServer/core/axscript/engine.go:26–46  ·  view source on GitHub ↗
(name string, manager *ScriptManager)

Source from the content-addressed store, hash-verified

24}
25
26func NewScriptEngine(name string, manager *ScriptManager) *ScriptEngine {
27 rt := goja.New()
28 rt.SetFieldNameMapper(goja.UncapFieldNameMapper())
29
30 engine := &ScriptEngine{
31 runtime: rt,
32 name: name,
33 manager: manager,
34 functions: make(map[string]goja.Callable),
35 }
36
37 consoleObj := rt.NewObject()
38 consoleObj.Set("log", func(call goja.FunctionCall) goja.Value { return goja.Undefined() })
39 consoleObj.Set("warn", func(call goja.FunctionCall) goja.Value { return goja.Undefined() })
40 consoleObj.Set("error", func(call goja.FunctionCall) goja.Value { return goja.Undefined() })
41 consoleObj.Set("info", func(call goja.FunctionCall) goja.Value { return goja.Undefined() })
42 consoleObj.Set("debug", func(call goja.FunctionCall) goja.Value { return goja.Undefined() })
43 rt.Set("console", consoleObj)
44
45 return engine
46}
47
48func NewScriptEngineFromPath(scriptPath string, manager *ScriptManager) (*ScriptEngine, error) {
49 abs, err := filepath.Abs(scriptPath)

Callers 3

NewScriptEngineFromPathFunction · 0.85
LoadAgentScriptMethod · 0.85
LoadUserScriptMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected