Skip to content

Commit

Permalink
make option to enable allowAccessToMethodsOnFunctions namely to be us…
Browse files Browse the repository at this point in the history
…ed by cwise transform
  • Loading branch information
archmoj committed Jun 11, 2020
1 parent 36587c2 commit e619afc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
var unparse = require('escodegen').generate;

module.exports = function (ast, vars) {
module.exports = function (ast, vars, opts) {
if(!opts) opts = {};
var rejectAccessToMethodsOnFunctions = !opts.allowAccessToMethodsOnFunctions;

if (!vars) vars = {};
var FAIL = {};

Expand Down Expand Up @@ -119,8 +122,9 @@ module.exports = function (ast, vars) {
}
else if (node.type === 'MemberExpression') {
var obj = walk(node.object, noExecute);
// do not allow access to methods on Function
if((obj === FAIL) || (typeof obj == 'function')){
if((obj === FAIL) || (
(typeof obj == 'function') && rejectAccessToMethodsOnFunctions
)){
return FAIL;
}
if (node.property.type === 'Identifier' && !node.computed) {
Expand Down

0 comments on commit e619afc

Please sign in to comment.