T09 · Insecure Skill Coding Practices
- Location
scripts/generate_weekly_report.py:78- Finding
Arbitrary File Overwrite Through Unrestricted Output Path
- Content
View full analysis
str: """将 HTML 渲染为 PDF,通过 Ghostscript 优化以兼容 macOS Preview""" import subprocess, tempfile, shutil, os tmp_path = output_path + ".tmp.pdf" HTML(string=html_content).write_pdf(tmp_path) gs_bin = shutil.which("gs") if gs_bin: try: subprocess.run([ gs_bin, "-dNOPAUSE", "-dBATCH", "-dSAFER", "-sDEVICE=pdfwrite", "-dCompatibilityLevel=1.4", "-dPDFSETTINGS=/prepress", "-dEmbedAllFonts=true", "-dSubsetFonts=true", f"-sOutputFile={output_path}", tmp_path, ], check=True, capture_output=True) os.remove(tmp_path) except subprocess.CalledProcessError: os.replace(tmp_path, output_path) else: os.replace(tmp_path, output_ ...[truncated 2298 chars]- Remediation
View remediation
