Skip to content

discovery: one-pass snapshot owners, search-only Containers, group roots by descriptor - #53

Merged
bojieli merged 5 commits into
mainfrom
fix/issue-49-discovery-followups
Nov 24, 2026
Merged

bojieli merged 5 commits into
mainfrom
fix/issue-49-discovery-followups

Conversation

@bojieli

@bojieli bojieli commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Closes #49

Follow-ups from the #45 review of duplicate-container discovery.

Changes

  1. One discovery pass for snapshot roots and owners. New WeChatAccountDiscovery.ownedDatabaseRoots(accountID:) returns each selected database root with the bundle ID of its owning container. greenbubbles-discover snapshot uses it, so the owner check covers the same roots that go to DatabaseSetPlanner, and each container is probed once. containerBundleIdentifiers(accountID:) stays as a wrapper so the 0.11.0 public API still compiles.
  2. Case-insensitive owner match, unknown still unverified. New ownersAllMatch(_:bundleIdentifier:): a nil owner (group container) never matches. An exact match is accepted. A match that differs only in case is accepted only when ~/Library/Containers/<installed id> and ~/Library/Containers/<owner> are the same real directory entry, compared with lstat so links aren't followed. This covers com.tencent.xinwechat on a case-insensitive volume. On a case-sensitive volume, where the two spellings can be different containers, the match is rejected.
  3. Search-only ~/Library/Containers. If opening it with O_RDONLY fails, the scanner reopens it with O_SEARCH and probes the standard name directly. The exact standard name is now also probed after any listed spellings of it, so a hidden or unlisted standard container isn't lost. If a listed spelling already reached that directory, the exact name is skipped before its accounts are listed.
  4. Group-container roots walked by descriptor. Group Containers is listed once. Each matching group and its xwechat_files are opened with openat, and the identity (fstat) and the account listing both come from that one xwechat_files descriptor. Accounts are checked with WeChatAppContainerScanner.accounts(inFiles:at:), which skips linked accounts and linked db_storage. One deliberate difference from app containers: a group or its xwechat_files may still be a symbolic link, because a group linked to an app container's data is a supported alias case (groupContainerLinkedToAnAppContainerIsOneAccount). Groups whose target was already seen skip the per-account checks.

Also: entryNames now skips UF_HIDDEN entries as well as dot-names. This restores the .skipsHiddenFiles behaviour that account and group listings had before 0.11.0.

Tests

  • New: standardAccountIsFoundWhenContainersIsSearchOnly (fails without the fix), groupContainerAccountsAreCheckedThroughDescriptors (linked, hidden, non-WeChat, and empty groups), ownerBundleIdentifiersMatchCaseInsensitivelyButUnknownOwnersNever, caseVariantOwnerInADifferentContainerDoesNotMatch (runs only on a case-sensitive volume), and an updated reportsTheOwnerOfSelectedAccounts.
  • Local run (scratch copy without GreenBubblesHistoryApp): all suites pass. swift format lint --strict is clean.

Review notes not addressed

  • Codex P2 (round 5): for a group that aliases an already-seen target, alias account IDs still come from contentsOfDirectory(at: alias) after the descriptor is closed, as in Discover WeChat data in duplicated app containers #45. Only extra IDs that select an account come from that listing. The data roots come from the verified descriptor. Deriving the IDs differently could change IDs that users saved from earlier versions.

Needs manual check

  • Privacy prompt (issue bullet 5): on a real Mac with WeChat and at least one other sandboxed app, run greenbubbles-discover accounts and snapshot, and confirm that no "would like to access data from other apps" (App Data) prompt appears. The scan opens other apps' container folders search-only on the way down, and now also opens matching group containers by descriptor.
  • No privileged code changed, so scripts/sudo-smoke-test-acquire.sh is unchanged.

🤖 Generated with Claude Code

bojieli and others added 5 commits November 24, 2026 09:28
…ots by descriptor

- snapshot takes database roots and their owning bundle IDs from a single
  discovery pass (WeChatAccountDiscovery.ownedDatabaseRoots).
- Owner bundle IDs are compared case-insensitively; an unknown owner still
  leaves the client build unverified.
- When ~/Library/Containers can't be listed, it is opened search-only so the
  standard container is still probed.
- Group-container xwechat_files roots are opened and listed through
  descriptors, with accounts checked by WeChatAppContainerScanner.accounts.

Closes #49

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…target

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ys probe the exact standard name

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…plicate standard probe

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bojieli
bojieli merged commit 6470384 into main Nov 24, 2026
4 checks passed
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.

discovery: follow-ups from the #45 review

1 participant