Backport legal-hold fixes to release/2026 (#377, #381) for a 2026.x security release #382

Merged
jcoffey-dev merged 2 commits from sec/legal-hold-backport into release/2026 2026-11-11 22:46:18 +00:00
2 Commits
Author SHA1 Message Date
jcoffey-dev dcd32909d5 Keep a deleted-but-held account's audit and journal records under the hold
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 9m26s
held_accounts() scanned only live accounts, so an account deleted while
undelete still kept it -- the case a legal hold is placed for -- was absent
from the set the retention purges trust. audit_purge consults it directly,
so a deleted-but-held account's audit trail was purged once past the 90-day
floor while the hold was active. The journal purge augmented the set at its
own call site, so it was affected only when a hold covered no live account.

held_accounts() now folds in the accounts undelete keeps that a hold covers,
through the domain and tenant their retained record carries, so every purge
that trusts it keeps a deleted-but-held account's records. The journal call
site's now-redundant augmentation is removed, leaving one source of truth.

Covered by legal_hold_tests: a deleted-but-held custodian is now present in
held_accounts() (LH-6, AU-7).

(cherry picked from commit c884bad555)
2026-11-11 12:44:22 -07:00
jcoffey-dev 9dae9b044f Freeze a deleted-but-kept account's archived mail under a legal hold
settle_archive's item loop collapsed any gone account to keeping=None, so
an archived item belonging to an account that was deleted while undelete
still retains it kept its finite deadline no matter what holds covered it.
The second loop froze the account's own kept_until but never the item
deadlines, so the scheduled purge destroyed individually-deleted messages
of a departed custodian while a hold was asserting over them (LH-8, LH-6).

A gone-but-kept account now resolves its Keeping from the holds covering
the domain and tenant its kept record carries, so its archived items
freeze and release on the same path a live account's do. A gone-and-not-
kept account still gets None (release only).

Covered by legal_hold_tests: a late, domain-scoped hold over a deleted
custodian now freezes the message they had deleted before leaving.

(cherry picked from commit 27e6b0a57b)
2026-11-11 12:44:18 -07:00