T08 · Insecure Dependencies
- Location
scripts/refresh_theme_assets_from_public_source.py:20- Finding
Unpinned Third-Party Theme Data Can Manipulate Market Analysis
- Content
View full analysis
dict[str, str | None]: req = Request(url, headers={"User-Agent": "codex-market-skills/refresh-theme-assets"}) try: with urlopen(req, timeout=30) as response: body = response.read() headers = response.headers except (HTTPError, URLError, TimeoutError) as exc: raise SystemExit(f"failed to download {url}: {exc}") from exc # Parse before writing so HTML error pages never replace valid assets. try: json.loads(body.decode("utf-8")) except Exception as exc: raise SystemExit(f"{url} did not return valid JSON") from exc with tempfile.NamedTemporaryFile( "wb", delete=False, dir=str(dest.parent), prefix=dest.name, suffix=".tmp", ) as tmp: tmp.write(body) tmp_path = Path(tmp.name) tmp_path.replace(dest) return { "url": url, "etag": headers.get("ETag"), "lastModified": headers.get("Last-Modified"), "contentLength": headers.get("Content-Length"), } ``` ```python parser.add_argument( "--base-url", default=DEFAULT_BASE_URL, help="Base URL that serves theme-data.json and theme-label-i18n.json", ) ``` ```python base_url = args.base_url.rstrip("/") file_meta: dict[str, dict[str, str | None]] = {} for filename in ASSET_FILES: url = f"{base_url}/{filename}" file_meta[filename] = download_json(url, target_dir / filename) ``` The corresponding Skill instruction mandates the refresh during normal theme-ranking operations: ```markdown 正常运行时执行一次映射刷新脚本;两份缓存都有效且未超过 ...[truncated 2826 chars]- Remediation
View remediation
