From 50ed6f20fa40acec41ba60cb94da6bcc46657e59 Mon Sep 17 00:00:00 2001 From: Dusk-92 Date: Fri, 4 Sep 2026 14:42:50 +0200 Subject: [PATCH] Tighten executable and wrapped MPQ validation --- setup_tool_dynamic.py | 17 +-- tests/test_strict_runtime_validation.py | 166 +++++++++++++++++++++ tests/test_vanilla_tweaks_normalization.py | 38 ++++- 3 files changed, 197 insertions(+), 24 deletions(-) create mode 100644 tests/test_strict_runtime_validation.py diff --git a/setup_tool_dynamic.py b/setup_tool_dynamic.py index 0448229..cb5a61c 100644 --- a/setup_tool_dynamic.py +++ b/setup_tool_dynamic.py @@ -330,16 +330,7 @@ class ModernWowSetupTool(_ModernWowSetupToolCore): @staticmethod def _validate_client_identity(data): - """Require immutable 1.12.1/5875 anchors for a real PE client. - - Unit fixtures intentionally use synthetic non-PE buffers. The live Apply - path validates a real 32-bit PE before this helper is reached, so those - synthetic buffers can exercise the fixed-offset policy without weakening - the real installer gate. - """ - if bytes(data[:2]) != b"MZ": - return - + """Require immutable Vanilla 1.12.1/5875 anchors before fixed-offset tweaks.""" build = bytes( data[_CLIENT_BUILD_OFFSET:_CLIENT_BUILD_OFFSET + len(_CLIENT_BUILD)] ) @@ -385,12 +376,6 @@ class ModernWowSetupTool(_ModernWowSetupToolCore): def _validate_staged_numeric_states(self, data, source_states, desired): """The upstream patcher may only leave source bytes or write our selection.""" - # Legacy unit fixtures are synthetic byte buffers, not executable files. - # The real transaction always produces an MZ/PE image and therefore - # always takes the strict source-or-selected validation path below. - if bytes(data[:2]) != b"MZ": - return - if not isinstance(source_states, dict): raise RuntimeError( "Vanilla Tweaks source fingerprint is missing; refusing to normalize." diff --git a/tests/test_strict_runtime_validation.py b/tests/test_strict_runtime_validation.py new file mode 100644 index 0000000..ad39ad3 --- /dev/null +++ b/tests/test_strict_runtime_validation.py @@ -0,0 +1,166 @@ +import os +import struct +import tempfile +import unittest + +import remote_packages +import setup_tool_dynamic as dynamic + + +def _classic_mpq_bytes( + *, + archive_size=96, + hash_table_offset=32, + block_table_offset=48, + inner_magic=b"MPQ\x1A", +): + header = inner_magic + struct.pack( + "