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

Isolated VM possible ? #418

Closed
TerminalFi opened this issue Mar 8, 2023 · 2 comments
Closed

Isolated VM possible ? #418

TerminalFi opened this issue Mar 8, 2023 · 2 comments

Comments

@TerminalFi
Copy link

Looking at Tengo for a larger initiative but noticed that tengo scripts have direct access to the host if using OS or if implementing a http library. Is there a native capability to isolate tengo code completely ?

@geseq
Copy link
Collaborator

geseq commented Mar 9, 2023

You can choose to not include the libraries that provide access to host. Something like

	s := script.New([]byte(code))
	s.SetImports(stdlib.GetModuleMap("math", "text", "times", "json", "enum"))

	c, err := s.Compile()
	if err != nil {
		return result, err
	}

	if err = c.Run(); err != nil {
		return result, err
	}

@geseq geseq closed this as completed Mar 9, 2023
@TerminalFi
Copy link
Author

You can choose to not include the libraries that provide access to host. Something like


	s := script.New([]byte(code))

	s.SetImports(stdlib.GetModuleMap("math", "text", "times", "json", "enum"))



	c, err := s.Compile()

	if err != nil {

		return result, err

	}



	if err = c.Run(); err != nil {

		return result, err

	}

So no is the right answer, I know I don't have to include those modules. That wasn't what I was asking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants