Skip to content

Audit MINOR #37: managed ARP (GetIpNetTable) + Ping rewrite - #78

Merged
bilbospocketses merged 2 commits into
masterfrom
fix/audit-network-managed
Jun 24, 2026
Merged

Audit MINOR #37: managed ARP (GetIpNetTable) + Ping rewrite#78
bilbospocketses merged 2 commits into
masterfrom
fix/audit-network-managed

Conversation

@bilbospocketses

Copy link
Copy Markdown
Owner

PR 3 of the audit MINOR mop-up — finding #37, the managed network rewrite (the full-managed option).

Replaces the shelled arp -a (locale-fragile regex parsing) and ping with managed APIs:

  • New IArpTableProvider abstraction. On Windows, WindowsArpTableProvider reads the ARP cache via the IP Helper API (GetIpNetTable) — no arp.exe spawn, no text scraping. On other platforms ShellArpTableProvider keeps arp -a (no managed ARP API there). Registered by OS in AddControlMenuServices.
  • PingAsync uses System.Net.NetworkInformation.Ping instead of spawning ping — cross-platform, honours cancellation.
  • NetworkDiscoveryService now depends on IArpTableProvider.

Tests: pure ARP-row mapping (MapRows), arp -a parse for both layouts, provider exit handling, a Windows-gated real GetIpNetTable marshal smoke, and managed-ping loopback/unroutable checks. Full suite 633 green; the real P/Invoke returns this machine's ARP table without throwing.

Independent review verified the P/Invoke marshaling (struct layout, offset, byte-order, memory safety) against the Win32 docs and came back clean. Its two reliability notes are addressed: a buffer-growth retry on GetIpNetTable (the table can grow between the size and fetch calls), and gating the real-ICMP ping tests to Windows.

Plan: docs/superpowers/plans/2026-06-24-audit-minor-mopup.md (PR 3 of 5).

….Net Ping

Replaces the shelled `arp -a` (locale-fragile regex parse) and `ping` with managed APIs:
- New IArpTableProvider abstraction. WindowsArpTableProvider reads the ARP cache via
  iphlpapi GetIpNetTable (P/Invoke); ShellArpTableProvider keeps `arp -a` for Linux/fallback.
  Registered by OS in AddControlMenuServices.
- PingAsync uses System.Net.NetworkInformation.Ping (cross-platform, no process spawn);
  honours cancellation, maps non-Success/exception to unreachable.
- NetworkDiscoveryService now depends on IArpTableProvider, not ICommandExecutor.

Tests: pure ARP-row mapping (MapRows), arp -a parse (both layouts), provider exit handling,
a real GetIpNetTable marshal smoke (Windows-gated), and managed-ping loopback/unroutable. 633 green.
…ows-gate ping tests

Whole-branch review follow-ups (both Important, reliability):
- WindowsArpTableProvider.Read now retries when GetIpNetTable returns ERROR_INSUFFICIENT_BUFFER
  (the ARP table can grow between the sizing call and the fetch), re-reading the bumped size —
  was silently returning an empty table on a busy host. ParseTable extracted; padding note added.
- The two real-ICMP ping tests are gated to Windows (the app's platform; loopback ICMP can be
  blocked on a locked-down Linux runner). Doc wording: "Linux" -> "non-Windows".
@bilbospocketses
bilbospocketses enabled auto-merge (squash) June 24, 2026 20:52
@bilbospocketses
bilbospocketses merged commit fd2e9c6 into master Jun 24, 2026
8 checks passed
@bilbospocketses
bilbospocketses deleted the fix/audit-network-managed branch June 24, 2026 20:55
bilbospocketses added a commit that referenced this pull request Jun 24, 2026
) (#81)

The wrap-up doc sweep caught four stale TECHNICAL_GUIDE references the feature PRs missed:
- NetworkDiscoveryService delegates to IArpTableProvider (Windows GetIpNetTable P/Invoke + arp -a
  fallback); PingAsync is managed System.Net.NetworkInformation.Ping (#37 / PR #78)
- GetDefaultBackupDirectory is pure — the backup-write path creates the dir, not the getter (#40 / PR #77)
- Expand-Cm7z extracts .7z via the bundled SharpCompress (tools/Cm7zExtract), no vendored 7zr (#46 / PR #80)
- in-app update apply signals via a shared UpdateApplyState flag + explicit Program return, not a
  clobberable Environment.ExitCode (#50 / PR #79)
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.

1 participant