@davoodmehraban89 / Aram-1 / commits / 7da86df
Fork 0

test(desktop): reject zip bombs and symlinked financial workbook input

davoodmehraban89 committed Oct 30, 2026 at 23:40 UTC 7da86dfdea23d398c94f15aabf2a2b4f85dd48e3
1 file changed +34
backend/tests/test_desktop_pilot.py
+34
@@ -151,3 +151,37 @@ def test_all_enabled_controls_are_backed_by_implemented_callbacks():
151 }
152 for action, method_name in PILOT_ACTIONS.items():
153 assert callable(getattr(PilotWindow, method_name)), action
154 +
155 +
156 +def test_bounded_zip_metadata_rejects_expansion_and_many_entries():
157 + from types import SimpleNamespace
158 + from aram_backend.desktop_pilot_core import (
159 + MAX_ZIP_ENTRIES, MAX_UNCOMPRESSED_BYTES, _check_archive_limits,
160 + )
161 + with pytest.raises(PilotInputError):
162 + _check_archive_limits([
163 + SimpleNamespace(file_size=MAX_UNCOMPRESSED_BYTES + 1),
164 + ])
165 + with pytest.raises(PilotInputError):
166 + _check_archive_limits([
167 + SimpleNamespace(file_size=1) for _ in range(MAX_ZIP_ENTRIES + 1)
168 + ])
169 + with pytest.raises(PilotInputError):
170 + _check_archive_limits([
171 + SimpleNamespace(file_size=MAX_UNCOMPRESSED_BYTES // 2 + 1),
172 + SimpleNamespace(file_size=MAX_UNCOMPRESSED_BYTES // 2 + 1),
173 + ])
174 +
175 +
176 +def test_symlink_cannot_be_selected_for_financial_preflight(tmp_path):
177 + target = tmp_path / "trusted.xlsx"
178 + target.write_bytes(workbook_bytes())
179 + link = tmp_path / "untrusted.xlsx"
180 + try:
181 + link.symlink_to(target)
182 + except (NotImplementedError, OSError):
183 + pytest.skip("Symlinks are not available on this test filesystem")
184 + controller = DesktopPilotController()
185 + with pytest.raises(PilotInputError):
186 + controller.choose_file(link)
187 + assert controller.state == "EMPTY"