fix: make command reconciliation binary safe
Some checks failed
tamq-ci / test (push) Failing after 6s
Some checks failed
tamq-ci / test (push) Failing after 6s
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
This commit is contained in:
parent
92881b6b56
commit
fbb56f5981
7 changed files with 95 additions and 10 deletions
21
tests/test_makefile.py
Normal file
21
tests/test_makefile.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_plain_make_lists_available_targets():
|
||||
project = Path(__file__).resolve().parents[1]
|
||||
result = subprocess.run(
|
||||
["make", "--no-print-directory"],
|
||||
cwd=project,
|
||||
text=True,
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
assert result.stdout.splitlines() == [
|
||||
" help List available targets",
|
||||
" install Install or refresh tamq as a user-level uv tool",
|
||||
" uninstall Uninstall the user-level tamq tool",
|
||||
" test Run the test suite",
|
||||
" check Run tests and repository consistency checks",
|
||||
]
|
||||
|
|
@ -184,6 +184,37 @@ def test_protocol_commands_absorb_forwarded_shell_lines(tmp_path):
|
|||
assert result.stdout == ""
|
||||
|
||||
|
||||
def test_protocol_reconciliation_skips_unrelated_binary_executables(tmp_path):
|
||||
command_dir = tmp_path / "commands"
|
||||
command_dir.mkdir()
|
||||
binary = command_dir / "other-tool"
|
||||
binary.write_bytes(b"\x7fELF\x8e\xff\x00")
|
||||
legacy = command_dir / "@audit-core"
|
||||
legacy.write_text(
|
||||
"#!/bin/sh\n# tamq-address-command v1\nexit 0\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
manager = tmux.TmuxManager("tamq-test", command_dir=command_dir)
|
||||
|
||||
manager._install_address_commands(["audit-core"])
|
||||
|
||||
assert binary.read_bytes() == b"\x7fELF\x8e\xff\x00"
|
||||
assert not legacy.exists()
|
||||
assert (command_dir / "To:audit-core:").is_file()
|
||||
|
||||
|
||||
def test_protocol_reconciliation_refuses_undecodable_command_collision(tmp_path):
|
||||
command_dir = tmp_path / "commands"
|
||||
command_dir.mkdir()
|
||||
collision = command_dir / "To:audit-core:"
|
||||
collision.write_bytes(b"\x8e\xff")
|
||||
manager = tmux.TmuxManager("tamq-test", command_dir=command_dir)
|
||||
|
||||
with pytest.raises(tmux.TmuxError, match="cannot inspect existing command"):
|
||||
manager._install_address_commands(["audit-core"])
|
||||
assert collision.read_bytes() == b"\x8e\xff"
|
||||
|
||||
|
||||
def test_address_commands_reject_unsafe_repository_names(tmp_path):
|
||||
manager = tmux.TmuxManager("tamq-test", command_dir=tmp_path / "commands")
|
||||
with pytest.raises(tmux.TmuxError, match="cannot be exposed"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue