Skip to content

Commit e209b56

Browse files
authored
Merge pull request #111 from RedisLabsModules/meriavg_remove_mudle_size_limit
remove size limit from unpacker
2 parents 8c894fa + d350ec4 commit e209b56

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

RAMP/unpacker.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77

88
INVALID_METADATA = "module metadata invalid"
9-
DEFAULT_MAX_MODULE_FILE_SIZE = 1024 * 1024 * 10
10-
119

1210
class UnpackerPackageError(Exception):
1311
"""
@@ -26,8 +24,8 @@ def __str__(self):
2624
return "{}, reason: {}".format(super(UnpackerPackageError, self).__str__(), self.reason)
2725

2826

29-
def unpack(bundle, max_bundle_size_mb=None):
30-
# type: (IO[bytes], Optional[int]) -> Tuple[Dict[str, Any], IO[bytes], Dict[str, IO[bytes]]]
27+
def unpack(bundle):
28+
# type: (IO[bytes]) -> Tuple[Dict[str, Any], IO[bytes], Dict[str, IO[bytes]]]
3129
"""
3230
Unpacks a bundled module, performs sanity validation on bundle.
3331
the module metadata, the actual module and bundle deps are returned
@@ -36,7 +34,7 @@ def unpack(bundle, max_bundle_size_mb=None):
3634
deps_files = dict()
3735
try:
3836
with ZipFile(bundle) as zf:
39-
_validate_zip_file(zf, max_bundle_size_mb)
37+
_validate_zip_file(zf)
4038
metadata = json.load(zf.open('module.json'))
4139
module = zf.open(metadata["module_file"])
4240
_validate_metadata(metadata)
@@ -57,8 +55,8 @@ def unpack(bundle, max_bundle_size_mb=None):
5755
return metadata, module, deps_files
5856

5957

60-
def _validate_zip_file(zip_file, max_bundle_size_mb):
61-
# type: (ZipFile, Optional[int]) -> None
58+
def _validate_zip_file(zip_file):
59+
# type: (ZipFile) -> None
6260
"""
6361
Checks if all entries within the zip file don't
6462
exceed a certain threshold.
@@ -74,18 +72,6 @@ def _validate_zip_file(zip_file, max_bundle_size_mb):
7472
reason="module zip file should contains exactly two files and deps folder",
7573
error_code="invalid_number_of_files")
7674

77-
file_size_limit_bytes = max_bundle_size_mb * 1024 * 1024 if max_bundle_size_mb else DEFAULT_MAX_MODULE_FILE_SIZE
78-
79-
# Check zip content size.
80-
for zip_info in infolist:
81-
# Size of the compressed/uncompressed data.
82-
if not zip_info.filename.startswith("deps/") and zip_info.file_size > file_size_limit_bytes:
83-
raise UnpackerPackageError(message="module zip file did not pass sanity validation",
84-
reason="module file content is too big",
85-
error_code="module_size_too_big",
86-
error_details={'module_size': zip_info.compress_size,
87-
'max_size': file_size_limit_bytes})
88-
8975

9076
def _validate_metadata(metadata):
9177
# type: (Dict[str, Any]) -> None

0 commit comments

Comments
 (0)