feat(ipc): hardened sessioned JSON-RPC IPC (WebSocket + NamedPipe)#1
Conversation
Co-authored-by: primeinc <4395149+primeinc@users.noreply.github.com>
Co-authored-by: primeinc <4395149+primeinc@users.noreply.github.com>
…ClientContext, interfaces) Co-authored-by: primeinc <4395149+primeinc@users.noreply.github.com>
…per structure) Co-authored-by: primeinc <4395149+primeinc@users.noreply.github.com>
…nd primitive types Co-authored-by: primeinc <4395149+primeinc@users.noreply.github.com>
Co-authored-by: primeinc <4395149+primeinc@users.noreply.github.com>
|
@copilot are we aligned with the repo's code style requirements? adversariarly review and correct so we are aligned Defend your reasoning |
…or code style alignment Co-authored-by: primeinc <4395149+primeinc@users.noreply.github.com>
... Code style alignment review completed. The IPC communication system now fully complies with the repository's code style requirements: ✅ Naming conventions: All classes, interfaces, methods, properties, fields, and constants follow proper naming patterns (PascalCase, camelCase with underscores for private fields, UPPER_CASE for constants) ✅ Class structure: Proper ordering of static fields/properties, readonly fields, regular fields, _disposed field, properties, constructors, methods, and dispose implementations ✅ Code readability: Removed unnecessary curly braces from 5 single-line if statements, proper line separations between class members, correct use of primitive types (int, long, string), proper number literal suffixes (L for long constants, d for doubles) ✅ Best practices: All classes properly marked as sealed, interfaces documented, IDisposable pattern correctly implemented with _disposed field, single-responsibility principle followed ✅ Repository standards: No #region directives, proper curly bracket alignment, boolean properties use Is/Has prefixes where appropriate, constants defined in Constants class structure Fixed violations in commit 77adf72. |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a comprehensive hardened IPC (Inter-Process Communication) system for Files that implements secure JSON-RPC communication over WebSocket and Named Pipe transports. The system includes robust security features like DPAPI-encrypted token storage, rate limiting, resource protection, and strict validation.
Key Changes
- Complete IPC communication framework with JSON-RPC 2.0 protocol implementation
- Security-hardened transport services (WebSocket + Named Pipe) with authentication and authorization
- Resource protection mechanisms including rate limiting, queue management, and operation timeouts
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Files.App/ViewModels/ShellIpcAdapter.cs | Main adapter providing IPC interface to shell operations with security validations |
| src/Files.App/Constants.cs | Added IPC-specific configuration constants and fixed integer type consistency |
| src/Files.App/Communication/WebSocketAppCommunicationService.cs | WebSocket transport implementation with HTTP listener and client management |
| src/Files.App/Communication/NamedPipeAppCommunicationService.cs | Named pipe transport with per-user ACL security and length-prefixed framing |
| src/Files.App/Communication/UIOperationQueue.cs | Utility for serializing UI operations on dispatcher thread |
| src/Files.App/Communication/RpcMethodRegistry.cs | Registry for RPC method definitions with authorization policies |
| src/Files.App/Communication/ProtectedTokenStore.cs | DPAPI-backed encrypted token storage with epoch-based rotation |
| src/Files.App/Communication/Models/ItemDto.cs | Data transfer object for file/folder metadata |
| src/Files.App/Communication/JsonRpcMessage.cs | Strict JSON-RPC 2.0 message implementation with validation |
| src/Files.App/Communication/IpcConfig.cs | Runtime configuration wrapper for IPC system settings |
| src/Files.App/Communication/IAppCommunicationService.cs | Interface defining communication service contract |
| src/Files.App/Communication/ClientContext.cs | Per-client state management with rate limiting and queue management |
| src/Files.App/Communication/ActionRegistry.cs | Registry for allowed IPC actions with allowlist validation |
| global.json | SDK version rollback for compatibility |
| docs/remote-control/README.md | Comprehensive documentation for the IPC system |
This pull request introduces a comprehensive and security-hardened IPC (Inter-Process Communication) subsystem for the Files application, focusing on resource protection, authentication, and correctness. The changes include strict JSON-RPC 2.0 validation, encrypted token storage with epoch-based rotation, centralized method registry, rate limiting, lossy message queuing, and serialization of UI operations. Additionally, the configuration is now centralized and adjustable, and several new core components have been added to support robust remote control features.
IPC Framework & Security Enhancements
JsonRpcMessageclass, ensuring only valid requests and responses are processed.ProtectedTokenStore, invalidating sessions upon token rotation for enhanced security.ClientContextfor per-client state management, including token bucket rate limiting, lossy message queue with coalescing, and authentication epoch tracking.RpcMethodRegistry, supporting per-method payload limits and custom authorization.UIOperationQueue, requiring a dispatcher queue for thread safety.IPC Transport & Communication Layer
IAppCommunicationServiceinterface for transport-agnostic communication services (WebSocket, Named Pipe), supporting request handling, broadcasting, and client responses.IpcConfig, allowing dynamic adjustment of message size caps, rate limits, and other resource controls.docs/remote-control/README.md, including merge checklist and implementation status.Action & Data Model Support
ActionRegistryto manage allowed IPC actions and support extensibility for remote control operations.ItemDtodata model for representing file/folder metadata in IPC responses.Constants
IpcSettingssection inConstants.csto define default IPC limits and settings.Constants.csfor consistency.