Class SafeFileChecker


  • public class SafeFileChecker
    extends java.lang.Object
    Checker for Sanity of file manipulation to avoid Path Traversal vulnerability
    Author:
    afraoucene
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkSafeFilePath​(java.lang.String path)
      do an ESAPI path sanityCheck and prevent a path traversal attack
      static void checkSafeFilePath​(java.lang.String rootPath, java.lang.String... subPaths)
      do an ESAPI path sanityCheck and prevent a path traversal attack
      static void checkSafePluginsFilesPath​(java.lang.String path)
      do an ESAPI path sanityCheck and prevent a path traversal attack
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • checkSafeFilePath

        public static void checkSafeFilePath​(java.lang.String path)
                                      throws java.io.IOException
        do an ESAPI path sanityCheck and prevent a path traversal attack
        Parameters:
        path - full path representing a FileSystem resource
        Throws:
        java.io.IOException - thrown when any check fails with UnChecked or Runtime exception
      • checkSafePluginsFilesPath

        public static void checkSafePluginsFilesPath​(java.lang.String path)
                                              throws java.io.IOException
        do an ESAPI path sanityCheck and prevent a path traversal attack
        Parameters:
        path - full path representing a FileSystem resource
        Throws:
        java.io.IOException - thrown when any check fails with UnChecked or Runtime exception
      • checkSafeFilePath

        public static void checkSafeFilePath​(java.lang.String rootPath,
                                             java.lang.String... subPaths)
                                      throws java.io.IOException
        do an ESAPI path sanityCheck and prevent a path traversal attack
        Parameters:
        rootPath - first or initial part(s) of a path representing a FileSystem resource
        subPaths - sub (additional) parts after root part(s) to be joined to rootPath parameter using File.separator FileSystem String
        Throws:
        java.io.IOException - thrown when any check fails with UnChecked or Runtime exception