Warxim commented on code in PR #26:
URL: https://github.com/apache/commons-jxpath/pull/26#discussion_r1003005419


##########
src/main/java/org/apache/commons/jxpath/ri/JXPathFilter.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.commons.jxpath.ri;
+
+/**
+ * Class filter (optional) to be used by JXPath.
+ *
+ * System property "jxpath.class.allow" can be set to specify the list of 
allowed classnames.
+ * This property takes a list of java classnames (use comma as separator to 
specify more than one class).
+ * If this property is not set, it exposes no java classes
+ * Ex: jxpath.class.allow=java.lang.Runtime will allow exposing 
java.lang.Runtime class via xpath, while all other
+ * classes will be not exposed. You can use the wildcard (*) to allow all 
classes.
+ * @since 1.4
+ */
+public interface JXPathFilter {

Review Comment:
   We might also consider creating two implementations:
   - one for allowing all paths by default (with huge security warning in 
javadoc) - it will always return `true`
   - one for programmatically defining allowed classNames, e.g. 
`CustomJXPathFilter` (with the `Set<String> allowedClasses` as constructor 
parameter). Most of the code from `SystemPropertyJXPathFilter` can be then 
moved to abstract class and be used in both CustomJXPathFilter and 
SystemPropertyJXPathFilter. In `CustomJXPathFilter`, we might just call 
`super(Collections.unmodifiableSet(allowedClasses));` and in 
`SystemPropertyJXPathFilter`, we might just call 
`super(loadAllowedClassesFromSystemProperty());`.



##########
src/main/java/org/apache/commons/jxpath/ri/JXPathFilter.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.commons.jxpath.ri;
+
+/**
+ * Class filter (optional) to be used by JXPath.
+ *
+ * System property "jxpath.class.allow" can be set to specify the list of 
allowed classnames.
+ * This property takes a list of java classnames (use comma as separator to 
specify more than one class).
+ * If this property is not set, it exposes no java classes
+ * Ex: jxpath.class.allow=java.lang.Runtime will allow exposing 
java.lang.Runtime class via xpath, while all other
+ * classes will be not exposed. You can use the wildcard (*) to allow all 
classes.
+ * @since 1.4
+ */
+public interface JXPathFilter {

Review Comment:
   We might also consider creating two implementations:
   - One for allowing all paths by default (with huge security warning in 
javadoc) - it will always return `true`.
   - One for programmatically defining allowed classNames, e.g. 
`CustomJXPathFilter` (with the `Set<String> allowedClasses` as constructor 
parameter). Most of the code from `SystemPropertyJXPathFilter` can be then 
moved to abstract class and be used in both CustomJXPathFilter and 
SystemPropertyJXPathFilter. In `CustomJXPathFilter`, we might just call 
`super(Collections.unmodifiableSet(allowedClasses));` and in 
`SystemPropertyJXPathFilter`, we might just call 
`super(loadAllowedClassesFromSystemProperty());`.



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to