From c494f5c1b4c2959d707e874e2abc8f2ca61b80bc Mon Sep 17 00:00:00 2001 From: Jakub Pyszczak Date: Tue, 29 Jun 2021 15:06:33 +0200 Subject: [PATCH] [EGD-7006] Removed sensitive data from db Sensitive data removed from logs in module db and service db. --- module-db/Database/Database.cpp | 7 +++---- module-db/Database/Field.cpp | 2 +- module-db/Interface/CalllogRecord.cpp | 6 +++--- module-db/Interface/SMSRecord.cpp | 2 +- module-services/service-db/DBServiceAPI.cpp | 4 ---- module-services/service-db/agents/settings/Settings.cpp | 2 +- .../service-db/agents/settings/SettingsAgent.cpp | 5 +---- module-services/service-db/test/test-settings/Database.cpp | 4 ++-- 8 files changed, 12 insertions(+), 20 deletions(-) diff --git a/module-db/Database/Database.cpp b/module-db/Database/Database.cpp index 705444ebda9942596fcc55aa0e9f82f7b97b42c4..8aebfedeb3fd5d91fad74f6b62184dd33b97ba39 100644 --- a/module-db/Database/Database.cpp +++ b/module-db/Database/Database.cpp @@ -141,7 +141,7 @@ bool Database::execute(const char *format, ...) if (const int result = sqlite3_exec(dbConnection, queryStatementBuffer, nullptr, nullptr, nullptr); result != SQLITE_OK) { - LOG_ERROR("Execution of \'%s\' failed with %d", queryStatementBuffer, result); + LOG_ERROR("Execution of query failed with %d", result); return false; } return true; @@ -164,7 +164,7 @@ std::unique_ptr Database::query(const char *format, ...) if (const int result = sqlite3_exec(dbConnection, queryStatementBuffer, queryCallback, queryResult.get(), nullptr); result != SQLITE_OK) { if (isNotPragmaRelated(queryStatementBuffer)) { - LOG_ERROR("SQL query \'%s\' failed selecting : %d", queryStatementBuffer, result); + LOG_ERROR("SQL query failed selecting : %d", result); } return nullptr; } @@ -181,7 +181,7 @@ int Database::queryCallback(void *usrPtr, int count, char **data, char **columns row.push_back(Field{data[i]}); } catch (...) { - LOG_FATAL("Error on: %" PRIu32 " %s", i, data[i]); + LOG_FATAL("Error on column: %" PRIu32, i); } } @@ -202,7 +202,6 @@ void Database::pragmaQuery(const std::string &pragmaStatemnt) do { for (uint32_t i = 0; i < fieldsCount; i++) { Field field = (*results)[i]; - LOG_INFO("%s: '%s'", pragmaStatemnt.c_str(), field.getCString()); } } while (results->nextRow()); } diff --git a/module-db/Database/Field.cpp b/module-db/Database/Field.cpp index eb554a0b8d97a2ce1666b23d098d6d2f317cc416..a83d26d0717ad5cc6f556d41f3178b5a761e397f 100644 --- a/module-db/Database/Field.cpp +++ b/module-db/Database/Field.cpp @@ -20,7 +20,7 @@ template static T lget(T &val, const std::string &mValue, std::functio return foo(); } catch (...) { - LOG_FATAL("Can't convert: %s to: %s", mValue.c_str(), typeid(T).name()); + LOG_FATAL("Can't convert value to: %s", typeid(T).name()); } return val; } diff --git a/module-db/Interface/CalllogRecord.cpp b/module-db/Interface/CalllogRecord.cpp index e24ab40b68aac647a3d14cbd4d96921bb24a1a9d..b9cb5d035d382bda62e2f7f6b3a4536cdfa57440 100644 --- a/module-db/Interface/CalllogRecord.cpp +++ b/module-db/Interface/CalllogRecord.cpp @@ -64,7 +64,7 @@ bool CalllogRecordInterface::Add(const CalllogRecord &rec) auto contactMatch = contactInterface.MatchByNumber(rec.phoneNumber, ContactRecordInterface::CreateTempContact::True); if (!contactMatch) { - LOG_ERROR("Cannot get contact, for number %s", rec.phoneNumber.getNonEmpty().c_str()); + LOG_ERROR("Cannot get contact, for id %" PRIu32, rec.contactId); return false; } auto &contactRec = contactMatch->contact; @@ -74,7 +74,7 @@ bool CalllogRecordInterface::Add(const CalllogRecord &rec) if (localRec.presentation == PresentationType::PR_UNKNOWN) { localRec.presentation = PresentationType::PR_ALLOWED; } - LOG_DEBUG("Adding call log record %s", localRec.str().c_str()); + LOG_DEBUG("Adding call log record"); } else { // private number so do not add contact just call log entry @@ -152,7 +152,7 @@ bool CalllogRecordInterface::Update(const CalllogRecord &rec) auto contactMatch = contactInterface.MatchByNumber(rec.phoneNumber, ContactRecordInterface::CreateTempContact::True); if (!contactMatch) { - LOG_ERROR("Cannot get or create temporary contact for number %s", rec.phoneNumber.getNonEmpty().c_str()); + LOG_ERROR("Cannot get or create temporary contact for id %" PRIu32, rec.contactId); return false; } contactID = contactMatch->contact.ID; diff --git a/module-db/Interface/SMSRecord.cpp b/module-db/Interface/SMSRecord.cpp index e020d1d5a92cdafa53bd3153dc40778c8af74926..564f9bb142dda6f9a183f5af7c9c376418d9cd41 100644 --- a/module-db/Interface/SMSRecord.cpp +++ b/module-db/Interface/SMSRecord.cpp @@ -32,7 +32,7 @@ bool SMSRecordInterface::Add(const SMSRecord &rec) ContactRecordInterface contactInterface(contactsDB); auto contactMatch = contactInterface.MatchByNumber(rec.number, ContactRecordInterface::CreateTempContact::True); if (!contactMatch.has_value()) { - LOG_ERROR("Cannot find contact, for number %s", rec.number.getFormatted().c_str()); + LOG_ERROR("Cannot find contact, for id %" PRIu32, rec.contactID); return false; } auto contactID = contactMatch->contactId; diff --git a/module-services/service-db/DBServiceAPI.cpp b/module-services/service-db/DBServiceAPI.cpp index 5c69a41c302a21c529240ad1266440338861ee31..bce021309c63b7a34fc9c3f3c36636c044acf4d8 100644 --- a/module-services/service-db/DBServiceAPI.cpp +++ b/module-services/service-db/DBServiceAPI.cpp @@ -193,8 +193,6 @@ auto DBServiceAPI::CalllogAdd(sys::Service *serv, const CalllogRecord &rec) -> C { std::shared_ptr msg = std::make_shared(MessageType::DBCalllogAdd, rec); - LOG_DEBUG("CalllogAdd %s", rec.str().c_str()); - auto ret = serv->bus.sendUnicastSync(msg, service::name::db, DefaultTimeoutInMs); auto calllogResponse = dynamic_cast(ret.second.get()); if (calllogResponse == nullptr) { @@ -232,8 +230,6 @@ auto DBServiceAPI::CalllogUpdate(sys::Service *serv, const CalllogRecord &rec) - { std::shared_ptr msg = std::make_shared(MessageType::DBCalllogUpdate, rec); - LOG_DEBUG("CalllogUpdate %s", rec.str().c_str()); - auto ret = serv->bus.sendUnicastSync(msg, service::name::db, DefaultTimeoutInMs); auto calllogResponse = dynamic_cast(ret.second.get()); if (calllogResponse == nullptr) { diff --git a/module-services/service-db/agents/settings/Settings.cpp b/module-services/service-db/agents/settings/Settings.cpp index ac10774778561a02e5f96320a611da267bf3540c..393115df662682c90cfac879cb523ceedfc94b96 100644 --- a/module-services/service-db/agents/settings/Settings.cpp +++ b/module-services/service-db/agents/settings/Settings.cpp @@ -46,7 +46,7 @@ namespace settings void Settings::handleVariableChanged(const EntryPath &path, const std::string &value) { - log_debug("handleVariableChanged: (k=v): (%s=%s)", path.to_string().c_str(), value.c_str()); + log_debug("handleVariableChanged: (key=%s)", path.to_string().c_str()); if (auto callbacks = cbValues.find(path); std::end(cbValues) != callbacks) { // we cant get by const ref here - as user can remove this callback from cbValues map which would cause use // after free diff --git a/module-services/service-db/agents/settings/SettingsAgent.cpp b/module-services/service-db/agents/settings/SettingsAgent.cpp index cf0c9d2a98dca921e4c21720eb7fed769a5698e9..dac6447029fe40ef5922882a2b57129c8329101b 100644 --- a/module-services/service-db/agents/settings/SettingsAgent.cpp +++ b/module-services/service-db/agents/settings/SettingsAgent.cpp @@ -155,10 +155,7 @@ auto SettingsAgent::handleRegisterOnVariableChange(sys::Message *req) -> sys::Me return std::make_shared(); } auto currentValue = dbGetValue(path).value_or(""); - LOG_DEBUG("[SettingsAgent::handleRegisterOnVariableChange] %s=%s to %s", - path.to_string().c_str(), - currentValue.c_str(), - msg->sender.c_str()); + LOG_DEBUG("[SettingsAgent::handleRegisterOnVariableChange] %s", path.to_string().c_str()); auto msgValue = std::make_shared<::settings::Messages::VariableChanged>(std::move(path), std::move(currentValue), ""); parentService->bus.sendUnicast(std::move(msgValue), msg->sender); diff --git a/module-services/service-db/test/test-settings/Database.cpp b/module-services/service-db/test/test-settings/Database.cpp index 6c396e79b84d0acb9c14e1067429b1cec32b3137..3245bb08934089a0d46294809257e9b704f7460c 100644 --- a/module-services/service-db/test/test-settings/Database.cpp +++ b/module-services/service-db/test/test-settings/Database.cpp @@ -39,7 +39,7 @@ bool stubExecute(const std::string &format, const std::string &path, const std:: } if (format == std::string(settings::Statements::insertValue)) { - LOG_DEBUG("Database::execute set %s = %s", path.c_str(), val.c_str()); + LOG_DEBUG("Database::execute set %s", path.c_str()); variables[path] = val; return true; } @@ -98,7 +98,7 @@ std::unique_ptr stubQuery(const std::string &format, const std::str if (variables.end() == variables.find(what)) { variables[what] = what + " _initialValue"; } - LOG_DEBUG("Database::query for %s returns %s", what.c_str(), variables[what].c_str()); + LOG_DEBUG("Database::query for %s", what.c_str()); row.push_back(Field{variables[what].c_str()}); } queryResult->addRow(row);