T09 · Insecure Skill Coding Practices
- Location
scripts/parse_input.py:53- Finding
Configurable OCR Endpoint Can Receive Sensitive Documents and Access Tokens
- Content
View full analysis
str: """调用 PaddleOCR AIStudio API 识别图片文字。""" _require_token("图片 OCR") try: import requests except ImportError: _install("requests") import requests with open(file_path, "rb") as f: b64 = base64.b64encode(f.read()).decode("utf-8") payload = {"file": b64, "fileType": 1} headers = { "Content-Type": "application/json", "Authorization": f"token {TOKEN}", } resp = _post_with_error_handling(requests, payload, headers, timeout=60) return _extract_text_from_response(resp) ``` ```python def _parse_pdf_via_api(file_path: str) -> str: """调用 PaddleOCR PP-StructureV3 API 解析扫描版 PDF。""" _require_token("扫描版 PDF 解析") try: import requests except ImportError: _install("requests") import requests with open(file_path, "rb") as f: b64 = base64.b64encode(f.read()).decode("utf-8") payload = {"file": b64, "fileType": 0} headers = { "Content-Type": "application/json", "Authorization": f"token {TOKEN}", } resp = _post_with_error_handling(requests, payload, headers, timeout=120) return _extract_text_from_response(resp) ``` ```python resp = requests_mod.post( STRUCT_ENDPOINT, json=payload, headers=headers, timeout=timeout ) resp.raise_for_status() return resp ``` ### Technical Analysis The parser allows `PADDLEOCR_ ...[truncated 2510 chars]- Remediation
View remediation
