fix: allow explicit native repair owner process queries
This commit is contained in:
1 parent
747ce1add2
commit
b90a9bbfab
3 files changed
+54
No files matched your search
@@ -155,3 +155,12 @@ Task 1 review fix round: 259 related tests passed (17.86s); compileall and
|
||||
`git diff --check` passed. These checks include busy retention, real readback
|
||||
failure branches, 30 malformed-success variants at both release and reopen/
|
||||
counting boundaries, and a complete actual worker-result replay control.
|
||||
|
||||
Runtime fix round 2 adds `iCDBProjectBackup.exe` and `ReuseBlockImporter.exe` to
|
||||
the process helper's fixed query whitelist. Without these entries, the real
|
||||
parent release probe rejected its own required queries and always denied safe
|
||||
release. New tests keep the release validator and process helper real and stub
|
||||
only WMI: no owners permits release, either native owner prevents it, and
|
||||
arbitrary query names remain rejected. Focused validation: 172 passed. Candidate
|
||||
`c823a4b` must be rebuilt with this correction before frozen/native validation;
|
||||
field recovery remains unverified.
|
||||
@@ -220,6 +220,8 @@ def _process_details(name):
|
||||
queries = {
|
||||
'ExpeditionPCB.exe': "SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine FROM Win32_Process WHERE Name='ExpeditionPCB.exe'",
|
||||
'LibraryManager.exe': "SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine FROM Win32_Process WHERE Name='LibraryManager.exe'",
|
||||
'iCDBProjectBackup.exe': "SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine FROM Win32_Process WHERE Name='iCDBProjectBackup.exe'",
|
||||
'ReuseBlockImporter.exe': "SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine FROM Win32_Process WHERE Name='ReuseBlockImporter.exe'",
|
||||
'cscript.exe': "SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine FROM Win32_Process WHERE Name='cscript.exe'",
|
||||
'viewdraw.exe': "SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine FROM Win32_Process WHERE Name='viewdraw.exe'",
|
||||
}
|
||||
|
||||
@@ -811,3 +811,46 @@ def test_malformed_native_success_never_reopens_or_counts_repaired(tmp_path, mon
|
||||
assert result.recovery_attempts[0]['status'] == 'UNCONFIRMED'
|
||||
assert result.recovery_attempts[0]['release']['safe_to_continue'] is False
|
||||
assert maintenance_counts([result])['repaired'] == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize('owner', [None, 'iCDBProjectBackup.exe', 'ReuseBlockImporter.exe'])
|
||||
def test_repair_release_uses_real_process_query_contract(tmp_path, monkeypatch, owner):
|
||||
from types import SimpleNamespace
|
||||
import win32com.client
|
||||
from cbb_refresh_verify.native_repair import repair_release_state
|
||||
request, diagnosis, target = target_fixture(tmp_path)
|
||||
queried = []
|
||||
names = ('ExpeditionPCB.exe', 'LibraryManager.exe', 'iCDBProjectBackup.exe',
|
||||
'ReuseBlockImporter.exe', 'cscript.exe')
|
||||
queries = {"SELECT ProcessId, ParentProcessId, ExecutablePath, CommandLine "
|
||||
f"FROM Win32_Process WHERE Name='{name}'": name for name in names}
|
||||
def query(wql):
|
||||
name = queries[wql]
|
||||
queried.append(name)
|
||||
return ([SimpleNamespace(ProcessId='456', ParentProcessId='1',
|
||||
ExecutablePath=f'C:\\Mentor\\{name}', CommandLine=f'{name} target')]
|
||||
if name == owner else [])
|
||||
def service(moniker):
|
||||
assert moniker == 'winmgmts:'
|
||||
return SimpleNamespace(ExecQuery=query)
|
||||
monkeypatch.setattr(win32com.client, 'GetObject', service)
|
||||
# Keep pcb_processes, _processes, _process_details and release validation real.
|
||||
state = repair_release_state(request, target, complete_native_success(target))
|
||||
assert 'error' not in state
|
||||
assert queried == list(names)
|
||||
assert state['safe_to_continue'] is (owner is None)
|
||||
assert state['remaining_pids'] == ([] if owner is None else [456])
|
||||
assert state['database_exclusive'] is (owner is None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('name', [
|
||||
'other.exe', 'icdbprojectbackup.exe',
|
||||
"iCDBProjectBackup.exe' OR Name='other.exe",
|
||||
"ReuseBlockImporter.exe' OR Name='other.exe",
|
||||
])
|
||||
def test_repair_process_queries_still_reject_arbitrary_input(monkeypatch, name):
|
||||
import win32com.client
|
||||
from cbb_refresh_verify.mentor_adapter import _process_details
|
||||
monkeypatch.setattr(win32com.client, 'GetObject', lambda *a: pytest.fail('Unsupported name reached WMI'))
|
||||
with pytest.raises(ValueError, match='Unsupported process query'):
|
||||
_process_details(name)
|
||||
Reference in new issue
Block a user