[ 
https://issues.apache.org/jira/browse/WW-5340?focusedWorklogId=881884&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-881884
 ]

ASF GitHub Bot logged work on WW-5340:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Sep/23 11:19
            Start Date: 26/Sep/23 11:19
    Worklog Time Spent: 10m 
      Work Description: 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)





Issue Time Tracking
-------------------

    Worklog Id:     (was: 881884)
    Time Spent: 2h 40m  (was: 2.5h)

> Introduce optional AST node exclusion list
> ------------------------------------------
>
>                 Key: WW-5340
>                 URL: https://issues.apache.org/jira/browse/WW-5340
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Kusal Kithul-Godage
>            Priority: Minor
>             Fix For: 6.4.0
>
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> Enhance security by implementing an optional exclusion list (in struts.xml) 
> where applications can specify AST nodes that are not required in their 
> applications or are known to carry higher security risk.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to