|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.zip.ZipFile
org.apache.poi.openxml4j.util.ZipSecureFile
public class ZipSecureFile
This class wraps a ZipFile
in order to check the
entries for zip bombs
while reading the archive.
If a ZipInputStream
is directly used, the wrapper
can be applied via addThreshold(InputStream)
.
The alert limits can be globally defined via setMaxEntrySize(long)
and setMinInflateRatio(double)
.
Nested Class Summary | |
---|---|
static class |
ZipSecureFile.ThresholdInputStream
|
Field Summary | |
---|---|
static int |
CENATT
|
static int |
CENATX
|
static int |
CENCOM
|
static int |
CENCRC
|
static int |
CENDSK
|
static int |
CENEXT
|
static int |
CENFLG
|
static int |
CENHDR
|
static int |
CENHOW
|
static int |
CENLEN
|
static int |
CENNAM
|
static int |
CENOFF
|
static long |
CENSIG
|
static int |
CENSIZ
|
static int |
CENTIM
|
static int |
CENVEM
|
static int |
CENVER
|
static int |
ENDCOM
|
static int |
ENDHDR
|
static int |
ENDOFF
|
static long |
ENDSIG
|
static int |
ENDSIZ
|
static int |
ENDSUB
|
static int |
ENDTOT
|
static int |
EXTCRC
|
static int |
EXTHDR
|
static int |
EXTLEN
|
static long |
EXTSIG
|
static int |
EXTSIZ
|
static int |
LOCCRC
|
static int |
LOCEXT
|
static int |
LOCFLG
|
static int |
LOCHDR
|
static int |
LOCHOW
|
static int |
LOCLEN
|
static int |
LOCNAM
|
static long |
LOCSIG
|
static int |
LOCSIZ
|
static int |
LOCTIM
|
static int |
LOCVER
|
Fields inherited from class java.util.zip.ZipFile |
---|
OPEN_DELETE, OPEN_READ |
Constructor Summary | |
---|---|
ZipSecureFile(java.io.File file)
|
|
ZipSecureFile(java.io.File file,
int mode)
|
|
ZipSecureFile(java.lang.String name)
|
Method Summary | |
---|---|
static ZipSecureFile.ThresholdInputStream |
addThreshold(java.io.InputStream zipIS)
|
java.io.InputStream |
getInputStream(java.util.zip.ZipEntry 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. |
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. |
Methods inherited from class java.util.zip.ZipFile |
---|
close, entries, finalize, getEntry, getName, size |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long LOCSIG
public static final long EXTSIG
public static final long CENSIG
public static final long ENDSIG
public static final int LOCHDR
public static final int EXTHDR
public static final int CENHDR
public static final int ENDHDR
public static final int LOCVER
public static final int LOCFLG
public static final int LOCHOW
public static final int LOCTIM
public static final int LOCCRC
public static final int LOCSIZ
public static final int LOCLEN
public static final int LOCNAM
public static final int LOCEXT
public static final int EXTCRC
public static final int EXTSIZ
public static final int EXTLEN
public static final int CENVEM
public static final int CENVER
public static final int CENFLG
public static final int CENHOW
public static final int CENTIM
public static final int CENCRC
public static final int CENSIZ
public static final int CENLEN
public static final int CENNAM
public static final int CENEXT
public static final int CENCOM
public static final int CENDSK
public static final int CENATT
public static final int CENATX
public static final int CENOFF
public static final int ENDSUB
public static final int ENDTOT
public static final int ENDSIZ
public static final int ENDOFF
public static final int ENDCOM
Constructor Detail |
---|
public ZipSecureFile(java.io.File file, int mode) throws java.io.IOException
java.io.IOException
public ZipSecureFile(java.io.File file) throws java.util.zip.ZipException, java.io.IOException
java.util.zip.ZipException
java.io.IOException
public ZipSecureFile(java.lang.String name) throws java.io.IOException
java.io.IOException
Method Detail |
---|
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 java.io.InputStream getInputStream(java.util.zip.ZipEntry 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 java.util.zip.ZipFile
entry
- the zip file entry
java.util.zip.ZipException
- if a ZIP format error has occurred
java.io.IOException
- if an I/O error has occurred
java.lang.IllegalStateException
- if the zip file has been closedpublic static ZipSecureFile.ThresholdInputStream addThreshold(java.io.InputStream zipIS) throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |