You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2026/09/21 12:59:58 UTC

(rocketmq-dashboard) branch rocketmq-studio updated: fix(ai): keep the provider token out of LlmProperties.toString (#4472)

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

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new 7c8ec156f fix(ai): keep the provider token out of LlmProperties.toString (#4472)
7c8ec156f is described below

commit 7c8ec156fc906c9cb5326d1ebdce95668720f3fb
Author: 0 <19...@qq.com>
AuthorDate: Mon Sep 21 20:59:51 2026 +0800

    fix(ai): keep the provider token out of LlmProperties.toString (#4472)
    
    `LlmProperties` is a Lombok `@Data` class, so its generated `toString()` printed the configured provider `token` in clear text next to `anthropicBaseUrl` and `cliAllowedEnvironment`.
    
    No call site leaks it today: the three consumers — `ClaudeCodeAgentProvider`, `CliProcessEnvironment` and `LlmConfigService` — read the fields individually, nothing logs or interpolates the properties object, and the actuator `configprops` endpoint serializes through Jackson getters with its own key sanitization. This is prevention rather than the fix for a live leak, but `token` was the one field on the class that a future debug log, exception message or diagnostic dump would have ca [...]
    
    It now carries `@ToString.Exclude`, matching how the login, cloud credential and ACL types in this repo already handle theirs, and `LlmPropertiesTest` asserts the other two fields still render while the token value does not.
    
    An earlier revision of this contribution also normalized and de-duplicated agent engine names in `AgentProviderRegistry`. That half was dropped at review: both providers' `ENGINE` constants are already lower-case, `forEngine` already normalized on lookup, and `Collectors.toMap` already throws on a duplicate key, so no reachable path exercised it.
---
 .../rocketmq/studio/ops/ai/LlmProperties.java      |  2 ++
 .../rocketmq/studio/ops/ai/LlmPropertiesTest.java} | 32 +++++++++++++---------
 2 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/server/src/main/java/org/apache/rocketmq/studio/ops/ai/LlmProperties.java b/server/src/main/java/org/apache/rocketmq/studio/ops/ai/LlmProperties.java
index 734c02219..274c2cab3 100644
--- a/server/src/main/java/org/apache/rocketmq/studio/ops/ai/LlmProperties.java
+++ b/server/src/main/java/org/apache/rocketmq/studio/ops/ai/LlmProperties.java
@@ -17,6 +17,7 @@
 package org.apache.rocketmq.studio.ops.ai;
 
 import lombok.Data;
+import lombok.ToString;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
 import java.util.ArrayList;
@@ -29,6 +30,7 @@ import java.util.List;
 @Data
 @ConfigurationProperties(prefix = "studio.llm")
 public class LlmProperties {
+    @ToString.Exclude
     private String token;
     private String anthropicBaseUrl;
     private List<String> cliAllowedEnvironment = new ArrayList<>();
diff --git a/server/src/main/java/org/apache/rocketmq/studio/ops/ai/LlmProperties.java b/server/src/test/java/org/apache/rocketmq/studio/ops/ai/LlmPropertiesTest.java
similarity index 54%
copy from server/src/main/java/org/apache/rocketmq/studio/ops/ai/LlmProperties.java
copy to server/src/test/java/org/apache/rocketmq/studio/ops/ai/LlmPropertiesTest.java
index 734c02219..18c60ba8d 100644
--- a/server/src/main/java/org/apache/rocketmq/studio/ops/ai/LlmProperties.java
+++ b/server/src/test/java/org/apache/rocketmq/studio/ops/ai/LlmPropertiesTest.java
@@ -16,20 +16,26 @@
  */
 package org.apache.rocketmq.studio.ops.ai;
 
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.junit.jupiter.api.Test;
 
-import java.util.ArrayList;
 import java.util.List;
 
-/**
- * LLM runtime settings supplied through the environment. Tokens and inherited
- * CLI environment values must never be persisted or logged.
- */
-@Data
-@ConfigurationProperties(prefix = "studio.llm")
-public class LlmProperties {
-    private String token;
-    private String anthropicBaseUrl;
-    private List<String> cliAllowedEnvironment = new ArrayList<>();
+import static org.assertj.core.api.Assertions.assertThat;
+
+class LlmPropertiesTest {
+
+    @Test
+    void toStringShouldNotExposeTheProviderTokenTest() {
+        LlmProperties properties = new LlmProperties();
+        properties.setToken("studio-llm-provider-token");
+        properties.setAnthropicBaseUrl("https://llm.example");
+        properties.setCliAllowedEnvironment(List.of("ANTHROPIC_AUTH_TOKEN"));
+
+        String value = properties.toString();
+
+        assertThat(value)
+                .contains("anthropicBaseUrl=https://llm.example")
+                .contains("cliAllowedEnvironment=[ANTHROPIC_AUTH_TOKEN]")
+                .doesNotContain("studio-llm-provider-token");
+    }
 }