Fix upload size limit

parent 3ee190b3
...@@ -73,7 +73,7 @@ class FileUploadHandler: ...@@ -73,7 +73,7 @@ class FileUploadHandler:
file.seek(0) file.seek(0)
if not validate_file_size(file_size): if not validate_file_size(file_size):
max_size_mb = current_app.config.get('MAX_CONTENT_LENGTH', 500 * 1024 * 1024) // (1024 * 1024) max_size_mb = current_app.config.get('MAX_CONTENT_LENGTH', 5 * 1024 * 1024 * 1024)
return False, f"File too large. Maximum size: {max_size_mb}MB" return False, f"File too large. Maximum size: {max_size_mb}MB"
return True, None return True, None
...@@ -613,4 +613,4 @@ def get_file_upload_handler(): ...@@ -613,4 +613,4 @@ def get_file_upload_handler():
global file_upload_handler global file_upload_handler
if file_upload_handler is None: if file_upload_handler is None:
file_upload_handler = FileUploadHandler() file_upload_handler = FileUploadHandler()
return file_upload_handler return file_upload_handler
\ No newline at end of file
...@@ -304,10 +304,10 @@ def validate_file_size(file_size, max_size=None): ...@@ -304,10 +304,10 @@ def validate_file_size(file_size, max_size=None):
def detect_malicious_content(file_path): def detect_malicious_content(file_path):
""" """
Basic malicious content detection Basic malicious content detection
Args: Args:
file_path: Path to file to check file_path: Path to file to check
Returns: Returns:
bool: True if potentially malicious content detected bool: True if potentially malicious content detected
""" """
...@@ -315,7 +315,9 @@ def detect_malicious_content(file_path): ...@@ -315,7 +315,9 @@ def detect_malicious_content(file_path):
# Check file size (extremely large files might be suspicious) # Check file size (extremely large files might be suspicious)
import os import os
file_size = os.path.getsize(file_path) file_size = os.path.getsize(file_path)
if file_size > 1024 * 1024 * 1024: # 1GB # Allow up to 5GB for ZIP files (configurable)
max_safe_size = current_app.config.get('MAX_CONTENT_LENGTH', 5 * 1024 * 1024 * 1024)
if file_size > max_safe_size:
return True return True
# Check for executable signatures in first few bytes # Check for executable signatures in first few bytes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment