Class FilePathValidator


  • public final class FilePathValidator
    extends Object
    Utilities for validation of Zip files.
    • Method Detail

      • validateFile

        public static boolean validateFile​(File destinationFile,
                                           File destinationDir)
        Validates a File. Checks that the file being created does not lie outside the target directory.
        Parameters:
        destinationFile - file to check
        destinationDir - target directory
        Returns:
        true if the Entry resolves to a file inside the target directory; false otherwise
      • validateZipEntry

        public static boolean validateZipEntry​(ZipEntry entry,
                                               File destinationDir)
        Validates a zip entry. Checks that the file being created does not lie outside the target directory. See https://snyk.io/research/zip-slip-vulnerability for more information.
        Parameters:
        entry - ZipEntry to check
        destinationDir - target directory
        Returns:
        true if the Entry resolves to a file inside the target directory; false otherwise