summaryrefslogtreecommitdiff
diff options
authorBastien Roucariès <rouca@debian.org>2018-06-06 16:58:20 +0200
committergit-ubuntu importer <ubuntu-devel-discuss@lists.ubuntu.com>2018-06-06 22:37:29 +0000
commit2d02a1d2ce4939b19f59397b0869bd9469b46710 (patch)
tree15ec934b939c90b630add7c089c81d3ee72cf69e
parent42dd9731d838ea3d75c131d7a76cb70378315681 (diff)
parente1d6bd545472c1d10dce4a682384a32ccb028528 (diff)
Imported using git-ubuntu import.
-rw-r--r--debian/.git-dpm14
-rw-r--r--debian/changelog8
-rw-r--r--debian/compat2
-rw-r--r--debian/control11
-rw-r--r--debian/copyright2
-rwxr-xr-xdebian/rules11
-rw-r--r--debian/tests/control6
-rwxr-xr-xdebian/tests/require2
-rwxr-xr-xdebian/tests/runexamples2
-rwxr-xr-xdebian/tests/runtestsuite13
-rw-r--r--index.js37
-rw-r--r--package.json2
-rw-r--r--test/eval.js18
13 files changed, 87 insertions, 41 deletions
diff --git a/debian/.git-dpm b/debian/.git-dpm
index 310ff72..9946e53 100644
--- a/debian/.git-dpm
+++ b/debian/.git-dpm
@@ -1,8 +1,8 @@
# see git-dpm(1) from git-dpm package
-ab81134a43431457508bc2ead500f2d93ac0a71d
-ab81134a43431457508bc2ead500f2d93ac0a71d
-ab81134a43431457508bc2ead500f2d93ac0a71d
-ab81134a43431457508bc2ead500f2d93ac0a71d
-node-static-eval_1.1.1.orig.tar.gz
-b3f452ab8c0f0f41784679695f14a973e0514a91
-3925
+2786e72af649857f826aafcf939bddd483544dfb
+2786e72af649857f826aafcf939bddd483544dfb
+2786e72af649857f826aafcf939bddd483544dfb
+2786e72af649857f826aafcf939bddd483544dfb
+node-static-eval_2.0.0.orig.tar.gz
+07fe54214994c14143984955cc125eaf5524ad53
+4260
diff --git a/debian/changelog b/debian/changelog
index 06b21d2..ec4b6f0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+node-static-eval (2.0.0-1) unstable; urgency=medium
+
+ * New upstream version
+ * Move to salsa
+ * Bump policy and compat
+
+ -- Bastien Roucariès <rouca@debian.org> Wed, 06 Jun 2018 16:58:20 +0200
+
node-static-eval (1.1.1-2) unstable; urgency=medium
* Fix continuous integration.
diff --git a/debian/compat b/debian/compat
index f599e28..b4de394 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-10
+11
diff --git a/debian/control b/debian/control
index 42419ab..a860db5 100644
--- a/debian/control
+++ b/debian/control
@@ -1,19 +1,20 @@
Source: node-static-eval
-Section: web
+Section: javascript
Priority: optional
Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org>
Uploaders: Bastien Roucariès <rouca@debian.org>
Build-Depends:
- debhelper (>= 10)
+ debhelper (>= 11)
, dh-buildinfo
, dpkg-dev (>= 1.17.14)
, nodejs (>= 4.7)
, node-tape (>= 0.1.5) <!nocheck>
, node-escodegen (>= 1.8.1) <!nocheck>
-Standards-Version: 3.9.8
+ , node-tap (>= 10) <!nocheck>
+Standards-Version: 4.1.4
Homepage: https://github.com/substack/static-eval
-Vcs-Git: https://anonscm.debian.org/git/collab-maint/node-static-eval.git
-Vcs-Browser: https://anonscm.debian.org/cgit/collab-maint/node-static-eval.git
+Vcs-Git: https://salsa.debian.org/js-team/node-static-eval.git
+Vcs-Browser: https://salsa.debian.org/js-team/node-static-eval
Package: node-static-eval
Architecture: all
diff --git a/debian/copyright b/debian/copyright
index 7486b92..54f7163 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,4 +1,4 @@
-Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: static-eval
Upstream-Contact: https://github.com/substack/static-eval/issues
Source: https://github.com/substack/static-eval
diff --git a/debian/rules b/debian/rules
index 86d350f..59a1e2b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -8,8 +8,8 @@
dh $@
override_dh_auto_test:
-ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
- tape test/*.js
+ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS) $(DEB_BUILD_PROFILES)))
+ tap -R spec test/*.js
else
@echo '**********************************************************'
@echo 'Skip test suite '
@@ -17,13 +17,10 @@ else
endif
override_dh_installexamples:
+ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS) $(DEB_BUILD_PROFILES)))
dh_installexamples
# patch example
find $(CURDIR)/debian/node-static-eval/usr/share/doc/node-static-eval/examples/ -name '*.js' -exec \
sed -i "s,require\s*[(]\s*'[.][.][^']*'\s*[)],require('static-eval'),g" {} \;
-
+endif
#override_dh_auto_build:
-
-
-
-
diff --git a/debian/tests/control b/debian/tests/control
index 9432198..1f92157 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,8 +1,8 @@
Tests: require
-Depends: node-static-eval
+Depends: node-static-eval, nodejs (>= 6)
Tests: runtestsuite
-Depends: node-static-eval, node-tape
+Depends: node-static-eval, node-tape, node-tap (>= 10)
Tests: runexamples
-Depends: node-static-eval
+Depends: node-static-eval, nodejs (>= 6)
diff --git a/debian/tests/require b/debian/tests/require
index bc775c9..d296d56 100755
--- a/debian/tests/require
+++ b/debian/tests/require
@@ -1,3 +1,3 @@
#!/bin/sh
set -e
-nodejs -e "require('static-eval');"
+node -e "require('static-eval');"
diff --git a/debian/tests/runexamples b/debian/tests/runexamples
index 86c102f..c13bd16 100755
--- a/debian/tests/runexamples
+++ b/debian/tests/runexamples
@@ -1,4 +1,4 @@
#!/bin/sh
set -e
cd /usr/share/doc/node-static-eval/examples/
-find . -name '*.js' -and ! -name 'eval.js' -print0 | xargs -0 -n1 nodejs
+find . -name '*.js' -and ! -name 'eval.js' -print0 | xargs -0 -n1 node
diff --git a/debian/tests/runtestsuite b/debian/tests/runtestsuite
index 162d106..a83c965 100755
--- a/debian/tests/runtestsuite
+++ b/debian/tests/runtestsuite
@@ -1,15 +1,4 @@
#!/bin/sh
set -e
-# notice the / at end in order to load this module
-PACKAGE='static-eval'
-SEDCMD="s,require\s*[(]\s*'[.][.]/?([^']*)'\s*[)],require('$PACKAGE/\1'),g"
-tmpdir=$(mktemp -d)
-trap 'rm -rf "$tmpdir"' EXIT INT TERM HUP
-
-cp -r test/ $tmpdir/test
-find test/ -name '*.js' -print0 | \
- xargs -0 -n1 \
- sh -c 'set -e; echo "Create: $3"; sed -E "$1" < "$3" > "$2/$3"' sedtape "$SEDCMD" "$tmpdir"
-# avoid false that does not work outside build dir
-tape $tmpdir/test/*.js
+tap -R spec test/*.js
diff --git a/index.js b/index.js
index fef382d..3cfbdba 100644
--- a/index.js
+++ b/index.js
@@ -4,7 +4,7 @@ module.exports = function (ast, vars) {
if (!vars) vars = {};
var FAIL = {};
- var result = (function walk (node) {
+ var result = (function walk (node, scopeVars) {
if (node.type === 'Literal') {
return node.value;
}
@@ -97,7 +97,10 @@ module.exports = function (ast, vars) {
}
else if (node.type === 'MemberExpression') {
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') {
return obj[node.property.name];
}
@@ -110,7 +113,37 @@ module.exports = function (ast, vars) {
if (val === FAIL) return FAIL;
return val ? walk(node.consequent) : walk(node.alternate)
}
+ 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);
var vals = keys.map(function(key) {
return vars[key];
diff --git a/package.json b/package.json
index 5e79dd6..d62b312 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "static-eval",
- "version": "1.1.1",
+ "version": "2.0.0",
"description": "evaluate statically-analyzable expressions",
"main": "index.js",
"dependencies": {
diff --git a/test/eval.js b/test/eval.js
index 443b532..c8d3d25 100644
--- a/test/eval.js
+++ b/test/eval.js
@@ -62,3 +62,21 @@ test('evaluate this', function(t) {
});
t.equal(res, 101);
});
+
+test('FunctionExpression unresolved', function(t) {
+ t.plan(1);
+
+ var src = '(function(){console.log("Not Good")})';
+ var ast = parse(src).body[0].expression;
+ var res = evaluate(ast, {});
+ t.equal(res, undefined);
+});
+
+test('MemberExpressions from Functions unresolved', function(t) {
+ t.plan(1);
+
+ var src = '(function () {}).constructor';
+ var ast = parse(src).body[0].expression;
+ var res = evaluate(ast, {});
+ t.equal(res, undefined);
+}); \ No newline at end of file