T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/extract_and_rename.py:263- Finding
Recursive ZIP Packaging Collects Unrelated Files
- Content
View full analysis
- Remediation
View remediation
str: zip_path = os.path.abspath(os.path.join(folder, zip_name)) root = os.path.abspath(folder) with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zf: for file_path in approved_files: file_path = os.path.abspath(file_path) if os.path.commonpath([root, file_path]) != root: raise ValueError("File is outside the approved folder") if os.path.isfile(file_path) and file_path.lower().endswith(".pdf"): zf.write(file_path, os.path.relpath(file_path, root)) return zip_path ``` ]]>
