Skip to content

Strongly type settings for the network extension - #806

Merged
mlw merged 5 commits into
mainfrom
mlw/netext-settings-type
Feb 23, 2026
Merged

Strongly type settings for the network extension#806
mlw merged 5 commits into
mainfrom
mlw/netext-settings-type

Conversation

@mlw

@mlw mlw commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Remove reliance on a dictionary and move to using real types.

Part of SNT-261

@mlw mlw added this to the 2026.2 milestone Feb 23, 2026
@mlw
mlw requested a review from a team as a code owner February 23, 2026 18:49
@github-actions github-actions Bot added comp/santad Issues or PRs related to the daemon lang/objc++ PRs modifying files in ObjC++ comp/common size/m Size: medium labels Feb 23, 2026
@coderabbitai

coderabbitai Bot commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5d58427 and 73e1f4d.

📒 Files selected for processing (1)
  • Source/common/ne/SNTNetworkExtensionSettingsTest.mm

📝 Walkthrough

Walkthrough

Replaces dictionary-based network-extension settings with a new NSSecureCoding class SNTNetworkExtensionSettings; updates XPC method signatures and NSXPCInterface registrations to use the new type; adapts santad network extension queue and daemon to produce/send the typed settings; adds build targets and unit tests for the new class.

Changes

Cohort / File(s) Summary
New settings class & tests
Source/common/ne/SNTNetworkExtensionSettings.h, Source/common/ne/SNTNetworkExtensionSettings.mm, Source/common/ne/SNTNetworkExtensionSettingsTest.mm
Adds SNTNetworkExtensionSettings : NSObject <NSSecureCoding> with readonly BOOL enable, secure-coding implementation, and unit tests covering init, encode/decode roundtrip, forward and backward compatibility.
XPC control interface
Source/common/SNTXPCControlInterface.h, Source/common/SNTXPCControlInterface.mm, Source/common/BUILD
Changes registerNetworkExtensionWithProtocolVersion:reply: to return SNTNetworkExtensionSettings * (was NSDictionary *), imports/ registers the class on the NSXPCInterface, and adds build dep on //Source/common/ne:SNTNetworkExtensionSettings.
XPC network extension interface
Source/common/ne/SNDXPCNetworkExtensionInterface.h, Source/common/ne/SNTXPCNetworkExtensionInterface.mm
Changes updateNetworkExtensionSettings: parameter to SNTNetworkExtensionSettings * and registers that class on the NSXPCInterface for the selector.
santad network extension queue & daemon
Source/santad/SNTNetworkExtensionQueue.h, Source/santad/SNTNetworkExtensionQueue.mm, Source/santad/SNTDaemonControlController.mm, Source/santad/BUILD
Replaces NSDictionary * return types with SNTNetworkExtensionSettings * in registration/settings generation and change notification flows, updates callers/locals, removes SNTDeepCopy dep, and adjusts build deps to include the new settings lib.
Build changes & test wiring
Source/common/ne/BUILD, Source/common/BUILD
Adds objc_library target SNTNetworkExtensionSettings, a unit test target SNTNetworkExtensionSettingsTest, and updates dependent targets to depend on the new lib; test target added to the unit_tests suite.

Sequence Diagram(s)

sequenceDiagram
  participant NetExtClient as NetExt Client
  participant XPC as XPC Endpoint
  participant Daemon as santad Daemon
  participant NetExtQueue as NetworkExtensionQueue

  NetExtClient->>XPC: registerNetworkExtensionWithProtocolVersion(version)
  XPC->>Daemon: forward registerNetworkExtensionWithProtocolVersion(version)
  Daemon->>NetExtQueue: handleRegistrationWithProtocolVersion(version)
  NetExtQueue-->>Daemon: SNTNetworkExtensionSettings(enable: Bool)
  Daemon-->>XPC: reply(SNTNetworkExtensionSettings, santaProtocolVersion, error)
  XPC->>NetExtClient: deliver reply(SNTNetworkExtensionSettings, santaProtocolVersion, error)

  Note over NetExtQueue, XPC: On settings changes:
  NetExtQueue->>XPC: updateNetworkExtensionSettings(SNTNetworkExtensionSettings)
  XPC->>NetExtClient: deliver update(SNTNetworkExtensionSettings)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'Strongly type settings for the network extension' directly and clearly describes the main objective of the changeset: replacing dictionary-based settings with a strongly-typed SNTNetworkExtensionSettings class throughout the codebase.
Description check ✅ Passed The PR description 'Remove reliance on a dictionary and move to using real types' is directly related to the changeset, which introduces SNTNetworkExtensionSettings to replace NSDictionary usage in network extension settings.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mlw/netext-settings-type

Comment @coderabbitai help to get the list of available commands and usage tips.

russellhancox
russellhancox previously approved these changes Feb 23, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Source/common/ne/SNTNetworkExtensionSettingsTest.mm`:
- Around line 76-105: The test method testForwardCompatibility has a
clang-format styling violation around the NSKeyedUnarchiver initialization and
subsequent calls; reformat the block (or run clang-format on the file) so the
NSKeyedUnarchiver initialization line (initForReadingFromData:error:), the
requiresSecureCoding assignment, the setClass:forClassName: call, and the
decodeObjectOfClass:forKey: call conform to the project's clang-format style;
ensure indentation, line breaks, and spacing in the testForwardCompatibility
method match surrounding code.
- Around line 107-122: The test uses a freshly encoded
SNTNetworkExtensionSettings so the 'enable' key is present; to simulate a legacy
archive that omits that key, add a small helper legacy class (e.g.
LegacyNetworkExtensionSettings) whose -encodeWithCoder: intentionally does not
encode the @"enable" key, archive an instance of that legacy class, then when
unarchiving remap the legacy class name to SNTNetworkExtensionSettings using
NSKeyedUnarchiver's class-for-name mapping (e.g. +[NSKeyedUnarchiver
setClass:forClassName:]) before calling unarchivedObjectOfClass:fromData:error:
and assert deserialized.enable is NO; modify testBackwardCompatibility to
perform these steps and remove the current direct-archiving of
SNTNetworkExtensionSettings.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 01bf95f and 5d58427.

📒 Files selected for processing (1)
  • Source/common/ne/SNTNetworkExtensionSettingsTest.mm

Comment thread Source/common/ne/SNTNetworkExtensionSettingsTest.mm
Comment thread Source/common/ne/SNTNetworkExtensionSettingsTest.mm
@mlw
mlw requested a review from russellhancox February 23, 2026 19:44
@mlw
mlw merged commit 7c9c0a2 into main Feb 23, 2026
7 checks passed
@mlw
mlw deleted the mlw/netext-settings-type branch February 23, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/common comp/santad Issues or PRs related to the daemon lang/objc++ PRs modifying files in ObjC++ size/m Size: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants