Harden startup enumeration and native recovery#129
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces safety bounds on directory and file enumerations across the application (including application payloads, secured data trees, SDK companions, and legacy profile catalogs) to prevent unbounded resource consumption at startup. It also refactors legacy profile migration and improves runtime state restoration during settings compensation. The reviewer feedback recommends exposing several private helper methods as internal to avoid brittle reflection in tests, calling .ToArray() on the legacy profile enumeration to prevent concurrent modification issues during file deletion, and using DirectoryInfo.EnumerateFileSystemInfos to avoid redundant system calls when retrieving file attributes.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR hardens WireSockUI’s elevated startup and recovery paths by bounding filesystem enumeration work (to prevent unbounded time/memory on malformed installs/config trees) and by ensuring verified native recovery clears recovery latches/markers and restores the prior UI/runtime state without requiring a restart.
Changes:
- Add entry-count limits to application payload traversal, WireSock SDK companion directory scanning, secured data-tree hardening, and legacy profile catalog enumeration.
- Clear verified native recovery state after successful settings compensation and preserved network-lock retries, restoring the prior connection/UI state.
- Strengthen legacy migration completion by content-verifying staged vs source profiles before deletion; add tests and document new operational limits/behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| WireSockUI/Program.cs | Adds bounded enumeration for application payload and SDK companion directory validation. |
| WireSockUI/Global.cs | Bounds secured data-tree traversal during ACL hardening via a shared entry counter across recursion. |
| WireSockUI/Forms/frmMain.cs | Centralizes “verified native recovery” completion to clear latches/markers and restore UI state. |
| WireSockUI/Config/LegacyProfileMigrationService.cs | Bounds legacy catalog enumeration; makes migration cleanup case-correct and content-verified before deleting sources. |
| WireSockUI.Tests/Program.cs | Adds targeted regression tests for the new enumeration bounds and migration behaviors. |
| README.md | Documents the new startup enumeration limits and recovery behavior changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Production-readiness findings addressed
Verification
WireSockUI.Testsharness passed (exit 0); the existing file-symlink case skipped because this host cannot create that linkReleasex64 solution build: 0 warnings, 0 errorsRelease UWPx64 solution build: 0 warnings, 0 errorsdotnet format ... --verify-no-changes: passedorigin/main: branch was 1 ahead / 0 behind before pushMigration notes
Startup now fails closed above 4,096 application or secured-tree entries, 1,024 SDK-directory entries, or 1,024 entries in either legacy profile catalog. Diagnostics identify the affected location/limit so unexpected files can be removed before retrying.
Remaining risk
Real driver/DLL lifecycle behavior still depends on the trusted elevated SDK integration runners; this PR does not replace those smoke checks.