feat(check): detect orphan LaunchAgents in mo check#695
Open
sebastianbreguel wants to merge 1 commit intotw93:mainfrom
Open
feat(check): detect orphan LaunchAgents in mo check#695sebastianbreguel wants to merge 1 commit intotw93:mainfrom
sebastianbreguel wants to merge 1 commit intotw93:mainfrom
Conversation
Add check_orphan_launch_agents() next to check_disk_smart in lib/check/all.sh. Read-only scan of ~/Library/LaunchAgents and /Library/LaunchAgents that flags plists whose Program (or ProgramArguments[0]) points to an absolute path that no longer exists on disk — the classic leftover after dragging an app to trash without uninstalling its background helper. Conservative defaults: - Skip com.apple.* (system XPC handlers) - Skip relative paths (PATH-resolved binaries) - Use plutil -extract over grep for safe plist parsing - Honor is_whitelisted "check_orphan_launch_agents" - Zero delete; mirrors check_login_items reporting style Extends the orphan-detection pattern from tw93#682 (SystemExtensions and LaunchAgents in lib/uninstall/batch.sh) into the check side, parallel to check_disk_smart. Surfaces for awareness only — actual removal stays on the uninstall path. Real-world audit on author's Mac across all plists: - 1 true positive (com.logitech.manager.daemon — Logi Options uninstalled, helper plist orphaned) - 1 true negative (com.lwouis.alt-tab-macos — binary present, correctly not flagged) - Zero false positives across remaining plists Tests: 5 new BATS cases in tests/check_system.bats covering empty state, orphan detection, com.apple.* skip, valid Program ignored, and whitelist honored. Hidden MOLE_LAUNCH_AGENT_DIRS env var provides directory override for test isolation. All 9 tests in the file pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
check_orphan_launch_agents()tomo check, parallel tocheck_disk_smart. Read-only scan of~/Library/LaunchAgentsand/Library/LaunchAgentsthat flags plists whoseProgram(orProgramArguments[0]) points to an absolute path that no longer exists — the classic leftover after dragging an app to trash without uninstalling its background helper.Extends the orphan-detection pattern from #682 (SystemExtensions / LaunchAgents in
lib/uninstall/batch.sh) into the check side. Surfaces for awareness only, mirroringcheck_login_items. Zero delete, no new flag, no new command.Behavior
com.apple.*(system XPC handlers without on-disk Program paths)plutil -extract Program raw(fallbackProgramArguments.0) for safe plist parsing — no grep/evalis_whitelisted "check_orphan_launch_agents"check_login_items: count + preview of up to 3 labelsReal-world audit
Tested across every plist on my Mac:
com.logitech.manager.daemon(Logi Options uninstalled, helper plist orphaned)com.lwouis.alt-tab-macos(binary present, correctly not flagged)Tests
3 new BATS cases in
tests/check_system.bats:com.apple.*skipped (combined)None orphanedwhen cleanAll 7 tests in the file pass. Hidden
MOLE_LAUNCH_AGENT_DIRSenv var (colon-separated) provides directory override for test isolation — no production surface.Diff
lib/check/all.sh: +34 LOCtests/check_system.bats: +55 LOCTest plan
bats tests/check_system.bats— 7/7 passing~/Library/LaunchAgents+/Library/LaunchAgentsmo whitelist add check_orphan_launch_agentssilences it)