diff --git a/scripts/largefiles.py b/scripts/largefiles.py index 348d65a4..685ac2cf 100644 --- a/scripts/largefiles.py +++ b/scripts/largefiles.py @@ -14,13 +14,10 @@ from hashing import compute_hashes LARGE_FILES_RELEASE = "large-files" - -LARGE_FILES_RELEASE = "large-files" -LARGE_FILES_REPO = "Abdess/retrobios" - LARGE_FILES_REPO = "Abdess/retrobios" LARGE_FILES_CACHE = ".cache/large" + def fetch_large_file( name: str, dest_dir: str = LARGE_FILES_CACHE, diff --git a/scripts/siterender.py b/scripts/siterender.py index e1018fcb..6a82ff63 100644 --- a/scripts/siterender.py +++ b/scripts/siterender.py @@ -9,8 +9,6 @@ from concurrent.futures import ThreadPoolExecutor import json import urllib.request WIKI_SRC_DIR = "wiki" # manually maintained wiki sources -SYSTEM_ICON_BASE = "https://raw.githubusercontent.com/libretro/retroarch-assets/master/xmb/systematic/png" - SYSTEM_ICON_BASE = "https://raw.githubusercontent.com/libretro/retroarch-assets/master/xmb/systematic/png" ICON_CACHE_PATH = Path(".cache") / "system_icons.json" diff --git a/scripts/ziptools.py b/scripts/ziptools.py index 851be686..bdb3155e 100644 --- a/scripts/ziptools.py +++ b/scripts/ziptools.py @@ -75,24 +75,22 @@ def build_zip_contents_index(db: dict, max_entry_size: int = 512 * 1024 * 1024) _zip_contents_cache = (fingerprint, index) return index + MAX_ZIP_MEMBERS = 100_000 MAX_ZIP_MEMBER_SIZE = 8 * 1024 * 1024 * 1024 -MAX_ZIP_MEMBER_SIZE = 8 * 1024 * 1024 * 1024 # The largest generated pack is already ~5 GB uncompressed and the collection # only grows; this bounds a malicious archive without capping a real one. MAX_ZIP_TOTAL_SIZE = 64 * 1024 * 1024 * 1024 -MAX_ZIP_TOTAL_SIZE = 64 * 1024 * 1024 * 1024 # DEFLATE cannot exceed roughly 1,032:1, so this rejects a declared ratio no # real DEFLATE member can reach. Methods with a higher ceiling (bzip2, LZMA) # are exempt and bounded by the per-member and per-archive size limits alone. -MAX_ZIP_COMPRESSION_RATIO = 1_100 - MAX_ZIP_COMPRESSION_RATIO = 1_100 _BOUNDED_RATIO_METHODS = (zipfile.ZIP_STORED, zipfile.ZIP_DEFLATED) + def safe_extract_zip( zip_path: str, dest_dir: str, diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 2689ef8e..c9b8d299 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -2,6 +2,7 @@ from __future__ import annotations +import ast import contextlib import hashlib import io @@ -1009,3 +1010,36 @@ class ContributorsSurviveAFailedRequest(unittest.TestCase): text.count(' list[str]: + seen: dict[str, str] = {} + again = [] + for node in ast.parse(path.read_text()).body: + if not isinstance(node, ast.Assign) or len(node.targets) != 1: + continue + target = node.targets[0] + if not isinstance(target, ast.Name): + continue + value = ast.unparse(node.value) + if seen.get(target.id) == value: + again.append(target.id) + seen[target.id] = value + return again + + def test_no_module_assigns_the_same_constant_twice(self): + offenders = {} + for path in sorted(ROOT.glob("scripts/**/*.py")) + [ROOT / "install.py"]: + again = self._redeclared(path) + if again: + offenders[path.name] = again + self.assertEqual(offenders, {})