Class ExtractionUtil

java.lang.Object
org.owasp.dependencycheck.utils.ExtractionUtil

@ThreadSafe public final class ExtractionUtil extends Object
Set of utilities to extract files from archives.
Author:
Jeremy Long
  • Method Details

    • extractFiles

      public static void extractFiles(File archive, File extractTo) throws ExtractionException
      Extracts the contents of an archive into the specified directory.
      Parameters:
      archive - an archive file such as a WAR or EAR
      extractTo - a directory to extract the contents to
      Throws:
      ExtractionException - thrown if an exception occurs while extracting the files
    • extractFiles

      public static void extractFiles(File archive, File extractTo, Engine engine) throws ExtractionException
      Extracts the contents of an archive into the specified directory. The files are only extracted if they are supported by the analyzers loaded into the specified engine. If the engine is specified as null then all files are extracted.
      Parameters:
      archive - an archive file such as a WAR or EAR
      extractTo - a directory to extract the contents to
      engine - the scanning engine
      Throws:
      ExtractionException - thrown if there is an error extracting the files
    • extractFiles

      public static void extractFiles(InputStream archive, File extractTo) throws ExtractionException
      Extracts the contents of an archive into the specified directory. The files are only extracted if they are supported by the analyzers loaded into the specified engine. If the engine is specified as null then all files are extracted.
      Parameters:
      archive - an archive file such as a WAR or EAR
      extractTo - a directory to extract the contents to
      Throws:
      ExtractionException - thrown if there is an error extracting the files
    • extractFilesUsingFilter

      public static void extractFilesUsingFilter(File archive, File destination, FilenameFilter filter) throws ExtractionException
      Extracts the contents of an archive into the specified directory.
      Parameters:
      archive - an archive file such as a WAR or EAR
      destination - a directory to extract the contents to
      filter - determines which files get extracted
      Throws:
      ExtractionException - thrown if the archive is not found
    • extractGzip

      public static void extractGzip(File file) throws FileNotFoundException, IOException
      Extracts the file contained in a gzip archive. The extracted file is placed in the exact same path as the file specified.
      Parameters:
      file - the archive file
      Throws:
      FileNotFoundException - thrown if the file does not exist
      IOException - thrown if there is an error extracting the file.
    • extractZip

      public static void extractZip(File file) throws FileNotFoundException, IOException
      Extracts the file contained in a Zip archive. The extracted file is placed in the exact same path as the file specified.
      Parameters:
      file - the archive file
      Throws:
      FileNotFoundException - thrown if the file does not exist
      IOException - thrown if there is an error extracting the file.