-
Notifications
You must be signed in to change notification settings - Fork 68
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
Syntax Error on Babel? #117
Comments
I have the same problem, but no clear solution has been found |
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. |
If you have time, could you also look at my problem, I would be very grateful |
@jehna @Anooxy17 Looking at the attached # ..snip..
static Qp(a, b) {
let c = new ib;
var d = w.J(a.d0, Ob)
, e = w.J(a.d1, Ob);
let f = a.color
, g = a.strength;
# ..snip.. It looks like the problem is less that there should be a I can see that a lot of the function names have a I wonder if running it again with Another theory is that the |
@Yusufkulcu Your problem in #111 (which is a duplicate of #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. |
I tried running this locally with the
@Anooxy17 Are you able to run this again with
This is still my main theory though, particularly given the same
I haven't looked deeply at the code that handles variable names returned from openai, but I am assuming OpenAI said to use |
So should I open it on openai again or try it locally? With which model? |
@0xdevalias |
This error seems to be related to the attempt to assign a value to an object within a
While I haven't looked deeply into it, this part makes me wonder if it's an issue with It seems Line 61 in c2e0be6
Looking at the releases we can see that the latest version is Looking at the release notes for
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 I'll also note that this seems like it might actually be a different issue to what was reported initially, so even if bumping |
@0xdevalias |
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: SyntaxError: Unexpected token, expected "," (74:70)
72 | });
73 | };
74 | subscribeHandler.prototype._subscribe = function (_subscribeHandler.syncErrorThrown) {
| ^
75 | var sourceObject = this.source;
76 | return sourceObject && sourceObject.subscribe(_subscribeHandler.syncErrorThrown);
77 | };
|
I made a few patches to my locally checked out version of
diff --git a/src/unminify.ts b/src/unminify.ts
index 948b4df..ff95ae0 100644
--- a/src/unminify.ts
+++ b/src/unminify.ts
@@ -9,22 +9,42 @@ export async function unminify(
plugins: ((code: string) => Promise<string>)[] = []
) {
ensureFileExists(filename);
+
+ console.log(`Reading input file: ${filename}`);
const bundledCode = await fs.readFile(filename, "utf-8");
+
+ console.log('Running webcrack to extract/decrypt bundled code...');
const extractedFiles = await webcrack(bundledCode, outputDir);
+ console.log(`Unbundled ${extractedFiles.length} files from ${filename} into ${outputDir}`);
+
for (let i = 0; i < extractedFiles.length; i++) {
- console.log(`Processing file ${i + 1}/${extractedFiles.length}`);
-
const file = extractedFiles[i];
+
+ console.log(`Processing file ${i + 1}/${extractedFiles.length} (${file.path})`);
+
+ // Skip extracted files till we find the one we actually want to try and process
+ if (file.path !== `${outputDir}/6blF.js`) {
+ console.log(' [hack] Skipping files that are not the one we want to process');
+ continue;
+ }
+
const code = await fs.readFile(file.path, "utf-8");
- const formattedCode = await plugins.reduce(
- (p, next) => p.then(next),
- Promise.resolve(code)
- );
+ if (code) {
+ const formattedCode = await plugins.reduce(
+ (p, next) => p.then(next),
+ Promise.resolve(code)
+ );
- verbose.log("Input: ", code);
- verbose.log("Output: ", formattedCode);
+ verbose.log(" Input: ", code);
+ verbose.log(" Output: ", formattedCode);
- await fs.writeFile(file.path, formattedCode);
+ await fs.writeFile(file.path, formattedCode);
+ }
+ else {
+ verbose.log(` Skipping empty file ${i + 1} (${file.path})`);
+ }
}
+
+ console.log(`Unminified (or skipped) ${extractedFiles.length} files from ${filename} into ${outputDir}`);
}
Then tried running it against This is how the lines that originally caused the error seemed to look like after being extracted with // ..snip..
_0x223285.prototype._subscribe = function (_0x3becc8) {
var _0x2e0ffb = this.source;
return _0x2e0ffb && _0x2e0ffb.subscribe(_0x3becc8);
};
// ..snip.. And this is how the equivalent code looked after my run of // ..snip..
createSubscription.prototype._subscribe = function (___dataProcessor) {
var sourceSubscription = this.source;
return sourceSubscription && sourceSubscription.subscribe(___dataProcessor);
};
// ..snip.. Which we can contrast against the version that @Yusufkulcu got the error with, which seemed to end up as: // ..snip..
subscribeHandler.prototype._subscribe = function (_subscribeHandler.syncErrorThrown) {
var sourceObject = this.source;
return sourceObject && sourceObject.subscribe(_subscribeHandler.syncErrorThrown);
};
// ..snip.. In the original code, the @jehna probably knows the answer to this better.. but from memory of skimming through the Edit: One thing I noticed is that when @Yusufkulcu was unpacking it |
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. |
@0xdevalias I am also grateful for your detailed Explanations |
Instead of writing it on my own record, I mixed it up and wrote it here. Sorry |
@Yusufkulcu Are you running Are you running with 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. |
I'm using OpenAI. Right now - I ran it with -verbose . How can I post the Verbose log here |
@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 |
|
I noticed that the syntax error appears in a different file every time. This is something I don't understand. |
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 |
@0xdevalias @jehna I wonder if you have any ideas or suggestions. |
I think I found the root issue: The LLM generates humanify/src/plugins/local-llm-rename/visit-all-identifiers.ts Lines 44 to 50 in 64a1b95
The proper fix would be to use
LLM use a random sampling technique
That's a different type of for-loop. But I'd recommend updating either way because of other bugs 😅 |
Where should the "toIdentifier" function be used? I don't fully understand the solution to the problem |
Gonna make a PR in a few minutes |
I am waiting |
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. |
@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
@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: #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
@j4k0xb @jehna From a 2sec search I couldn't find rendered docs, but here's the relevant source for each:
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
@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:
Since - let safeRenamed = isValidIdentifier(renamed) ? renamed : `_${renamed}`;
+ let safeRenamed = toIdentifier(renamed);
@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) |
Yeah there's for sure a way to improve (also mentioned in other issues afaik) if you're willing to do the work. |
@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: |
Thank you for your help, my problem has been solved |
@0xdevalias Do you have any ideas on this? |
@Yusufkulcu I don't particularly have any ideas on it except for making sure the terminal screen doesn't close, or using something like 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: |
obfuscated.txt
It's on OPENAI. Cant decode this file in OpenAI, cant on Gemini, local etc, nothing :(
The text was updated successfully, but these errors were encountered: