reswqa commented on code in PR #21125:
URL: https://github.com/apache/flink/pull/21125#discussion_r1007918440
##########
flink-core/src/main/java/org/apache/flink/util/FileUtils.java:
##########
@@ -648,6 +648,29 @@ public static String stripFileExtension(String fileName) {
return fileName;
}
+ /**
+ * Get a target path(the path that replaced symbolic links with linked
path) if the original
+ * path contains symbolic path, return the original path otherwise.
+ *
+ * @param path the original path.
+ * @return the path that replaced symbolic links with real path.
+ */
+ public static java.nio.file.Path
getTargetPathIfContainsSymbolicPath(java.nio.file.Path path)
+ throws IOException {
+ java.nio.file.Path targetPath = path;
+ java.nio.file.Path suffixPath = Paths.get("");
+ while (path != null && path.getFileName() != null) {
+ if (Files.isSymbolicLink(path)) {
+ java.nio.file.Path linkedPath = path.toRealPath();
+ targetPath = Paths.get(linkedPath.toString(),
suffixPath.toString());
+ break;
Review Comment:
I think it can be handled correctly, because java api(toRealPath) will
replace all symbolic links in the path with real paths. But for security
reasons, I added a test that includes multiple symbolic links.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]