mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 20:05:19 +00:00
Merge pull request #947 from permissionlesstech/fix/BCH-01-013-clear-snapshots-on-reset
fix(security): clear iOS app switcher snapshots on panic reset [BCH-01-013]
This commit is contained in:
@@ -2055,6 +2055,12 @@ final class ChatViewModel: ObservableObject, BitchatDelegate, CommandContextProv
|
|||||||
} catch {
|
} catch {
|
||||||
SecureLogger.error("Failed to clear media files during panic: \(error)", category: .session)
|
SecureLogger.error("Failed to clear media files during panic: \(error)", category: .session)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BCH-01-013: Clear iOS app switcher snapshots
|
||||||
|
// These are stored in Library/Caches/Snapshots/<bundle_id>/
|
||||||
|
#if os(iOS)
|
||||||
|
Self.clearAppSwitcherSnapshots()
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force immediate UI update for panic mode
|
// Force immediate UI update for panic mode
|
||||||
@@ -2062,6 +2068,29 @@ final class ChatViewModel: ObservableObject, BitchatDelegate, CommandContextProv
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// BCH-01-013: Clear iOS app switcher snapshots during panic mode
|
||||||
|
/// iOS stores preview screenshots in Library/Caches/Snapshots/<bundle_id>/
|
||||||
|
/// These could reveal sensitive information visible in the app at the time
|
||||||
|
#if os(iOS)
|
||||||
|
private static func clearAppSwitcherSnapshots() {
|
||||||
|
do {
|
||||||
|
let cacheDir = try FileManager.default.url(for: .cachesDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
|
||||||
|
let snapshotsDir = cacheDir.appendingPathComponent("Snapshots", isDirectory: true)
|
||||||
|
|
||||||
|
// Clear all snapshots (iOS stores them in subdirectories by bundle ID and scene)
|
||||||
|
if FileManager.default.fileExists(atPath: snapshotsDir.path) {
|
||||||
|
let contents = try FileManager.default.contentsOfDirectory(at: snapshotsDir, includingPropertiesForKeys: nil)
|
||||||
|
for item in contents {
|
||||||
|
try FileManager.default.removeItem(at: item)
|
||||||
|
}
|
||||||
|
SecureLogger.info("🗑️ Cleared app switcher snapshots during panic clear", category: .session)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
SecureLogger.error("Failed to clear app switcher snapshots: \(error)", category: .session)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// MARK: - Autocomplete
|
// MARK: - Autocomplete
|
||||||
|
|
||||||
func updateAutocomplete(for text: String, cursorPosition: Int) {
|
func updateAutocomplete(for text: String, cursorPosition: Int) {
|
||||||
|
|||||||
Reference in New Issue
Block a user