From 9cb1e9650965b330c4adb078c1db47b804cc7dee Mon Sep 17 00:00:00 2001 From: AzuLX Date: Tue, 13 Jan 2026 23:35:42 +0000 Subject: [PATCH 1/2] Replace the shell zip cmd with rustyzipper --- requirements.txt | 1 + review/routes.py | 45 ++++++++------------------------------------- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/requirements.txt b/requirements.txt index 253c62a..e7ba5c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,6 +9,7 @@ bleach==6.1.0 requests==2.31.0 Werkzeug==3.0.1 resend==2.0.0 +rustyzipper==1.0.5 # Testing pytest==7.4.3 diff --git a/review/routes.py b/review/routes.py index 94e887c..12c1556 100644 --- a/review/routes.py +++ b/review/routes.py @@ -27,7 +27,7 @@ import bcrypt import requests -from subprocess import call +from rustyzipper import compress_file, EncryptionMethod from bson.objectid import ObjectId from review.logger import log_reviewer_operation @@ -498,56 +498,27 @@ def create_password_protected_zip(source_path, dest_path_without_ext, filename_i Returns: Tuple of (success: bool, error_message: str or None) """ - # Move to temp location with desired filename + dest_path = dest_path_without_ext + '.zip' temp_path = os.path.join(CRACKMESONE_DIR, filename_in_archive) - shutil.move(source_path, temp_path) try: - # Find zip command (use full path to avoid PATH issues in web server) - zip_cmd = shutil.which("zip") or "/usr/bin/zip" - - # Create password-protected zip - ret = call([ - zip_cmd, "-j", "--password", ARCHIVE_PASSWORD, - dest_path_without_ext, "--", temp_path - ]) - - if ret != 0: - # Move file back on failure - if os.path.exists(temp_path): - try: - shutil.move(temp_path, source_path) - except Exception: - pass - return False, "Failed to create zip archive" - + shutil.move(source_path, temp_path) + compress_file(temp_path, dest_path, password=ARCHIVE_PASSWORD, encryption=EncryptionMethod.ZIPCRYPTO, suppress_warning=True) + os.remove(temp_path) return True, None - except FileNotFoundError: - # zip command not found - move file back - if os.path.exists(temp_path): - try: - shutil.move(temp_path, source_path) - except Exception: - pass - return False, "zip command not found" - except Exception as e: - # Other errors - move file back if os.path.exists(temp_path): try: shutil.move(temp_path, source_path) except Exception: pass - return False, f"Error creating zip: {str(e)}" - - finally: - # Clean up temp file (only if zip succeeded, file was moved to archive) - if os.path.exists(temp_path): + if os.path.exists(dest_path): try: - os.remove(temp_path) + os.remove(dest_path) except Exception: pass + return False, f"Error creating zip: {str(e)}" # ============================================================================= From 45894606aa9201c8c529f2f25309b84f9dae8537 Mon Sep 17 00:00:00 2001 From: Erdit Date: Thu, 15 Jan 2026 14:24:43 +0000 Subject: [PATCH 2/2] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e7ba5c9..9960a76 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ bleach==6.1.0 requests==2.31.0 Werkzeug==3.0.1 resend==2.0.0 -rustyzipper==1.0.5 +rustyzipper==1.0.6 # Testing pytest==7.4.3