Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

static-eval

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

static-eval - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

37

index.js

@@ -7,3 +7,3 @@ var unparse = require('escodegen').generate;

var result = (function walk (node) {
var result = (function walk (node, scopeVars) {
if (node.type === 'Literal') {

@@ -101,3 +101,6 @@ return node.value;

var obj = walk(node.object);
if (obj === FAIL) return FAIL;
// do not allow access to methods on Function
if((obj === FAIL) || (typeof obj == 'function')){
return FAIL;
}
if (node.property.type === 'Identifier') {

@@ -115,3 +118,33 @@ return obj[node.property.name];

}
else if (node.type === 'ExpressionStatement') {
var val = walk(node.expression)
if (val === FAIL) return FAIL;
return val;
}
else if (node.type === 'ReturnStatement') {
return walk(node.argument)
}
else if (node.type === 'FunctionExpression') {
var bodies = node.body.body;
// Create a "scope" for our arguments
var oldVars = {};
Object.keys(vars).forEach(function(element){
oldVars[element] = vars[element];
})
node.params.forEach(function(key) {
if(key.type == 'Identifier'){
vars[key.name] = null;
}
});
for(var i in bodies){
if(walk(bodies[i]) === FAIL){
return FAIL;
}
}
// restore the vars and scope after we walk
vars = oldVars;
var keys = Object.keys(vars);

@@ -118,0 +151,0 @@ var vals = keys.map(function(key) {

2

package.json
{
"name": "static-eval",
"version": "1.1.1",
"version": "2.0.0",
"description": "evaluate statically-analyzable expressions",

@@ -5,0 +5,0 @@ "main": "index.js",

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