You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2022/07/22 06:11:30 UTC

[dubbo] branch 3.0 updated: Disable telnet command by default (#10351)

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

albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.0 by this push:
     new 8aa4227468 Disable telnet command by default (#10351)
8aa4227468 is described below

commit 8aa42274683140506b871c10557b85243988cb45
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Fri Jul 22 14:11:09 2022 +0800

    Disable telnet command by default (#10351)
    
    * Disable telnet command by default
    
    * fix uts
---
 .../apache/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java    | 4 ++--
 .../dubbo/remoting/telnet/support/TelnetHandlerAdapterTest.java       | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java
index cc1b952e58..9168a87c05 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java
@@ -67,7 +67,7 @@ public class TelnetHandlerAdapter extends ChannelHandlerAdapter implements Telne
                 } else {
                     buf.append("Command: ");
                     buf.append(command);
-                    buf.append(" disabled");
+                    buf.append(" disabled for security reasons, please enable support by listing the commands through 'telnet'");
                 }
             } else {
                 buf.append("Unsupported command: ");
@@ -86,7 +86,7 @@ public class TelnetHandlerAdapter extends ChannelHandlerAdapter implements Telne
     private boolean commandEnabled(URL url, String command) {
         String supportCommands = url.getParameter(TELNET_KEY);
         if (StringUtils.isEmpty(supportCommands)) {
-            return true;
+            return false;
         }
         String[] commands = COMMA_SPLIT_PATTERN.split(supportCommands);
         for (String c : commands) {
diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/telnet/support/TelnetHandlerAdapterTest.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/telnet/support/TelnetHandlerAdapterTest.java
index 1bac08d8f2..17b120522e 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/telnet/support/TelnetHandlerAdapterTest.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/telnet/support/TelnetHandlerAdapterTest.java
@@ -53,7 +53,7 @@ class TelnetHandlerAdapterTest {
         Assertions.assertEquals(expectedResult, telnetHandlerAdapter.telnet(channel, message));
 
         message = "--no-prompt help";
-        expectedResult = "Command: help disabled\r\n";
+        expectedResult = "Command: help disabled for security reasons, please enable support by listing the commands through 'telnet'\r\n";
         Assertions.assertEquals(expectedResult, telnetHandlerAdapter.telnet(channel, message));
 
         message = "--no-prompt";
@@ -61,7 +61,7 @@ class TelnetHandlerAdapterTest {
         Assertions.assertEquals(expectedResult, telnetHandlerAdapter.telnet(channel, message));
 
         message = "help";
-        expectedResult = "Command: help disabled\r\ndubbo>";
+        expectedResult = "Command: help disabled for security reasons, please enable support by listing the commands through 'telnet'\r\ndubbo>";
         Assertions.assertEquals(expectedResult, telnetHandlerAdapter.telnet(channel, message));
     }
 }