-
Notifications
You must be signed in to change notification settings - Fork 36
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
removeDeadNode
Function Issues with Conditional Statements
#90
Comments
I'm pushing a fix for this in flAST. I'll update when it's out. |
Btw, output containing empty if-else blocks are the intended behavior. Consider the following: var J;
if (J = true) {}
else {}
console.log(J ? 'success' : 'failure'); The test clause can contain any type of code that might have side effects, while returning either a truthy or falsy values, so it's hard to determine if it can be safely removed. I this the deobfuscation should err on the side of caution. |
I believed this is solved by #91 |
Thank you so much for your swift response, and for your relentless efforts in refining this important tool. I completely understand the concerns you raised about the potential side effects that could occur in the test clause. My apologies if my previous explanation was not as clear as it could be. What I was attempting to suggest was that in certain, well-defined scenarios, the conditional blocks can be safely simplified without altering the program's behavior. For example:
These changes ensure that no side-effects could occur, thus preserving the original intent of the code while also making it more succinct. |
I haven't thought of just keeping the test clause - that's a good idea! |
I believe that simplifying these if statements should be its own module, and not part of the |
Hopefully this was solved with the new |
Yes, I agree that this should be a separate new module. Thank you for your assistance. In dealing with obfuscated js files, I've also employed two approaches to simplify For example, transforming nested if (condition1) {
// ...
} else {
if (condition2) {
// ...
} else {
if (condition3) {
// ...
}
}
} into if (condition1) {
// ...
} else if (condition2) {
// ...
} else if (condition3) {
// ...
} And, turning nested if (condition1) {
if (condition2) {
if (condition3) {
// ...
}
}
} into combined conditions: if (condition1 && condition2 && condition3) {
// ...
} Both techniques reduce awkward indentation and improve code readability in my result. I believe these can also be incorporated into the new module. |
Description:
When running the
removeDeadNode
function on specific code snippets that contain conditional statements, two issues arise:For the snippet:
An error is thrown indicating a failure in generating code because
consequent
branch of the if statement isundefined
.For the snippet:
The output contains empty
if
andelse
blocks:Possible Solutions:
Enhance
removeDeadNode
to better handle conditional statements without braces.Add a new module to remove empty
if
andelse
blocks when deobfuscating, if that is considered ideal behavior.Again, I'm not certain which approach is best, but I would appreciate your expertise on how to best solve this issue. Thank you for your continuous efforts to improve this invaluable tool.
The text was updated successfully, but these errors were encountered: