Skip to content

Commit a013e7e

Browse files
authored
[enhance](auth)Hidden the token info during StreamLoad in BE info (#60656)
1 parent fa24ad1 commit a013e7e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

be/src/http/http_request.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ namespace doris {
3737

3838
static std::string s_empty = "";
3939

40+
// Helper function to check if a header should be masked in logs
41+
static bool is_sensitive_header(const std::string& header_name) {
42+
return iequal(header_name, HttpHeaders::AUTHORIZATION) ||
43+
iequal(header_name, HttpHeaders::PROXY_AUTHORIZATION) || iequal(header_name, "token") ||
44+
iequal(header_name, HttpHeaders::AUTH_TOKEN);
45+
}
46+
4047
HttpRequest::HttpRequest(evhttp_request* evhttp_request) : _ev_req(evhttp_request) {}
4148

4249
HttpRequest::~HttpRequest() {
@@ -88,8 +95,7 @@ std::string HttpRequest::debug_string() const {
8895
<< "raw_path:" << _raw_path << "\n"
8996
<< "headers: \n";
9097
for (auto& iter : _headers) {
91-
if (iequal(iter.first, HttpHeaders::AUTHORIZATION) ||
92-
iequal(iter.first, HttpHeaders::PROXY_AUTHORIZATION)) {
98+
if (is_sensitive_header(iter.first)) {
9399
ss << "key=" << iter.first << ", value=***MASKED***\n";
94100
} else {
95101
ss << "key=" << iter.first << ", value=" << iter.second << "\n";
@@ -123,8 +129,7 @@ std::string HttpRequest::get_all_headers() const {
123129
std::stringstream headers;
124130
for (const auto& header : _headers) {
125131
// Mask sensitive headers
126-
if (iequal(header.first, HttpHeaders::AUTHORIZATION) ||
127-
iequal(header.first, HttpHeaders::PROXY_AUTHORIZATION)) {
132+
if (is_sensitive_header(header.first)) {
128133
headers << header.first << ":***MASKED***, ";
129134
} else {
130135
headers << header.first << ":" << header.second + ", ";

0 commit comments

Comments
 (0)