@@ -37,6 +37,13 @@ namespace doris {
3737
3838static 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+
4047HttpRequest::HttpRequest (evhttp_request* evhttp_request) : _ev_req(evhttp_request) {}
4148
4249HttpRequest::~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