Page MenuHomePhorge

D4728.1767177249.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D4728.1767177249.diff

diff --git a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
@@ -58,6 +58,7 @@
virtual void storeOlmPersistData(crypto::Persist persist) const = 0;
virtual void setNotifyToken(std::string token) const = 0;
virtual void clearNotifyToken() const = 0;
+ virtual void clearSensitiveData() const = 0;
};
} // namespace comm
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
@@ -10,7 +10,7 @@
namespace comm {
class SQLiteQueryExecutor : public DatabaseQueryExecutor {
- void migrate();
+ void migrate() const;
static auto &getStorage();
static std::once_flag initialized;
@@ -57,6 +57,7 @@
void storeOlmPersistData(crypto::Persist persist) const override;
void setNotifyToken(std::string token) const override;
void clearNotifyToken() const override;
+ void clearSensitiveData() const override;
};
} // namespace comm
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
@@ -401,7 +401,7 @@
{22, {enable_write_ahead_logging_mode, false}},
{23, {create_metadata_table, true}}}};
-void SQLiteQueryExecutor::migrate() {
+void SQLiteQueryExecutor::migrate() const {
validate_encryption();
sqlite3 *db;
@@ -775,4 +775,20 @@
SQLiteQueryExecutor::getStorage().remove<Metadata>("notify_token");
}
+void SQLiteQueryExecutor::clearSensitiveData() const {
+ if (file_exists(SQLiteQueryExecutor::sqliteFilePath) &&
+ std::remove(SQLiteQueryExecutor::sqliteFilePath.c_str())) {
+ std::string error_message = "Failed to delete database file. Details: " +
+ std::string(strerror(errno));
+ throw std::system_error(errno, std::generic_category(), error_message);
+ }
+ CommSecureStore commSecureStore;
+ std::string encryptionKey = comm::crypto::Tools::generateRandomHexString(
+ SQLiteQueryExecutor::sqlcipherEncryptionKeySize);
+ commSecureStore.set(
+ SQLiteQueryExecutor::secureStoreEncryptionKeyID, encryptionKey);
+ SQLiteQueryExecutor::encryptionKey = encryptionKey;
+ this->migrate();
+}
+
} // namespace comm

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 31, 10:34 AM (5 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5873133
Default Alt Text
D4728.1767177249.diff (2 KB)

Event Timeline