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

casion pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new 6add87610 [BUG] fix shell engine danger usage information (#3939)
6add87610 is described below

commit 6add876107426523d5c136f373f0bddd71c13376
Author: GuoPhilipse <[email protected]>
AuthorDate: Fri Dec 2 17:24:33 2022 +0800

    [BUG] fix shell engine danger usage information (#3939)
---
 .../linkis-computation-orchestrator.md             |  2 +-
 docs/configuration/linkis-entrance.md              |  2 +-
 .../entrance/conf/EntranceConfiguration.scala      |  5 ++-
 .../impl/ShellDangerousGrammerInterceptor.scala    |  6 ++--
 .../TestShellDangerousGrammerInterceptor.scala     | 41 ++++++++++++++++++++++
 .../conf/ComputationOrchestratorConf.scala         |  5 ++-
 6 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/docs/configuration/linkis-computation-orchestrator.md 
b/docs/configuration/linkis-computation-orchestrator.md
index ab7abe5a8..aaa6893a2 100644
--- a/docs/configuration/linkis-computation-orchestrator.md
+++ b/docs/configuration/linkis-computation-orchestrator.md
@@ -8,7 +8,7 @@
 
|linkis-computation-orchestrator|wds.linkis.orchestrator.computation.code.executor.manager.class|
    |orchestrator.computation.code.executor.manager.class|
 
|linkis-computation-orchestrator|wds.linkis.orchestrator.max.ask.executor.time| 
10m  |orchestrator.max.ask.executor.time|
 
|linkis-computation-orchestrator|wds.linkis.shell.danger.usage|rm,sh,find,kill,python,for,source,hdfs,hadoop,spark-sql,spark-submit,pyspark,spark-shell,hive,yarn
 |danger.usage|
-|linkis-computation-orchestrator|wds.linkis.shell.white.usage| cd,ls| 
shell.white.usage |
+|linkis-computation-orchestrator|wds.linkis.shell.white.usage|sqoop,cd,ll,ls,echo,cat,tree,diff,who,grep,whoami,set,pwd,cut,file,head,less,if,while|
 shell.white.usage |
 |linkis-computation-orchestrator|wds.linkis.shell.white.usage.enabled|false| 
white.usage.enabled|
 |linkis-computation-orchestrator|wds.linkis.cache.service.application.name| 
linkis-ps-publicservice |service.application.nam|
 
|linkis-computation-orchestrator|wds.linkis.orchestrator.computation.session.factory.class|
  | orchestrator.computation.session.factory.class|
diff --git a/docs/configuration/linkis-entrance.md 
b/docs/configuration/linkis-entrance.md
index c1d640986..333e35b5f 100644
--- a/docs/configuration/linkis-entrance.md
+++ b/docs/configuration/linkis-entrance.md
@@ -33,7 +33,7 @@
 |linkis-entrance|wds.linkis.entrance.bdp.env| printInfo -|hive.printinfo.log|
 |linkis-entrance|wds.linkis.errorcode.file.dir| true | entrance.bdp.env|
 |linkis-entrance|wds.linkis.entrance.shell.danger.check.enabled|true | 
check.enabled|
-|linkis-entrance|wds.linkis.shell.danger.usage| bdp-client  |danger.usage|
+|linkis-entrance|wds.linkis.shell.danger.usage|rm,sh,find,kill,python,for,source,hdfs,hadoop,spark-sql,spark-submit,pyspark,spark-shell,hive,yarn
 |danger.usage|
 
|linkis-entrance|wds.linkis.shell.white.usage|sqoop,cd,ll,ls,echo,cat,tree,diff,who,grep,whoami,set,pwd,cut,file,head,less,if,while
 |.white.usage|
 |linkis-entrance|wds.linkis.entrance.flow.creator| nodeexecution|flow.creator|
 |linkis-entrance|wds.linkis.entrance.scheduler.creator| 
Schedulis|scheduler.creator|
diff --git 
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
 
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
index 5be871f8c..7082005c4 100644
--- 
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
+++ 
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
@@ -144,7 +144,10 @@ object EntranceConfiguration {
   val SHELL_DANGER_CHECK_SWITCH =
     CommonVars("wds.linkis.entrance.shell.danger.check.enabled", true)
 
-  val SHELL_DANGER_USAGE = CommonVars("wds.linkis.shell.danger.usage", 
"bdp-client")
+  val SHELL_DANGER_USAGE = CommonVars(
+    "wds.linkis.shell.danger.usage",
+    
"rm,sh,find,kill,python,for,source,hdfs,hadoop,spark-sql,spark-submit,pyspark,spark-shell,hive,yarn"
+  )
 
   val SHELL_WHITE_USAGE = CommonVars(
     "wds.linkis.shell.white.usage",
diff --git 
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/ShellDangerousGrammerInterceptor.scala
 
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/ShellDangerousGrammerInterceptor.scala
index c2b668039..f7ab469c2 100644
--- 
a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/ShellDangerousGrammerInterceptor.scala
+++ 
b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/ShellDangerousGrammerInterceptor.scala
@@ -34,7 +34,7 @@ class ShellDangerousGrammerInterceptor extends 
EntranceInterceptor with Logging
   private val shellDangerousGrammerCheckSwitch =
     EntranceConfiguration.SHELL_DANGER_CHECK_SWITCH.getValue
 
-  private val shellDangerCode = 
EntranceConfiguration.SHELL_DANGER_USAGE.getValue.split(",")
+  private val shellDangerCode = 
EntranceConfiguration.SHELL_DANGER_USAGE.getValue
   private val shellWhiteCodes = 
EntranceConfiguration.SHELL_WHITE_USAGE.getValue
 
   logger.info(s"shellDangerousGrammerCheckSwitch : 
${shellDangerousGrammerCheckSwitch}")
@@ -61,7 +61,7 @@ class ShellDangerousGrammerInterceptor extends 
EntranceInterceptor with Logging
   }
 
   /**
-   * check dander shell usage
+   * check danger shell usage
    *
    * @param shellContent
    * @return
@@ -75,7 +75,7 @@ class ShellDangerousGrammerInterceptor extends 
EntranceInterceptor with Logging
       } else {
         val shellCommands = shellLine.trim.split(" ")
         shellCommands foreach { shellCommand =>
-          if (shellDangerCode.contains(shellCommand)) {
+          if (shellDangerCode.split(",").contains(shellCommand)) {
             signature = true
           }
         }
diff --git 
a/linkis-computation-governance/linkis-entrance/src/test/scala/org/apache/linkis/entrance/interceptor/impl/TestShellDangerousGrammerInterceptor.scala
 
b/linkis-computation-governance/linkis-entrance/src/test/scala/org/apache/linkis/entrance/interceptor/impl/TestShellDangerousGrammerInterceptor.scala
new file mode 100644
index 000000000..c53be9175
--- /dev/null
+++ 
b/linkis-computation-governance/linkis-entrance/src/test/scala/org/apache/linkis/entrance/interceptor/impl/TestShellDangerousGrammerInterceptor.scala
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.entrance.interceptor.impl
+
+import org.apache.linkis.entrance.conf.EntranceConfiguration
+
+import org.junit.jupiter.api.{Assertions, Test}
+
+class TestShellDangerousGrammerInterceptor {
+
+  private val shellDangerCode = 
EntranceConfiguration.SHELL_DANGER_USAGE.getValue
+
+  @Test
+  def testShellDangerCode: Unit = {
+    val shellDangerousGrammerInterceptor = new ShellDangerousGrammerInterceptor
+
+    Assertions.assertEquals(
+      
"rm,sh,find,kill,python,for,source,hdfs,hadoop,spark-sql,spark-submit,pyspark,spark-shell,hive,yarn",
+      shellDangerCode
+    )
+    
Assertions.assertTrue(shellDangerousGrammerInterceptor.shellContainDangerUsage("rm"))
+    
Assertions.assertFalse(shellDangerousGrammerInterceptor.shellContainDangerUsage("ls"))
+
+  }
+
+}
diff --git 
a/linkis-orchestrator/linkis-computation-orchestrator/src/main/scala/org/apache/linkis/orchestrator/computation/conf/ComputationOrchestratorConf.scala
 
b/linkis-orchestrator/linkis-computation-orchestrator/src/main/scala/org/apache/linkis/orchestrator/computation/conf/ComputationOrchestratorConf.scala
index 56d4baf21..e5ebb6d78 100644
--- 
a/linkis-orchestrator/linkis-computation-orchestrator/src/main/scala/org/apache/linkis/orchestrator/computation/conf/ComputationOrchestratorConf.scala
+++ 
b/linkis-orchestrator/linkis-computation-orchestrator/src/main/scala/org/apache/linkis/orchestrator/computation/conf/ComputationOrchestratorConf.scala
@@ -40,7 +40,10 @@ object ComputationOrchestratorConf {
     
"rm,sh,find,kill,python,for,source,hdfs,hadoop,spark-sql,spark-submit,pyspark,spark-shell,hive,yarn"
   )
 
-  val SHELL_WHITE_USAGE = CommonVars("wds.linkis.shell.white.usage", "cd,ls")
+  val SHELL_WHITE_USAGE = CommonVars(
+    "wds.linkis.shell.white.usage",
+    
"sqoop,cd,ll,ls,echo,cat,tree,diff,who,grep,whoami,set,pwd,cut,file,head,less,if,while"
+  )
 
   val SHELL_WHITE_USAGE_ENABLED = 
CommonVars("wds.linkis.shell.white.usage.enabled", false)
 


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

Reply via email to