GithubHelp home page GithubHelp logo

caracal7 / vee-eight Goto Github PK

View Code? Open in Web Editor NEW

This project forked from devnullprod/vee-eight

0.0 0.0 0.0 11 KB

VEight - Execute untrusted JavaScript from NodeJS

License: MIT License

JavaScript 29.34% C++ 67.76% Python 2.90%

vee-eight's Introduction

vee-eight

Safely execute arbitrary untrusted JavaScript from nodejs. This module implements a lightweight isolated JavaScript environment that can be used to run any code without being able to escape the sandbox. The V8 context is initialized and executed entirely from C++ so it's impossible for the JS stack frames to lead back to the nodejs environment. It's usable from a nodejs process, but the JS environment is pure V8.

See example.js for usage

Installation

npm install vee-eight

Once installed, import it into your module via:

const VeeEight = require('vee-eight').VeeEight

API

Initialize a new VeeEight instance:

const v8 = new VeeEight()

Use execute(code) to run the specified code block:

v8.execute("1+2")
// #=> 3

State will be preserved between function calls:

v8.execute("var = 42")
v8.execute("var")
// # => 42

To clear the context invoke reset():

v8.reset()
v8.execute("var")
// # => ReferenceError: s is not defined

To limit long running operations, set a timeout with: timeout(milliseconds):

v8.timeout(1000) // 1 second timeout
v8.execute("while(true){}")
// # => timed out

License

vee-eight is licensed under The MIT License

vee-eight's People

Contributors

movitto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.