Skip to content

Add CI tests for macOS and Windows with sensor FIN probe - #191

Merged
vsn411 merged 4 commits into
secfoo-com:mainfrom
aaas72:ci/113-macos-windows
Nov 22, 2026
Merged

vsn411 merged 4 commits into
secfoo-com:mainfrom
aaas72:ci/113-macos-windows

Conversation

@aaas72

@aaas72 aaas72 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #113

All four jobs are green: Ubuntu py3.10 and py3.12, macos-15 py3.12 and windows-latest py3.12. Test, runtime probe conformance, skills validation and the coverage floor all run as blocking steps on every OS. Nothing has || true except the existing non-blocking ruff step (#114).

CI

  • Matrix as the issue asks: both Python versions on Ubuntu, one on macOS and Windows.
  • macos-15, not macos-14: GitHub has retired the macos-14 image, and the job failed with "The configuration 'macos-14-arm64-us-default' is not supported".
  • Job names: the Linux jobs keep the exact names branch protection requires (Test (py3.10), Test (py3.12)). The others add their OS, e.g. Test (py3.12, windows-latest).
  • shell: bash on every OS, because the coverage summary step uses bash redirection. PYTHONIOENCODING=utf-8 and PYTHONUTF8=1 are set so box-drawing output can't hit a cp1252 console.
  • No step needed to be Linux-only. secfoo sensor conformance passes on all three.

The macOS sensor failure: fixed in the probe, not the test

SocketTransport._read_control() treated recv() == b"" as "nothing to read". That is the sensor's FIN, so after the sensor closed the connection the probe kept writing into a half-closed socket.

  • Linux surfaced it anyway: the peer's RST turns the next write into EPIPE, which send() already handles.
  • macOS keeps accepting those writes into the send buffer, so every send returned True and the probe never noticed the sensor was gone.

Fix in sensor/transport.py: an EOF on the control channel closes the connection. The probe also reads the control channel before each write, not only after. So a FIN that has already arrived means the next batch goes to a fresh connection instead of the dead one, and if the sensor is gone that connection fails fast. One existing test changes expectation: test_the_probe_reconnects_after_a_live_sensor_dies used to require dropped >= 1, because the first write after EOF was always lost. It now asserts dropped == 0.

An earlier version of this fix also marked a batch as dropped when a FIN arrived right after the write. That races with a sensor that reads the batch and then closes, and it failed the py3.10 job once. The version here doesn't do that.

What else broke on Windows

What Where Fix
secfoo skills remove left the whole pack behind skills/packs.py Git writes its object files read-only, and rmtree(ignore_errors=True) silently skipped them on Windows. New _remove_tree makes a file writable and retries. It is used by remove_pack and by the clean-up after a failed install.
Installing a pack from a local Windows path without --name failed in git clone skills/packs.py default_pack_name split only on / and :, so C:\\...\\acme\\appsec-skills became one very long name. It now splits on \\ too, giving acme-appsec-skills.
Adversarial corpus digest differed on Windows scripts/adversarial_eval.py sorted(Path) ignores case on Windows, so CLAUDE.md.fixture and README.md changed places. It now sorts by case-sensitive path parts, the same order as on POSIX, so existing digests stay valid.
SHA-256 of committed evaluation evidence differed .gitattributes A core.autocrlf checkout rewrote line endings. docs/evaluations/** -text and tests/fixtures/adversarial/** -text, as fuzz/corpus/** already had.
A config error message did not match tests/test_property_fuzz_targets.py The longer Windows config path made the console wrap mid-sentence. The assertion now joins whitespace.

The items the issue suspected (_normalize_path, temp clone cleanup in targets/, _kill_process_tree, Path.as_uri() in SARIF) all pass on Windows as they are, so they are not changed here.

skipif markers added (Windows only)

Test Reason
test_adversarial_eval.py::test_source_boundaries_preserve_lines_and_quote_filenames Windows filenames cannot contain a newline
test_cloud.py::test_save_cloud_config_sets_restrictive_permissions POSIX permission bits (same marker test_store_privacy.py and test_mcp.py already use)
test_review_hardening.py::test_claude_capture_preserves_production_grants_and_records_stream The fake CLI is a #! script, which Windows cannot execute directly
test_port_guard.py::test_stop_gracefully_succeeds_after_sigterm, test_stop_gracefully_falls_back_to_sigkill_when_sigterm_is_ignored Windows stops a process with taskkill, not signals. A new test, test_stop_gracefully_uses_taskkill_on_windows, covers that branch on every OS.

In test_memory.py only the 0o600 assertion is skipped on Windows. The rest of those two tests still runs.

Testing

  • CI on this PR: all four test jobs, CodeQL and the fuzz jobs pass.
  • Windows: 2258 passed, 12 skipped (7 skipped before this PR).
  • New tests: the taskkill branch, default_pack_name on Windows paths, and _remove_tree with read-only files.
  • The sensor and runtime suites passed 5 runs in a row locally after the final transport change.

@aaas72
aaas72 requested a review from vsn411 as a code owner November 22, 2026 14:34
@aaas72
aaas72 marked this pull request as draft November 22, 2026 14:34
- skill packs: remove read-only git objects (rmtree silently left the
  checkout behind on Windows) and name a pack from a local Windows path
- .gitattributes: byte-hashed evaluation evidence and corpus stay LF
- tests: OS-limited skips with reasons; Windows taskkill branch tested

Refs secfoo-com#113
try:
os.chmod(target, stat.S_IWRITE)
func(target)
except OSError:
- transport: read the control channel before a write too, so a batch is
  never written into a socket the sensor already closed, and a FIN that
  arrives right after a batch the sensor did read no longer marks that
  batch dropped (that race failed test_sensor_dying_mid_run on py3.10)
- adversarial_eval.corpus_digest: WindowsPath sorts case-insensitively,
  which reordered files and changed the digest on Windows

Refs secfoo-com#113
@aaas72
aaas72 marked this pull request as ready for review November 22, 2026 15:18
@vsn411
vsn411 merged commit 509bd9b into secfoo-com:main Nov 22, 2026
15 checks passed
@github-actions

Copy link
Copy Markdown

Leaderboard update

aaas72 now has 28 points (rank #2, Bronze). 22 more to reach Silver.

Full leaderboard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: sensor test fails on macOS; CI only runs on Ubuntu. Add macOS and Windows to the matrix and fix what breaks

3 participants