-
Notifications
You must be signed in to change notification settings - Fork 78
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
Expand reserved Keywords list for renaming variables or functions #20
Comments
Hmm. This is an interesting view; e.g. const crypto = 'foo' But it is a global variable in browsers, which will cause shadowing to occur, which can break any code that is depending on the global variable. Very good that you brought this up, I've completely missed this. I'll fix this in the upcoming versions. |
I think I'd need to grab a list of all global browser variables to fix this reliably. Didn't find anything sufficient with a quick googling, so I'm thinking if I would add Playwright so I could do |
I suggest using https://www.npmjs.com/package/globals and adding an option to choose |
Maybe we can think of adding extra checks if the renamed variables clash with one another? I haven't seen evidence of this happening but it could be an unknown corner case. |
See also: |
@jehna I think this might come handy to get a list of all reserved browser keywords.
|
While debugging solutions to #117, @j4k0xb mentioned
I also note that Though it seemed to contain at least a few words that weren't included in Babel's list, from a quick manual diff:
I'm not sure how important those are, and why they were on the original reserved list but not in Babel's.
See also:
If this is to be included, I think that it should be a configurable option; so that we can pick not just between node/browser, but also choose to potentially disable it entirely. |
Hello, I found this repository and the capabilities from using it is miles better than Obfuscate io and other similar de-obfuscation websites.
However, there are many more reserved keywords that are not addressed in your
humanify/src/openai/is-reserved-word.ts
file. I found that the W3 schools website gave a more comprehensive list than what is found on the MDN website.(which looks to be where the reserved list you made seems to have been generated from)https://www.w3schools.com/js/js_reserved.asp & https://github.com/AnanthaRajuC/Reserved-Key-Words-list-of-various-programming-languages/blob/master/language-files/JavaScript%20Reserved%20Words.md & https://www.geeksforgeeks.org/javascript-reserved-words/
Most notably the keyword
crypto
was generated by your tool and will NOT work as it is a reserved HTML keyword.One possibility of preventing this problem from occurring is by making sure all generated keywords have the
_
character appended to the leftmost side of the keyword. similar to how C programmers dealt with changes without breaking older code. https://stackoverflow.com/questions/56211904/why-does-c-have-keywords-starting-with-underscoreI do, also, notice that obfuscation tools that rename vars to hex keywords will also have the underscore character appended to the leftmost side. likely to make sure all generated keywords are not accidentally used elsewhere.
Instead of how C uses the underscore to declare new reserved keywords, we will be taking advantage that NONE of the reserved keywords have the underscore character. Thus future proofing it for the foreseeable future.
For now, adding the keywords in the W3 schools lists would work just fine. However, there are also many more other keywords that could be used that we may not know about and appending the underscore to all generated keywords will prove to be a more robust method.
Also, I wish to make a note that the GPT will produce varying names. Seems like the first one I was given produced subpar results but subsequent retries made better names. This was tested a few days apart. I wonder if the GPT changes based on input given or something because this new iteration of names for this specific JS file is just better.
I also made an attempt to rewrite some of the code to use GPT-4o, and the new openAI package version. I then compared the returned output from your version of Humanify and my updated version of Humanify. Strangely enough your older package produced better names than the GPT-4o version. https://github.com/Acters/humanify-ng/tree/GPT4o
The text was updated successfully, but these errors were encountered: