Class SecurePathUtils
java.lang.Object
com.inductiveautomation.ignition.client.launch.util.SecurePathUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic Path
resolvePath
(Path baseDirPath, String first, String... more) Resolves an untrusted user-specified path against the API's base directory.static Path
resolvePath
(Path baseDirPath, Path userPath) Resolves an untrusted user-specified path against the API's base directory.
-
Method Details
-
resolvePath
Resolves an untrusted user-specified path against the API's base directory. Paths that try to escape the base directory are rejected.Credit to: https://stackoverflow.com/questions/33083397/filtering-upwards-path-traversal-in-java-or-scala
- Parameters:
baseDirPath
- the absolute path of the base directory that all user-specified paths should be withinuserPath
- the untrusted path provided by the API user, expected to be relative tobaseDirPath
- Returns:
- the resolved path
- Throws:
IllegalArgumentException
- if baseDirPath is not absolute, userPath is absolute, or if userPath tries to escape baseDirPath
-
resolvePath
Resolves an untrusted user-specified path against the API's base directory. Paths that try to escape the base directory are rejected. The userPath is built from the parts given by first, ..., more arguments using the baseDirPath'sFileSystem
.- Parameters:
baseDirPath
- the absolute path of the base directory that all user-specified paths should be withinfirst
- the path string or initial part of the path stringmore
- additional strings to be joined to form the path string- Returns:
- the resolved path
- Throws:
IllegalArgumentException
- if baseDirPath is not absolute, or if the first,...,more path parts forms a userPath that is absolute or tries to escape baseDirPath- See Also:
-