diff -Nru node-static-eval-1.1.1/debian/changelog node-static-eval-2.0.0/debian/changelog --- node-static-eval-1.1.1/debian/changelog 2017-04-12 16:45:43.000000000 +0000 +++ node-static-eval-2.0.0/debian/changelog 2018-06-06 14:58:20.000000000 +0000 @@ -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 Wed, 06 Jun 2018 16:58:20 +0200 + node-static-eval (1.1.1-2) unstable; urgency=medium * Fix continuous integration. diff -Nru node-static-eval-1.1.1/debian/compat node-static-eval-2.0.0/debian/compat --- node-static-eval-1.1.1/debian/compat 2017-04-08 15:03:08.000000000 +0000 +++ node-static-eval-2.0.0/debian/compat 2018-06-06 14:58:20.000000000 +0000 @@ -1 +1 @@ -10 +11 diff -Nru node-static-eval-1.1.1/debian/control node-static-eval-2.0.0/debian/control --- node-static-eval-1.1.1/debian/control 2017-04-08 15:31:26.000000000 +0000 +++ node-static-eval-2.0.0/debian/control 2018-06-06 14:58:20.000000000 +0000 @@ -1,19 +1,20 @@ Source: node-static-eval -Section: web +Section: javascript Priority: optional Maintainer: Debian Javascript Maintainers Uploaders: Bastien Roucariès Build-Depends: - debhelper (>= 10) + debhelper (>= 11) , dh-buildinfo , dpkg-dev (>= 1.17.14) , nodejs (>= 4.7) , node-tape (>= 0.1.5) , node-escodegen (>= 1.8.1) -Standards-Version: 3.9.8 + , node-tap (>= 10) +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 -Nru node-static-eval-1.1.1/debian/copyright node-static-eval-2.0.0/debian/copyright --- node-static-eval-1.1.1/debian/copyright 2017-04-12 16:45:43.000000000 +0000 +++ node-static-eval-2.0.0/debian/copyright 2018-06-06 14:58:20.000000000 +0000 @@ -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 -Nru node-static-eval-1.1.1/debian/.git-dpm node-static-eval-2.0.0/debian/.git-dpm --- node-static-eval-1.1.1/debian/.git-dpm 2017-04-08 15:02:46.000000000 +0000 +++ node-static-eval-2.0.0/debian/.git-dpm 2018-06-06 14:56:38.000000000 +0000 @@ -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 -Nru node-static-eval-1.1.1/debian/rules node-static-eval-2.0.0/debian/rules --- node-static-eval-1.1.1/debian/rules 2017-04-08 15:15:11.000000000 +0000 +++ node-static-eval-2.0.0/debian/rules 2018-06-06 14:58:20.000000000 +0000 @@ -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 @@ 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 -Nru node-static-eval-1.1.1/debian/tests/control node-static-eval-2.0.0/debian/tests/control --- node-static-eval-1.1.1/debian/tests/control 2017-04-12 16:45:43.000000000 +0000 +++ node-static-eval-2.0.0/debian/tests/control 2018-06-06 14:58:20.000000000 +0000 @@ -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 -Nru node-static-eval-1.1.1/debian/tests/require node-static-eval-2.0.0/debian/tests/require --- node-static-eval-1.1.1/debian/tests/require 2017-04-07 21:47:24.000000000 +0000 +++ node-static-eval-2.0.0/debian/tests/require 2018-06-06 14:58:20.000000000 +0000 @@ -1,3 +1,3 @@ #!/bin/sh set -e -nodejs -e "require('static-eval');" +node -e "require('static-eval');" diff -Nru node-static-eval-1.1.1/debian/tests/runexamples node-static-eval-2.0.0/debian/tests/runexamples --- node-static-eval-1.1.1/debian/tests/runexamples 2017-04-12 16:45:43.000000000 +0000 +++ node-static-eval-2.0.0/debian/tests/runexamples 2018-06-06 14:58:20.000000000 +0000 @@ -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 -Nru node-static-eval-1.1.1/debian/tests/runtestsuite node-static-eval-2.0.0/debian/tests/runtestsuite --- node-static-eval-1.1.1/debian/tests/runtestsuite 2017-04-12 16:35:13.000000000 +0000 +++ node-static-eval-2.0.0/debian/tests/runtestsuite 2018-06-06 14:58:20.000000000 +0000 @@ -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 -Nru node-static-eval-1.1.1/index.js node-static-eval-2.0.0/index.js --- node-static-eval-1.1.1/index.js 2016-09-28 15:55:44.000000000 +0000 +++ node-static-eval-2.0.0/index.js 2017-10-05 08:58:45.000000000 +0000 @@ -4,7 +4,7 @@ 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 @@ } 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 @@ 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 -Nru node-static-eval-1.1.1/package.json node-static-eval-2.0.0/package.json --- node-static-eval-1.1.1/package.json 2016-09-28 15:55:44.000000000 +0000 +++ node-static-eval-2.0.0/package.json 2017-10-05 08:58:45.000000000 +0000 @@ -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 -Nru node-static-eval-1.1.1/test/eval.js node-static-eval-2.0.0/test/eval.js --- node-static-eval-1.1.1/test/eval.js 2016-09-28 15:55:44.000000000 +0000 +++ node-static-eval-2.0.0/test/eval.js 2017-10-05 08:58:45.000000000 +0000 @@ -62,3 +62,21 @@ }); 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