You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by co...@apache.org on 2020/10/02 09:41:34 UTC
[camel] branch master updated: CAMEL-15591 - Put a configurable
limit on the size of unzipped data using camel-zipfile + camel-tarfile
(#4314)
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new c636338 CAMEL-15591 - Put a configurable limit on the size of unzipped data using camel-zipfile + camel-tarfile (#4314)
c636338 is described below
commit c63633853a2bbfb01ea0b951de57c2ddfa0e41e0
Author: Colm O hEigeartaigh <co...@users.noreply.github.com>
AuthorDate: Fri Oct 2 10:41:21 2020 +0100
CAMEL-15591 - Put a configurable limit on the size of unzipped data using camel-zipfile + camel-tarfile (#4314)
---
.../apache/camel/catalog/dataformats/tarfile.json | 1 +
.../apache/camel/catalog/dataformats/zipfile.json | 1 +
.../camel/catalog/docs/tarfile-dataformat.adoc | 3 ++-
.../camel/catalog/docs/zipfile-dataformat.adoc | 3 ++-
.../org/apache/camel/catalog/models/tarfile.json | 1 +
.../org/apache/camel/catalog/models/zipfile.json | 1 +
.../apache/camel/catalog/schemas/camel-spring.xsd | 20 ++++++++++++++++++++
.../tarfile/TarFileDataFormatConfigurer.java | 2 ++
.../org/apache/camel/dataformat/tarfile/tarfile.json | 1 +
.../src/main/docs/tarfile-dataformat.adoc | 3 ++-
.../camel/dataformat/tarfile/TarFileDataFormat.java | 15 ++++++++++++++-
.../dataformat/tarfile/TarFileDataFormatTest.java | 12 ++++++++++++
.../zipfile/ZipFileDataFormatConfigurer.java | 2 ++
.../org/apache/camel/dataformat/zipfile/zipfile.json | 1 +
.../src/main/docs/zipfile-dataformat.adoc | 3 ++-
.../camel/dataformat/zipfile/ZipFileDataFormat.java | 15 ++++++++++++++-
.../dataformat/zipfile/ZipFileDataFormatTest.java | 12 ++++++++++++
.../org/apache/camel/model/dataformat/tarfile.json | 1 +
.../org/apache/camel/model/dataformat/zipfile.json | 1 +
.../camel/model/dataformat/TarFileDataFormat.java | 19 +++++++++++++++++++
.../camel/model/dataformat/ZipFileDataFormat.java | 17 +++++++++++++++++
.../reifier/dataformat/TarFileDataFormatReifier.java | 1 +
.../reifier/dataformat/ZipFileDataFormatReifier.java | 1 +
.../main/java/org/apache/camel/util/IOHelper.java | 11 +++++++++++
.../java/org/apache/camel/xml/in/ModelParser.java | 2 ++
.../dataformats/pages/tarfile-dataformat.adoc | 3 ++-
.../dataformats/pages/zipfile-dataformat.adoc | 3 ++-
.../ROOT/pages/camel-3x-upgrade-guide-3_6.adoc | 15 +++++++++++++++
28 files changed, 162 insertions(+), 8 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/tarfile.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/tarfile.json
index e63ae5c..ec954dc 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/tarfile.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/tarfile.json
@@ -19,6 +19,7 @@
"usingIterator": { "kind": "attribute", "displayName": "Using Iterator", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the tar file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode." },
"allowEmptyDirectory": { "kind": "attribute", "displayName": "Allow Empty Directory", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the tar file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty" },
"preservePathElements": { "kind": "attribute", "displayName": "Preserve Path Elements", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the file name contains path elements, setting this option to true, allows the path to be maintained in the tar file." },
+ "maxDecompressedSize": { "kind": "attribute", "displayName": "Max Decompressed Size", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "secret": false, "defaultValue": "1073741824L", "description": "Set the maximum decompressed size of a tar file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed [...]
"contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JS [...]
"id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The id of this node" }
}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/zipfile.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/zipfile.json
index d885bc5..276a373 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/zipfile.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/zipfile.json
@@ -19,6 +19,7 @@
"usingIterator": { "kind": "attribute", "displayName": "Using Iterator", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the zip file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode." },
"allowEmptyDirectory": { "kind": "attribute", "displayName": "Allow Empty Directory", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the zip file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty" },
"preservePathElements": { "kind": "attribute", "displayName": "Preserve Path Elements", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the file name contains path elements, setting this option to true, allows the path to be maintained in the zip file." },
+ "maxDecompressedSize": { "kind": "attribute", "displayName": "Max Decompressed Size", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "secret": false, "defaultValue": "1073741824L", "description": "Set the maximum decompressed size of a zip file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed [...]
"contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JS [...]
"id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The id of this node" }
}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/tarfile-dataformat.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/tarfile-dataformat.adoc
index 8b5e754..d25c6a8 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/tarfile-dataformat.adoc
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/tarfile-dataformat.adoc
@@ -21,7 +21,7 @@ aggregate multiple messages into a single Tar File.
// dataformat options: START
-The Tar File dataformat supports 4 options, which are listed below.
+The Tar File dataformat supports 5 options, which are listed below.
@@ -31,6 +31,7 @@ The Tar File dataformat supports 4 options, which are listed below.
| usingIterator | false | Boolean | If the tar file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode.
| allowEmptyDirectory | false | Boolean | If the tar file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty
| preservePathElements | false | Boolean | If the file name contains path elements, setting this option to true, allows the path to be maintained in the tar file.
+| maxDecompressedSize | 1073741824L | Long | Set the maximum decompressed size of a tar file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed size.
| contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc.
|===
// dataformat options: END
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/zipfile-dataformat.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/zipfile-dataformat.adoc
index c36c59a..495b16e 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/zipfile-dataformat.adoc
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/zipfile-dataformat.adoc
@@ -18,7 +18,7 @@ This data format supports ZIP64, as long as Java 7 or later is being used].
== ZipFile Options
// dataformat options: START
-The Zip File dataformat supports 4 options, which are listed below.
+The Zip File dataformat supports 5 options, which are listed below.
@@ -28,6 +28,7 @@ The Zip File dataformat supports 4 options, which are listed below.
| usingIterator | false | Boolean | If the zip file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode.
| allowEmptyDirectory | false | Boolean | If the zip file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty
| preservePathElements | false | Boolean | If the file name contains path elements, setting this option to true, allows the path to be maintained in the zip file.
+| maxDecompressedSize | 1073741824L | Long | Set the maximum decompressed size of a zip file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed size.
| contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc.
|===
// dataformat options: END
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/tarfile.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/tarfile.json
index c0a07c34..505d1ee 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/tarfile.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/tarfile.json
@@ -15,6 +15,7 @@
"usingIterator": { "kind": "attribute", "displayName": "Using Iterator", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the tar file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode." },
"allowEmptyDirectory": { "kind": "attribute", "displayName": "Allow Empty Directory", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the tar file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty" },
"preservePathElements": { "kind": "attribute", "displayName": "Preserve Path Elements", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the file name contains path elements, setting this option to true, allows the path to be maintained in the tar file." },
+ "maxDecompressedSize": { "kind": "attribute", "displayName": "Max Decompressed Size", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "secret": false, "defaultValue": "1073741824L", "description": "Set the maximum decompressed size of a tar file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed [...]
"contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JS [...]
"id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The id of this node" }
}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/zipfile.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/zipfile.json
index 279beb7..0d4a094 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/zipfile.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/zipfile.json
@@ -15,6 +15,7 @@
"usingIterator": { "kind": "attribute", "displayName": "Using Iterator", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the zip file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode." },
"allowEmptyDirectory": { "kind": "attribute", "displayName": "Allow Empty Directory", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the zip file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty" },
"preservePathElements": { "kind": "attribute", "displayName": "Preserve Path Elements", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the file name contains path elements, setting this option to true, allows the path to be maintained in the zip file." },
+ "maxDecompressedSize": { "kind": "attribute", "displayName": "Max Decompressed Size", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "secret": false, "defaultValue": "1073741824L", "description": "Set the maximum decompressed size of a zip file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed [...]
"contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JS [...]
"id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The id of this node" }
}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index 8458f3b..727c1aa 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -7374,6 +7374,16 @@ path to be maintained in the tar file. Default value: false
]]></xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute name="maxDecompressedSize" type="xs:string">
+ <xs:annotation>
+ <xs:documentation xml:lang="en"><![CDATA[
+Set the maximum decompressed size of a tar file (in bytes). The default value if
+not specified corresponds to 1 gigabyte. An IOException will be thrown if the
+decompressed size exceeds this amount. Set to -1 to disable setting a maximum
+decompressed size. Default value: 1073741824L
+ ]]></xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
@@ -8002,6 +8012,16 @@ path to be maintained in the zip file. Default value: false
]]></xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute name="maxDecompressedSize" type="xs:string">
+ <xs:annotation>
+ <xs:documentation xml:lang="en"><![CDATA[
+Set the maximum decompressed size of a zip file (in bytes). The default value if
+not specified corresponds to 1 gigabyte. An IOException will be thrown if the
+decompressed size exceeds this amount. Set to -1 to disable setting a maximum
+decompressed size. Default value: 1073741824L
+ ]]></xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
diff --git a/components/camel-tarfile/src/generated/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatConfigurer.java b/components/camel-tarfile/src/generated/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatConfigurer.java
index faaef7c..978c9af 100644
--- a/components/camel-tarfile/src/generated/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatConfigurer.java
+++ b/components/camel-tarfile/src/generated/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatConfigurer.java
@@ -24,6 +24,8 @@ public class TarFileDataFormatConfigurer extends PropertyConfigurerSupport imple
case "allowEmptyDirectory": dataformat.setAllowEmptyDirectory(property(camelContext, boolean.class, value)); return true;
case "preservepathelements":
case "preservePathElements": dataformat.setPreservePathElements(property(camelContext, boolean.class, value)); return true;
+ case "maxdecompressedsize":
+ case "maxDecompressedSize": dataformat.setMaxDecompressedSize(property(camelContext, long.class, value)); return true;
default: return false;
}
}
diff --git a/components/camel-tarfile/src/generated/resources/org/apache/camel/dataformat/tarfile/tarfile.json b/components/camel-tarfile/src/generated/resources/org/apache/camel/dataformat/tarfile/tarfile.json
index e63ae5c..ec954dc 100644
--- a/components/camel-tarfile/src/generated/resources/org/apache/camel/dataformat/tarfile/tarfile.json
+++ b/components/camel-tarfile/src/generated/resources/org/apache/camel/dataformat/tarfile/tarfile.json
@@ -19,6 +19,7 @@
"usingIterator": { "kind": "attribute", "displayName": "Using Iterator", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the tar file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode." },
"allowEmptyDirectory": { "kind": "attribute", "displayName": "Allow Empty Directory", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the tar file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty" },
"preservePathElements": { "kind": "attribute", "displayName": "Preserve Path Elements", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the file name contains path elements, setting this option to true, allows the path to be maintained in the tar file." },
+ "maxDecompressedSize": { "kind": "attribute", "displayName": "Max Decompressed Size", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "secret": false, "defaultValue": "1073741824L", "description": "Set the maximum decompressed size of a tar file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed [...]
"contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JS [...]
"id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The id of this node" }
}
diff --git a/components/camel-tarfile/src/main/docs/tarfile-dataformat.adoc b/components/camel-tarfile/src/main/docs/tarfile-dataformat.adoc
index 8b5e754..d25c6a8 100644
--- a/components/camel-tarfile/src/main/docs/tarfile-dataformat.adoc
+++ b/components/camel-tarfile/src/main/docs/tarfile-dataformat.adoc
@@ -21,7 +21,7 @@ aggregate multiple messages into a single Tar File.
// dataformat options: START
-The Tar File dataformat supports 4 options, which are listed below.
+The Tar File dataformat supports 5 options, which are listed below.
@@ -31,6 +31,7 @@ The Tar File dataformat supports 4 options, which are listed below.
| usingIterator | false | Boolean | If the tar file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode.
| allowEmptyDirectory | false | Boolean | If the tar file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty
| preservePathElements | false | Boolean | If the file name contains path elements, setting this option to true, allows the path to be maintained in the tar file.
+| maxDecompressedSize | 1073741824L | Long | Set the maximum decompressed size of a tar file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed size.
| contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc.
|===
// dataformat options: END
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
index 51d4847..ed3332e 100644
--- a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarFileDataFormat.java
@@ -45,9 +45,14 @@ import static org.apache.camel.Exchange.FILE_NAME;
*/
@Dataformat("tarfile")
public class TarFileDataFormat extends ServiceSupport implements DataFormat, DataFormatName {
+ /**
+ * The default maximum decompressed size (in bytes), which corresponds to 1G.
+ */
+ private static final long DEFAULT_MAXIMUM_DECOMPRESSED_SIZE = 1073741824L;
private boolean usingIterator;
private boolean allowEmptyDirectory;
private boolean preservePathElements;
+ private long maxDecompressedSize = DEFAULT_MAXIMUM_DECOMPRESSED_SIZE;
@Override
public String getDataFormatName() {
@@ -108,7 +113,7 @@ public class TarFileDataFormat extends ServiceSupport implements DataFormat, Dat
TarArchiveEntry entry = tis.getNextTarEntry();
if (entry != null) {
exchange.getMessage().setHeader(FILE_NAME, entry.getName());
- IOHelper.copy(tis, osb);
+ IOHelper.copy(tis, osb, IOHelper.DEFAULT_BUFFER_SIZE, false, maxDecompressedSize);
} else {
throw new IllegalStateException("Unable to untar the file, it may be corrupted.");
}
@@ -175,6 +180,14 @@ public class TarFileDataFormat extends ServiceSupport implements DataFormat, Dat
this.preservePathElements = preservePathElements;
}
+ public long getMaxDecompressedSize() {
+ return maxDecompressedSize;
+ }
+
+ public void setMaxDecompressedSize(long maxDecompressedSize) {
+ this.maxDecompressedSize = maxDecompressedSize;
+ }
+
@Override
protected void doStart() throws Exception {
// noop
diff --git a/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatTest.java b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatTest.java
index 972c655..afdd4c2 100644
--- a/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatTest.java
+++ b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatTest.java
@@ -236,6 +236,13 @@ public class TarFileDataFormatTest extends CamelTestSupport {
deleteDirectory(new File("hello_out"));
}
+ @Test
+ public void testUnzipMaxDecompressedSize() throws Exception {
+ // We are only allowing 10 bytes to be decompressed, so we expect an error
+ assertThrows(CamelExecutionException.class,
+ () -> template.sendBody("direct:untarMaxDecompressedSize", getTaredText("file")));
+ }
+
@Override
@BeforeEach
public void setUp() throws Exception {
@@ -307,6 +314,11 @@ public class TarFileDataFormatTest extends CamelTestSupport {
from("direct:dslTar").marshal(tar).to("mock:dslTar");
from("direct:dslUntar").unmarshal(tar).to("mock:dslUntar");
from("direct:corruptUntar").unmarshal(tar).to("mock:corruptUntar");
+
+ TarFileDataFormat maxDecompressedSizeTar = new TarFileDataFormat();
+ // Only allow 10 bytes to be decompressed
+ maxDecompressedSizeTar.setMaxDecompressedSize(10L);
+ from("direct:untarMaxDecompressedSize").unmarshal(maxDecompressedSizeTar).to("mock:untar");
}
};
}
diff --git a/components/camel-zipfile/src/generated/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatConfigurer.java b/components/camel-zipfile/src/generated/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatConfigurer.java
index 72ea179..8f68fc1 100644
--- a/components/camel-zipfile/src/generated/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatConfigurer.java
+++ b/components/camel-zipfile/src/generated/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatConfigurer.java
@@ -24,6 +24,8 @@ public class ZipFileDataFormatConfigurer extends PropertyConfigurerSupport imple
case "allowEmptyDirectory": dataformat.setAllowEmptyDirectory(property(camelContext, boolean.class, value)); return true;
case "preservepathelements":
case "preservePathElements": dataformat.setPreservePathElements(property(camelContext, boolean.class, value)); return true;
+ case "maxdecompressedsize":
+ case "maxDecompressedSize": dataformat.setMaxDecompressedSize(property(camelContext, long.class, value)); return true;
default: return false;
}
}
diff --git a/components/camel-zipfile/src/generated/resources/org/apache/camel/dataformat/zipfile/zipfile.json b/components/camel-zipfile/src/generated/resources/org/apache/camel/dataformat/zipfile/zipfile.json
index d885bc5..276a373 100644
--- a/components/camel-zipfile/src/generated/resources/org/apache/camel/dataformat/zipfile/zipfile.json
+++ b/components/camel-zipfile/src/generated/resources/org/apache/camel/dataformat/zipfile/zipfile.json
@@ -19,6 +19,7 @@
"usingIterator": { "kind": "attribute", "displayName": "Using Iterator", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the zip file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode." },
"allowEmptyDirectory": { "kind": "attribute", "displayName": "Allow Empty Directory", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the zip file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty" },
"preservePathElements": { "kind": "attribute", "displayName": "Preserve Path Elements", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the file name contains path elements, setting this option to true, allows the path to be maintained in the zip file." },
+ "maxDecompressedSize": { "kind": "attribute", "displayName": "Max Decompressed Size", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "secret": false, "defaultValue": "1073741824L", "description": "Set the maximum decompressed size of a zip file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed [...]
"contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JS [...]
"id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The id of this node" }
}
diff --git a/components/camel-zipfile/src/main/docs/zipfile-dataformat.adoc b/components/camel-zipfile/src/main/docs/zipfile-dataformat.adoc
index c36c59a..495b16e 100644
--- a/components/camel-zipfile/src/main/docs/zipfile-dataformat.adoc
+++ b/components/camel-zipfile/src/main/docs/zipfile-dataformat.adoc
@@ -18,7 +18,7 @@ This data format supports ZIP64, as long as Java 7 or later is being used].
== ZipFile Options
// dataformat options: START
-The Zip File dataformat supports 4 options, which are listed below.
+The Zip File dataformat supports 5 options, which are listed below.
@@ -28,6 +28,7 @@ The Zip File dataformat supports 4 options, which are listed below.
| usingIterator | false | Boolean | If the zip file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode.
| allowEmptyDirectory | false | Boolean | If the zip file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty
| preservePathElements | false | Boolean | If the file name contains path elements, setting this option to true, allows the path to be maintained in the zip file.
+| maxDecompressedSize | 1073741824L | Long | Set the maximum decompressed size of a zip file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed size.
| contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc.
|===
// dataformat options: END
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
index 30ada21..e1295d6 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
@@ -42,9 +42,14 @@ import static org.apache.camel.Exchange.FILE_NAME;
*/
@Dataformat("zipfile")
public class ZipFileDataFormat extends ServiceSupport implements DataFormat, DataFormatName {
+ /**
+ * The default maximum decompressed size (in bytes), which corresponds to 1G.
+ */
+ private static final long DEFAULT_MAXIMUM_DECOMPRESSED_SIZE = 1073741824L;
private boolean usingIterator;
private boolean allowEmptyDirectory;
private boolean preservePathElements;
+ private long maxDecompressedSize = DEFAULT_MAXIMUM_DECOMPRESSED_SIZE;
@Override
public String getDataFormatName() {
@@ -96,7 +101,7 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
ZipEntry entry = zis.getNextEntry();
if (entry != null) {
exchange.getMessage().setHeader(FILE_NAME, entry.getName());
- IOHelper.copy(zis, osb);
+ IOHelper.copy(zis, osb, IOHelper.DEFAULT_BUFFER_SIZE, false, maxDecompressedSize);
} else {
throw new IllegalStateException("Unable to unzip the file, it may be corrupted.");
}
@@ -158,6 +163,14 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
this.preservePathElements = preservePathElements;
}
+ public long getMaxDecompressedSize() {
+ return maxDecompressedSize;
+ }
+
+ public void setMaxDecompressedSize(long maxDecompressedSize) {
+ this.maxDecompressedSize = maxDecompressedSize;
+ }
+
@Override
protected void doStart() throws Exception {
// noop
diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
index a7bd241..0a04867 100644
--- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
+++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormatTest.java
@@ -251,6 +251,13 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
assertMockEndpointsSatisfied();
}
+ @Test
+ public void testUnzipMaxDecompressedSize() throws Exception {
+ // We are only allowing 10 bytes to be decompressed, so we expect an error
+ assertThrows(CamelExecutionException.class,
+ () -> template.sendBody("direct:unzipMaxDecompressedSize", getZippedText("file")));
+ }
+
@Override
@BeforeEach
public void setUp() throws Exception {
@@ -322,6 +329,11 @@ public class ZipFileDataFormatTest extends CamelTestSupport {
from("direct:dslUnzip").unmarshal().zipFile().to("mock:dslUnzip");
from("direct:corruptUnzip").unmarshal().zipFile().to("mock:corruptUnzip");
from("direct:zipStreamCache").streamCaching().marshal().zipFile().to("mock:zipStreamCache");
+
+ ZipFileDataFormat maxDecompressedSizeZip = new ZipFileDataFormat();
+ // Only allow 10 bytes to be decompressed
+ maxDecompressedSizeZip.setMaxDecompressedSize(10L);
+ from("direct:unzipMaxDecompressedSize").unmarshal(maxDecompressedSizeZip).to("mock:unzip");
}
};
}
diff --git a/core/camel-core-engine/src/generated/resources/org/apache/camel/model/dataformat/tarfile.json b/core/camel-core-engine/src/generated/resources/org/apache/camel/model/dataformat/tarfile.json
index c0a07c34..505d1ee 100644
--- a/core/camel-core-engine/src/generated/resources/org/apache/camel/model/dataformat/tarfile.json
+++ b/core/camel-core-engine/src/generated/resources/org/apache/camel/model/dataformat/tarfile.json
@@ -15,6 +15,7 @@
"usingIterator": { "kind": "attribute", "displayName": "Using Iterator", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the tar file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode." },
"allowEmptyDirectory": { "kind": "attribute", "displayName": "Allow Empty Directory", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the tar file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty" },
"preservePathElements": { "kind": "attribute", "displayName": "Preserve Path Elements", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the file name contains path elements, setting this option to true, allows the path to be maintained in the tar file." },
+ "maxDecompressedSize": { "kind": "attribute", "displayName": "Max Decompressed Size", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "secret": false, "defaultValue": "1073741824L", "description": "Set the maximum decompressed size of a tar file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed [...]
"contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JS [...]
"id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The id of this node" }
}
diff --git a/core/camel-core-engine/src/generated/resources/org/apache/camel/model/dataformat/zipfile.json b/core/camel-core-engine/src/generated/resources/org/apache/camel/model/dataformat/zipfile.json
index 279beb7..0d4a094 100644
--- a/core/camel-core-engine/src/generated/resources/org/apache/camel/model/dataformat/zipfile.json
+++ b/core/camel-core-engine/src/generated/resources/org/apache/camel/model/dataformat/zipfile.json
@@ -15,6 +15,7 @@
"usingIterator": { "kind": "attribute", "displayName": "Using Iterator", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the zip file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode." },
"allowEmptyDirectory": { "kind": "attribute", "displayName": "Allow Empty Directory", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the zip file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty" },
"preservePathElements": { "kind": "attribute", "displayName": "Preserve Path Elements", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "If the file name contains path elements, setting this option to true, allows the path to be maintained in the zip file." },
+ "maxDecompressedSize": { "kind": "attribute", "displayName": "Max Decompressed Size", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "secret": false, "defaultValue": "1073741824L", "description": "Set the maximum decompressed size of a zip file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed [...]
"contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JS [...]
"id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The id of this node" }
}
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/model/dataformat/TarFileDataFormat.java b/core/camel-core-engine/src/main/java/org/apache/camel/model/dataformat/TarFileDataFormat.java
index 5d06cd8..205178c 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/model/dataformat/TarFileDataFormat.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/model/dataformat/TarFileDataFormat.java
@@ -40,6 +40,9 @@ public class TarFileDataFormat extends DataFormatDefinition {
@XmlAttribute
@Metadata(javaType = "java.lang.Boolean")
private String preservePathElements;
+ @XmlAttribute
+ @Metadata(javaType = "java.lang.Long", defaultValue = "1073741824L")
+ private String maxDecompressedSize;
public TarFileDataFormat() {
super("tarfile");
@@ -57,6 +60,10 @@ public class TarFileDataFormat extends DataFormatDefinition {
return preservePathElements;
}
+ public String getMaxDecompressedSize() {
+ return maxDecompressedSize;
+ }
+
/**
* If the tar file has more then one entry, the setting this option to true, allows to work with the splitter EIP,
* to split the data using an iterator in a streaming mode.
@@ -80,4 +87,16 @@ public class TarFileDataFormat extends DataFormatDefinition {
public void setPreservePathElements(String preservePathElements) {
this.preservePathElements = preservePathElements;
}
+
+ /**
+ * Set the maximum decompressed size of a tar file (in bytes). The default value if not specified corresponds to 1
+ * gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable
+ * setting a maximum decompressed size.
+ *
+ * @param maxDecompressedSize the maximum decompressed size of a tar file (in bytes)
+ */
+ public void setMaxDecompressedSize(String maxDecompressedSize) {
+ this.maxDecompressedSize = maxDecompressedSize;
+ }
+
}
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java b/core/camel-core-engine/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java
index 6488d3d..4a58042 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/model/dataformat/ZipFileDataFormat.java
@@ -40,6 +40,9 @@ public class ZipFileDataFormat extends DataFormatDefinition {
@XmlAttribute
@Metadata(javaType = "java.lang.Boolean")
private String preservePathElements;
+ @XmlAttribute
+ @Metadata(javaType = "java.lang.Long", defaultValue = "1073741824L")
+ private String maxDecompressedSize;
public ZipFileDataFormat() {
super("zipfile");
@@ -57,6 +60,10 @@ public class ZipFileDataFormat extends DataFormatDefinition {
return preservePathElements;
}
+ public String getMaxDecompressedSize() {
+ return maxDecompressedSize;
+ }
+
/**
* If the zip file has more then one entry, the setting this option to true, allows to work with the splitter EIP,
* to split the data using an iterator in a streaming mode.
@@ -81,4 +88,14 @@ public class ZipFileDataFormat extends DataFormatDefinition {
this.preservePathElements = preservePathElements;
}
+ /**
+ * Set the maximum decompressed size of a zip file (in bytes). The default value if not specified corresponds to 1
+ * gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable
+ * setting a maximum decompressed size.
+ *
+ * @param maxDecompressedSize the maximum decompressed size of a zip file (in bytes)
+ */
+ public void setMaxDecompressedSize(String maxDecompressedSize) {
+ this.maxDecompressedSize = maxDecompressedSize;
+ }
}
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/dataformat/TarFileDataFormatReifier.java b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/dataformat/TarFileDataFormatReifier.java
index 3245645..889db99 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/dataformat/TarFileDataFormatReifier.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/dataformat/TarFileDataFormatReifier.java
@@ -32,6 +32,7 @@ public class TarFileDataFormatReifier extends DataFormatReifier<TarFileDataForma
protected void prepareDataFormatConfig(Map<String, Object> properties) {
properties.put("usingIterator", definition.getUsingIterator());
properties.put("preservePathElements", definition.getPreservePathElements());
+ properties.put("maxDecompressedSize", definition.getMaxDecompressedSize());
}
}
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/dataformat/ZipFileDataFormatReifier.java b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/dataformat/ZipFileDataFormatReifier.java
index a67c61f..2c7c0db 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/dataformat/ZipFileDataFormatReifier.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/dataformat/ZipFileDataFormatReifier.java
@@ -33,6 +33,7 @@ public class ZipFileDataFormatReifier extends DataFormatReifier<ZipFileDataForma
properties.put("usingIterator", definition.getUsingIterator());
properties.put("allowEmptyDirectory", definition.getAllowEmptyDirectory());
properties.put("preservePathElements", definition.getPreservePathElements());
+ properties.put("maxDecompressedSize", definition.getMaxDecompressedSize());
}
}
diff --git a/core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java b/core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
index 7318961..97184dd 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
@@ -149,6 +149,14 @@ public final class IOHelper {
public static int copy(final InputStream input, final OutputStream output, int bufferSize, boolean flushOnEachWrite)
throws IOException {
+ return copy(input, output, bufferSize, flushOnEachWrite, -1);
+ }
+
+ public static int copy(
+ final InputStream input, final OutputStream output, int bufferSize, boolean flushOnEachWrite,
+ long maxSize)
+ throws IOException {
+
if (input instanceof ByteArrayInputStream) {
// optimized for byte array as we only need the max size it can be
input.mark(0);
@@ -191,6 +199,9 @@ public final class IOHelper {
output.flush();
}
total += n;
+ if (maxSize > 0 && total > maxSize) {
+ throw new IOException("The InputStream entry being copied exceeds the maximum allowed size");
+ }
n = input.read(buffer);
}
}
diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
index 31cea3a..394b9a3 100644
--- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
+++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
@@ -2120,6 +2120,7 @@ public class ModelParser extends BaseParser {
return doParse(new TarFileDataFormat(), (def, key, val) -> {
switch (key) {
case "allowEmptyDirectory": def.setAllowEmptyDirectory(val); break;
+ case "maxDecompressedSize": def.setMaxDecompressedSize(val); break;
case "preservePathElements": def.setPreservePathElements(val); break;
case "usingIterator": def.setUsingIterator(val); break;
default: return dataFormatDefinitionAttributeHandler().accept(def, key, val);
@@ -2317,6 +2318,7 @@ public class ModelParser extends BaseParser {
return doParse(new ZipFileDataFormat(), (def, key, val) -> {
switch (key) {
case "allowEmptyDirectory": def.setAllowEmptyDirectory(val); break;
+ case "maxDecompressedSize": def.setMaxDecompressedSize(val); break;
case "preservePathElements": def.setPreservePathElements(val); break;
case "usingIterator": def.setUsingIterator(val); break;
default: return dataFormatDefinitionAttributeHandler().accept(def, key, val);
diff --git a/docs/components/modules/dataformats/pages/tarfile-dataformat.adoc b/docs/components/modules/dataformats/pages/tarfile-dataformat.adoc
index e3ef5af..4ba86a4 100644
--- a/docs/components/modules/dataformats/pages/tarfile-dataformat.adoc
+++ b/docs/components/modules/dataformats/pages/tarfile-dataformat.adoc
@@ -23,7 +23,7 @@ aggregate multiple messages into a single Tar File.
// dataformat options: START
-The Tar File dataformat supports 4 options, which are listed below.
+The Tar File dataformat supports 5 options, which are listed below.
@@ -33,6 +33,7 @@ The Tar File dataformat supports 4 options, which are listed below.
| usingIterator | false | Boolean | If the tar file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode.
| allowEmptyDirectory | false | Boolean | If the tar file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty
| preservePathElements | false | Boolean | If the file name contains path elements, setting this option to true, allows the path to be maintained in the tar file.
+| maxDecompressedSize | 1073741824L | Long | Set the maximum decompressed size of a tar file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed size.
| contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc.
|===
// dataformat options: END
diff --git a/docs/components/modules/dataformats/pages/zipfile-dataformat.adoc b/docs/components/modules/dataformats/pages/zipfile-dataformat.adoc
index 6f2d2f5..a9781eb 100644
--- a/docs/components/modules/dataformats/pages/zipfile-dataformat.adoc
+++ b/docs/components/modules/dataformats/pages/zipfile-dataformat.adoc
@@ -20,7 +20,7 @@ This data format supports ZIP64, as long as Java 7 or later is being used].
== ZipFile Options
// dataformat options: START
-The Zip File dataformat supports 4 options, which are listed below.
+The Zip File dataformat supports 5 options, which are listed below.
@@ -30,6 +30,7 @@ The Zip File dataformat supports 4 options, which are listed below.
| usingIterator | false | Boolean | If the zip file has more then one entry, the setting this option to true, allows to work with the splitter EIP, to split the data using an iterator in a streaming mode.
| allowEmptyDirectory | false | Boolean | If the zip file has more then one entry, setting this option to true, allows to get the iterator even if the directory is empty
| preservePathElements | false | Boolean | If the file name contains path elements, setting this option to true, allows the path to be maintained in the zip file.
+| maxDecompressedSize | 1073741824L | Long | Set the maximum decompressed size of a zip file (in bytes). The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount. Set to -1 to disable setting a maximum decompressed size.
| contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc.
|===
// dataformat options: END
diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_6.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_6.adoc
index f1f7ea3..594799d 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_6.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_6.adoc
@@ -164,3 +164,18 @@ The following features has been removed due they become not compatible with OSGi
Class `CamelFileDataSource` has moved from `camel-http-common` in package `org.apache.camel.http.common` to `camel-attachments` package `org.apache.camel.attachment.CamelFileDataSource`.
If your code directly depends on this class, you will need to update the package reference to the new location.
+
+=== Default limit set on decompressed file size
+
+From Apache Camel 3.6.0, a default limit is enforced on the maximum size of a decompressed file, to prevent possible denial of service attacks.
+This applies to the camel-zipfile and camel-tarfile data formats. This can be configured as follows:
+
+[source,java]
+----
+ZipFileDataFormat maxDecompressedSizeZip = new ZipFileDataFormat();
+maxDecompressedSizeZip.setMaxDecompressedSize(100000000000L);
+.unmarshal(maxDecompressedSizeZip)
+----
+
+The default value if not specified corresponds to 1 gigabyte. An IOException will be thrown if the decompressed size exceeds this amount.
+Set to -1 to disable setting a maximum decompressed size.