@discue/somewhat-secure-insecure-fn-executor
Version:
Tries to isolate execution of untrusted code
17 lines (15 loc) • 442 B
JavaScript
/**
*
* @param {string} script the user provided script
* @param {Array.<string>} argNames variables to be destructured to make it seem like they were passed to the function as a parameter
* @returns {string}
*/
module.exports.wrapScript = (script, argNames = ['args']) => {
return `
function userSuppliedScript(params) {
'use strict'
const {${argNames.join(', ')}} = params
${script}
}`
}