diff options
| author | Ken Chen <cken@google.com> | 2019-03-19 17:41:28 +0800 |
|---|---|---|
| committer | Ken Chen <cken@google.com> | 2019-03-21 17:12:48 +0800 |
| commit | ffc224aae14c52e27005bb35d4113f76a60f89eb (patch) | |
| tree | 27c453f65e627e26bbc151c66b5008e4509b0a73 /res_debug.cpp | |
| parent | 36796f35666cf53dc537112d711e9f52122781ec (diff) | |
Disable sensitive logs
- PII logs can only appear in VERBOSE level
- logSeverityStrToEnum() no more support VERBOSE level input, only
accept DEBUG, INFO, WARNING, and ERROR.
- developer can set DBG flag from code to have a debug build, the DEBUG
level is automatically promote to VERBOSE.
- uniform log format to [FILE NAME]: [FUNC NAME]: [MSG]
- move from ALOG to LOG on DnsProxyListener
- adjust severity for some logs
- correct print format on uint8_t type
Bug: 128736560
Test: builds, boots
Test: atest resolv_integration_test
Change-Id: I0ff03824901168165bbe1f5abae9ff3e74db63d6
Diffstat (limited to 'res_debug.cpp')
| -rw-r--r-- | res_debug.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/res_debug.cpp b/res_debug.cpp index f9225c00..482fdadb 100644 --- a/res_debug.cpp +++ b/res_debug.cpp @@ -96,6 +96,7 @@ */ #define LOG_TAG "res_debug" +#define DBG 0 #include <sys/param.h> #include <sys/socket.h> @@ -161,7 +162,7 @@ static void do_section(ns_msg* handle, ns_sect section) { char* buf = (char*) malloc((size_t) buflen); if (buf == NULL) { dbprint(p, end, ";; memory allocation failure\n"); - LOG(VERBOSE) << temp; + LOG(VERBOSE) << __func__ << ": " << temp; return; } @@ -234,7 +235,7 @@ static void do_section(ns_msg* handle, ns_sect section) { } if (buf == NULL) { p = dbprint(p, end, ";; memory allocation failure\n"); - LOG(VERBOSE) << temp; + LOG(VERBOSE) << __func__ << ": " << temp; return; } continue; @@ -499,24 +500,23 @@ const char* p_rcode(int rcode) { android::base::LogSeverity logSeverityStrToEnum(const std::string& logSeverityStr) { android::base::LogSeverity logSeverityEnum; - if (logSeverityStr == "VERBOSE") { - logSeverityEnum = android::base::VERBOSE; - } else if (logSeverityStr == "DEBUG") { - logSeverityEnum = android::base::DEBUG; + + if (logSeverityStr == "DEBUG") { + // *** enable verbose logging only when DBG is set. It prints sensitive data *** + if (DBG) + logSeverityEnum = android::base::VERBOSE; + else + logSeverityEnum = android::base::DEBUG; } else if (logSeverityStr == "INFO") { logSeverityEnum = android::base::INFO; } else if (logSeverityStr == "WARNING") { logSeverityEnum = android::base::WARNING; } else if (logSeverityStr == "ERROR") { logSeverityEnum = android::base::ERROR; - } else if (logSeverityStr == "FATAL_WITHOUT_ABORT") { - logSeverityEnum = android::base::FATAL_WITHOUT_ABORT; - } else if (logSeverityStr == "FATAL") { - logSeverityEnum = android::base::FATAL; } else { // Invalid parameter is treated as WARNING (default setting) logSeverityEnum = android::base::WARNING; } - LOG(INFO) << "logSeverityEnum " << logSeverityEnum; + LOG(INFO) << __func__ << ": " << logSeverityEnum; return logSeverityEnum; } |
