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

Add identifiers prefix generation #20

Open
sanex3339 opened this issue Mar 5, 2020 · 2 comments
Open

Add identifiers prefix generation #20

sanex3339 opened this issue Mar 5, 2020 · 2 comments

Comments

@sanex3339
Copy link
Member

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!

@slig
Copy link
Collaborator

slig commented Mar 5, 2020

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!

@softworkz
Copy link

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

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

No branches or pull requests

3 participants