From 1ecc62802ddf0a2fedbe4ab66ac121bcce446d2f Mon Sep 17 00:00:00 2001 From: Guangming Lu <71873108+LuGuangming@users.noreply.github.com> Date: Tue, 26 Dec 2023 21:59:47 +0800 Subject: [PATCH] [Bug](security) BE download_files function exists log print sensitive msg #28592 (#28594) --- be/src/olap/task/engine_clone_task.cpp | 15 +++++++++++---- be/src/olap/task/engine_clone_task.h | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/be/src/olap/task/engine_clone_task.cpp b/be/src/olap/task/engine_clone_task.cpp index 581cd3515c204a1..068e87233547d1b 100644 --- a/be/src/olap/task/engine_clone_task.cpp +++ b/be/src/olap/task/engine_clone_task.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -390,7 +391,7 @@ Status EngineCloneTask::_make_and_download_snapshots(DataDir& data_dir, status = _download_files(&data_dir, remote_url_prefix, local_data_path); if (!status.ok()) [[unlikely]] { LOG_WARNING("failed to download snapshot from remote BE") - .tag("url", remote_url_prefix) + .tag("url", _mask_token(remote_url_prefix)) .error(status); continue; // Try another BE } @@ -528,11 +529,11 @@ Status EngineCloneTask::_download_files(DataDir* data_dir, const std::string& re std::string local_file_path = local_path + "/" + file_name; - LOG(INFO) << "clone begin to download file from: " << remote_file_url + LOG(INFO) << "clone begin to download file from: " << _mask_token(remote_file_url) << " to: " << local_file_path << ". size(B): " << file_size << ", timeout(s): " << estimate_timeout; - auto download_cb = [&remote_file_url, estimate_timeout, &local_file_path, + auto download_cb = [this, &remote_file_url, estimate_timeout, &local_file_path, file_size](HttpClient* client) { RETURN_IF_ERROR(client->init(remote_file_url)); client->set_timeout_ms(estimate_timeout * 1000); @@ -548,7 +549,8 @@ Status EngineCloneTask::_download_files(DataDir* data_dir, const std::string& re } if (local_file_size != file_size) { LOG(WARNING) << "download file length error" - << ", remote_path=" << remote_file_url << ", file_size=" << file_size + << ", remote_path=" << _mask_token(remote_file_url) + << ", file_size=" << file_size << ", local_file_size=" << local_file_size; return Status::InternalError("downloaded file size is not equal"); } @@ -829,4 +831,9 @@ Status EngineCloneTask::_finish_full_clone(Tablet* tablet, // TODO(plat1ko): write cooldown meta to remote if this replica is cooldown replica } +std::string EngineCloneTask::_mask_token(const std::string& str) { + std::regex pattern("token=[\\w|-]+"); + return regex_replace(str, pattern, "token=******"); +} + } // namespace doris diff --git a/be/src/olap/task/engine_clone_task.h b/be/src/olap/task/engine_clone_task.h index 4f502ea50fd87f5..dd33f263e185077 100644 --- a/be/src/olap/task/engine_clone_task.h +++ b/be/src/olap/task/engine_clone_task.h @@ -86,6 +86,8 @@ class EngineCloneTask : public EngineTask { Status _release_snapshot(const std::string& ip, int port, const std::string& snapshot_path); + std::string _mask_token(const std::string& str); + private: const TCloneReq& _clone_req; vector* _tablet_infos = nullptr;