kuczoram commented on code in PR #6928:
URL: https://github.com/apache/hive/pull/6928#discussion_r4437609940


##########
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/CompactorPropertyValidator.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.hadoop.hive.ql.txn.compactor;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.conf.HiveConfUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+/**
+ * The allow list bounding which configuration parameters a table property may 
override on a compaction
+ * job, read from {@link HiveConf.ConfVars#HIVE_COMPACTOR_CONF_ALLOWLIST}. 
This config limits the scope
+ * of the overridable config parameters, because most of the parameters have 
no effect on a compaction job.
+ * With this limitation, the regex defined by the deny list can be kept simple 
and short.
+ * <p>
+ * The config parameters are first evaluated against the allow list config. If 
they match, then they will be
+ * evaluated against the deny list, read from {@link 
HiveConf.ConfVars#HIVE_COMPACTOR_CONF_DENYLIST}.
+ * The purpose of the deny list is to filter for parameters which could lead 
to security gaps.
+ * <p>
+ * The admins can extend the allow list through {@link 
HiveConf.ConfVars#HIVE_COMPACTOR_CONF_ALLOWLIST_APPEND}.
+ * The config parameters listed here are also evaluated against the deny list 
to prevent accidentally allowing
+ * configs which hold security risk.
+ * <p>
+ * As last step, all config parameters are checked against the already 
existing lists such as
+ * {@link HiveConf.ConfVars#HIVE_CONF_RESTRICTED_LIST}, {@link 
HiveConf.ConfVars#HIVE_CONF_HIDDEN_LIST}
+ * and {@link HiveConf.ConfVars#HIVE_CONF_LOCKED_LIST}
+ * This applies for the parameters defined through {@link 
HiveConf.ConfVars#HIVE_COMPACTOR_CONF_ALLOWLIST_APPEND}
+ * as well.
+ */
+final class CompactorPropertyValidator {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(CompactorPropertyValidator.class);
+  private static final Map<String, Pattern> ALLOW_PATTERN_CACHE = new 
ConcurrentHashMap<>();
+  private static final Map<String, Pattern> DENY_PATTERN_CACHE = new 
ConcurrentHashMap<>();
+
+  private static final Pattern MATCHES_NOTHING = Pattern.compile("(?!)");

Review Comment:
   "?!" is not a valid pattern, it will throw PatternSyntaxException when try 
to compile. The parenthesis is needed to get the "match nothing" pattern.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to