lukaszlenart commented on code in PR #747:
URL: https://github.com/apache/struts/pull/747#discussion_r1337046041
##########
core/src/main/java/org/apache/struts2/StrutsConstants.java:
##########
@@ -234,6 +234,8 @@ public final class StrutsConstants {
/** The name of the parameter to determine whether static field access
will be allowed in OGNL expressions or not */
public static final String STRUTS_ALLOW_STATIC_FIELD_ACCESS =
"struts.ognl.allowStaticFieldAccess";
+ public static final String STRUTS_OGNL_GUARD = "struts.ognlGuard";
Review Comment:
What about `struts.ognl.guard` to keep everything in the same _namespace_?
##########
core/src/main/java/com/opensymphony/xwork2/ognl/OgnlGuard.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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 com.opensymphony.xwork2.ognl;
+
+import ognl.Ognl;
+import ognl.OgnlException;
+
+/**
+ * Guards all expressions parsed by Struts Core. It is evaluated by {@link
OgnlUtil} immediately after parsing any
+ * expression.
+ *
+ * @since 6.4.0
+ */
+public interface OgnlGuard {
+
+ String GUARD_BLOCKED = "_ognl_guard_blocked";
Review Comment:
Wouldn't be better to name this `EXPRESSION_BLOCKED`? This sounds like the
guard itself has been blocked.
##########
core/src/main/resources/struts-beans.xml:
##########
@@ -166,6 +166,8 @@
class="com.opensymphony.xwork2.validator.DefaultValidatorFileParser"/>
<bean class="com.opensymphony.xwork2.ognl.OgnlUtil"/>
+ <bean type="com.opensymphony.xwork2.ognl.OgnlGuard" name="struts"
+ class="com.opensymphony.xwork2.ognl.StrutsOgnlGuard" />
Review Comment:
Just missed that, I prefer to use `org.apache.struts2.ognl` namespace as
`com.opensymphony.xwork2` should be removed at some point (in 7.x)
--
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]