Package org.apache.solr.core
Class SolrPaths
- java.lang.Object
-
- org.apache.solr.core.SolrPaths
-
public final class SolrPaths extends Object
Utility methods about paths in Solr.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSolrPaths.AllowPathBuilderBuilds a set of allowedPath.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertNoPathTraversal(Path pathToAssert)Asserts that a path does not contain directory traversalstatic voidassertNotUnc(Path pathToAssert)Asserts that a path is not a Windows UNC pathstatic voidassertPathAllowed(Path pathToAssert, Set<Path> allowPaths)Checks that the given path is relative to one of the allowPaths supplied.static StringnormalizeDir(String path)Ensures a directory name always ends with a '/'.
-
-
-
Field Detail
-
ALL_PATH
public static final Path ALL_PATH
Special path which means to accept all paths.
-
-
Method Detail
-
normalizeDir
public static String normalizeDir(String path)
Ensures a directory name always ends with a '/'.
-
assertPathAllowed
public static void assertPathAllowed(Path pathToAssert, Set<Path> allowPaths) throws org.apache.solr.common.SolrException
Checks that the given path is relative to one of the allowPaths supplied. Typically this will be called fromCoreContainer.assertPathAllowed(Path)and allowPaths pre-filled with the node's SOLR_HOME, SOLR_DATA_HOME and coreRootDirectory folders, as well as any paths specified in solr.xml's allowPaths element. The following paths will always fail validation:- Relative paths starting with
.. - Windows UNC paths (such as
\\host\share\path) - Paths which are not relative to any of allowPaths
- Parameters:
pathToAssert- path to checkallowPaths- list of paths that should be allowed prefixes for pathToAssert- Throws:
org.apache.solr.common.SolrException- if path is outside allowed paths
- Relative paths starting with
-
assertNoPathTraversal
public static void assertNoPathTraversal(Path pathToAssert)
Asserts that a path does not contain directory traversal
-
assertNotUnc
public static void assertNotUnc(Path pathToAssert)
Asserts that a path is not a Windows UNC path
-
-