CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Pareto Security Development Guide
Build & Test Commands
- Build:
make build
- Run tests:
make test
- Run single test:
NSUnbufferedIO=YES xcodebuild -project "Pareto Security.xcodeproj" -scheme "Pareto Security" -test-timeouts-enabled NO -only-testing:ParetoSecurityTests/TestClassName/testMethodName -destination platform=macOS test
- Format:
make fmt or mint run swiftformat --swiftversion 5 .
- Archive builds:
make archive-debug, make archive-release, make archive-debug-setapp, make archive-release-setapp
- Create DMG:
make dmg
- Create PKG:
make pkg
Application Architecture
Core Components
- Main App (
/Pareto/): SwiftUI-based status bar application
- Helper Tool (
/ParetoSecurityHelper/): XPC service for privileged operations requiring admin access
- Security Checks (
/Pareto/Checks/): Modular security check system organized by category
Security Checks System
The app uses a modular check architecture with these categories:
- Access Security: Autologin, password policies, SSH keys, screensaver
- System Integrity: FileVault, Gatekeeper, Boot security, Time Machine
- Firewall & Sharing: Firewall settings, file sharing, remote access
- macOS Updates: System updates, automatic updates
- Application Updates: Third-party app update checks
Key files:
ParetoCheck.swift - Base class for all security checks
Checks.swift - Central registry organizing checks into claims
Claim.swift - Groups related checks together
XPC Helper Tool
The ParetoSecurityHelper is a privileged helper tool that:
- Handles firewall configuration checks
- Performs system-level operations requiring admin privileges
- Communicates with the main app via XPC
Distribution Targets
- Direct distribution: Standard macOS app with auto-updater
- SetApp: Subscription service integration with separate build target
- Team/Enterprise: JWT-based licensing for organization management
Code Style
- Imports: Group imports alphabetically, Foundation/SwiftUI first, then third-party libraries
- Naming: Use camelCase for variables/functions, PascalCase for types; be descriptive
- Error Handling: Use Swift's do/catch with specific error enums
- Types: Prefer explicit typing, especially for collections
- Formatting: Max line length 120 chars, use Swift's standard indentation (4 spaces)
- Comments: Only add comments for complex logic; include header comment for files
- Code Organization: Group related functionality with MARK comments
- Testing: All new features should include tests
- Logging: Use
os_log for logging, with appropriate log levels
This project uses SwiftFormat for auto-formatting.
Key Dependencies
- Defaults: User preferences management
- LaunchAtLogin: Auto-launch functionality
- Alamofire: HTTP networking for update checks
- JWTDecode: Team licensing authentication
- Cache: Response caching layer
URL Scheme Support
The app supports custom URL scheme paretosecurity:// for:
reset - Reset to default settings
showMenu - Open status bar menu
update - Force update check (not available in SetApp build)
welcome - Show welcome window
runChecks - Trigger security checks
debug - Output detailed check status (supports ?check=<checkname> parameter)
logs - Copy system logs
showPrefs - Show preferences window
showBeta - Enable beta channel
enrollTeam - Enroll device to team (not available in SetApp build)
Testing Strategy
- Unit tests in
ParetoSecurityTests/ cover core functionality
- UI tests in
ParetoSecurityUITests/ test user flows
- Tests are organized by feature area (checks, settings, team, updater, welcome)
- Use
make test for full test suite with formatted output via xcbeautify
Development Notes
- The app runs as a status bar utility (
LSUIElement: true)
- Requires Apple Events permission for system automation
- No sandboxing to allow system security checks
- Uses privileged helper tool for admin operations
- Supports both individual and team/enterprise deployments
Pareto Security App Structure
Overview
Pareto Security is a macOS security monitoring app built with SwiftUI. It performs various security checks and uses a privileged helper tool for system-level operations on macOS 15+.
Core Architecture
Security Checks System
Helper Tool System (macOS 15+ Firewall Checks)
Helper Tool: /ParetoSecurityHelper/main.swift
- XPC service for privileged operations
- Static version:
helperToolVersion = "1.0.3"
- Implements
ParetoSecurityHelperProtocol
- Functions:
isFirewallEnabled(), isFirewallStealthEnabled(), getVersion()
Helper Management: /Pareto/Extensions/HelperTool.swift
HelperToolUtilities: Static utility methods (non-actor-isolated)
HelperToolManager: Main actor class for XPC communication
- Expected version:
expectedHelperVersion = "1.0.3"
- Auto-update logic:
ensureHelperIsUpToDate()
Helper Configuration: /ParetoSecurityHelper/co.niteo.ParetoSecurityHelper.plist
- System daemon configuration
- Critical:
BundleProgram must be Contents/MacOS/ParetoSecurityHelper
UI Structure
Main Views
Permission System
- PermissionsChecker: Continuous monitoring with 2-second timer
- Properties:
firewallAuthorized, other permissions
- UI States: Authorized/Disabled buttons, consistent spacing (20pt)
Key Technical Concepts
XPC Communication
- Service Name:
co.niteo.ParetoSecurityHelper
- Protocol:
ParetoSecurityHelperProtocol
- Connection Management: Automatic retry, timeout handling
- Error Handling: Comprehensive logging, graceful degradation
Concurrency & Threading
- Main Actor: UI components, HelperToolManager
- Actor Isolation: HelperToolUtilities for non-isolated static methods
- Async/Await: Proper continuation handling, avoid semaphores in async contexts
- Thread Safety: NSLock for XPC continuation management
Version Management
- Manual Versioning: Static constants for helper versions
- Update Logic: Compare current vs expected, auto-reinstall if outdated
- Version Display: About screen shows both app and helper versions
Important Implementation Details
Helper Tool Requirements
- macOS 15+ Only: Firewall checks require helper on macOS 15+
- Authorization: User must approve in System Settings > Login Items
- Question Mark UI: Shows when helper required but not authorized
- Live Status Checks: Always use
HelperToolUtilities.isHelperInstalled(), never cached values
Common Patterns
- Check Implementation: Override
requiresHelper and isRunnable in check classes
- Permission Monitoring: Use Timer with 2-second intervals for continuous checking
- Error Handling: Use
os_log for logging, specific error enums for Swift errors
- UI Consistency: 20pt spacing, medium font weight, secondary colors for labels
Troubleshooting Tools
- Helper Status:
launchctl print system/co.niteo.ParetoSecurityHelper
- Helper Logs: Check system logs for "Helper:" prefixed messages
- XPC Debugging: Comprehensive logging throughout XPC chain
- Version Mismatches: Check both static constants match when updating
File Locations Reference
Core Files
- Base Check:
/Pareto/Checks/ParetoCheck.swift
- Firewall Check:
/Pareto/Checks/Firewall and Sharing/Firewall.swift
- Helper Tool:
/ParetoSecurityHelper/main.swift
- Helper Manager:
/Pareto/Extensions/HelperTool.swift
UI Files
- Welcome:
/Pareto/Views/Welcome/PermissionsView.swift
- About:
/Pareto/Views/Settings/AboutSettingsView.swift
- Permissions Settings:
/Pareto/Views/Settings/PermissionsSettingsView.swift
Configuration
- Helper Plist:
/ParetoSecurityHelper/co.niteo.ParetoSecurityHelper.plist
- Build Config: Use
make build, make test, make lint, make fmt
Version Update Procedure
- Increment
HelperToolUtilities.expectedHelperVersion in HelperTool.swift
- Increment
helperToolVersion in helper's main.swift
- Both versions must match for proper operation
- App will auto-detect and reinstall helper on next check
1---2name: pareto-security-development-guide3description: This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.4---5# CLAUDE.md67This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.89# Pareto Security Development Guide1011## Build & Test Commands12- Build: `make build`13- Run tests: `make test`14- Run single test: `NSUnbufferedIO=YES xcodebuild -project "Pareto Security.xcodeproj" -scheme "Pareto Security" -test-timeouts-enabled NO -only-testing:ParetoSecurityTests/TestClassName/testMethodName -destination platform=macOS test`15- Format: `make fmt` or `mint run swiftformat --swiftversion 5 .`16- Archive builds: `make archive-debug`, `make archive-release`, `make archive-debug-setapp`, `make archive-release-setapp`17- Create DMG: `make dmg`18- Create PKG: `make pkg`1920## Application Architecture2122### Core Components23- **Main App (`/Pareto/`)**: SwiftUI-based status bar application24- **Helper Tool (`/ParetoSecurityHelper/`)**: XPC service for privileged operations requiring admin access25- **Security Checks (`/Pareto/Checks/`)**: Modular security check system organized by category2627### Security Checks System28The app uses a modular check architecture with these categories:29- **Access Security**: Autologin, password policies, SSH keys, screensaver30- **System Integrity**: FileVault, Gatekeeper, Boot security, Time Machine31- **Firewall & Sharing**: Firewall settings, file sharing, remote access32- **macOS Updates**: System updates, automatic updates33- **Application Updates**: Third-party app update checks3435Key files:36- `ParetoCheck.swift` - Base class for all security checks37- `Checks.swift` - Central registry organizing checks into claims38- `Claim.swift` - Groups related checks together3940### XPC Helper Tool41The `ParetoSecurityHelper` is a privileged helper tool that:42- Handles firewall configuration checks43- Performs system-level operations requiring admin privileges44- Communicates with the main app via XPC4546### Distribution Targets47- **Direct distribution**: Standard macOS app with auto-updater48- **SetApp**: Subscription service integration with separate build target49- **Team/Enterprise**: JWT-based licensing for organization management5051## Code Style52- **Imports**: Group imports alphabetically, Foundation/SwiftUI first, then third-party libraries53- **Naming**: Use camelCase for variables/functions, PascalCase for types; be descriptive54- **Error Handling**: Use Swift's do/catch with specific error enums55- **Types**: Prefer explicit typing, especially for collections56- **Formatting**: Max line length 120 chars, use Swift's standard indentation (4 spaces)57- **Comments**: Only add comments for complex logic; include header comment for files58- **Code Organization**: Group related functionality with MARK comments59- **Testing**: All new features should include tests60- **Logging**: Use `os_log` for logging, with appropriate log levels6162This project uses SwiftFormat for auto-formatting.6364## Key Dependencies65- **Defaults**: User preferences management66- **LaunchAtLogin**: Auto-launch functionality67- **Alamofire**: HTTP networking for update checks68- **JWTDecode**: Team licensing authentication69- **Cache**: Response caching layer7071## URL Scheme Support72The app supports custom URL scheme `paretosecurity://` for:73- `reset` - Reset to default settings74- `showMenu` - Open status bar menu75- `update` - Force update check (not available in SetApp build)76- `welcome` - Show welcome window77- `runChecks` - Trigger security checks78- `debug` - Output detailed check status (supports `?check=<checkname>` parameter)79- `logs` - Copy system logs80- `showPrefs` - Show preferences window81- `showBeta` - Enable beta channel82- `enrollTeam` - Enroll device to team (not available in SetApp build)8384## Testing Strategy85- Unit tests in `ParetoSecurityTests/` cover core functionality86- UI tests in `ParetoSecurityUITests/` test user flows87- Tests are organized by feature area (checks, settings, team, updater, welcome)88- Use `make test` for full test suite with formatted output via xcbeautify8990## Development Notes91- The app runs as a status bar utility (`LSUIElement: true`)92- Requires Apple Events permission for system automation93- No sandboxing to allow system security checks94- Uses privileged helper tool for admin operations95- Supports both individual and team/enterprise deployments9697# Pareto Security App Structure9899## Overview100Pareto Security is a macOS security monitoring app built with SwiftUI. It performs various security checks and uses a privileged helper tool for system-level operations on macOS 15+.101102## Core Architecture103104### Security Checks System105- **Base Class**: `ParetoCheck` (`/Pareto/Checks/ParetoCheck.swift`)106 - All security checks inherit from this base class107 - Key properties: `requiresHelper`, `isRunnable`, `isActive`108 - `menu()` method handles UI display including question mark icons for helper-dependent checks109 - `infoURL` redirects to helper docs when helper authorization missing110111- **Check Categories**:112 - Firewall checks: `/Pareto/Checks/Firewall and Sharing/`113 - System checks: `/Pareto/Checks/System/`114 - Application checks: `/Pareto/Checks/Applications/`115116### Helper Tool System (macOS 15+ Firewall Checks)117- **Helper Tool**: `/ParetoSecurityHelper/main.swift`118 - XPC service for privileged operations119 - Static version: `helperToolVersion = "1.0.3"`120 - Implements `ParetoSecurityHelperProtocol`121 - Functions: `isFirewallEnabled()`, `isFirewallStealthEnabled()`, `getVersion()`122123- **Helper Management**: `/Pareto/Extensions/HelperTool.swift`124 - `HelperToolUtilities`: Static utility methods (non-actor-isolated)125 - `HelperToolManager`: Main actor class for XPC communication126 - Expected version: `expectedHelperVersion = "1.0.3"`127 - Auto-update logic: `ensureHelperIsUpToDate()`128129- **Helper Configuration**: `/ParetoSecurityHelper/co.niteo.ParetoSecurityHelper.plist`130 - System daemon configuration131 - Critical: `BundleProgram` must be `Contents/MacOS/ParetoSecurityHelper`132133### UI Structure134135#### Main Views136- **Welcome Screen**: `/Pareto/Views/Welcome/PermissionsView.swift`137 - Permissions checker with continuous monitoring138 - Firewall permission section (macOS 15+ only)139 - Window size: 450×500140141- **Settings**: `/Pareto/Views/Settings/`142 - `AboutSettingsView.swift`: Shows app + helper versions143 - `PermissionsSettingsView.swift`: Continuous permission monitoring144 - Various other settings views145146#### Permission System147- **PermissionsChecker**: Continuous monitoring with 2-second timer148- **Properties**: `firewallAuthorized`, other permissions149- **UI States**: Authorized/Disabled buttons, consistent spacing (20pt)150151### Key Technical Concepts152153#### XPC Communication154- **Service Name**: `co.niteo.ParetoSecurityHelper`155- **Protocol**: `ParetoSecurityHelperProtocol`156- **Connection Management**: Automatic retry, timeout handling157- **Error Handling**: Comprehensive logging, graceful degradation158159#### Concurrency & Threading160- **Main Actor**: UI components, HelperToolManager161- **Actor Isolation**: HelperToolUtilities for non-isolated static methods162- **Async/Await**: Proper continuation handling, avoid semaphores in async contexts163- **Thread Safety**: NSLock for XPC continuation management164165#### Version Management166- **Manual Versioning**: Static constants for helper versions167- **Update Logic**: Compare current vs expected, auto-reinstall if outdated168- **Version Display**: About screen shows both app and helper versions169170## Important Implementation Details171172### Helper Tool Requirements173- **macOS 15+ Only**: Firewall checks require helper on macOS 15+174- **Authorization**: User must approve in System Settings > Login Items175- **Question Mark UI**: Shows when helper required but not authorized176- **Live Status Checks**: Always use `HelperToolUtilities.isHelperInstalled()`, never cached values177178### Common Patterns179- **Check Implementation**: Override `requiresHelper` and `isRunnable` in check classes180- **Permission Monitoring**: Use Timer with 2-second intervals for continuous checking181- **Error Handling**: Use `os_log` for logging, specific error enums for Swift errors182- **UI Consistency**: 20pt spacing, medium font weight, secondary colors for labels183184### Troubleshooting Tools185- **Helper Status**: `launchctl print system/co.niteo.ParetoSecurityHelper`186- **Helper Logs**: Check system logs for "Helper:" prefixed messages187- **XPC Debugging**: Comprehensive logging throughout XPC chain188- **Version Mismatches**: Check both static constants match when updating189190## File Locations Reference191192### Core Files193- **Base Check**: `/Pareto/Checks/ParetoCheck.swift`194- **Firewall Check**: `/Pareto/Checks/Firewall and Sharing/Firewall.swift`195- **Helper Tool**: `/ParetoSecurityHelper/main.swift`196- **Helper Manager**: `/Pareto/Extensions/HelperTool.swift`197198### UI Files199- **Welcome**: `/Pareto/Views/Welcome/PermissionsView.swift`200- **About**: `/Pareto/Views/Settings/AboutSettingsView.swift`201- **Permissions Settings**: `/Pareto/Views/Settings/PermissionsSettingsView.swift`202203### Configuration204- **Helper Plist**: `/ParetoSecurityHelper/co.niteo.ParetoSecurityHelper.plist`205- **Build Config**: Use `make build`, `make test`, `make lint`, `make fmt`206207## Version Update Procedure2081. Increment `HelperToolUtilities.expectedHelperVersion` in HelperTool.swift2092. Increment `helperToolVersion` in helper's main.swift2103. Both versions must match for proper operation2114. App will auto-detect and reinstall helper on next check