Repository navigation
fix(sensor): close socket on peer EOF and extend CI matrix to macOS and Windows - #141
kushaldave002 wants to merge 2 commits into
Conversation
…ards, and macos-15 runner
| try: | ||
| os.chmod(target, stat.S_IWRITE) | ||
| func(target) | ||
| except OSError: |
|
Thank you, @kushaldave002. The socket fix is a real improvement: on macOS, Blocking
Should fix
The intermittent py3.10 conformance timeout on main comes from the overhead step's 1,000,000-call loop, not from this code, so it's out of scope here. Looking forward to the next version. |
Closes #113
Root Cause (macOS sensor test failure)
tests/test_sensor/test_python_probe.py::test_sensor_dying_mid_run_drops_events_without_blockingfailed deterministically on macOS becauseSocketTransport._read_control()insrc/secfoo/sensor/transport.pydid not handle EOF (conn.recv() == b"") when the peer closed the TCP connection cleanly:RSTquickly enough that subsequentsendall()calls raiseOSError.conn.recv()immediately returnsb""(EOF from the peer'sFIN), but_read_control()iterated overb"".splitlines()and leftself._connopen, allowing the three tightsendall()calls to buffer in the kernel and returnTrue.Fixes
src/secfoo/sensor/transport.py): closeself._conninSocketTransport._read_control()whenrecv()returnsb""(peer EOF) so the nextsend()drops and attempts to reconnect instead of writing into a half-closed socket.src/secfoo/skills/packs.py):default_pack_name()now splits on backslashes as well as forward slashes and colons, preventing local Windows paths from turning into 120+ character pack names that exceed WindowsMAX_PATH._rmtree()clearing Windows read-only attributes on.git/objects/*before unlinking soremove_pack()and failedinstall_pack()cleanups actually delete git checkouts on Windows (fixingremove_packandinstall_from_lock)..github/workflows/ci.yml):ubuntu-latest(Python 3.10 and 3.12),macos-15(Python 3.12 —macos-14is no longer supported on GitHub Actions), andwindows-latest(Python 3.12).ruff check . || truewithcontinue-on-error: trueso the non-blocking lint step (backlog tracked in Make lint and security scanning blocking in CI: ruff has 133 errors behind|| true, bandit findings are unreviewed, pip-audit never runs #114) works on Windows PowerShell without|| true.tests/test_port_guard.py,tests/test_skill_packs.py):test_stop_gracefully_uses_taskkill_on_windowsverifying the Windowstaskkill/taskkill /Fpath on all OSes.test_default_pack_name_variants.test_stop_gracefully_gives_up_if_the_process_never_diesto patch_signalinstead of onlyos.kill.skipif/ platform guards addedtests/test_cloud.py::test_save_cloud_config_sets_restrictive_permissions:skipif(sys.platform == "win32")— Windows NTFS does not enforce POSIX0o600file mode bits.tests/test_port_guard.py::test_stop_gracefully_succeeds_after_sigterm&test_stop_gracefully_falls_back_to_sigkill_when_sigterm_is_ignored:skipif(sys.platform == "win32")— test POSIXSIGTERM/SIGKILLsignaling; Windows usestaskkill(covered bytest_stop_gracefully_uses_taskkill_on_windows).tests/test_memory.py(2 tests): guarded only thestat.S_IMODE(...) == 0o600assertion withif sys.platform != "win32":so the rest of both tests still runs on Windows.