Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MBetterd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mbetter
MBetterd
Commits
b840a724
Commit
b840a724
authored
Sep 26, 2025
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix upload size limit
parent
3ee190b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
file_handler.py
app/upload/file_handler.py
+2
-2
security.py
app/utils/security.py
+5
-3
No files found.
app/upload/file_handler.py
View file @
b840a724
...
@@ -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'
,
5
00
*
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
app/utils/security.py
View file @
b840a724
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment