executor

package
v1.3.4-alpha6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForEachParams

func ForEachParams(params *NaslBuildInMethodParam, handle func(value *yakvm.Value))

Types

type Executor

type Executor struct {
	*yakvm.VirtualMachine

	Compiler *visitors.Compiler
	// contains filtered or unexported fields
}

func NewNaslExecutor

func NewNaslExecutor() *Executor

func NewWithContext

func NewWithContext() *Executor

func (*Executor) Compile

func (e *Executor) Compile(code string) error

func (*Executor) Debug

func (engine *Executor) Debug(bool2 ...bool)

func (*Executor) EvalInclude

func (e *Executor) EvalInclude(name string) error

func (*Executor) Exec

func (e *Executor) Exec(code, fileName string) error

func (*Executor) GetCompiler

func (e *Executor) GetCompiler() *visitors.Compiler

func (*Executor) IsDebug

func (e *Executor) IsDebug() bool

func (*Executor) RunFile

func (e *Executor) RunFile(path string) error
func (e *Executor) LoadScript(path string) (*NaslScriptInfo, error) {
	e.SetDescription(true)
	oldIns := e.GetScriptObject()
	defer func() {
		e.SetDescription(false)
		e.scriptObj = oldIns
	}()
	e.scriptObj = NewNaslScriptObject()
	e.scriptObj.OriginFileName = filepath.Base(path)
	code, err := os.ReadFile(path)
	if err != nil {
		script, err := NewNaslScriptObjectFromDb(e.scriptObj.OriginFileName, e.dbcache)
		if err != nil {
			return nil, utils.Errorf("not found script file: %s", path)
		}
		return script, err
	} else {
		err = e.safeEvalWithFileName(string(code), e.scriptObj.OriginFileName)
		return e.scriptObj, err
	}
}

func (*Executor) SafeEval

func (e *Executor) SafeEval(code string) (err error)

func (*Executor) SafeRunFile

func (e *Executor) SafeRunFile(path string) (err error)

func (*Executor) SetIncludePath

func (engine *Executor) SetIncludePath(path string)

func (*Executor) SetLib

func (e *Executor) SetLib(lib map[string]func(param *NaslBuildInMethodParam) any)

type NaslBuildInMethodParam

type NaslBuildInMethodParam struct {
	MapParams  map[string]*yakvm.Value
	ListParams []*yakvm.Value
}

func NewNaslBuildInMethodParam

func NewNaslBuildInMethodParam() *NaslBuildInMethodParam

func (*NaslBuildInMethodParam) GetParamByName

func (n *NaslBuildInMethodParam) GetParamByName(name string, defaultValue ...interface{}) *yakvm.Value

func (*NaslBuildInMethodParam) GetParamByNumber

func (n *NaslBuildInMethodParam) GetParamByNumber(index int, defaultValue ...interface{}) *yakvm.Value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL