Skip to content

The agent that grows with you

fix: round-10 — PowerShell probe via -File; enable-grant test follows #64228; stage-hold fixture requests access

ethernetd0c91f47f15b
diff --git a/tests/hermes_cli/test_plugins_cmd_enable_disable_nested.py b/tests/hermes_cli/test_plugins_cmd_enable_disable_nested.py
index ae27691c5e3..3858f2223d8 100644
--- a/tests/hermes_cli/test_plugins_cmd_enable_disable_nested.py
+++ b/tests/hermes_cli/test_plugins_cmd_enable_disable_nested.py
@@ -73,6 +73,11 @@ def test_dependency_free_enable_no_churn_and_tool_override_fails_closed(plugin_w
monkeypatch.setattr("rich.console.Console.input", eof)
world.command("enable", name="plugin-worker-proof")
config = yaml.safe_load((world.home / "config.yaml").read_text())
+ # Enabling is not a request for undeclared privileges (#64228): no grant is prompted for or
+ # written; only an explicit flag persists one.
+ assert "allow_tool_override" not in config.get("plugins", {}).get("entries", {}).get("plugin-worker-proof", {})
+ world.command("enable", name="plugin-worker-proof", no_allow_tool_override=True)
+ config = yaml.safe_load((world.home / "config.yaml").read_text())
assert config["plugins"]["entries"]["plugin-worker-proof"]["allow_tool_override"] is False
assert world.selected() == selected
assert receipt.latest()["venv_rebuild"]["ok"] is False
diff --git a/tests/pm/test_stage_only.py b/tests/pm/test_stage_only.py
index e676b6b6328..9f2b2c7a78c 100644
--- a/tests/pm/test_stage_only.py
+++ b/tests/pm/test_stage_only.py
@@ -201,8 +201,10 @@ def test_stage_repin_refuses_a_native_directory_hold_then_recovers(sandbox, monk
kernel.CreateFileW.restype = wintypes.HANDLE
kernel.CloseHandle.argtypes = [wintypes.HANDLE]
kernel.CloseHandle.restype = wintypes.BOOL
- # FILE_FLAG_BACKUP_SEMANTICS opens a directory; omit FILE_SHARE_DELETE.
- handle = kernel.CreateFileW(str(entry), 0, 3, None, 3, 0x02000000, None)
+ # FILE_FLAG_BACKUP_SEMANTICS opens a directory; omit FILE_SHARE_DELETE. The access mask must
+ # be non-zero (FILE_LIST_DIRECTORY): a zero-access handle takes no sharing lock and the rename
+ # the stage repin performs goes through unopposed.
+ handle = kernel.CreateFileW(str(entry), 1, 3, None, 3, 0x02000000, None)
assert handle != wintypes.HANDLE(-1).value, ctypes.get_last_error()
try:
with pytest.raises(InstallError):
diff --git a/tests/scripts/test_source_build_env.py b/tests/scripts/test_source_build_env.py
index 68a6017e692..f5ad82b58aa 100644
--- a/tests/scripts/test_source_build_env.py
+++ b/tests/scripts/test_source_build_env.py
@@ -84,14 +84,18 @@ if (result.error || result.status !== 0) throw new Error(`stamp child failed: ${
console.log(JSON.stringify(process.env));
''']
else:
- command = [shell, "-NoProfile", "-NonInteractive", "-Command", '''
-$ErrorActionPreference = 'Stop'
+ # -File, not -Command: Windows PowerShell 5.1 reads a multi-line -Command argument as
+ # far as the first line break and exits 0 having run only the preference line.
+ script = tmp_path / "probe.ps1"
+ script.write_text('''$ErrorActionPreference = 'Stop'
. (Join-Path $env:ASSETS 'source-build-env.ps1')
Invoke-SourceBuild { & $env:PROBE_PYTHON -I -S $env:PROBE_SCRIPT; if ($LASTEXITCODE) { throw 'stamp failed' } }
try { Invoke-SourceBuild { throw 'child failure' }; throw 'lost exception' }
catch { if ($_.Exception.Message -ne 'child failure') { throw } }
& $env:PROBE_PYTHON -I -S -c 'import json, os; print(json.dumps(dict(os.environ)))'
-''']
+if ($LASTEXITCODE) { exit $LASTEXITCODE }
+''', encoding="utf-8-sig")
+ command = [shell, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", str(script)]
for sha in (old, new):
git("checkout", "-q", "-B", "installed", sha)
result = subprocess.run(command, env=env, cwd=tmp_path, capture_output=True,