Skip to content

Commit

Permalink
Merge pull request #6015 from bvanav648/MigrationPreparer-RDK-55520-x…
Browse files Browse the repository at this point in the history
…umo4

RDK-55520: Obscure "value" field from getting printed in MigrationPreparer logs
  • Loading branch information
binuinbaraj authored Jan 23, 2025
2 parents a516bbb + 5ce07bf commit 0651d86
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
3 changes: 3 additions & 0 deletions MigrationPreparer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ All notable changes to this RDK Service will be documented in this file.

For more details, refer to versioning section under Main README.

## [1.0.1] - 2025-20-01
- Changes to avoid any "value" field from getting printed in MigrationPreparer related logs.

## [1.0.0] - 2024-12-01
### Added
- New RDK Service MigrationPreparer to aid the Data Harvesting process, where it exposes APIs to applications such as ResidentApp and others to store user settings in a standardized format (as a JSON file) suitable for EntOS consumption. The MigrationPreparer Thunder plugin will exist only in the RDKV ecosystem.
2 changes: 1 addition & 1 deletion MigrationPreparer/MigrationPreparer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#define API_VERSION_NUMBER_MAJOR 1
#define API_VERSION_NUMBER_MINOR 0
#define API_VERSION_NUMBER_PATCH 0
#define API_VERSION_NUMBER_PATCH 1

namespace WPEFramework
{
Expand Down
26 changes: 16 additions & 10 deletions MigrationPreparer/MigrationPreparerImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ namespace Plugin {
}

int8_t MigrationPreparerImplementation::split(std::list<string>& list, string& value, std::string delimiter) {
LOGINFO("split: %s", value.c_str());
// LOGINFO("split: %s", value.c_str());
string::size_type start = 0, pos = 0;
while ((pos = value.find(delimiter, start) )!= std::string::npos) {
list.emplace_back(value.substr(start, pos - start));
Expand All @@ -178,7 +178,7 @@ namespace Plugin {
}
// Add the last element without an underscore
value += *it;
LOGINFO("join: %s", value.c_str());
// LOGINFO("join: %s", value.c_str());
return Core::ERROR_NONE;
}

Expand All @@ -196,7 +196,8 @@ namespace Plugin {

uint32_t MigrationPreparerImplementation::write(const string& name, const string &value) {

LOGINFO("[WRITE] params={name: %s, value: %s}", name.c_str(), value.c_str());
// LOGINFO("[WRITE] params={name: %s, value: %s}", name.c_str(), value.c_str());
LOGINFO("Writing entry for name: %s", name.c_str());
string entry;
string key = name;
string newValue = value;
Expand Down Expand Up @@ -232,7 +233,8 @@ namespace Plugin {

if(!dataStore.Open(false)) {
LOGERR("Failed to open migration datastore %s, errno: %d, reason: %s", DATASTORE_PATH, errno, strerror(errno));
LOGERR("Failed to create entry for {%s:%s} in migration datastore", key.c_str(), newValue.c_str());
// LOGERR("Failed to create entry for {%s:%s} in migration datastore", key.c_str(), newValue.c_str());
LOGERR("Failed to create entry for name: %s in migration datastore", key.c_str());
_dataStoreMutex.unlock();
return ERROR_OPEN;
}
Expand All @@ -253,7 +255,8 @@ namespace Plugin {
string oldValue = _valueEntry[_lineNumber[key] - 2];

if(oldValue == newValue) {
LOGWARN("Entry {%s:%s} is already existing in the dataStore, returning success", oldValue.c_str(), key.c_str());
// LOGWARN("Entry {%s:%s} is already existing in the dataStore, returning success", oldValue.c_str(), key.c_str());
LOGWARN("Entry for name: %s is already existing in the dataStore, returning success", key.c_str());
_dataStoreMutex.unlock();
return Core::ERROR_NONE;
}
Expand All @@ -279,23 +282,26 @@ namespace Plugin {
return Core::ERROR_NONE;
}
result = WEXITSTATUS(result);
LOGERR("Failed to update entry for {%s:%s} in migration datastore, v_secure_system failed with error %d",key.c_str(), newValue.c_str(), result);
// LOGERR("Failed to update entry for {%s:%s} in migration datastore, v_secure_system failed with error %d",key.c_str(), newValue.c_str(), result);
LOGERR("Failed to update entry for name: %s in migration datastore, v_secure_system failed with error %d",key.c_str(), result);
_dataStoreMutex.unlock();
return ERROR_WRITE;
}

// Handle subsequent Write request
if(!dataStore.Open(false)) {
LOGERR("Failed to create migration datastore %s, errno: %d, reason: %s", DATASTORE_PATH, errno, strerror(errno));
LOGERR("Failed to create entry for {%s:%s} in migration datastore", key.c_str(), newValue.c_str());
// LOGERR("Failed to create entry for {%s:%s} in migration datastore", key.c_str(), newValue.c_str());
LOGERR("Failed to create entry for name: %s in migration datastore", key.c_str());
_dataStoreMutex.unlock();
return ERROR_OPEN;
}

// append new key-value pair to the dataStore
if(!dataStore.Position(false, dataStore.Size() - 2)) {
LOGERR("DataStore truncate failed with errno: %d, reason: %s\n", errno, strerror(errno));
LOGERR("Failed to create entry for {%s:%s} in migration datastore", key.c_str(), newValue.c_str());
// LOGERR("Failed to create entry for {%s:%s} in migration datastore", key.c_str(), newValue.c_str());
LOGERR("Failed to create entry for %s in migration datastore", key.c_str());
dataStore.Close();
_dataStoreMutex.unlock();
return ERROR_WRITE;
Expand All @@ -311,7 +317,7 @@ namespace Plugin {

uint32_t MigrationPreparerImplementation::read(const string& name, string &result) {

LOGINFO("[READ] params={name: %s}", name.c_str());
LOGINFO("Reading entry for name: %s", name.c_str());
string key = name;

if(!_fileExist) {
Expand All @@ -336,7 +342,7 @@ namespace Plugin {

uint32_t MigrationPreparerImplementation::Delete(const string& name) {

LOGINFO("[DELETE] params={name: %s}", name.c_str());
LOGINFO("Deleting entry for name: %s", name.c_str());
string key = name;
int result;

Expand Down
4 changes: 3 additions & 1 deletion MigrationPreparer/MigrationPreparerJsonRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ namespace Plugin {
response["error"] = error;
break;
case Core::ERROR_NONE:
status = true;
// In order to avoid printing "value" field in the MigrationPreparer logs, we bypass "returnResponse" macro
response["value"] = value;
response["success"] = true;
return WPEFramework::Core::ERROR_NONE;
break;
default:
error["message"] = "Unknown Error";
Expand Down

0 comments on commit 0651d86

Please sign in to comment.