Skip to content

Error with es6 destructuring #29

Closed

Description

@eltiodelsofa

Create test.js file with

function foo({bar}) {
  return bar;
}

foo({bar: 'baz'});

$ javascript-obfuscator test.js
$ node test-obfuscated.js

ReferenceError: _0x5c1443 is not defined

_0x5c1443 is bar in original return bar; but foo({bar}) can not be changed.
I think the only solution is with _0x5c1443 = obj.bar;
I am using babel over the obfuscated file to solve the problem

$ node -v
v6.9.4

$ javascript-obfuscator --version
0.8.4

Activity

  1. sanex3339 commented on Jan 11, 2017

    @sanex3339
    Member

    Thank you for the issue. I will fix it later today.

  2. added 2 commits that reference this issue on Jan 11, 2017
  3. sanex3339 commented on Jan 11, 2017

    @sanex3339
    Member

    [email protected] and [email protected] are out

    After fix all Identifier nodes inside object destructing inside function params and variable declaration will be skipped, so after obfuscation your example will be like:

        function _0x303cfa({ bar }) {
            return bar;
        }
    
        _0x303cfa({
            '\x62\x61\x72': '\x62\x61\x7a'
        });

    I will think about transforming of object destructing to es5 like it did Babel, but if i will do it, it will be in 0.9.0.

    function _0x303cfa(_0xabc123) {
        var _0xcde345 = _0xabc123['\x62\x61\x72'];
    
        return _0xcde345;
    }
    

    Right now i thinking that transform es6 code to es5 is a bad idea, i don't want to copy big amount of logic from Babel transformers to javascript-obfuscator transformers.

  4. sanex3339 commented on Jan 11, 2017

    @sanex3339
    Member

    Hoops, i forgot about catch clause =(

  5. sanex3339 commented on Jan 11, 2017

    @sanex3339
    Member

    [email protected] and [email protected] are out (with fix of CatchClause node ObjectPattern parameter)

  6. sanex3339 commented on Jan 11, 2017

    @sanex3339
    Member

    Also latest changes available under dev tag - [email protected] and javascript-obfuscator@dev

  7. eltiodelsofa commented on Jan 11, 2017

    @eltiodelsofa
    Author

    Thanks for the quick fix, its works perfect.
    IMO is bad idea to make that babel do with variables because the purpose of the library is obfuscate, not transform es6 in es5. If someone want this behavior, always can use babel before obfuscate it.

  8. sanex3339 commented on Jan 12, 2017

    @sanex3339
    Member

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions