New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jailed-function

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jailed-function - npm Package Compare versions

Comparing version 0.5.5 to 0.5.6

26

lib/jailed-function.js

@@ -21,6 +21,3 @@ "use strict";

const allowedNodeTypes = (0, types_extractor_1.extractTypes)(baseLanguageSubset + languageSubset);
const reservedGlobalIdentifiers = [
'createRuntime',
'__globals'
];
const reservedIdentifiersValues = Object.values(util_1.reservedIdentifiers);
const readOnlyNatives = {

@@ -95,3 +92,3 @@ console: (0, util_2.readOnly)((0, util_1.getConsole)(), (0, util_1.createGetTrap)([

}
if (reservedGlobalIdentifiers.indexOf(name) !== -1) {
if (reservedIdentifiersValues.indexOf(name) !== -1) {
throw new Error(`Reserved identifier '${name}'`);

@@ -101,5 +98,4 @@ }

const { code = '' } = (0, compiler_1.compile)(source, allowedNodeTypes, globalNamesSet);
const __globals = '__globals';
const resetContext = (0, endent_1.default) `const { ${globalNamesSet.join(', ')} } = ${__globals};`;
const transformedCode = `"use strict"; exports.default = (${__globals}) => { ${resetContext} ${__globals} = void 0;
const resetContext = (0, endent_1.default) `const { ${globalNamesSet.join(', ')} } = ${util_1.reservedIdentifiers.globals}`;
const transformedCode = `"use strict"; exports.default = (${util_1.reservedIdentifiers.globals}, ${util_1.reservedIdentifiers.runtime}) => { ${resetContext}
${`return ${code}`}

@@ -111,9 +107,2 @@ }`;

const vmCtx = {
createRuntime: () => {
return (0, runtime_1.createRuntime)({
timeout,
syncTimeout,
memoryLimit,
});
},
exports: Object.create(null),

@@ -144,5 +133,10 @@ };

}
const runtime = (0, runtime_1.createRuntime)({
timeout,
syncTimeout,
memoryLimit,
});
// execute function
const result = (fn
.call(null, importedGlobals)
.call(null, importedGlobals, runtime)
.apply(null, importedArgs));

@@ -149,0 +143,0 @@ // deep-clone results

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createRuntimePlugin = void 0;
const util_1 = require("./util");
const getParentFunctionNode = (t, path) => {

@@ -158,7 +159,5 @@ let parent = path;

&& functionPath.node.async) {
;
functionPath.isTopLevel = true;
state.runtimeInstanceIdentifier = functionPath.scope.generateUidIdentifier('r');
const runtimeAssignment = t.assignmentExpression('=', state.runtimeInstanceIdentifier, t.callExpression(t.identifier('createRuntime'), []));
functionPath.scope.push(t.declareVariable(state.runtimeInstanceIdentifier));
functionPath.node.body.body.unshift(t.expressionStatement(runtimeAssignment));
state.runtimeInstanceIdentifier = t.identifier(util_1.reservedIdentifiers.runtime);
}

@@ -165,0 +164,0 @@ else {

@@ -5,3 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.readOnly = exports.getConsole = exports.isProduction = exports.isThenable = exports.isPrimitive = exports.isFunction = exports.isObject = exports.noop = exports.isReadOnly = exports.createGetTrap = exports.isValidIdentifier = exports.formatBytes = exports.isProtectedProperty = exports.sizeOf = void 0;
exports.readOnly = exports.getConsole = exports.isProduction = exports.isThenable = exports.isPrimitive = exports.isFunction = exports.isObject = exports.noop = exports.isReadOnly = exports.reservedIdentifiers = exports.createGetTrap = exports.isValidIdentifier = exports.formatBytes = exports.isProtectedProperty = exports.sizeOf = void 0;
const sizeOf = (obj) => {

@@ -82,2 +82,6 @@ let bytes = 2;

const readOnlySymbol = Symbol('read-only');
exports.reservedIdentifiers = {
globals: '$$g',
runtime: '$$r',
};
const isReadOnly = (obj) => !(0, exports.isPrimitive)(obj) && obj[readOnlySymbol];

@@ -84,0 +88,0 @@ exports.isReadOnly = isReadOnly;

{
"name": "jailed-function",
"version": "0.5.5",
"version": "0.5.6",
"description": "Safely run untrusted code",

@@ -5,0 +5,0 @@ "keywords": ["sandbox", "jail", "vm", "low-code"],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc