mirror of
https://github.com/jehna/humanify.git
synced 2026-04-28 01:55:56 +03:00
[GH-ISSUE #117] Syntax Error on Babel? #44
Labels
No labels
bug
enhancement
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/humanify#44
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Anooxy17 on GitHub (Sep 23, 2024).
Original GitHub issue: https://github.com/jehna/humanify/issues/117
obfuscated.txt
It's on OPENAI. Cant decode this file in OpenAI, cant on Gemini, local etc, nothing :(
@Yusufkulcu commented on GitHub (Sep 25, 2024):
I have the same problem, but no clear solution has been found
@jehna commented on GitHub (Sep 25, 2024):
Thank you for the detailed issue! I'll look into it. It seems that this line is indeed missing a
,:Tha does seem super strange to me, as there should definitely not be a space there. I'll have a look at it a bit later.
@Yusufkulcu commented on GitHub (Sep 25, 2024):
If you have time, could you also look at my problem, I would be very grateful
https://github.com/jehna/humanify/issues/111
@0xdevalias commented on GitHub (Sep 25, 2024):
@jehna @Anooxy17 Looking at the attached
obfuscated.txt, on what appears to be that same lines of code:It looks like the problem is less that there should be a
,, and more that that something is adding the_staticprefix to the variable where it presumably shouldn't be.I can see that a lot of the function names have a
staticprefix; not sure if that ended up confusing the LLM when it was trying to come up with useful param renames or similar; but that is where I would start looking.I wonder if running it again with
--verboseor similar would provide better info for debugging this further? May help narrow down where/why the_staticprefix is being introduced to things?Another theory is that the
_is being prefixed ontostaticto avoid it clashing with a JS keyword. I still don't know that it should be present for this param at all in general though.@0xdevalias commented on GitHub (Sep 26, 2024):
@Yusufkulcu Your problem in https://github.com/jehna/humanify/issues/111 (which is a duplicate of https://github.com/jehna/humanify/issues/54) isn't the same as the problem in this issue.
@Yusufkulcu Spamming other issues trying to draw more attention to an issue you raised is generally considered rude and bad practice in open-source.
@0xdevalias commented on GitHub (Sep 26, 2024):
I tried running this locally with the
--verboseflag. I didn't let it complete, but I did let it get past the aboveQpcode, without running into any errors:@Anooxy17 Are you able to run this again with
--verboseand see if you get the error again? And if so, can you paste the relevant logs (or maybe the full logs as an attachment)? That may help narrow down where the issue might be coming from.This is still my main theory though, particularly given the same
_static calculateQualityParameter'variable name' can be seen on lines 1327, 1329, 1330:I haven't looked deeply at the code that handles variable names returned from openai, but I am assuming OpenAI said to use
static calculateQualityParameteras a variable name, and thenhumanifyprefixed it with_; or similar based on something like this:@Anooxy17 commented on GitHub (Sep 26, 2024):
So should I open it on openai again or try it locally? With which model?
@Anooxy17 commented on GitHub (Sep 26, 2024):
@0xdevalias
errors.txt
It was made in OpenAI, not even went into over 70% now
@0xdevalias commented on GitHub (Sep 26, 2024):
This error seems to be related to the attempt to assign a value to an object within a
forloop, which isn't allowed:While I haven't looked deeply into it, this part makes me wonder if it's an issue with
webcrackand how it's choosing to inline certain variables/etc withinforloops.It seems
humanifyis currently usingwebcrack2.13.0:github.com/jehna/humanify@c2e0be679d/package.json (L61)Looking at the releases we can see that the latest version is
2.14.1:Looking at the release notes for
2.14.0, there is a line that talks about extracting sequences from for loops; I wonder if that would also fix this issue:It also seems to change how variables/parameters are named by default, which might give better starting names to pass to the LLM:
@Anooxy17 You could potentially try cloning the
humanifyrepo, bumpingwebcrackto the latest version inpackage.json, and then seeing if that resolves this issue.I'll also note that this seems like it might actually be a different issue to what was reported initially, so even if bumping
webcrackto the latest version helps solve it, it may still be worth looking deeper into the cause of the original issue.@Anooxy17 commented on GitHub (Sep 26, 2024):
@0xdevalias
Yeees, it exactly looks like different error now, im crazy right now, doesnt matter how much I try, I cant really deobfuscate this file 😆
I will try when I came back to home and let u know then, ty
@0xdevalias commented on GitHub (Sep 27, 2024):
Looks like @Yusufkulcu is hitting a similar sort of error now, so perhaps they can try the workaround steps above and see if that helps in their case too:
@0xdevalias commented on GitHub (Sep 27, 2024):
I made a few patches to my locally checked out version of
humanifyto help provide better output info + skip through to the relevant files that seem to be causing errors:src/unminify.ts:Then tried running it against
main.txt, configured to skip all of the extracted files except foroutput/6blF.js; but I didn't seem to run into an error when I ran it (for reference, I hadn't bumped my version ofwebcrackto the latest before running this):This is how the lines that originally caused the error seemed to look like after being extracted with
webcrack:And this is how the equivalent code looked after my run of
humanifyhad finished with it:Which we can contrast against the version that @Yusufkulcu got the error with, which seemed to end up as:
In the original code, the
_0x3becc8seems to only exist in that functions parameter + the usage of it within the function. That is the same for___dataProcessorwithin my version. So my best guess is that with @Yusufkulcu's version, the LLM must have chosen the invalid variable name_subscribeHandler.syncErrorThrownas a replacement or similar, but I can't really validate that as the screenshots/output shown in this comment https://github.com/jehna/humanify/issues/111#issuecomment-2378375379 seem to not mention what variable renames were being applied; which should have been shown in the output fromopenaiRename(Ref) (assuming they were runninghumanify openai, and nothumanify localor similar?)@jehna probably knows the answer to this better.. but from memory of skimming through the
humanifycode I don't think there is any context shared between the files being processed; so I wouldn't have expected the 'skip other files' hack I implemented above should have impacted the outcome.. so I'm even more confused as to why I can't reproduce the error that @Yusufkulcu was seeing.Edit: One thing I noticed is that when @Yusufkulcu was unpacking it
output/6blF.jswas file 63, yet when I was running unpacking it was file 66, so it seemswebcrack's file order may not be the same each time it's run (even though the filenames seem consistent, at least based on this one example)@Yusufkulcu commented on GitHub (Sep 27, 2024):
Thank you very much for your reply. I updated the "webcrack" package, but the same problem persists. The problem is another file this time. Interestingly, I can't find the file with the error.
@Yusufkulcu commented on GitHub (Sep 27, 2024):
@0xdevalias I am also grateful for your detailed Explanations
@Yusufkulcu commented on GitHub (Sep 27, 2024):
Instead of writing it on my own record, I mixed it up and wrote it here. Sorry
@0xdevalias commented on GitHub (Sep 27, 2024):
@Yusufkulcu Are you running
humanify openaior one of the other commands?Are you running with
--verbose?It looks like the screenshots of your latest output are still missing the critical detail I mentioned above; of what the before and after names are when the variables are renamed.
@Yusufkulcu Thats fine; now that you're getting the same types of errors; this is a good place to centralise the discussion of these types of error.
@Yusufkulcu commented on GitHub (Sep 27, 2024):
I'm using OpenAI. Right now - I ran it with -verbose . How can I post the Verbose log here
@0xdevalias commented on GitHub (Sep 27, 2024):
@Yusufkulcu Cool, does it have the log lines that talk about 'Renaming VAR' and 'Renamed to NEWVAR' or similar? Did it still get the error?
It should look something like this:
I usually copy/paste all of the text output from my terminal into a
.txtfile (eg. With notepad if you're on windows); then you should be able to attach that to a comment here.@Yusufkulcu commented on GitHub (Sep 27, 2024):
@Yusufkulcu commented on GitHub (Sep 27, 2024):
@0xdevalias
I noticed that the syntax error appears in a different file every time. This is something I don't understand.
@Yusufkulcu commented on GitHub (Sep 27, 2024):
It's really strange, the error occurs in a different file each time. I am adding the error logs below. "main.txt" is the original file, "+Branch.txt" is the file from which the error was received.
I use the "humanify openi" command
+Dal.txt
main.txt
verbose-log.txt
@Yusufkulcu commented on GitHub (Sep 28, 2024):
@0xdevalias @jehna I wonder if you have any ideas or suggestions.
@j4k0xb commented on GitHub (Sep 28, 2024):
I think I found the root issue:
The LLM generates
this.kLengthas a name -> detected as invalid and changed to_this.kLength:github.com/jehna/humanify@64a1b9511d/src/plugins/local-llm-rename/visit-all-identifiers.ts (L44-L50)The proper fix would be to use
toIdentifierfrom@babel/typesLLM use a random sampling technique
That's a different type of for-loop. But I'd recommend updating either way because of other bugs 😅
edit: https://github.com/jehna/humanify/pull/38 it's already the newest, just not in package.json for some reason
@Yusufkulcu commented on GitHub (Sep 28, 2024):
Where should the "toIdentifier" function be used? I don't fully understand the solution to the problem
@j4k0xb commented on GitHub (Sep 28, 2024):
Gonna make a PR in a few minutes
@Yusufkulcu commented on GitHub (Sep 28, 2024):
I am waiting
@Yusufkulcu commented on GitHub (Sep 28, 2024):
@j4k0xb
This fix seems to have worked, the files that previously gave errors are now progressing smoothly. I will inform you when the process is completed.
@0xdevalias commented on GitHub (Sep 29, 2024):
@Yusufkulcu Thanks for that verbose log, it seems to confirm that the bug is what I thought it might have been, with the LLM choosing an invalid variable name:
While the context it's showing doesn't make a lot of sense to me as to where
_0x53274bfits into it, we can see that the variable name chosen by the LLM wassetChangeDetection.prototype.updateValue, which obviously isn't valid for a single variable name:@Yusufkulcu This is happening because the bug is related to the LLM suggesting an invalid variable name. Because the LLM can come up with different answers every time it's run (related: https://github.com/jehna/humanify/issues/97), this is why the error ends up being in a different file each time.
@j4k0xb Agreed, that's the bug as I see it too. Thanks for pointing out the
safeRenamed/isValidIdentifierpart. I knew I read something about prefixing variables somewhere (eg. https://github.com/jehna/humanify/issues/8, https://github.com/jehna/humanify/issues/20), but hadn't looked deeply into the code to figure out where that was happening.@j4k0xb @jehna From a 2sec search I couldn't find rendered docs, but here's the relevant source for each:
isValidIdentifier:github.com/babel/babel@a2025d7d69/packages/babel-types/src/validators/isValidIdentifier.ts (L7-L25)toIdentifier:github.com/babel/babel@a2025d7d69/packages/babel-types/src/converters/toIdentifier.ts (L4-L26)toIdentifierdefinitely seems like a more robust approach than the current 'prefix with_' approach for sure.Though I wonder if a 'proper fix' should also involve tweaking how we prompt for/filter the suggestions coming back from the LLM itself as well. Like instead of just forcing an invalid suggestion to be valid (with
toIdentifier), we could detect that it's invalid (withisValidIdentifier) and then provide that feedback to the LLM, asking it to give a new suggestion; probably with some max retry limit; after which we could fall back to using the invalid suggestion run throughtoIdentifier, or log a warning and leave it un-renamed or similar.@j4k0xb Haha, yeah, that's fair enough. I didn't look too deeply + we didn't have a lot more information at the time so was just throwing out ideas/potentials 😅
@Yusufkulcu Basically on this line:
github.com/jehna/humanify@64a1b9511d/src/plugins/local-llm-rename/visit-all-identifiers.ts (L44)Since
toIdentifiercallsisValidIdentifierwithin itself, the basic workaround change could be as simple as:@j4k0xb Thanks for making a PR with the workaround fix!
Will add some thoughts to it (though realistically they can probably be handled as a separate PR)
@j4k0xb commented on GitHub (Sep 29, 2024):
Yeah there's for sure a way to improve (also mentioned in other issues afaik) if you're willing to do the work.
That PR is just a quick fix to prevent crashing.
@0xdevalias commented on GitHub (Sep 29, 2024):
@j4k0xb Yup, seems I mentioned a similar pattern in this comment:
Made a reference back to the suggestion here in this followup comment for continuity:
@Yusufkulcu commented on GitHub (Sep 29, 2024):
I had a question. The corresponding file size in the image is too large (134881 lines). And the processing of the file seems to take a very long time. Is there a faster way to do this? If the terminal screen closes the process will reset and that would be very sad
@Yusufkulcu commented on GitHub (Sep 29, 2024):
Thank you for your help, my problem has been solved
@Yusufkulcu commented on GitHub (Sep 29, 2024):
@0xdevalias Do you have any ideas on this?
@0xdevalias commented on GitHub (Oct 15, 2024):
@Yusufkulcu I don't particularly have any ideas on it except for making sure the terminal screen doesn't close, or using something like
screenortmuxor similar to run it in a background sort of shell.I assume the running slow is related to overall filesize and the calls to the LLM, not just inefficiency in the code, but this recent PR may slightly speed things up in the AST parsing/renaming aspect: