Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32545181
D4728.1767177249.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D4728.1767177249.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D4728: Introduce and implement 'clearSensitiveData' method in DetabaseQueryExecutor and SQLiteQueryExecutor
Attached
Detach File
Event Timeline
Log In to Comment