Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when obfuscating TypeScript with deadCodeInjection: true #78

Closed
msheakoski opened this issue Aug 1, 2017 · 6 comments
Closed

Comments

@msheakoski
Copy link

msheakoski commented Aug 1, 2017

Using webpack-obfuscator 0.10.1 (also with 0.10.0), I receive the following error when running webpack -p. It only occurs when deadCodeInjection is turned on and happens at any deadCodeInjectionThreshold. I'm not sure if it's my specific setup or an issue with javascript/webpack-obfuscator.

./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:52
                .keys(node)
                     ^
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at e (./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:52:22)
    at Array.map (native)
    at ./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:62:48
    at Array.forEach (native)
    at e (./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:54:25)
    at Array.map (native)
    at ./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:62:48
    at Array.forEach (native)
    at e (./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:54:25)
    at ./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:64:53
    at Array.forEach (native)
    at e (./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:54:25)
    at Array.map (native)
    at ./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:62:48
    at Array.forEach (native)
    at e (./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:54:25)
    at Array.map (native)
    at ./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:62:48
    at Array.forEach (native)
    at e (./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:54:25)
    at Array.map (native)
    at ./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:62:48
    at Array.forEach (native)
    at e (./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:54:25)
    at ./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:64:53
    at Array.forEach (native)
    at e (./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:54:25)
    at Array.map (native)
    at ./node_modules/javascript-obfuscator/dist/webpack:/src/node/NodeUtils.ts:62:48
@sanex3339
Copy link
Member

Interesting , can you attach your source code or simple project that can reproduce this error?

@msheakoski
Copy link
Author

msheakoski commented Aug 1, 2017

@sanex3339 I narrowed down the error to what I believe is related to TypeScript's generated code for async/await inside of a try/catch when targeting ES5 as the compilation language. Please see the attached .zip file for the example project that I made.

javascript-obfuscator-example.zip

@msheakoski msheakoski changed the title Error when deadCodeInjection: true Error when obfuscating TypeScript with deadCodeInjection: true Aug 1, 2017
@sanex3339
Copy link
Member

sanex3339 commented Aug 1, 2017

Oh, catch it!

This construction thows error:

_a.trys.push([0, 2, , 3]);

In ast tree empty array element parsed as null and i didn't expect this behaviour.
I'll release 0.10.2 in a hour or so.

@sanex3339
Copy link
Member

Fixed! Please check new javascript-obfuscator@0.10.2 and webpack-obfuscator@0.10.2.

@msheakoski
Copy link
Author

@sanex3339 I tested it out and the error no longer occurs during webpack compilation. The generated JavaScript appears to run without any visible issues in Chrome. Thank you! 👏👏👏

@sanex3339
Copy link
Member

You're welcome.

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

No branches or pull requests

2 participants