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

Suggestion for how to make this module safer #662

Open
dmfenton opened this issue Apr 21, 2016 · 4 comments
Open

Suggestion for how to make this module safer #662

dmfenton opened this issue Apr 21, 2016 · 4 comments

Comments

@dmfenton
Copy link

dmfenton commented Apr 21, 2016

I came across an interesting module in the Node stdlib called vm. Since alasql makes heavy use of evaluating strings as functions as I thought this may be something to look at.

https://nodejs.org/api/vm.html

It allows you to specify to explicitly specify the execution context for a given script. Therefore you can disable things like requiring external modules, the filesystem api, etc

const vm = require('vm')
vm.runInContext('require("foo")', {})
ReferenceError: require is not defined
@mathiasrw
Copy link
Member

So you would use vm to run the string constructed functions?

It would be interesting to see if there is a performance gain or loss from this.

On another note: would also be usefull to run alasql as a whole in a vm

@dmfenton
Copy link
Author

I agree the performance trade off would be worth measuring. I don't think you could run all of alasql inside a vm without disabling user defined functions. User defined functions in general are the tricky part I think.

@mathiasrw
Copy link
Member

Do you know if vm can run within a vm?

@dmfenton
Copy link
Author

> vm.runInContext(vm.runInContext('2*2', vm.createContext()), vm.createContext({vm}))
4

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

No branches or pull requests

2 participants