~aleteoryx/muditaos

c494f5c1b4c2959d707e874e2abc8f2ca61b80bc — Jakub Pyszczak 4 years ago bf3cc2f
[EGD-7006] Removed sensitive data from db

Sensitive data removed from logs in module db and service db.
M module-db/Database/Database.cpp => module-db/Database/Database.cpp +3 -4
@@ 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<QueryResult> 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());
    }

M module-db/Database/Field.cpp => module-db/Database/Field.cpp +1 -1
@@ 20,7 20,7 @@ template <class T> 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;
}

M module-db/Interface/CalllogRecord.cpp => module-db/Interface/CalllogRecord.cpp +3 -3
@@ 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;

M module-db/Interface/SMSRecord.cpp => module-db/Interface/SMSRecord.cpp +1 -1
@@ 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;

M module-services/service-db/DBServiceAPI.cpp => module-services/service-db/DBServiceAPI.cpp +0 -4
@@ 193,8 193,6 @@ auto DBServiceAPI::CalllogAdd(sys::Service *serv, const CalllogRecord &rec) -> C
{
    std::shared_ptr<DBCalllogMessage> msg = std::make_shared<DBCalllogMessage>(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<DBCalllogResponseMessage *>(ret.second.get());
    if (calllogResponse == nullptr) {


@@ 232,8 230,6 @@ auto DBServiceAPI::CalllogUpdate(sys::Service *serv, const CalllogRecord &rec) -
{
    std::shared_ptr<DBCalllogMessage> msg = std::make_shared<DBCalllogMessage>(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<DBCalllogResponseMessage *>(ret.second.get());
    if (calllogResponse == nullptr) {

M module-services/service-db/agents/settings/Settings.cpp => module-services/service-db/agents/settings/Settings.cpp +1 -1
@@ 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

M module-services/service-db/agents/settings/SettingsAgent.cpp => module-services/service-db/agents/settings/SettingsAgent.cpp +1 -4
@@ 155,10 155,7 @@ auto SettingsAgent::handleRegisterOnVariableChange(sys::Message *req) -> sys::Me
                return std::make_shared<sys::ResponseMessage>();
            }
            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);

M module-services/service-db/test/test-settings/Database.cpp => module-services/service-db/test/test-settings/Database.cpp +2 -2
@@ 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<QueryResult> 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);