Fix ClassesProcessor not whitelisting class files#594
Open
aoqia194 wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
I forgot to mention that it's also possible to just check the folders exist again right before writing the file, but I think this might be cheaper anyway? Also it may be better internally that these folders are marked as whitelisted in the first place. |
Contributor
Author
|
I'm converting this to draft because this same issue has come up again on this branch despite this fixing it previously? |
2300a57 to
e5ecff0
Compare
Contributor
Author
|
Ok it seems that this still works after checking, I think it was just user error with my vineflower wrapper. Maybe to prevent false-positives in the whitelisting with this extra check, we can also check for a suffix like |
d10b4f3 to
f77c88e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #593!
This PR branch should probably be tested on the CLI against some other projects, because I am not sure if adding this second check will influence anything.
An explanation about the bug
When using
--only=com/example, thecom/exampleis marked as a whitelisted prefix; thus any directories in a JAR being matched against these whitelist prefixes will be created. However, when matching a singular class file (e.g.--only=com/example/MyClass), the original check against the to-be-created directorycom/examplewould fail.The check will boil down to:
and it is obvious that this would fail, thus the directory would not be created, and after decompilation happens and the class file is being dumped to a file, it will fail because of the parent directories not existing.
It took me a few hours to find a fix that didn't feel hacky, though I will admit that this still feels a little hacky and might have some unknown-to-me consequences. This simple change will affect this whitelist check and makes the check:
This check satisfies the directory-creating code and will create the directories just fine. Yippee!