From c96fbe6b0aeb413a17c429133ee6d81d138144b9 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期二, 09 六月 2026 10:58:52 +0800
Subject: [PATCH] Merge branch '1.0' of http://120.76.84.145:10101/gitblit/r/java/Robotaxi into 1.0

---
 xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/config/log/RequestResponseLoggingFilter.java |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/config/log/RequestResponseLoggingFilter.java b/xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/config/log/RequestResponseLoggingFilter.java
index 0df4aad..138102d 100644
--- a/xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/config/log/RequestResponseLoggingFilter.java
+++ b/xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/config/log/RequestResponseLoggingFilter.java
@@ -37,6 +37,11 @@
             "/actuator", "/healthcheck", "/health", "/prometheus"
     ));
 
+    /** 不打印请求/响应 body 的敏感路径前缀 */
+    private static final Set<String> SENSITIVE_BODY_PATHS = new HashSet<>(Arrays.asList(
+            "/vehicle/v1/robotaxi/sms"
+    ));
+
     /** 只对这些 Content-Type 打印 body(避免打印二进制流) */
     private static final Set<String> LOGGABLE_CONTENT_TYPES = new HashSet<>(Arrays.asList(
             MediaType.APPLICATION_JSON_VALUE,
@@ -101,7 +106,7 @@
         String uri     = request.getRequestURI();
         String query   = request.getQueryString();
         String method  = request.getMethod();
-        String body    = extractBody(request.getContentAsByteArray(), request.getContentType());
+        String body    = isSensitiveBodyPath(uri) ? "[sensitive body masked]" : extractBody(request.getContentAsByteArray(), request.getContentType());
 
         if (logHeaderProperties.isEnabled()) {
             String headers = extractHeaders(request);
@@ -148,7 +153,8 @@
     private void logResponse(ContentCachingResponseWrapper response, long cost) {
         String traceId = MDC.get("traceId");
         int    status  = response.getStatus();
-        String body    = extractBody(response.getContentAsByteArray(), response.getContentType());
+        String uri = MDC.get("requestUri");
+        String body = isSensitiveBodyPath(uri) ? "[sensitive body masked]" : extractBody(response.getContentAsByteArray(), response.getContentType());
 
         log.info("<<< [{}] status={} cost={}ms | body={}",
                 traceId, status, cost, body);
@@ -173,4 +179,8 @@
         String ct = contentType.toLowerCase();
         return LOGGABLE_CONTENT_TYPES.stream().anyMatch(ct::contains);
     }
+
+    private boolean isSensitiveBodyPath(String uri) {
+        return uri != null && SENSITIVE_BODY_PATHS.stream().anyMatch(uri::startsWith);
+    }
 }

--
Gitblit v1.7.1