From b72cda2fc310186fc4c350cac6a3fcfd655e4f58 Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Fri, 29 Nov 2024 15:06:52 -0300 Subject: [PATCH 1/4] removing log params --- libstuff/SLog.cpp | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/libstuff/SLog.cpp b/libstuff/SLog.cpp index 107269ef0..70223b2b5 100644 --- a/libstuff/SLog.cpp +++ b/libstuff/SLog.cpp @@ -41,57 +41,16 @@ void SLogStackTrace(int level) { } // If the param name is not in this whitelist, we will log in addLogParams. -static const set PARAMS_WHITELIST = { - "accountID", - "authEmail", - "accountIDs", - "attendees", - "bankAccountID", - "cardData", - "cardID", - "clientUpdateID", +static set PARAMS_WHITELIST = { "command", - "companyName", - "companyWebsite", "Connection", "Content-Length", "count", - "currentTime", - "domainAccountID", - "domainName", - "email", - "errorMessage", - "feed", - "feedCountry", - "feedID", - "feedName", - "field", - "index", "indexName", - "invoice", "isUnique", - "key", - "lastIP", "logParam", - "nvpName", - "policyAccountID", - "policyID", - "reimbursementEntryID", - "reportID", - "requestID", - "requestTimestamp", - "secondaryLogin", - "shouldCompleteOnboarding", - "shouldDismissHybridAppOnboarding", "status", - "step", - "timeDiff", - "token", - "transactionID", - "type", "userID", - "secondaryLogin", - "walletBankAccountID" }; string addLogParams(string&& message, const STable& params) { From 4524ec35bcbe5a8ed1c623048fca9b0dce526a81 Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Fri, 29 Nov 2024 15:07:09 -0300 Subject: [PATCH 2/4] adding function to add log params in the plugin --- libstuff/SLog.cpp | 4 ++++ libstuff/libstuff.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/libstuff/SLog.cpp b/libstuff/SLog.cpp index 70223b2b5..cdb0dee8f 100644 --- a/libstuff/SLog.cpp +++ b/libstuff/SLog.cpp @@ -73,3 +73,7 @@ string addLogParams(string&& message, const STable& params) { return message; } + +void SAddLogParamWhitelist(string param) { + PARAMS_WHITELIST.insert(param); +} diff --git a/libstuff/libstuff.h b/libstuff/libstuff.h index 1d8bddc91..5b69c15d0 100644 --- a/libstuff/libstuff.h +++ b/libstuff/libstuff.h @@ -233,6 +233,8 @@ void SLogLevel(int level); // Stack trace logging void SLogStackTrace(int level = LOG_WARNING); +void SAddLogParamWhitelist(string param); + // This is a drop-in replacement for syslog that directly logs to `/run/systemd/journal/syslog` bypassing journald. void SSyslogSocketDirect(int priority, const char* format, ...); From e61146bfea066c6f5c9a17692e8966df2275bcd4 Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Fri, 29 Nov 2024 15:15:48 -0300 Subject: [PATCH 3/4] changing parameter to receive a set instead of a single paramter --- libstuff/SLog.cpp | 4 ++-- libstuff/libstuff.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libstuff/SLog.cpp b/libstuff/SLog.cpp index cdb0dee8f..ce3799be7 100644 --- a/libstuff/SLog.cpp +++ b/libstuff/SLog.cpp @@ -74,6 +74,6 @@ string addLogParams(string&& message, const STable& params) { return message; } -void SAddLogParamWhitelist(string param) { - PARAMS_WHITELIST.insert(param); +void SWhitelistLogParams(set params) { + PARAMS_WHITELIST.insert(params.begin(), params.end()); } diff --git a/libstuff/libstuff.h b/libstuff/libstuff.h index 5b69c15d0..bb12018f8 100644 --- a/libstuff/libstuff.h +++ b/libstuff/libstuff.h @@ -233,7 +233,7 @@ void SLogLevel(int level); // Stack trace logging void SLogStackTrace(int level = LOG_WARNING); -void SAddLogParamWhitelist(string param); +void SWhitelistLogParams(set params); // This is a drop-in replacement for syslog that directly logs to `/run/systemd/journal/syslog` bypassing journald. void SSyslogSocketDirect(int priority, const char* format, ...); From 86bcbf2303e8be46c6018bd6902efee1f778c7e9 Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Fri, 29 Nov 2024 15:39:51 -0300 Subject: [PATCH 4/4] adding comment and requestID --- libstuff/SLog.cpp | 1 + libstuff/libstuff.h | 1 + 2 files changed, 2 insertions(+) diff --git a/libstuff/SLog.cpp b/libstuff/SLog.cpp index ce3799be7..bb3943082 100644 --- a/libstuff/SLog.cpp +++ b/libstuff/SLog.cpp @@ -49,6 +49,7 @@ static set PARAMS_WHITELIST = { "indexName", "isUnique", "logParam", + "requestID", "status", "userID", }; diff --git a/libstuff/libstuff.h b/libstuff/libstuff.h index bb12018f8..c4dcf084f 100644 --- a/libstuff/libstuff.h +++ b/libstuff/libstuff.h @@ -233,6 +233,7 @@ void SLogLevel(int level); // Stack trace logging void SLogStackTrace(int level = LOG_WARNING); +// This method will allow plugins to whitelist log params they need to log. void SWhitelistLogParams(set params); // This is a drop-in replacement for syslog that directly logs to `/run/systemd/journal/syslog` bypassing journald.