T09 · Insecure Skill Coding Practices
- Location
scripts/export_reply.py:110- Finding
Predictable and Insecure Temporary File Handling
- Content
View full analysis
Path: import tempfile, subprocess # Strategy 1: Chrome / Chromium headless (best quality, CJK native) chrome = _find_chrome() if chrome: html_tmp = Path(tempfile.mktemp(suffix=".html")) try: write_html(content, html_tmp, title) result = subprocess.run( [ chrome, "--headless", "--disable-gpu", "--no-sandbox", "--run-all-compositor-stages-before-draw", f"--print-to-pdf={output_path}", "--print-to-pdf-no-header", str(html_tmp), ], capture_output=True, timeout=30, ) if output_path.exists() and output_path.stat().st_size > 1000: return output_path except Exception: pass finally: html_tmp.unlink(missing_ok=True) # Strategy 2: weasyprint try: from weasyprint import HTML as WH html_tmp = Path(tempfile.mktemp(suffix=".html")) write_html(content, html_tmp, title) WH(filename=str(html_tmp)).write_pdf(str(output_path)) html_tmp.unlink(missing_ok=True) return output_path except ImportError: p ...[truncated 2199 chars]- Remediation
View remediation
