Skip to content

Commit

Permalink
[Bug](security) BE download_files function exists log print sensitive…
Browse files Browse the repository at this point in the history
  • Loading branch information
LuGuangming authored and stephen committed Dec 28, 2023
1 parent 3f3d0a6 commit 1ecc628
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 11 additions & 4 deletions be/src/olap/task/engine_clone_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <memory>
#include <mutex>
#include <ostream>
#include <regex>
#include <set>
#include <shared_mutex>
#include <system_error>
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
Expand All @@ -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");
}
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions be/src/olap/task/engine_clone_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<TTabletInfo>* _tablet_infos = nullptr;
Expand Down

0 comments on commit 1ecc628

Please sign in to comment.