Bladeren bron

AMBARI-14061. Oozie/Hive "Database Name" field validation missed. (Andriy Babiichuk via Jaimin)

Jaimin Jetly 10 jaren geleden
bovenliggende
commit
677e4e3061

+ 1 - 0
ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-env.xml

@@ -80,6 +80,7 @@
     <value>hive</value>
     <description>Database name.</description>
     <value-attributes>
+      <type>database</type>
       <visible>false</visible>
       <editable-only-at-install>true</editable-only-at-install>
       <overridable>false</overridable>

+ 1 - 0
ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-site.xml

@@ -37,6 +37,7 @@ limitations under the License.
     <display-name>Database Name</display-name>
     <description>Database name used as the Hive Metastore</description>
     <value-attributes>
+      <type>database</type>
       <type>host</type>
       <overridable>false</overridable>
     </value-attributes>

+ 1 - 0
ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/configuration/oozie-site.xml

@@ -110,6 +110,7 @@
       Oozie DataBase Name
     </description>
     <value-attributes>
+      <type>database</type>
       <overridable>false</overridable>
     </value-attributes>
   </property>

+ 1 - 0
ambari-server/src/main/resources/common-services/OOZIE/4.2.0.2.3/configuration/oozie-site.xml

@@ -95,6 +95,7 @@
       Oozie DataBase Name
     </description>
     <value-attributes>
+      <type>database</type>
       <overridable>false</overridable>
     </value-attributes>
   </property>

+ 3 - 0
ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HIVE/configuration/hive-env.xml

@@ -42,6 +42,9 @@
     <name>hive_database_name</name>
     <value>hive</value>
     <description>Database name.</description>
+    <value-attributes>
+      <type>database</type>
+    </value-attributes>
   </property>
   <property>
     <name>hive_dbroot</name>

+ 3 - 0
ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HIVE/configuration/hive-site.xml

@@ -30,6 +30,9 @@ limitations under the License.
     <name>ambari.hive.db.schema.name</name>
     <value>hive</value>
     <description>Database name used as the Hive Metastore</description>
+    <value-attributes>
+      <type>database</type>
+    </value-attributes>
   </property>
 
   <property>

+ 3 - 0
ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/OOZIE/configuration/oozie-site.xml

@@ -108,6 +108,9 @@
     <description>
       Oozie DataBase Name
     </description>
+    <value-attributes>
+      <type>database</type>
+    </value-attributes>
   </property>
 
   <property>

+ 1 - 0
ambari-server/src/main/resources/stacks/HDP/2.2/services/HIVE/configuration/hive-site.xml

@@ -1412,6 +1412,7 @@ limitations under the License.
     <display-name>Database Name</display-name>
     <description>Database name used as the Hive Metastore</description>
     <value-attributes>
+      <type>database</type>
       <overridable>false</overridable>
     </value-attributes>
   </property>

+ 3 - 0
ambari-server/src/main/resources/stacks/HDP/2.3.GlusterFS/services/HIVE/configuration/hive-site.xml

@@ -29,6 +29,9 @@ limitations under the License.
     <name>ambari.hive.db.schema.name</name>
     <value>hive</value>
     <description>Database name used as the Hive Metastore</description>
+    <value-attributes>
+      <type>database</type>
+    </value-attributes>
   </property>
 
   <property>

+ 3 - 0
ambari-server/src/main/resources/stacks/HDP/2.3.GlusterFS/services/OOZIE/configuration/oozie-site.xml

@@ -115,6 +115,9 @@
     <description>
       Oozie DataBase Name
     </description>
+    <value-attributes>
+      <type>database</type>
+    </value-attributes>
   </property>
 
   <property>

+ 1 - 0
ambari-server/src/main/resources/stacks/HDPWIN/2.2/services/HIVE/configuration/hive-site.xml

@@ -1404,6 +1404,7 @@ limitations under the License.
     <display-name>Database Name</display-name>
     <description>Database name used as the Hive Metastore</description>
     <value-attributes>
+      <type>database</type>
       <overridable>false</overridable>
     </value-attributes>
   </property>

+ 12 - 0
ambari-web/app/models/configs/objects/service_config_property.js

@@ -433,6 +433,18 @@ App.ServiceConfigProperty = Em.Object.extend({
             isError = true;
           }
           break;
+        case 'user':
+          if (!validator.isValidUNIXUser(value)){
+            this.set('errorMessage', 'Username is not valid');
+            isError = true;
+          }
+          break;
+        case 'database':
+          if (!validator.isValidDbName(value)){
+            this.set('errorMessage', 'Database is not valid');
+            isError = true;
+          }
+          break;
         case 'multiLine':
         case 'content':
         default:

+ 10 - 0
ambari-web/app/utils/validator.js

@@ -168,6 +168,16 @@ module.exports = {
     return usernameRegex.test(value);
   },
 
+  /**
+   * validate db name
+   * @param value
+   * @returns {boolean}
+   */
+  isValidDbName: function(value) {
+    var dbPattern = /^\S+$/;
+    return dbPattern.test(value);
+  },
+
   /**
    * validate key of configurations
    * @param value