[GH-ISSUE #111] Error: Failed to stringify code #40

Closed
opened 2026-03-03 13:52:27 +03:00 by kerem · 30 comments
Owner

Originally created by @Yusufkulcu on GitHub (Sep 21, 2024).
Original GitHub issue: https://github.com/jehna/humanify/issues/111

I trade using chatgpt. I am getting the error shown in the screenshot. The file size is large (7mb on average) and the number of lines is high (134881 lines). What is the problem? Can you help me? This is very important to me

image

Originally created by @Yusufkulcu on GitHub (Sep 21, 2024). Original GitHub issue: https://github.com/jehna/humanify/issues/111 I trade using chatgpt. I am getting the error shown in the screenshot. The file size is large (7mb on average) and the number of lines is high (134881 lines). What is the problem? Can you help me? This is very important to me ![image](https://github.com/user-attachments/assets/4684e355-ff6e-4fa4-a524-637eeb08f74c)
kerem closed this issue 2026-03-03 13:52:27 +03:00
Author
Owner

@Yusufkulcu commented on GitHub (Sep 22, 2024):

@jehna please help me

<!-- gh-comment-id:2365657627 --> @Yusufkulcu commented on GitHub (Sep 22, 2024): @jehna please help me
Author
Owner

@jehna commented on GitHub (Sep 22, 2024):

Can you run humanify using --verbose flag and post the output? It gives a lot more debug data to work with

<!-- gh-comment-id:2365690213 --> @jehna commented on GitHub (Sep 22, 2024): Can you run humanify using `--verbose` flag and post the output? It gives a lot more debug data to work with
Author
Owner

@Yusufkulcu commented on GitHub (Sep 22, 2024):

Can you run humanify using --verbose flag and post the output? It gives a lot more debug data to work with

I'm trying right now

<!-- gh-comment-id:2365717855 --> @Yusufkulcu commented on GitHub (Sep 22, 2024): > Can you run humanify using `--verbose` flag and post the output? It gives a lot more debug data to work with I'm trying right now
Author
Owner

@Yusufkulcu commented on GitHub (Sep 22, 2024):

@jehna

image

<!-- gh-comment-id:2365764329 --> @Yusufkulcu commented on GitHub (Sep 22, 2024): @jehna ![image](https://github.com/user-attachments/assets/dbf7bc3b-61cd-464c-95a0-01d4593ec195)
Author
Owner

@Yusufkulcu commented on GitHub (Sep 22, 2024):

@jehna

Do you have any suggestions on what I can do to fix the problem?

<!-- gh-comment-id:2366022938 --> @Yusufkulcu commented on GitHub (Sep 22, 2024): @jehna Do you have any suggestions on what I can do to fix the problem?
Author
Owner

@jehna commented on GitHub (Sep 22, 2024):

Hmm. Seems like an issue with some of the dependencies, at least that error does not originate from humanify's code.
In hindsight it seems that using pkgroll was a bad idea, as it seems to mess with the dependencies' stack traces.
I think this would need some extra debugging to solve.

<!-- gh-comment-id:2366124192 --> @jehna commented on GitHub (Sep 22, 2024): Hmm. Seems like an issue with some of the dependencies, at least that error does not originate from humanify's code. In hindsight it seems that using pkgroll was a bad idea, as it seems to mess with the dependencies' stack traces. I think this would need some extra debugging to solve.
Author
Owner

@Yusufkulcu commented on GitHub (Sep 22, 2024):

Hmm. Bazı bağımlılıklarla ilgili bir sorun gibi görünüyor, en azından bu hata humanify'ın kodundan kaynaklanmıyor. Geriye dönüp bakıldığında pkgroll'u kullanmanın kötü bir fikir olduğu anlaşılıyor, çünkü bağımlılıkların yığın izlerini bozuyor gibi görünüyor. Bunun çözülmesi için biraz daha hata ayıklamaya ihtiyaç olduğunu düşünüyorum.

@jehna

So what can I do as a solution? Solving this code is very important to me

<!-- gh-comment-id:2366143380 --> @Yusufkulcu commented on GitHub (Sep 22, 2024): > Hmm. Bazı bağımlılıklarla ilgili bir sorun gibi görünüyor, en azından bu hata humanify'ın kodundan kaynaklanmıyor. Geriye dönüp bakıldığında pkgroll'u kullanmanın kötü bir fikir olduğu anlaşılıyor, çünkü bağımlılıkların yığın izlerini bozuyor gibi görünüyor. Bunun çözülmesi için biraz daha hata ayıklamaya ihtiyaç olduğunu düşünüyorum. @jehna So what can I do as a solution? Solving this code is very important to me
Author
Owner

@Yusufkulcu commented on GitHub (Sep 22, 2024):

How can I send you error details

<!-- gh-comment-id:2366147466 --> @Yusufkulcu commented on GitHub (Sep 22, 2024): How can I send you error details
Author
Owner

@jehna commented on GitHub (Sep 22, 2024):

Whoops, closed this by accident. You could check which part of the bundle throws the error, that would help

<!-- gh-comment-id:2366242788 --> @jehna commented on GitHub (Sep 22, 2024): Whoops, closed this by accident. You could check which part of the bundle throws the error, that would help
Author
Owner

@Yusufkulcu commented on GitHub (Sep 22, 2024):

Whoops, closed this by accident. You could check which part of the bundle throws the error, that would help

@jehna

When I check, the "transformFromAstAsync" function in the "@babel/core" package gives an error. Since I'm not familiar with the package, I have no idea how to fix the problem. I would be grateful if you could help

image

<!-- gh-comment-id:2366257252 --> @Yusufkulcu commented on GitHub (Sep 22, 2024): > Whoops, closed this by accident. You could check which part of the bundle throws the error, that would help @jehna When I check, the "transformFromAstAsync" function in the "@babel/core" package gives an error. Since I'm not familiar with the package, I have no idea how to fix the problem. I would be grateful if you could help ![image](https://github.com/user-attachments/assets/64d59b6f-de1b-41b5-bad6-4756f4464a72)
Author
Owner

@Yusufkulcu commented on GitHub (Sep 22, 2024):

@jehna

Please help me

<!-- gh-comment-id:2366730880 --> @Yusufkulcu commented on GitHub (Sep 22, 2024): @jehna Please help me
Author
Owner

@Yusufkulcu commented on GitHub (Sep 22, 2024):

@jehna

Will you help?

<!-- gh-comment-id:2366863968 --> @Yusufkulcu commented on GitHub (Sep 22, 2024): @jehna Will you help?
Author
Owner

@jehna commented on GitHub (Sep 22, 2024):

@Yusufkulcu thanks for the additional info, but unfortunately I'm not able to respond to bigger work immediately (not being paid for doing ppen source etc)

<!-- gh-comment-id:2366864692 --> @jehna commented on GitHub (Sep 22, 2024): @Yusufkulcu thanks for the additional info, but unfortunately I'm not able to respond to bigger work immediately (not being paid for doing ppen source etc)
Author
Owner

@jehna commented on GitHub (Sep 22, 2024):

I think I'll be able to investigate more within a few weeks when I have some time

<!-- gh-comment-id:2366864922 --> @jehna commented on GitHub (Sep 22, 2024): I think I'll be able to investigate more within a few weeks when I have some time
Author
Owner

@Yusufkulcu commented on GitHub (Sep 22, 2024):

I understood. I would be very happy if I know when the study is concluded. We hope that it will be concluded as soon as possibleI understood. I would be very happy if I know when the study is concluded. Hoping to conclude it as soon as possible 😊

<!-- gh-comment-id:2366865274 --> @Yusufkulcu commented on GitHub (Sep 22, 2024): I understood. I would be very happy if I know when the study is concluded. We hope that it will be concluded as soon as possibleI understood. I would be very happy if I know when the study is concluded. Hoping to conclude it as soon as possible 😊
Author
Owner

@0xdevalias commented on GitHub (Sep 25, 2024):

When I check, the "transformFromAstAsync" function in the "@babel/core" package gives an error. Since I'm not familiar with the package, I have no idea how to fix the problem.

@Yusufkulcu I haven't looked too deeply into this, but I suspect the issue is likely not going to be directly within transformFromAstAsync within @babel/core; but more with how it is being used by either humanify's AST parsing code, or how the webcrack project it depends on is using it.

Looking up that "Failed to stringify code" error leads to this source within humanify:

github.com/jehna/humanify@2ac5d25d1d/src/plugins/local-llm-rename/visit-all-identifiers.ts (L57-L62)

It looks like it throws that when the result from transformFromAstAsync has a falsy value for stringified?.code

Depending on your skill at debugging, it might be useful to see what the value of ast being passed in is, as well as the full value of stringified that is being returned.

Depending on the sensitivity of the code you're running this on, it could also be useful if you're able to attach the code that consistently triggers this area; even better if you're first able to reduce it to a minimal example that triggers the error; as that would make it a lot easier for others to help debug/understand what might be causing it.

<!-- gh-comment-id:2372693405 --> @0xdevalias commented on GitHub (Sep 25, 2024): > When I check, the "transformFromAstAsync" function in the "@babel/core" package gives an error. Since I'm not familiar with the package, I have no idea how to fix the problem. @Yusufkulcu I haven't looked too deeply into this, but I suspect the issue is likely not going to be directly within `transformFromAstAsync` within `@babel/core`; but more with how it is being used by either `humanify`'s AST parsing code, or how the `webcrack` project it depends on is using it. Looking up that `"Failed to stringify code"` error leads to this source within `humanify`: https://github.com/jehna/humanify/blob/2ac5d25d1d6a314043e57d06bf4d57e61e03f649/src/plugins/local-llm-rename/visit-all-identifiers.ts#L57-L62 It looks like it throws that when the result from `transformFromAstAsync` has a falsy value for `stringified?.code` Depending on your skill at debugging, it might be useful to see what the value of `ast` being passed in is, as well as the full value of `stringified` that is being returned. Depending on the sensitivity of the code you're running this on, it could also be useful if you're able to attach the code that consistently triggers this area; even better if you're first able to reduce it to a minimal example that triggers the error; as that would make it a lot easier for others to help debug/understand what might be causing it.
Author
Owner

@Yusufkulcu commented on GitHub (Sep 25, 2024):

When I check, the "transformFromAstAsync" function in the "@babel/core" package gives an error. Since I'm not familiar with the package, I have no idea how to fix the problem.

@Yusufkulcu I haven't looked too deeply into this, but I suspect the issue is likely not going to be directly within transformFromAstAsync within @babel/core; but more with how it is being used by either humanify's AST parsing code, or how the webcrack project it depends on is using it.

Looking up that "Failed to stringify code" error leads to this source within humanify:

github.com/jehna/humanify@2ac5d25d1d/src/plugins/local-llm-rename/visit-all-identifiers.ts (L57-L62)

It looks like it throws that when the result from transformFromAstAsync has a falsy value for stringified?.code

Depending on your skill at debugging, it might be useful to see what the value of ast being passed in is, as well as the full value of stringified that is being returned.

Depending on the sensitivity of the code you're running this on, it could also be useful if you're able to attach the code that consistently triggers this area; even better if you're first able to reduce it to a minimal example that triggers the error; as that would make it a lot easier for others to help debug/understand what might be causing it.

I didn't understand exactly what I was supposed to do:(

<!-- gh-comment-id:2373040871 --> @Yusufkulcu commented on GitHub (Sep 25, 2024): > > When I check, the "transformFromAstAsync" function in the "@babel/core" package gives an error. Since I'm not familiar with the package, I have no idea how to fix the problem. > > @Yusufkulcu I haven't looked too deeply into this, but I suspect the issue is likely not going to be directly within `transformFromAstAsync` within `@babel/core`; but more with how it is being used by either `humanify`'s AST parsing code, or how the `webcrack` project it depends on is using it. > > Looking up that `"Failed to stringify code"` error leads to this source within `humanify`: > > https://github.com/jehna/humanify/blob/2ac5d25d1d6a314043e57d06bf4d57e61e03f649/src/plugins/local-llm-rename/visit-all-identifiers.ts#L57-L62 > > It looks like it throws that when the result from `transformFromAstAsync` has a falsy value for `stringified?.code` > > Depending on your skill at debugging, it might be useful to see what the value of `ast` being passed in is, as well as the full value of `stringified` that is being returned. > > Depending on the sensitivity of the code you're running this on, it could also be useful if you're able to attach the code that consistently triggers this area; even better if you're first able to reduce it to a minimal example that triggers the error; as that would make it a lot easier for others to help debug/understand what might be causing it. I didn't understand exactly what I was supposed to do:(
Author
Owner

@0xdevalias commented on GitHub (Sep 25, 2024):

I didn't understand exactly what I was supposed to do:(

@Yusufkulcu At a minimum, if you are able to attach the code you're trying to decrypt, that would be really useful to help narrow things down.

<!-- gh-comment-id:2373147616 --> @0xdevalias commented on GitHub (Sep 25, 2024): > I didn't understand exactly what I was supposed to do:( @Yusufkulcu At a minimum, if you are able to attach the code you're trying to decrypt, that would be really useful to help narrow things down.
Author
Owner

@Yusufkulcu commented on GitHub (Sep 25, 2024):

Tam olarak ne yapmam gerektiğini anlamadım :(

@YusufkulcuEn azından, şifresini çözmeye çalıştığınız kodu ekleyebilirseniz, bu, işleri daraltmanıza yardımcı olmak için gerçekten yararlı olacaktır.

Yes, you are right, I have attached the file below. Github I uploaded it to my Google drive account because it doesn't allow javascript file uploading.

https://drive.google.com/file/d/1H9_g6L32xMchrpi-dIRksz7MyQkmWm2a/view?usp=drivesdk

@jehna
@0xdevalias

<!-- gh-comment-id:2373184179 --> @Yusufkulcu commented on GitHub (Sep 25, 2024): > > Tam olarak ne yapmam gerektiğini anlamadım :( > > @YusufkulcuEn azından, şifresini çözmeye çalıştığınız kodu ekleyebilirseniz, bu, işleri daraltmanıza yardımcı olmak için gerçekten yararlı olacaktır. Yes, you are right, I have attached the file below. Github I uploaded it to my Google drive account because it doesn't allow javascript file uploading. https://drive.google.com/file/d/1H9_g6L32xMchrpi-dIRksz7MyQkmWm2a/view?usp=drivesdk @jehna @0xdevalias
Author
Owner

@0xdevalias commented on GitHub (Sep 25, 2024):

I uploaded it to my Google drive account because it doesn't allow javascript file uploading.

@Yusufkulcu Thanks. If you just rename the .js file to .txt that would usually let you upload it directly to GitHub as well.

<!-- gh-comment-id:2373219756 --> @0xdevalias commented on GitHub (Sep 25, 2024): > I uploaded it to my Google drive account because it doesn't allow javascript file uploading. @Yusufkulcu Thanks. If you just rename the .js file to .txt that would usually let you upload it directly to GitHub as well.
Author
Owner

@Yusufkulcu commented on GitHub (Sep 25, 2024):

Javascript dosya yüklemeye izin vermediği için Google Drive hesabıma yükledim.

@YusufkulcuTeşekkürler. .js dosyasının adını .txt olarak değiştirirseniz genellikle onu doğrudan GitHub'a da yükleyebilirsiniz.

I uploaded it to my Google drive account because it doesn't allow javascript file uploading.

@Yusufkulcu Thanks. If you just rename the .js file to .txt that would usually let you upload it directly to GitHub as well.

I uploaded it to my Google drive account because it doesn't allow javascript file uploading.

@Yusufkulcu Thanks. If you just rename the .js file to .txt that would usually let you upload it directly to GitHub as well.

Thanks for the info. I reloaded it as txt. I will be waiting for your help. It's an important project for me
main.txt

<!-- gh-comment-id:2373233206 --> @Yusufkulcu commented on GitHub (Sep 25, 2024): > > Javascript dosya yüklemeye izin vermediği için Google Drive hesabıma yükledim. > > @YusufkulcuTeşekkürler. .js dosyasının adını .txt olarak değiştirirseniz genellikle onu doğrudan GitHub'a da yükleyebilirsiniz. > > I uploaded it to my Google drive account because it doesn't allow javascript file uploading. > > @Yusufkulcu Thanks. If you just rename the .js file to .txt that would usually let you upload it directly to GitHub as well. > > I uploaded it to my Google drive account because it doesn't allow javascript file uploading. > > @Yusufkulcu Thanks. If you just rename the .js file to .txt that would usually let you upload it directly to GitHub as well. Thanks for the info. I reloaded it as txt. I will be waiting for your help. It's an important project for me [main.txt](https://github.com/user-attachments/files/17126700/main.txt)
Author
Owner

@0xdevalias commented on GitHub (Sep 26, 2024):

Thanks for the info. I reloaded it as txt.

@Yusufkulcu Thanks for that. I ran it through the web version of and it seemed to unpack correctly there, which makes it a higher likelihood that the issue is withinhumanify`:

Depending on your use case, I wonder if you might be able to use that unpacked/unmangled version as a starting point for your analysis; even though it doesn't have the 'nice variable renames' that humanify adds on top? You might also be able to run humanify against individual files from that extracted version in the interim as well.

<!-- gh-comment-id:2375625766 --> @0xdevalias commented on GitHub (Sep 26, 2024): > Thanks for the info. I reloaded it as txt. @Yusufkulcu Thanks for that. I ran it through the web version of ` and it seemed to unpack correctly there, which makes it a higher likelihood that the issue is within `humanify`: - https://webcrack.netlify.app/ Depending on your use case, I wonder if you might be able to use that unpacked/unmangled version as a starting point for your analysis; even though it doesn't have the 'nice variable renames' that `humanify` adds on top? You might also be able to run `humanify` against individual files from that extracted version in the interim as well.
Author
Owner

@0xdevalias commented on GitHub (Sep 26, 2024):

@Yusufkulcu Looking at your screenshot from https://github.com/jehna/humanify/issues/111#issuecomment-2365764329, it looks like the error is occuring on file 18:

image

Looking at the code where this happens, it seems to be within unminify, just after webcrack has run to extract the files, and in the main loop where those files are being processed:

github.com/jehna/humanify@c2e0be679d/src/unminify.ts (L6-L30)

Since even with --verbose enabled, humanify doesn't output the filenames it's processing, it makes it a bit harder to debug; but running it through a debugger we can see what 'file 18' of extractedFiles corresponds with anyway (assuming webcrack consistently unpacks the code the same way); which since the output log shows i + 1, that makes it actually entry 17 in the array (because it's 0-indexed); which seems to be the extracted file 1.js:

image

Looking at the contents of output/1.js, we can see that it's an empty file:

⇒ cat output/1.js | wc -m
       0

As part of the main unminify loop, the code then calls plugins.reduce on the plugins passed in to unminify:

github.com/jehna/humanify@c2e0be679d/src/commands/openai.ts (L26-L30)

When run as humanify openai, these plugins are:

  • babel (Ref)
  • openaiRename({ apiKey, model: opts.model }) (Ref)
  • prettier (Ref)

The Failed to stringify code error you're seeing comes from the visitAllIdentifiers function, just after calling babel's transformFromAstAsync:

github.com/jehna/humanify@c2e0be679d/src/plugins/local-llm-rename/visit-all-identifiers.ts (L57-L61)

Which is called by the openaiRename plugin that is passed to unminify:

github.com/jehna/humanify@c2e0be679d/src/plugins/openai/openai-rename.ts (L6-L38)

transformFromAstAsync accepts a parsed ast, and returns an object with code, map, and ast.

Presumably, with an empty file as input, that would result in an empty ast, which when passed to transformFromAstAsync, would result in an empty string returned in the code field.

Given the check that ends up throwing the error you're seeing is looking for a falsy value in stringified.code; the empty string would definitely trigger that:

github.com/jehna/humanify@c2e0be679d/src/plugins/local-llm-rename/visit-all-identifiers.ts (L57-L62)


@Yusufkulcu @jehna So the above seems to be the debugging as to the 'why' of what is going on; though I'm not familiar enough with the codebase to suggest where the best point of implementing the fix is.

If I was to suggest the most minimal/localised fix, it would be to the if (!stringified?.code) check within visitAllIdentifiers (Ref)

Though an argument could also be made that filtering out empty/similar files at the unminify level could have it's merits (Ref); though that would then make it less generic/flexible, as theoretically a plugin in the chain could make it a non-empty file before the openaiRename actually needs to process it.

So I still think the best fix is probably within visitAllIdentifiers.

In fact, in looking through related issues, this just seems to be a variation of the same root cause that I raised in this issue:

I also think the general CLI output should be improved to explain what is happening better. eg. a message before running webcrack, outputting the actual filenames (not just the file number), etc.

These issues also seem to tangentially relate to some aspect of this latter suggestion:

<!-- gh-comment-id:2375785482 --> @0xdevalias commented on GitHub (Sep 26, 2024): @Yusufkulcu Looking at your screenshot from https://github.com/jehna/humanify/issues/111#issuecomment-2365764329, it looks like the error is occuring on file 18: ![image](https://github.com/user-attachments/assets/48fcd461-2e3c-466d-a4ce-9230c8d8bf3a) Looking at the code where this happens, it seems to be within `unminify`, just after `webcrack` has run to extract the files, and in the main loop where those files are being processed: https://github.com/jehna/humanify/blob/c2e0be679dcab43ec684668202d709f41452c0e9/src/unminify.ts#L6-L30 Since even with `--verbose` enabled, `humanify` doesn't output the filenames it's processing, it makes it a bit harder to debug; but running it through a debugger we can see what 'file 18' of `extractedFiles` corresponds with anyway (assuming `webcrack` consistently unpacks the code the same way); which since the output log shows `i + 1`, that makes it actually entry 17 in the array (because it's 0-indexed); which seems to be the extracted file `1.js`: ![image](https://github.com/user-attachments/assets/2d0d066f-e113-405f-bbe4-c5bfa30a6d75) Looking at the contents of `output/1.js`, we can see that it's an empty file: ```shell ⇒ cat output/1.js | wc -m 0 ``` As part of the main `unminify` loop, the code then calls `plugins.reduce` on the `plugins` passed in to `unminify`: https://github.com/jehna/humanify/blob/c2e0be679dcab43ec684668202d709f41452c0e9/src/commands/openai.ts#L26-L30 When run as `humanify openai`, these plugins are: - `babel` ([Ref](https://github.com/jehna/humanify/blob/main/src/plugins/babel/babel.ts)) - `openaiRename({ apiKey, model: opts.model })` ([Ref](https://github.com/jehna/humanify/blob/main/src/plugins/openai/openai-rename.ts)) - `prettier` ([Ref](https://github.com/jehna/humanify/blob/main/src/plugins/prettier.ts)) The `Failed to stringify code` error you're seeing comes from the `visitAllIdentifiers` function, just after calling `babel`'s `transformFromAstAsync`: https://github.com/jehna/humanify/blob/c2e0be679dcab43ec684668202d709f41452c0e9/src/plugins/local-llm-rename/visit-all-identifiers.ts#L57-L61 - https://babeljs.io/docs/babel-core#transformfromastasync Which is called by the `openaiRename` plugin that is passed to `unminify`: https://github.com/jehna/humanify/blob/c2e0be679dcab43ec684668202d709f41452c0e9/src/plugins/openai/openai-rename.ts#L6-L38 `transformFromAstAsync` accepts a parsed `ast`, and returns an object with `code`, `map`, and `ast`. Presumably, with an empty file as input, that would result in an empty ast, which when passed to `transformFromAstAsync`, would result in an empty string returned in the `code` field. Given the check that ends up throwing the error you're seeing is looking for a falsy value in `stringified.code`; the empty string would definitely trigger that: https://github.com/jehna/humanify/blob/c2e0be679dcab43ec684668202d709f41452c0e9/src/plugins/local-llm-rename/visit-all-identifiers.ts#L57-L62 --- @Yusufkulcu @jehna So the above seems to be the debugging as to the 'why' of what is going on; though I'm not familiar enough with the codebase to suggest where the best point of implementing the fix is. If I was to suggest the most minimal/localised fix, it would be to the `if (!stringified?.code)` check within `visitAllIdentifiers` ([Ref](https://github.com/jehna/humanify/blob/c2e0be679dcab43ec684668202d709f41452c0e9/src/plugins/local-llm-rename/visit-all-identifiers.ts#L57-L62)) Though an argument could also be made that filtering out empty/similar files at the `unminify` level could have it's merits ([Ref](https://github.com/jehna/humanify/blob/c2e0be679dcab43ec684668202d709f41452c0e9/src/unminify.ts#L6-L30)); though that would then make it less generic/flexible, as theoretically a plugin in the chain could make it a non-empty file before the `openaiRename` actually needs to process it. So I still think the best fix is probably within `visitAllIdentifiers`. In fact, in looking through related issues, this just seems to be a variation of the same root cause that I raised in this issue: - https://github.com/jehna/humanify/issues/54 I also think the general CLI output should be improved to explain what is happening better. eg. a message before running `webcrack`, outputting the actual filenames (not just the file number), etc. These issues also seem to tangentially relate to some aspect of this latter suggestion: - https://github.com/jehna/humanify/issues/92 - https://github.com/jehna/humanify/issues/58
Author
Owner

@Yusufkulcu commented on GitHub (Sep 26, 2024):

Thanks for the info. I reloaded it as txt.

@Yusufkulcu Thanks for that. I ran it through the web version of and it seemed to unpack correctly there, which makes it a higher likelihood that the issue is withinhumanify`:

Depending on your use case, I wonder if you might be able to use that unpacked/unmangled version as a starting point for your analysis; even though it doesn't have the 'nice variable renames' that humanify adds on top? You might also be able to run humanify against individual files from that extracted version in the interim as well.

Thanks for the suggested solution. It works largely without "beautifying variable" values. But my goal is to change it completely. It seems to take a long time to decode the files in the "outputs" folder one by one with Humanify. Is there a shortcut to this?

<!-- gh-comment-id:2375898753 --> @Yusufkulcu commented on GitHub (Sep 26, 2024): > > Thanks for the info. I reloaded it as txt. > > @Yusufkulcu Thanks for that. I ran it through the web version of `and it seemed to unpack correctly there, which makes it a higher likelihood that the issue is within`humanify`: > > * https://webcrack.netlify.app/ > > Depending on your use case, I wonder if you might be able to use that unpacked/unmangled version as a starting point for your analysis; even though it doesn't have the 'nice variable renames' that `humanify` adds on top? You might also be able to run `humanify` against individual files from that extracted version in the interim as well. Thanks for the suggested solution. It works largely without "beautifying variable" values. But my goal is to change it completely. It seems to take a long time to decode the files in the "outputs" folder one by one with Humanify. Is there a shortcut to this?
Author
Owner

@0xdevalias commented on GitHub (Sep 26, 2024):

It seems to take a long time to decode the files in the "outputs" folder one by one with Humanify. Is there a shortcut to this?

@Yusufkulcu Do you mean that the process takes a long time in general? Or that having to manually run it against each file takes a long time?

If the latter, you could probably extract them with webcrack, then write a bash script/similar that runs humanify on each of those files individually. I'm not 100% sure how the renames works across module boundaries/for exports/similar.. but I think it already reads/parses each of the split files individually anyway, so I don't think it would be much worse to run it this way..

Actually.. it will probably still be a bit slower because of the startup boilerplate, and then trying to run webcrack against the file each time (even though they are already split)..

While it's not currently a feature, if you're going to need to be re-running the variable renaming process on future versions of the same code, this feature request would probably also be relevant to you:


@jehna It might be a neat/useful feature to be able to run humanify against a source file (or multiple files/directory of files/etc) while bypassing the webcrack step; that way it could be used on files that had already been unpacked/etc with webcrack (or another tool like wakaru) previously.

Edit: I split this last part into its own issue:

<!-- gh-comment-id:2376061750 --> @0xdevalias commented on GitHub (Sep 26, 2024): > It seems to take a long time to decode the files in the "outputs" folder one by one with Humanify. Is there a shortcut to this? @Yusufkulcu Do you mean that the process takes a long time in general? Or that having to manually run it against each file takes a long time? If the latter, you could probably extract them with `webcrack`, then write a bash script/similar that runs `humanify` on each of those files individually. I'm not 100% sure how the renames works across module boundaries/for exports/similar.. but I think it already reads/parses each of the split files individually anyway, so I don't think it would be much worse to run it this way.. Actually.. it will probably still be a bit slower because of the startup boilerplate, and then trying to run `webcrack` against the file each time (even though they are already split).. While it's not currently a feature, if you're going to need to be re-running the variable renaming process on future versions of the same code, this feature request would probably also be relevant to you: - https://github.com/jehna/humanify/issues/97 --- @jehna It might be a neat/useful feature to be able to run `humanify` against a source file (or multiple files/directory of files/etc) while bypassing the `webcrack` step; that way it could be used on files that had already been unpacked/etc with `webcrack` (or another tool like `wakaru`) previously. **Edit:** I split this last part into its own issue: - https://github.com/jehna/humanify/issues/129
Author
Owner

@Yusufkulcu commented on GitHub (Sep 26, 2024):

It seems to take a long time to decode the files in the "outputs" folder one by one with Humanify. Is there a shortcut to this?

@Yusufkulcu Do you mean that the process takes a long time in general? Or that having to manually run it against each file takes a long time?

If the latter, you could probably extract them with webcrack, then write a bash script/similar that runs humanify on each of those files individually. I'm not 100% sure how the renames works across module boundaries/for exports/similar.. but I think it already reads/parses each of the split files individually anyway, so I don't think it would be much worse to run it this way..

Actually.. it will probably still be a bit slower because of the startup boilerplate, and then trying to run webcrack against the file each time (even though they are already split)..

While it's not currently a feature, if you're going to need to be re-running the variable renaming process on future versions of the same code, this feature request would probably also be relevant to you:

@jehna It might be a neat/useful feature to be able to run humanify against a source file (or multiple files/directory of files/etc) while bypassing the webcrack step; that way it could be used on files that had already been unpacked/etc with webcrack (or another tool like wakaru) previously.

Edit: Split this last part into its own issue:

Thank you for your detailed explanation. I'm going to try the parsed source code separately by writing a script that implements the humanify command. I have one more question.

What is the reason why the "Webcrack" package breaks the code into pieces. I divide it into many files in the Outputs folder and I don't know what they are. I wonder if you can explain that. Thank you in advance

<!-- gh-comment-id:2376157841 --> @Yusufkulcu commented on GitHub (Sep 26, 2024): > > It seems to take a long time to decode the files in the "outputs" folder one by one with Humanify. Is there a shortcut to this? > > @Yusufkulcu Do you mean that the process takes a long time in general? Or that having to manually run it against each file takes a long time? > > If the latter, you could probably extract them with `webcrack`, then write a bash script/similar that runs `humanify` on each of those files individually. I'm not 100% sure how the renames works across module boundaries/for exports/similar.. but I think it already reads/parses each of the split files individually anyway, so I don't think it would be much worse to run it this way.. > > Actually.. it will probably still be a bit slower because of the startup boilerplate, and then trying to run `webcrack` against the file each time (even though they are already split).. > > While it's not currently a feature, if you're going to need to be re-running the variable renaming process on future versions of the same code, this feature request would probably also be relevant to you: > > * [More deterministic renames across different versions of the same code #97](https://github.com/jehna/humanify/issues/97) > > @jehna It might be a neat/useful feature to be able to run `humanify` against a source file (or multiple files/directory of files/etc) while bypassing the `webcrack` step; that way it could be used on files that had already been unpacked/etc with `webcrack` (or another tool like `wakaru`) previously. > > **Edit:** Split this last part into its own issue: > > * [Allow running humanify against one or more source files that have already been unpacked (eg. skip re-running through webcrack) #129](https://github.com/jehna/humanify/issues/129) Thank you for your detailed explanation. I'm going to try the parsed source code separately by writing a script that implements the humanify command. I have one more question. What is the reason why the "Webcrack" package breaks the code into pieces. I divide it into many files in the Outputs folder and I don't know what they are. I wonder if you can explain that. Thank you in advance
Author
Owner

@0xdevalias commented on GitHub (Sep 26, 2024):

Thank you for your detailed explanation. I'm going to try the parsed source code separately by writing a script that implements the humanify command.

@Yusufkulcu It might actually be quicker for you to just clone the humanify repo and temporarily patch the code to skip trying to run against empty files.

I haven't tried it, but a quick/dirty hack fix could just be to add an if check to skip empty files within unminify:

Something like:

  export async function unminify(
    filename: string,
    outputDir: string,
    plugins: ((code: string) => Promise<string>)[] = []
  ) {
    ensureFileExists(filename);
    const bundledCode = await fs.readFile(filename, "utf-8");
    const extractedFiles = await webcrack(bundledCode, outputDir);
  
    for (let i = 0; i < extractedFiles.length; i++) {
      console.log(`Processing file ${i + 1}/${extractedFiles.length}`);
  
      const file = extractedFiles[i];
      const code = await fs.readFile(file.path, "utf-8");
+     if (code) {
      const formattedCode = await plugins.reduce(
        (p, next) => p.then(next),
        Promise.resolve(code)
      );
  
      verbose.log("Input: ", code);
      verbose.log("Output: ", formattedCode);
  
      await fs.writeFile(file.path, formattedCode);
+     }
+     else {
+       verbose.log(`Skipping empty file ${i + 1} (${file.path})`);
+     }
    }
  }

While this wouldn't really be suited for a proper fix, it should hopefully be enough to do what you need to work around this bug in the meantime.


What is the reason why the "Webcrack" package breaks the code into pieces. I divide it into many files in the Outputs folder and I don't know what they are. I wonder if you can explain that.

@Yusufkulcu The original source file you provided is a webpack bundle of code (or similar), where the original many code files have been combined into a single file. When webcrack runs on it, it 'undoes' this bundling, and so splits the single file back into many files similar to how it was originally.

<!-- gh-comment-id:2378108249 --> @0xdevalias commented on GitHub (Sep 26, 2024): > Thank you for your detailed explanation. I'm going to try the parsed source code separately by writing a script that implements the humanify command. @Yusufkulcu It might actually be quicker for you to just clone the `humanify` repo and temporarily patch the code to skip trying to run against empty files. I haven't tried it, but a quick/dirty hack fix could just be to add an `if` check to skip empty files within [`unminify`](https://github.com/jehna/humanify/blob/c2e0be679dcab43ec684668202d709f41452c0e9/src/unminify.ts#L19-L28): Something like: ```diff export async function unminify( filename: string, outputDir: string, plugins: ((code: string) => Promise<string>)[] = [] ) { ensureFileExists(filename); const bundledCode = await fs.readFile(filename, "utf-8"); const extractedFiles = await webcrack(bundledCode, outputDir); for (let i = 0; i < extractedFiles.length; i++) { console.log(`Processing file ${i + 1}/${extractedFiles.length}`); const file = extractedFiles[i]; const code = await fs.readFile(file.path, "utf-8"); + if (code) { const formattedCode = await plugins.reduce( (p, next) => p.then(next), Promise.resolve(code) ); verbose.log("Input: ", code); verbose.log("Output: ", formattedCode); await fs.writeFile(file.path, formattedCode); + } + else { + verbose.log(`Skipping empty file ${i + 1} (${file.path})`); + } } } ``` While this wouldn't really be suited for a proper fix, it should hopefully be enough to do what you need to work around this bug in the meantime. --- > What is the reason why the "Webcrack" package breaks the code into pieces. I divide it into many files in the Outputs folder and I don't know what they are. I wonder if you can explain that. @Yusufkulcu The original source file you provided is a [webpack](https://webpack.js.org/) bundle of code (or similar), where the original many code files have been combined into a single file. When `webcrack` runs on it, it 'undoes' this bundling, and so splits the single file back into many files similar to how it was originally.
Author
Owner

@Yusufkulcu commented on GitHub (Sep 27, 2024):

ensureFileExists(filename);
    const bundledCode = await fs.readFile(filename, "utf-8");
    const extractedFiles = await webcrack(bundledCode, outputDir);
  
    for (let i = 0; i < extractedFiles.length; i++) {
      console.log(`Processing file ${i + 1}/${extractedFiles.length}`);
  
      const file = extractedFiles[i];
      const code = await fs.readFile(file.path, "utf-8");
+     if (code) {
      const formattedCode = await plugins.reduce(
        (p, next) => p.then(next),
        Promise.resolve(code)
      );
  
      verbose.log("Input: ", code);
      verbose.log("Output: ", formattedCode);
  
      await fs.writeFile(file.path, formattedCode);
+     }
+     else {
+       verbose.log(`Skipping empty file ${i + 1} (${file.path})`);
+     }
    }

Thanks for the suggestion, it doesn't give that error anymore, but now I'm getting another error. I get the following error in file 63. I've added the original file and the file where I got the error below. It's a pretty long mistake, so I added some more pictures.

image

image

image

image

image

image

6blF.txt

main.txt

<!-- gh-comment-id:2378375379 --> @Yusufkulcu commented on GitHub (Sep 27, 2024): > ```diff > ensureFileExists(filename); > const bundledCode = await fs.readFile(filename, "utf-8"); > const extractedFiles = await webcrack(bundledCode, outputDir); > > for (let i = 0; i < extractedFiles.length; i++) { > console.log(`Processing file ${i + 1}/${extractedFiles.length}`); > > const file = extractedFiles[i]; > const code = await fs.readFile(file.path, "utf-8"); > + if (code) { > const formattedCode = await plugins.reduce( > (p, next) => p.then(next), > Promise.resolve(code) > ); > > verbose.log("Input: ", code); > verbose.log("Output: ", formattedCode); > > await fs.writeFile(file.path, formattedCode); > + } > + else { > + verbose.log(`Skipping empty file ${i + 1} (${file.path})`); > + } > } > ``` Thanks for the suggestion, it doesn't give that error anymore, but now I'm getting another error. I get the following error in file 63. I've added the original file and the file where I got the error below. It's a pretty long mistake, so I added some more pictures. ![image](https://github.com/user-attachments/assets/6518b0bb-7bad-4578-9e8a-29cb31cb96c8) ![image](https://github.com/user-attachments/assets/3d272c0f-d75a-43dc-9267-c7671681c5bf) ![image](https://github.com/user-attachments/assets/ae1f81db-4aa6-48ec-920a-1a205bceabe6) ![image](https://github.com/user-attachments/assets/3f3ce8f4-85fc-4752-a306-e4f06709fed8) ![image](https://github.com/user-attachments/assets/7ace8a21-5367-4061-acec-9e64ffaacbee) ![image](https://github.com/user-attachments/assets/51556cad-a031-4c89-acfd-8770a086bc78) [6blF.txt](https://github.com/user-attachments/files/17158987/6blF.txt) [main.txt](https://github.com/user-attachments/files/17158990/main.txt)
Author
Owner

@0xdevalias commented on GitHub (Sep 27, 2024):

Thanks for the suggestion, it doesn't give that error anymore, but now I'm getting another error. I get the following error in file 63. I've added the original file and the file where I got the error below. It's a pretty long mistake, so I added some more pictures.

6blF.txt

main.txt

image

..snip..

image

..snip..

@Yusufkulcu I'm glad that workaround helped get around the first issue :)

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 |    };

That new error you're running into seems to now be the same/similar to the errors being discussed in this issue:

You might like to try the potential solution I described in this comment, RE: cloning the humanify repo and bumping the webcrack version in package.json to the latest version (2.14.1):

<!-- gh-comment-id:2378407904 --> @0xdevalias commented on GitHub (Sep 27, 2024): > Thanks for the suggestion, it doesn't give that error anymore, but now I'm getting another error. I get the following error in file 63. I've added the original file and the file where I got the error below. It's a pretty long mistake, so I added some more pictures. > [6blF.txt](https://github.com/user-attachments/files/17158987/6blF.txt) > > [main.txt](https://github.com/user-attachments/files/17158990/main.txt) > ![image](https://private-user-images.githubusercontent.com/69112573/371389851-6518b0bb-7bad-4578-9e8a-29cb31cb96c8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mjc0MTMzNzksIm5iZiI6MTcyNzQxMzA3OSwicGF0aCI6Ii82OTExMjU3My8zNzEzODk4NTEtNjUxOGIwYmItN2JhZC00NTc4LTllOGEtMjljYjMxY2I5NmM4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTI3VDA0NTc1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM1MTE1ZmQ1M2E1ZjdlMzc4N2UxYmFiODUzMjRhODVmMjRhNGExYzY1NWY3ODkxMjIxYjVhZjQwZDQzNDk2MWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Egw90ef2egH2t60qtkMxxIIo2bJOck2g5OHu3DW1yyA) > > ..snip.. > > ![image](https://private-user-images.githubusercontent.com/69112573/371390037-3f3ce8f4-85fc-4752-a306-e4f06709fed8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mjc0MTMzNzksIm5iZiI6MTcyNzQxMzA3OSwicGF0aCI6Ii82OTExMjU3My8zNzEzOTAwMzctM2YzY2U4ZjQtODVmYy00NzUyLWEzMDYtZTRmMDY3MDlmZWQ4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTI3VDA0NTc1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE0MDNlNzM2MzBiN2MwOGVmOGRkN2MxODUwYmEyZjRmYmVkZjNmMGJhOGY3MWIzMDZkZTU0M2ZkYTdmMDU0NDkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.PRBPC8-RLSWIAkdj4HZg4lEpahI-XvNOx1D9Zkb6H4E) > > ..snip.. @Yusufkulcu I'm glad that workaround helped get around the first issue :) > ```shell > 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 | }; > ``` That new error you're running into seems to now be the same/similar to the errors being discussed in this issue: - https://github.com/jehna/humanify/issues/117 You might like to try the potential solution I described in this comment, RE: cloning the `humanify` repo and bumping the `webcrack` version in `package.json` to the latest version (`2.14.1`): - https://github.com/jehna/humanify/issues/117#issuecomment-2378098164
Author
Owner

@0xdevalias commented on GitHub (Sep 29, 2024):

For context/continuity, @j4k0xb has raised 2 bugfix PR's for the bugs identified in this issue:

<!-- gh-comment-id:2381048545 --> @0xdevalias commented on GitHub (Sep 29, 2024): For context/continuity, @j4k0xb has raised 2 bugfix PR's for the bugs identified in this issue: - https://github.com/jehna/humanify/pull/133 - https://github.com/jehna/humanify/pull/134
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/humanify#40
No description provided.