Skip to content

feat(clean): respect user whitelist in orphaned-data scan (#741)#744

Merged
tw93 merged 2 commits intotw93:mainfrom
sebastianbreguel:feat/741-whitelist-orphan-data
Apr 15, 2026
Merged

feat(clean): respect user whitelist in orphaned-data scan (#741)#744
tw93 merged 2 commits intotw93:mainfrom
sebastianbreguel:feat/741-whitelist-orphan-data

Conversation

@sebastianbreguel
Copy link
Copy Markdown
Contributor

Closes part of #741.

Problem

clean_orphaned_app_data and clean_orphaned_system_services bypassed the user-facing WHITELIST_PATTERNS list, so there was no way to protect individual config/cache paths from auto-removal. Real case from the issue: apps run outside the .app bundle model (dev tools, custom builds) would have their Preferences/Caches wiped on every mo clean.

Change

  • lib/clean/apps.sh: add is_path_whitelisted check before safe_clean in both the Claude VM path and the generic bundle-ID orphan loop. For system services, filter the collected orphan array before reporting counts (so the "Found N" number reflects what will actually be removed).
  • No CLI changes: manage_whitelist already writes to WHITELIST_PATTERNS, so users can add any absolute path or glob via the existing flow and the orphan scan now respects it.

What this PR does NOT include

The issue also asks for an interactive per-orphan checkbox UX inside mo clean --whitelist. That's a separate, larger change (dynamic scan results rendered as a TUI submenu) and I wanted to land the foundation first. Happy to open a follow-up PR once this is in and the shape feels right.

Tests

Two regression tests in tests/clean_apps.bats:

  • whitelist protects a Claude VM bundle
  • whitelist protects an orphaned cache path
bats tests/clean_apps.bats -f orphan
... 11 tests, 0 failures

No behavior change when WHITELIST_PATTERNS is empty.

Orphan detection in `clean_orphaned_app_data` and
`clean_orphaned_system_services` bypassed the user-facing
`WHITELIST_PATTERNS` list, so users had no way to protect individual
config/cache paths from auto-removal — a real problem for apps run
outside the .app bundle model (dev tools, custom builds, etc.).

Adds `is_path_whitelisted` checks before `safe_clean` in the app-data
scan (Claude VM + generic bundle-ID match), and filters the collected
orphan list for system services before reporting counts. Existing
`manage_whitelist` flow already writes to `WHITELIST_PATTERNS`, so no
CLI changes are required — users can now add any absolute path or glob
and the orphan scan will skip it.

Interactive per-orphan checkbox UX (as described in the issue) is a
follow-up once this foundation lands.
@sebastianbreguel sebastianbreguel requested a review from tw93 as a code owner April 14, 2026 21:22
The help text in lib/core/help.sh documents the --permanent flag
with a string containing "rm -rf", triggering a false positive in
the security check. Add "echo " to the grep exclusion filter.
@tw93 tw93 merged commit 0876d34 into tw93:main Apr 15, 2026
9 checks passed
@tw93
Copy link
Copy Markdown
Owner

tw93 commented Apr 15, 2026

@sebastianbreguel thanks for respecting the whitelist in orphaned-data scans, merged and will be in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants