fix: enforce native repair ownership and cancellation boundaries

This commit is contained in:
阿白叔 committed 2026-10-27 18:08:14 +08:00
1 parent 2490067b2d
commit 9cd4968a97
8 files changed
+248 -10

No files matched your search

+9 -2
View File
@@ -1,9 +1,10 @@
"""Production safeguards: no input injection, no desktop switching, no menu driving.
"""Production safeguards: no input injection or uncontrolled menu driving.
These asserts encode the operating rules for this tool: the user's mouse,
keyboard and desktop are never touched. Dialogs that belong to a process this
run started are answered with a posted BM_CLICK, which is a message to that
dialog and not user input.
dialog and not user input. Native Project Backup Repair is restricted to an
owned private desktop/PID, a resolved resource command and an exact PRJ.
"""
from pathlib import Path
@@ -24,6 +25,7 @@ FORBIDDEN_APIS = (
'AttachThreadInput',
'WM_MOUSEMOVE',
'WM_CONTEXTMENU',
'WM_COMMAND',
'VK_APPS',
'TVM_SELECTITEM',
'EndMenu',
@@ -39,6 +41,11 @@ def test_no_input_injection_or_desktop_switching_in_production_code():
for path in production_sources():
text = path.read_text(encoding='utf-8')
for api in FORBIDDEN_APIS:
if path.name == 'native_repair_ui.py' and api == 'WM_COMMAND':
# Only the installed Project Backup Repair menu is allowed:
# resolve its native resource, own the private desktop/PID,
# and confirm the exact PRJ before posting the command.
continue
if path.name == 'library_manager_verify.py' and api in {'WM_MOUSEMOVE', 'TVM_SELECTITEM'}:
continue
if path.name == 'library_manager_verify.py' and api == 'click_input':