fix: discover listening ports on macOS - #69
Conversation
Review 1ABLOCKING — FOLLOW-UP — Review method: confirmed pinned HEAD NEEDS ATTENTION |
Review 1BINCOMPLETE — required reviewer
No substitute reviewer was used because the dispatch explicitly requires Kimi K3-256K. No remediation has started; the initial high-risk wave remains incomplete on unchanged head INCOMPLETE |
Initial review-wave aggregateThe wave is incomplete and blocked: Review 1A reported one Per the high-risk review-wave policy, no code or documentation edits will be made until every initial slot completes on the same unchanged head. The findings therefore remain undispositioned pending completion of Review 1B. No sensitive content was present or redacted. |
Replacement Review 1BReview 1B (replacement) — PR 69, initial waveRisk: high — listener discovery is disclosed to the relay and sits on the port-exposure boundary. Pinned range reviewed: Limitation: this is the replacement 1B slot after a Kimi K3-256K quota blocker. Same model family as other grok reviewers; isolated context only. FindingsFOLLOW-UP — README still claims live port status is Linux-only
This PR removes that gap. Darwin Concrete scenario: a macOS operator who last read the supported-platforms section still believes the relay cannot learn which loopback/wildcard services are up. After this head, This is not a code or policy-boundary defect. It is a published false claim about the exact surface this PR changes. Acceptance: in the default-repo README supported-platforms section, delete or rewrite the Linux-only live-status paragraph so it states that Linux and macOS both report TCP LISTEN ports bound to loopback or wildcard, and that the listing is filtered through No The Darwin command matches the versioned manpage: Residual risks (not defects)
APPROVE |
Initial review-wave aggregate (replacement 1B complete)The main orchestrator selected Deduplicated findings
Wave verdicts
Both findings are accepted. They will be remediated together in one batch, then exact-head checks will run before both original reviewer contexts review the full history and remediation delta. No sensitive content was present or redacted. |
a29498f to
97d6aa5
Compare
Final Review 1ANo findings. Prior BLOCKING resolved: Prior FOLLOW-UP resolved: README now accurately describes Linux/macOS listener discovery and policy filtering ( Reviewed the complete current 7-file diff and remediation deltas APPROVE |
Final Replacement Review 1BReview 1B (replacement) — PR 69, final remediationRisk: high — listener discovery is disclosed to the relay and sits on the port-exposure boundary. Final range:
Prior dispositionsMy FOLLOW-UP (stale Linux-only README) — resolved. Terra BLOCKING (valid empty family discarded the other family) — resolved. Apple Policy filtering, Linux No No new material regression in the remediation: empty success is no longer treated as malformed; nonempty unrecognized output still fails the whole discovery; relay disclosure is still Residual risk, unchanged from the initial review: Darwin CI is APPROVE |
Final review aggregateBoth required reviewer contexts approve exact head
All findings are dispositioned. No |
97d6aa5 to
110e998
Compare
Post-review rebase deltaA merge attempt was rejected because The owned log statement now uses the gate's explicit |
Post-rebase Final Review 1ANo findings. The rebase preserves both prior remediations: empty Darwin family output retains the other family’s ports with a reachable fixture, and the README accurately documents macOS discovery. The integration delta is limited to quoting local discovery errors with Reviewed the complete 7-file current diff, APPROVE |
Post-rebase Final Replacement Review 1BReview 1B (replacement) — PR 69, post-rebase integrationRisk: high — listener discovery is disclosed to the relay and sits on the port-exposure boundary. Final range: The only owned delta since the last approval is Prior dispositionsREADME FOLLOW-UP — still resolved. Terra empty-family BLOCKING — still resolved. Integration changeBase
No No material regression: the rebase-only fix satisfies the new static gate without widening relay disclosure or weakening empty-family / malformed handling. APPROVE |
Post-rebase final review aggregateBoth required reviewer contexts approve exact head |
Fixes https://github.com/nicodes/ormos-be/issues/289
Part of epic https://github.com/nicodes/ormos-be/issues/493
Risk: high — listening-service discovery is disclosed to the relay and participates in the port-exposure boundary.
Summary
/proc/net/tcp*parser behind a Linux helper/usr/sbin/netstat -anl -f <family>callsLISTENrows bound to loopback or wildcard addresses, with deterministic deduplication and orderingDarwin mechanism and constraints
Apple Darwin
netstat(1)source/manpage at versionnetwork_cmds-596.100.2documents-a,-n,-f inet|inet6, lowercase-l, local/foreign address output, wildcard*, andLISTEN: https://github.com/apple-oss-distributions/network_cmds/blob/network_cmds-596.100.2/netstat.tproj/netstat.1. Go 1.25 supports macOS 12+: https://go.dev/doc/go1.25#darwin. The implementation uses the absolute base-system path and does not assumelsof.The manpage documents semantic columns but not a machine-readable stable schema. Parsing therefore validates the documented header and listener shape and treats unrecognized/malformed output as an error. Its synopsis makes
-fand-palternatives, so the code intentionally selects each family with-fand filterstcp4/tcp6rows itself rather than combining flags undocumentedly. A shared 2-second context bounds both family calls, each command has a 250msWaitDelay, and stdout/stderr are drained into 1 MiB capped buffers.Verification
mise exec -- go version→go1.25.13 linux/amd64mise exec -- go test -race -count=1 ./...mise exec -- govulncheck ./...→ no reachable vulnerabilitiesgo vet ./...mise exec -- go test -count=1 internal/system/ports_darwin.go internal/system/ports_darwin_test.goLocal Linux runs do not exercise the Darwin command integration. The macOS exact-head CI job must prove the real ephemeral listener and policy assertions.
Deliberate failure proof
Changed the deterministic expected result from
[4100, 4200, 4300]to[4101, 4200, 4300], then ranmise exec -- go test -count=1 internal/system/ports_darwin.go internal/system/ports_darwin_test.go. It failed with:discoverDarwinPorts() = [4100 4200 4300], want [4101 4200 4300]. The mutation was reverted and the identical command passed.The real ephemeral-listener gate was also mutated from
PorttoPort + 1and pushed. Exact-head macOS run https://github.com/nicodes/ormos/actions/runs/32661759428 failed undergo test -race -count=1 ./...with:ports_test.go:57: with no policy the listing should contain the test listener :49205 (got [49204]). Linux failed analogously. The mutation was restored in commitd4ee8f9; the focused local test passed before push.Review remediation
Initial aggregate: #69 (comment). Commit
97d6aa5(rebased equivalent ofa29498f) accepts whitespace-only successful family output while preserving errors for nonempty malformed output, adds the empty-IPv6/valid-IPv4 fixture, and corrects the stale README statement.The new assertion was deliberately changed from
[4100]to[4101].mise exec -- go test -count=1 internal/system/ports_darwin.go internal/system/ports_darwin_test.gofailed withTestDiscoverDarwinPortsKeepsOtherFamilyWhenOneIsEmpty: discoverDarwinPorts() = [4100], want [4101]; the mutation was reverted and the identical command passed. Full Go 1.25.13 race tests, vet, govulncheck, platform-selection/build checks, and exact-head Linux/Darwin CI passed.gh stack syncreplayed the four commits ontoorigin/mainat6b3acae676d0b6ff24020cd0f3697ef4538d48a2; stable patch IDs before and after sync both equal5336098fec29cd241f7a52c58c7b023c792a4cb0, confirming the PR diff was unchanged by the rebase. Final review head is97d6aa5585d29b2731895a53ff7abb242164eb27; green CI run: https://github.com/nicodes/ormos/actions/runs/32665564761.