Class SolrPaths


  • public final class SolrPaths
    extends Object
    Utility methods about paths in Solr.
    • 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 from CoreContainer.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 check
        allowPaths - list of paths that should be allowed prefixes for pathToAssert
        Throws:
        org.apache.solr.common.SolrException - if path is outside allowed paths
      • 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