Skip to content

Commit

Permalink
fix: 🐛 Solve security alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
albinmedoc committed Jul 31, 2024
1 parent e6e9d68 commit c719c29
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/wizarr-backend/wizarr_backend/api/routes/image_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class ImageAPI(Resource):
@api.response(500, "Internal server error")
def get(self, filename):
"""Get image"""
# Sanitize the filename to avoid directory traversal
filename = secure_filename(filename)

# Assuming images are stored in a directory specified by UPLOAD_FOLDER config
upload_folder = current_app.config['UPLOAD_FOLDER']
image_path = os.path.join(upload_folder, filename)
Expand All @@ -74,6 +77,9 @@ def get(self, filename):
@api.response(500, "Internal server error")
def delete(self, filename):
"""Delete image"""
# Sanitize the filename to avoid directory traversal
filename = secure_filename(filename)

upload_folder = current_app.config['UPLOAD_FOLDER']
image_path = os.path.join(upload_folder, filename)

Expand Down

0 comments on commit c719c29

Please sign in to comment.