soumyakanti3578 commented on code in PR #6851:
URL: https://github.com/apache/hive/pull/6851#discussion_r4593066816


##########
ql/src/java/org/apache/hadoop/hive/ql/io/SymbolicInputFormat.java:
##########
@@ -98,4 +102,58 @@ public void rework(HiveConf job, MapredWork work) throws 
IOException {
       work.getMapWork().removePathToPartitionInfo(toRemove);
     }
   }
+
+  /**
+   * Expands a symlink file line, accepting only matches under the symlink 
file's directory or an allowed root.
+   */
+  static List<Path> resolveTargets(Configuration conf, Path symlinkFile, 
List<Path> allowedRoots, String line)
+      throws IOException {
+    // Qualified against the default filesystem, so no filesystem is created 
for an arbitrary scheme.
+    FileSystem defaultFs = FileSystem.get(conf);
+    List<Path> roots = new ArrayList<>(allowedRoots);
+    roots.add(qualify(defaultFs, symlinkFile.getParent()));
+    Path pattern = qualify(defaultFs, new Path(line));
+    // Matches are checked too, as a glob can climb out of the root.
+    checkAllowed(pattern, roots);
+    FileStatus[] statuses = pattern.getFileSystem(conf).globStatus(pattern);

Review Comment:
   I think we cannot reuse the defaultFs because the target can be another FS 
than the default. This will be covered by a test in the next commit: 
`testTargetOnOtherAllowedFileSystem`



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to