[PM-33500] - delete attachments from deleted ciphers#7208
[PM-33500] - delete attachments from deleted ciphers#7208jaasen-livefront wants to merge 2 commits intomainfrom
Conversation
|
New Issues (2)Checkmarx found the following issues in this Pull Request
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7208 +/- ##
==========================================
+ Coverage 57.68% 57.69% +0.01%
==========================================
Files 2035 2035
Lines 89645 89663 +18
Branches 7993 7996 +3
==========================================
+ Hits 51709 51732 +23
+ Misses 36072 36066 -6
- Partials 1864 1865 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Claude finished @gbubemismith's task in 1m 46s —— View job Code Review Complete
Result: Clean — No Issues FoundThis PR correctly fixes orphaned attachment files left behind when ciphers are deleted in bulk, an organization vault is purged, or an organization is deleted. The implementation is consistent with the existing pattern in What was reviewed:
Key observations:
No bugs, security issues, or style concerns were identified. |
|





🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-33500
📔 Objective
Fix orphaned attachment files left behind when ciphers are deleted in bulk, an organization vault is purged, or an organization is deleted.
When a single cipher is deleted via
CipherService.DeleteAsync, attachment files are properly removed from blob/disk storage viaDeleteAttachmentsForCipherAsync. However, three other deletion paths only removed DB records, leaving attachment files permanently orphaned in storage:CipherService.DeleteManyAsync(bulk cipher delete) — deleted cipher rows but never cleaned up attachment storage.CipherService.PurgeAsync(org vault purge) — deleted cipher rows but never cleaned up attachment storage.OrganizationDeleteCommand.DeleteAsync(org deletion) — cascade-deleted cipher rows via SQL stored proc but never cleaned up attachment storage.Changes
CipherService.DeleteManyAsync: After DB deletion, iterate deleted ciphers and callDeleteAttachmentsForCipherAsyncfor each.CipherService.PurgeAsync: Fetch org cipher IDs before DB deletion, then clean up each cipher's attachments after.OrganizationDeleteCommand.DeleteAsync: InjectICipherRepositoryandIAttachmentStorageService. Fetch org cipher IDs before DB cascade delete, then clean up each cipher's attachments after.DeleteManyAsync(org admin + personal owner paths) andOrganizationDeleteCommand.Delete_Successto assert attachment cleanup. Added newPurgeAsync_WithOrganizationId_DeletesCiphersAndAttachmentstest.📸 Screenshots