Confine ExecutableManager file access to its managed directories - #18328
Open
arpitjain099 wants to merge 1 commit into
Open
Confine ExecutableManager file access to its managed directories#18328arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
ExecutableManager addresses files under libRoot and temporaryLibRoot by building the path with string concatenation, so a name containing parent directory segments or an absolute path resolves outside the directory the manager is responsible for. Add resolveUnderRoot(), which resolves the name against the root, normalizes the result and rejects anything that does not stay inside it, and route the by-name accessors through it. The has* predicates return false rather than throwing, since their callers treat them as simple existence checks. This is a robustness improvement in the shared accessor, so the trigger, UDF and pipe plugin paths that all use it get consistent behaviour from one place rather than each needing its own check. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
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.
Description
ExecutableManageraddresses files underlibRootandtemporaryLibRootby concatenating the root with a caller-supplied name:A name containing parent-directory segments, or an absolute path, therefore resolves outside the directory the manager is responsible for. The accessors have no check that the result stayed inside its root.
This adds
resolveUnderRoot(), which resolves the name against the root, normalizes it, and rejects anything that escapes:and routes the by-name accessors through it:
removeFileUnderLibRoot,hasFileUnderLibRoot,hasFileUnderInstallDir,hasFileUnderTemporaryRoot,saveTextAsFileUnderTemporaryRoot,removeFileUnderTemporaryRootandreadTextFromFileUnderTemporaryRoot.Putting it in the shared accessor means the trigger, UDF and pipe-plugin paths that all go through
ExecutableManagerget the same behaviour from one place, rather than each growing its own check and drifting apart later.The
has*methods returnfalseinstead of propagating the exception, since their callers use them as plain existence checks and would not expect one.Normal names are unaffected, including relative ones that stay inside the root such as
install/udf.jarorsub/../udf.jar.Tests
ExecutableManagerTestcovers:../name,../../name,sub/../../nameand an absolute path are all rejectedsaveTextAsFileUnderTemporaryRootwrites nothing to diskremoveFileUnderLibRootleaves the outside file in placehas*predicates returnfalsefor an escaping name rather than throwingVerified with
mvn -pl iotdb-core/node-commons -am -Dtest=ExecutableManagerTest test: 7 tests pass with the change, and 5 of the 7 fail without it.This PR has: