npm

Join us for the upcoming webinar, "Enterprise JavaScript done right: the tools you love, the security you need."Sign up here »

safevm

1.3.5 • Public • Published

Safe secure Sandboxed VM for code.

    const safevm = require('safevm');

    result = safevm( // result is the module.exports
        function () {
            output("test");
        },
            // string or function of code to be run safely
        [{ output: console.log }],
            // array of context/globals, default use is the first or a new object
        { filename: "" }
            // Options from https://nodejs.org/api/vm.html#vm_vm_runinnewcontext_code_sandbox_options with a few added options like dirname, globalIndex, onError, etc.
    );

    result = safevm(require("fs").readFileSync("path/to/file.js"), {}, { filename: "vm.js"});

install

npm i safevm

Downloadsweekly downloads

3

version

1.3.5

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability