This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new 0c35b080488 branch-4.0:[enhance](auth)Hidden the token info during 
StreamLoad in BE info #60656 && [enhance](auth)Hidden the auth info during 
StreamLoad in BE info #59743 (#62188)
0c35b080488 is described below

commit 0c35b080488da7ca590e8a77ffbd97a15aae5160
Author: 黄瑞鑫 <[email protected]>
AuthorDate: Wed Apr 15 14:36:14 2026 +0800

    branch-4.0:[enhance](auth)Hidden the token info during StreamLoad in BE 
info #60656 && [enhance](auth)Hidden the auth info during StreamLoad in BE info 
#59743 (#62188)
    
    ### What problem does this PR solve?
    
    Issue Number: close #xxx
    
    Related PR: #xxx
    
    Problem Summary:
    
    pick https://github.com/apache/doris/pull/60656 and
    https://github.com/apache/doris/pull/59743
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [ ] Regression test
        - [ ] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [ ] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [ ] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [ ] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [ ] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
---
 be/src/http/action/stream_load_forward_handler.cpp |  8 +-------
 be/src/http/http_request.cpp                       | 20 ++++++++++++++++++--
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/be/src/http/action/stream_load_forward_handler.cpp 
b/be/src/http/action/stream_load_forward_handler.cpp
index d3d713971ca..37657947ba5 100644
--- a/be/src/http/action/stream_load_forward_handler.cpp
+++ b/be/src/http/action/stream_load_forward_handler.cpp
@@ -32,12 +32,6 @@ namespace doris {
 #include "common/compile_check_begin.h"
 
 int StreamLoadForwardHandler::on_header(HttpRequest* req) {
-    std::ostringstream headers_info;
-    const auto& headers = req->headers();
-    for (const auto& header : headers) {
-        headers_info << header.first << ":" << header.second << " ";
-    }
-
     std::ostringstream params_info;
     const auto* params = req->params();
     for (const auto& param : *params) {
@@ -46,7 +40,7 @@ int StreamLoadForwardHandler::on_header(HttpRequest* req) {
 
     LOG(INFO) << "StreamLoadForward request started - "
               << "path: " << req->raw_path() << ", remote: " << 
req->remote_host() << ", headers: ["
-              << headers_info.str() << "]"
+              << req->get_all_headers() << "]"
               << ", params: [" << params_info.str() << "]";
 
     std::shared_ptr<StreamLoadForwardContext> ctx(new 
StreamLoadForwardContext());
diff --git a/be/src/http/http_request.cpp b/be/src/http/http_request.cpp
index f7432978016..8bc4d4e51d7 100644
--- a/be/src/http/http_request.cpp
+++ b/be/src/http/http_request.cpp
@@ -28,11 +28,19 @@
 #include <utility>
 
 #include "http/http_handler.h"
+#include "http/http_headers.h"
 
 namespace doris {
 
 static std::string s_empty = "";
 
+// Helper function to check if a header should be masked in logs
+static bool is_sensitive_header(const std::string& header_name) {
+    return iequal(header_name, HttpHeaders::AUTHORIZATION) ||
+           iequal(header_name, HttpHeaders::PROXY_AUTHORIZATION) || 
iequal(header_name, "token") ||
+           iequal(header_name, HttpHeaders::AUTH_TOKEN);
+}
+
 HttpRequest::HttpRequest(evhttp_request* evhttp_request) : 
_ev_req(evhttp_request) {}
 
 HttpRequest::~HttpRequest() {
@@ -84,7 +92,11 @@ std::string HttpRequest::debug_string() const {
        << "raw_path:" << _raw_path << "\n"
        << "headers: \n";
     for (auto& iter : _headers) {
-        ss << "key=" << iter.first << ", value=" << iter.second << "\n";
+        if (is_sensitive_header(iter.first)) {
+            ss << "key=" << iter.first << ", value=***MASKED***\n";
+        } else {
+            ss << "key=" << iter.first << ", value=" << iter.second << "\n";
+        }
     }
     ss << "params: \n";
     for (auto& iter : _params) {
@@ -113,7 +125,11 @@ const std::string& HttpRequest::param(const std::string& 
key) const {
 std::string HttpRequest::get_all_headers() const {
     std::stringstream headers;
     for (const auto& header : _headers) {
-        headers << header.first << ":" << header.second + ", ";
+        if (is_sensitive_header(header.first)) {
+            headers << header.first << ":***MASKED***, ";
+        } else {
+            headers << header.first << ":" << header.second + ", ";
+        }
     }
     return headers.str();
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to