public class ZipSecureFile
extends org.apache.commons.compress.archivers.zip.ZipFile
ZipFile
in order to check the
entries for zip bombs
while reading the archive.
The alert limits can be globally defined via setMaxEntrySize(long)
and setMinInflateRatio(double)
.
Constructor and Description |
---|
ZipSecureFile(java.io.File file) |
ZipSecureFile(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
ZipArchiveThresholdInputStream |
getInputStream(org.apache.commons.compress.archivers.zip.ZipArchiveEntry entry)
Returns an input stream for reading the contents of the specified
zip file entry.
|
static long |
getMaxEntrySize()
Returns the current maximum allowed uncompressed file size.
|
static long |
getMaxTextSize()
Returns the current maximum allowed text size.
|
static double |
getMinInflateRatio()
Returns the current minimum compression rate that is used.
|
java.lang.String |
getName()
Returns the path name of the ZIP file.
|
static void |
setMaxEntrySize(long maxEntrySize)
Sets the maximum file size of a single zip entry.
|
static void |
setMaxTextSize(long maxTextSize)
Sets the maximum number of characters of text that are
extracted before an exception is thrown during extracting
text from documents.
|
static void |
setMinInflateRatio(double ratio)
Sets the ratio between de- and inflated bytes to detect zipbomb.
|
public ZipSecureFile(java.io.File file) throws java.io.IOException
java.io.IOException
public ZipSecureFile(java.lang.String name) throws java.io.IOException
java.io.IOException
public static void setMinInflateRatio(double ratio)
ratio
- the ratio between de- and inflated bytes to detect zipbombpublic static double getMinInflateRatio()
public static void setMaxEntrySize(long maxEntrySize)
maxEntrySize
- the max. file size of a single zip entrypublic static long getMaxEntrySize()
public static void setMaxTextSize(long maxTextSize)
maxTextSize
- the max. file size of a single zip entrypublic static long getMaxTextSize()
public ZipArchiveThresholdInputStream getInputStream(org.apache.commons.compress.archivers.zip.ZipArchiveEntry entry) throws java.io.IOException
Closing this ZIP file will, in turn, close all input streams that have been returned by invocations of this method.
getInputStream
in class org.apache.commons.compress.archivers.zip.ZipFile
entry
- the zip file entryjava.io.IOException
- if an I/O error has occurredjava.lang.IllegalStateException
- if the zip file has been closedpublic java.lang.String getName()
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.