mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-11-18 10:28:20 +01:00
fix(release): validate stored Windows updater archives
This commit is contained in:
1 parent
7cf546620d
commit
f93056aca2
4 files changed
+135
-1
No files matched your search
+2
-1
@@ -19,8 +19,9 @@
|
||||
"test:mcp": "pnpm --filter @helixnotes/mcp test",
|
||||
"test:rust": "cargo test --manifest-path src-tauri/Cargo.toml",
|
||||
"test:browser": "playwright test --config tests/browser/playwright.config.ts --workers=2",
|
||||
"test:updater-packaging": "python3 -m unittest discover -s packaging/updater -p 'test_*.py'",
|
||||
"lint:rust": "cargo fmt --manifest-path src-tauri/Cargo.toml --check && cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets -- -D warnings",
|
||||
"verify": "pnpm check && pnpm test && pnpm test:mcp && pnpm test:rust && pnpm test:mcp:native && pnpm lint:rust && pnpm build",
|
||||
"verify": "pnpm check && pnpm test && pnpm test:updater-packaging && pnpm test:mcp && pnpm test:rust && pnpm test:mcp:native && pnpm lint:rust && pnpm build",
|
||||
"tauri": "tauri",
|
||||
"tauri:dev": "tauri dev",
|
||||
"tauri:build": "tauri build"
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# Windows updater packaging
|
||||
|
||||
Tauri updater 2.10 accepts a signed NSIS executable directly. The public Windows
|
||||
feed uses `HelixNotes_<version>_x64-setup.exe` and its matching `.exe.sig`.
|
||||
|
||||
Legacy ZIP updater archives must contain exactly one installer at their root,
|
||||
with **ZIP_STORED** entries. The updater's `zip` dependency disables default
|
||||
features and has no Deflate decoder. A ZIP opening successfully in Python,
|
||||
Explorer or 7-Zip does not prove that the updater can extract it.
|
||||
|
||||
Prepare compatibility archives from the already-tested installers:
|
||||
|
||||
```sh
|
||||
python3 packaging/updater/prepare_windows_updaters.py \
|
||||
--version 1.3.8 --installers /path/to/installers --output /path/to/staging
|
||||
pnpm test:updater-packaging
|
||||
```
|
||||
|
||||
Sign each final archive with the existing Tauri updater identity. Verify every
|
||||
signature against the public key embedded in the app. Never reuse an installer's
|
||||
signature for its ZIP wrapper. Regenerate release checksums after signing.
|
||||
|
||||
Before publication, test the actual previous Windows release's **Download &
|
||||
Install** flow against the final payload and signature. Verify that the upgraded
|
||||
app reports the target version and preserves synthetic notes. Keep personal
|
||||
profiles backed up and restore them after QA.
|
||||
|
||||
## 1.3.8 correction
|
||||
|
||||
The initial compatibility ZIPs incorrectly used Deflate. This reproduced
|
||||
`unsupported Zip archive: Compression method not supported` in the native
|
||||
1.3.7 Windows app. The feed was changed to the existing signed native EXE and
|
||||
an actual 1.3.7-to-1.3.8 in-app update passed. Both compatibility ZIPs were
|
||||
repacked as Stored and re-signed; installer binaries were not changed.
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Wrap existing signed Windows installers for Tauri's legacy ZIP updater.
|
||||
|
||||
Tauri updater 2.10 builds zip with default-features=false. Only ZIP_STORED
|
||||
entries work; Python's ability to extract Deflate does not prove compatibility.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
import re
|
||||
import zipfile
|
||||
|
||||
|
||||
def validate_archive(archive: Path, installer: Path) -> None:
|
||||
with zipfile.ZipFile(archive) as wrapper:
|
||||
entries = wrapper.infolist()
|
||||
if len(entries) != 1 or entries[0].filename != installer.name:
|
||||
raise ValueError("Updater ZIP must contain exactly one root-level installer")
|
||||
if entries[0].compress_type != zipfile.ZIP_STORED or entries[0].flag_bits & 1:
|
||||
raise ValueError("Tauri requires unencrypted ZIP_STORED installer entries")
|
||||
if hashlib.sha256(wrapper.read(entries[0])).digest() != hashlib.sha256(installer.read_bytes()).digest():
|
||||
raise ValueError("Wrapped installer differs from the tested original")
|
||||
|
||||
|
||||
def build_archive(installer: Path, archive: Path) -> None:
|
||||
if not installer.is_file() or installer.suffix.lower() not in {".exe", ".msi"}:
|
||||
raise ValueError("Expected an existing Windows EXE or MSI installer")
|
||||
archive.parent.mkdir(parents=True, exist_ok=True)
|
||||
temporary = archive.with_name(archive.name + ".tmp")
|
||||
try:
|
||||
with zipfile.ZipFile(temporary, "w", compression=zipfile.ZIP_STORED) as wrapper:
|
||||
wrapper.write(installer, arcname=installer.name, compress_type=zipfile.ZIP_STORED)
|
||||
validate_archive(temporary, installer)
|
||||
temporary.replace(archive)
|
||||
finally:
|
||||
temporary.unlink(missing_ok=True)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--version", required=True)
|
||||
parser.add_argument("--installers", type=Path, required=True)
|
||||
parser.add_argument("--output", type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
if not re.fullmatch(r"\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?", args.version):
|
||||
parser.error("Invalid release version")
|
||||
prefix = "HelixNotes_" + args.version
|
||||
for source, target in [(prefix + "_x64-setup.exe", prefix + "_x64-setup.nsis.zip"),
|
||||
(prefix + "_x64_en-US.msi", prefix + "_x64_en-US.msi.zip")]:
|
||||
build_archive(args.installers / source, args.output / target)
|
||||
print("Validated ZIP_STORED:", target)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,44 @@
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
import zipfile
|
||||
from prepare_windows_updaters import build_archive, validate_archive
|
||||
|
||||
|
||||
class WindowsUpdaterArchiveTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.temp.cleanup)
|
||||
self.root = Path(self.temp.name)
|
||||
self.installer = self.root / "HelixNotes_1.3.8_x64-setup.exe"
|
||||
self.installer.write_bytes(b"MZ" + b"synthetic installer payload\n" * 100)
|
||||
self.archive = self.root / "update.zip"
|
||||
|
||||
def test_generated_archive_is_stored_and_preserves_exact_installer(self):
|
||||
build_archive(self.installer, self.archive)
|
||||
validate_archive(self.archive, self.installer)
|
||||
with zipfile.ZipFile(self.archive) as archive:
|
||||
self.assertEqual(archive.infolist()[0].compress_type, zipfile.ZIP_STORED)
|
||||
self.assertEqual(archive.read(self.installer.name), self.installer.read_bytes())
|
||||
|
||||
def test_deflate_is_rejected_even_when_python_can_extract_it(self):
|
||||
with zipfile.ZipFile(self.archive, "w", compression=zipfile.ZIP_DEFLATED) as archive:
|
||||
archive.write(self.installer, self.installer.name)
|
||||
with self.assertRaisesRegex(ValueError, "ZIP_STORED"):
|
||||
validate_archive(self.archive, self.installer)
|
||||
|
||||
def test_nested_installer_is_rejected(self):
|
||||
with zipfile.ZipFile(self.archive, "w") as archive:
|
||||
archive.write(self.installer, "nested/" + self.installer.name)
|
||||
with self.assertRaisesRegex(ValueError, "root-level"):
|
||||
validate_archive(self.archive, self.installer)
|
||||
|
||||
def test_changed_installer_is_rejected(self):
|
||||
build_archive(self.installer, self.archive)
|
||||
self.installer.write_bytes(b"different payload")
|
||||
with self.assertRaisesRegex(ValueError, "differs"):
|
||||
validate_archive(self.archive, self.installer)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user