fix(agent99): harden Windows99 no-IME transport
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 2s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m29s
CD Pipeline / build-and-deploy (push) Successful in 29m59s
AI 技術雷達監控 / ai-technology-watch (push) Successful in 38s
CD Pipeline / post-deploy-checks (push) Successful in 4m20s
AWOOOI Harbor 110 Local Repair / workflow-shape (push) Successful in 1s
AWOOOI Harbor 110 Local Repair / harbor-110-local-repair (push) Successful in 18s
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 2s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m29s
CD Pipeline / build-and-deploy (push) Successful in 29m59s
AI 技術雷達監控 / ai-technology-watch (push) Successful in 38s
CD Pipeline / post-deploy-checks (push) Successful in 4m20s
AWOOOI Harbor 110 Local Repair / workflow-shape (push) Successful in 1s
AWOOOI Harbor 110 Local Repair / harbor-110-local-repair (push) Successful in 18s
This commit is contained in:
@@ -54,12 +54,25 @@ def test_collector_contract_forbids_secret_and_runtime_actions() -> None:
|
||||
assert "StrictHostKeyChecking=accept-new" in text
|
||||
assert "StrictHostKeyChecking=no" not in text
|
||||
assert 'REMOTE_VERIFY_TIMEOUT="${WINDOWS99_REMOTE_VERIFY_TIMEOUT:-45}"' in text
|
||||
assert "REMOTE_VERIFY_TIMEOUT - 15" in text
|
||||
assert "unsafe_legacy_override_rejected" in text
|
||||
assert "SSH_USERS=(Administrator ogt wooo ooo administrator)" in text
|
||||
assert "GSSAPIAuthentication=no" in text
|
||||
assert "--via-host" in text
|
||||
assert "via_host=" in text
|
||||
assert "in_memory_stdin_scriptblock" in text
|
||||
assert "[Console]::In.ReadToEnd()" in text
|
||||
assert "encoded_command_bounded_job_base64_line" in text
|
||||
assert "[Console]::In.ReadLine()" in text
|
||||
assert "FromBase64String" in text
|
||||
assert "[Console]::In.ReadToEnd()" not in text
|
||||
assert "$ProgressPreference = 'SilentlyContinue'" in text
|
||||
assert "[Text.UTF8Encoding]::new($false)" in text
|
||||
assert "Start-Job" in text
|
||||
assert "Wait-Job" in text
|
||||
assert "Stop-Job" in text
|
||||
assert "Remove-Job" in text
|
||||
assert "-NonInteractive" in text
|
||||
assert "-EncodedCommand" in text
|
||||
assert 'Command \"& ([scriptblock]::Create([Console]::In.ReadToEnd()))' not in text
|
||||
assert ".\\\\windows99-vmware-autostart.ps1 -Mode Verify" not in text
|
||||
for forbidden in [
|
||||
"sshpass",
|
||||
@@ -161,6 +174,45 @@ def test_check_mode_probes_all_explicit_users_without_secret_prompt(tmp_path: Pa
|
||||
assert values["password_prompt_allowed"] == "false"
|
||||
|
||||
|
||||
def test_collect_mode_rejects_legacy_readtoend_override(
|
||||
tmp_path: Path, monkeypatch
|
||||
) -> None:
|
||||
fake_bin = tmp_path / "bin"
|
||||
fake_bin.mkdir()
|
||||
_write_executable(
|
||||
fake_bin / "nc",
|
||||
"""
|
||||
#!/usr/bin/env bash
|
||||
exit 0
|
||||
""",
|
||||
)
|
||||
_write_executable(
|
||||
fake_bin / "ssh",
|
||||
"""
|
||||
#!/usr/bin/env bash
|
||||
args="$*"
|
||||
if [[ "$args" == *"powershell"* ]]; then
|
||||
exit 44
|
||||
fi
|
||||
printf '%s\n' 'AWOOOI_WINDOWS99_SSH_READY'
|
||||
exit 0
|
||||
""",
|
||||
)
|
||||
monkeypatch.setenv(
|
||||
"WINDOWS99_REMOTE_VERIFY_COMMAND",
|
||||
"powershell -Command [Console]::In.ReadToEnd()",
|
||||
)
|
||||
|
||||
result = _run_collector(fake_bin, "--collect", "--max-auth-users", "1")
|
||||
|
||||
assert result.returncode == 75
|
||||
values = _key_values(result.stdout)
|
||||
assert values["remote_verify_mode"] == "unsafe_legacy_override_rejected"
|
||||
assert values["remote_transport_ready"] == "0"
|
||||
assert values["remote_verify_attempted"] == "0"
|
||||
assert values["verify_collection_status"] == "blocked_local_transport_encoder_missing"
|
||||
|
||||
|
||||
def test_check_mode_can_cap_auth_probe_user_count_without_secret_prompt(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
@@ -254,7 +306,9 @@ def test_check_mode_auth_ready_does_not_run_remote_verify(tmp_path: Path) -> Non
|
||||
assert result.returncode == 0
|
||||
values = _key_values(result.stdout)
|
||||
assert values["ssh_batchmode_auth_ready"] == "1"
|
||||
assert values["remote_verify_mode"] == "in_memory_stdin_scriptblock"
|
||||
assert values["remote_verify_mode"] == "encoded_command_bounded_job_base64_line"
|
||||
assert values["remote_transport_ready"] == "1"
|
||||
assert values["remote_verify_job_timeout_seconds"] == "30"
|
||||
assert values["local_verify_script_present"] == "1"
|
||||
assert values["remote_verify_attempted"] == "0"
|
||||
assert values["verify_collection_status"] == "ready_ssh_batchmode_auth_probe_only"
|
||||
@@ -296,6 +350,7 @@ def test_collect_mode_runs_readonly_remote_verify_when_auth_ready(tmp_path: Path
|
||||
assert values["dry_run"] == "false"
|
||||
assert values["ssh_batchmode_auth_ready"] == "1"
|
||||
assert values["remote_verify_attempted"] == "1"
|
||||
assert values["remote_transport_ready"] == "1"
|
||||
assert values["remote_verify_exit_status"] == "0"
|
||||
assert values["verify_collection_status"] == "collected_windows99_vmware_verify_stdout"
|
||||
assert "remote_verify_output_begin" in result.stdout
|
||||
|
||||
@@ -52,8 +52,21 @@ def test_locator_contract_forbids_secret_runtime_actions_and_vmx_content_reads()
|
||||
assert "NumberOfPasswordPrompts=0" in bash_text
|
||||
assert "--via-host" in bash_text
|
||||
assert "via_host=" in bash_text
|
||||
assert "in_memory_stdin_scriptblock" in bash_text
|
||||
assert "[Console]::In.ReadToEnd()" in bash_text
|
||||
assert "REMOTE_LOCATOR_TIMEOUT - 15" in bash_text
|
||||
assert "unsafe_legacy_override_rejected" in bash_text
|
||||
assert "encoded_command_bounded_job_base64_line" in bash_text
|
||||
assert "[Console]::In.ReadLine()" in bash_text
|
||||
assert "FromBase64String" in bash_text
|
||||
assert "[Console]::In.ReadToEnd()" not in bash_text
|
||||
assert "$ProgressPreference = 'SilentlyContinue'" in bash_text
|
||||
assert "[Text.UTF8Encoding]::new($false)" in bash_text
|
||||
assert "Start-Job" in bash_text
|
||||
assert "Wait-Job" in bash_text
|
||||
assert "Stop-Job" in bash_text
|
||||
assert "Remove-Job" in bash_text
|
||||
assert "-NonInteractive" in bash_text
|
||||
assert "-EncodedCommand" in bash_text
|
||||
assert 'Command \"& ([scriptblock]::Create([Console]::In.ReadToEnd()))' not in bash_text
|
||||
assert "Get-ChildItem" in ps_text
|
||||
assert "Test-Path" in ps_text
|
||||
for text in [bash_text, ps_text]:
|
||||
@@ -110,6 +123,9 @@ def test_check_mode_reports_auth_probe_without_remote_locator(tmp_path: Path) ->
|
||||
assert values["target_host_alias"] == "99"
|
||||
assert values["target_vm_alias"] == "111"
|
||||
assert values["ssh_batchmode_auth_ready"] == "1"
|
||||
assert values["remote_locator_mode"] == "encoded_command_bounded_job_base64_line"
|
||||
assert values["remote_transport_ready"] == "1"
|
||||
assert values["remote_locator_job_timeout_seconds"] == "45"
|
||||
assert values["remote_locator_attempted"] == "0"
|
||||
assert values["locator_collection_status"] == "ready_ssh_batchmode_auth_probe_only"
|
||||
assert values["secret_value_read"] == "false"
|
||||
|
||||
Reference in New Issue
Block a user