From 4edd802497de6d00131fc74df79124f53c164221 Mon Sep 17 00:00:00 2001 From: ogt Date: Tue, 14 Jul 2026 21:07:29 +0800 Subject: [PATCH] fix(agent99): frame remote bootstrap input --- .../deploy-agent99-via-windows99-ssh.sh | 10 +++++++++- ..._agent99_remote_atomic_deploy_transport_contract.py | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/reboot-recovery/deploy-agent99-via-windows99-ssh.sh b/scripts/reboot-recovery/deploy-agent99-via-windows99-ssh.sh index 03a40d40e..a00e59c9c 100755 --- a/scripts/reboot-recovery/deploy-agent99-via-windows99-ssh.sh +++ b/scripts/reboot-recovery/deploy-agent99-via-windows99-ssh.sh @@ -320,8 +320,16 @@ compressed = gzip.compress( compresslevel=9, mtime=0, ) +payload = base64.b64encode(compressed).decode("ascii") +line_width = 65536 +payload_lines = [ + payload[offset : offset + line_width] + for offset in range(0, len(payload), line_width) +] +if not payload_lines or len(payload_lines) > 8: + raise SystemExit("remote_bootstrap_payload_line_contract_failed") output_path.write_text( - base64.b64encode(compressed).decode("ascii") + "\n" + sentinel + "\n", + "\n".join(payload_lines) + "\n" + sentinel + "\n", encoding="ascii", ) PY diff --git a/scripts/reboot-recovery/tests/test_agent99_remote_atomic_deploy_transport_contract.py b/scripts/reboot-recovery/tests/test_agent99_remote_atomic_deploy_transport_contract.py index d7908d8f3..bb6975af5 100644 --- a/scripts/reboot-recovery/tests/test_agent99_remote_atomic_deploy_transport_contract.py +++ b/scripts/reboot-recovery/tests/test_agent99_remote_atomic_deploy_transport_contract.py @@ -154,6 +154,10 @@ def test_sender_builds_sha256_envelope_and_streams_it_without_remote_cli_data() assert "[Console]::In.ReadLine()" in source assert "remote_bootstrap_input_limit_exceeded" in source assert "remote_bootstrap_sentinel_missing" in source + assert "line_width = 65536" in source + assert "len(payload_lines) > 8" in source + assert '"\\n".join(payload_lines)' in source + assert "remote_bootstrap_payload_line_contract_failed" in source assert "$lineCount -gt 8" in source assert "$charCount -gt 1048576" in source assert '<"${BOOTSTRAP_PAYLOAD_PATH}"' in source