Skip to content

Commit 1ecc628

Browse files
LuGuangmingstephen
authored andcommitted
[Bug](security) BE download_files function exists log print sensitive msg apache#28592 (apache#28594)
1 parent 3f3d0a6 commit 1ecc628

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎be/src/olap/task/engine_clone_task.cpp‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <memory>
3232
#include <mutex>
3333
#include <ostream>
34+
#include <regex>
3435
#include <set>
3536
#include <shared_mutex>
3637
#include <system_error>
@@ -390,7 +391,7 @@ Status EngineCloneTask::_make_and_download_snapshots(DataDir& data_dir,
390391
status = _download_files(&data_dir, remote_url_prefix, local_data_path);
391392
if (!status.ok()) [[unlikely]] {
392393
LOG_WARNING("failed to download snapshot from remote BE")
393-
.tag("url", remote_url_prefix)
394+
.tag("url", _mask_token(remote_url_prefix))
394395
.error(status);
395396
continue; // Try another BE
396397
}
@@ -528,11 +529,11 @@ Status EngineCloneTask::_download_files(DataDir* data_dir, const std::string& re
528529

529530
std::string local_file_path = local_path + "/" + file_name;
530531

531-
LOG(INFO) << "clone begin to download file from: " << remote_file_url
532+
LOG(INFO) << "clone begin to download file from: " << _mask_token(remote_file_url)
532533
<< " to: " << local_file_path << ". size(B): " << file_size
533534
<< ", timeout(s): " << estimate_timeout;
534535

535-
auto download_cb = [&remote_file_url, estimate_timeout, &local_file_path,
536+
auto download_cb = [this, &remote_file_url, estimate_timeout, &local_file_path,
536537
file_size](HttpClient* client) {
537538
RETURN_IF_ERROR(client->init(remote_file_url));
538539
client->set_timeout_ms(estimate_timeout * 1000);
@@ -548,7 +549,8 @@ Status EngineCloneTask::_download_files(DataDir* data_dir, const std::string& re
548549
}
549550
if (local_file_size != file_size) {
550551
LOG(WARNING) << "download file length error"
551-
<< ", remote_path=" << remote_file_url << ", file_size=" << file_size
552+
<< ", remote_path=" << _mask_token(remote_file_url)
553+
<< ", file_size=" << file_size
552554
<< ", local_file_size=" << local_file_size;
553555
return Status::InternalError("downloaded file size is not equal");
554556
}
@@ -829,4 +831,9 @@ Status EngineCloneTask::_finish_full_clone(Tablet* tablet,
829831
// TODO(plat1ko): write cooldown meta to remote if this replica is cooldown replica
830832
}
831833

834+
std::string EngineCloneTask::_mask_token(const std::string& str) {
835+
std::regex pattern("token=[\\w|-]+");
836+
return regex_replace(str, pattern, "token=******");
837+
}
838+
832839
} // namespace doris

‎be/src/olap/task/engine_clone_task.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ class EngineCloneTask : public EngineTask {
8686

8787
Status _release_snapshot(const std::string& ip, int port, const std::string& snapshot_path);
8888

89+
std::string _mask_token(const std::string& str);
90+
8991
private:
9092
const TCloneReq& _clone_req;
9193
vector<TTabletInfo>* _tablet_infos = nullptr;

0 commit comments

Comments
 (0)