javascript-obfuscator / grunt-contrib-obfuscator

Grunt plugin for the javascript-obfuscator package.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add identifiers prefix generation

sanex3339 opened this issue · comments

Hi.
javascript-obfuscator/javascript-obfuscator#568

It would be nice if you add a unique identifier names prefix generation for each obfuscated file.
The prefix should be as aX, where X - number or counter of the current obfuscated file (0, 1, 2, ...)

The prefix can be overridden by the user prefix.

I just implemented this logic for webpack-obfuscator, you can see example:
javascript-obfuscator/webpack-obfuscator@2b227b2#diff-ed009b6b86b017532ef0489c77de5100

Thank you!

Hi,

I believe that grunt works differently from webpack. Here each task is specific for a group of files, so the prefix should be specified directly in that task options. On webpack each plugin works on multiple bundles, so there's no way to specify a prefix for each one individually and thus your new logic was necessary.

Inside each task, all the source files are concatenated together and then obfuscated, so there's no issues of duplicated identifiers inside each task https://github.com/javascript-obfuscator/grunt-contrib-obfuscator/blob/master/tasks/obfuscator.js#L58-L60

Please let me know what you think and if I got this right.

Thanks!

Inside each task, all the source files are concatenated together and then obfuscated, so there's no issues of duplicated identifiers inside each task master/tasks/obfuscator.js#L58-L60

Please let me know what you think and if I got this right.

This is not right, because depending on the task setup you can have many output files, even one output file for each input file and each output file needs its own identifiersPrefix.

I've created a PR here: #41 and for those who cannot wait (like me) a new Grunt task: https://www.npmjs.com/package/grunt-contrib-obfuscator-4