This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/struts-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new ceda7ce3fc Automatic Site Publish by Buildbot
ceda7ce3fc is described below

commit ceda7ce3fc655563e894e63d5efb27647e4d0e83
Author: buildbot <[email protected]>
AuthorDate: Tue Dec 1 19:55:50 2026 +0000

    Automatic Site Publish by Buildbot
---
 output/core-developers/default-properties.html |  5 ++
 output/plugins/plugins-architecture.html       |  8 ++-
 output/security/index.html                     | 79 +++++++++++++++++++++++++-
 3 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/output/core-developers/default-properties.html 
b/output/core-developers/default-properties.html
index da990d3768..ffc64896e7 100644
--- a/output/core-developers/default-properties.html
+++ b/output/core-developers/default-properties.html
@@ -443,6 +443,11 @@ struts.ognl.disallowCustomOgnlMap=true
 # struts.ognl.valueStackFallbackToContext=false
 # 
struts.ognl.excludedNodeTypes=ognl.ASTRootVarRef,ognl.ASTThisVarRef,ognl.ASTVarRef
 
+### Selects the org.apache.struts2.ognl.OgnlNodeGuard asked about each node of 
an OGNL expression, on top of
+### struts.ognl.excludedNodeTypes. A guard is always in place: when this is 
not set, the default one is used,
+### which allows every node. Set it to a class name, a bean name or an id 
known to the object factory.
+# struts.ognl.nodeGuard=com.example.MyNodeGuard
+
 ### Whether to enable OGNL allowlist, protects against critical 
vulnerabilities, strongly recommended to keep enabled!
 struts.allowlist.enable=true
 ### Whether to require @StrutsParameter annotations on Action parameter 
injection methods
diff --git a/output/plugins/plugins-architecture.html 
b/output/plugins/plugins-architecture.html
index e120110c60..c432714997 100644
--- a/output/plugins/plugins-architecture.html
+++ b/output/plugins/plugins-architecture.html
@@ -486,10 +486,16 @@ For example, a plugin could provide a new class to create 
Action classes or map
     </tr>
     <tr>
       <td>struts.ognlGuard</td>
-      <td>Define a custom OgnlGuard implementation to block raw or compiled 
OGNL expressions (since 6.4.0)</td>
+      <td>Define a custom OgnlGuard implementation to block raw or compiled 
OGNL expressions (since 6.4.0, deprecated since 7.6.0)</td>
       <td>singleton</td>
       <td>org.apache.struts2.ognl.OgnlGuard</td>
     </tr>
+    <tr>
+      <td>struts.ognl.nodeGuard</td>
+      <td>Define a custom OgnlNodeGuard implementation, asked about each node 
of an OGNL expression before it is evaluated (since 7.6.0)</td>
+      <td>singleton</td>
+      <td>org.apache.struts2.ognl.OgnlNodeGuard</td>
+    </tr>
     <tr>
       <td>struts.securityMemberAccess</td>
       <td>Define a custom SecurityMemberAccess implementation, used to 
restrict OGNL evaluations based on classes involved (since 6.4.0)</td>
diff --git a/output/security/index.html b/output/security/index.html
index 7202499358..354a38bdfe 100644
--- a/output/security/index.html
+++ b/output/security/index.html
@@ -720,11 +720,84 @@ Please be aware that this list WILL break certain Struts 
features.</p>
 "</span><span class="nt">/&gt;</span>
 </code></pre></div></div>
 
+<p>Since Struts 7.6.0 the excluded node types are checked twice: when an 
expression is parsed, as before, and again by
+OGNL itself right before the expression is evaluated. The second check also 
covers an expression that was not parsed
+by the framework’s own <code class="language-plaintext 
highlighter-rouge">OgnlUtil</code>.</p>
+
 <h4 id="extensibility-1">Extensibility</h4>
 
-<p>The Struts OGNL Guard mechanism is extensible, allowing you to define your 
own rules for blocking access to both raw
-OGNL expressions and compiled syntax trees. To do so, you may use the <code 
class="language-plaintext highlighter-rouge">struts.ognlGuard</code> extension 
point. You may choose
-to override the default implementation or implement the <code 
class="language-plaintext highlighter-rouge">OgnlGuard</code> interface 
directly.</p>
+<blockquote>
+  <p>Note: since Struts 7.6.0.</p>
+</blockquote>
+
+<p>A list of node types cannot express every rule. <code 
class="language-plaintext highlighter-rouge">ognl.ASTCtor</code>, for instance, 
stands for both <code class="language-plaintext highlighter-rouge">new 
Foo()</code> and
+<code class="language-plaintext highlighter-rouge">new int[10]</code>, so 
excluding it forbids both. For a rule that depends on what a node contains, 
implement
+<code class="language-plaintext 
highlighter-rouge">org.apache.struts2.ognl.OgnlNodeGuard</code> and select it 
with the <code class="language-plaintext 
highlighter-rouge">struts.ognl.nodeGuard</code> constant. The guard is asked
+about every node of an expression before any part of it is evaluated; 
returning <code class="language-plaintext highlighter-rouge">false</code> for 
one node refuses the whole
+expression.</p>
+
+<p>Extending OGNL’s <code class="language-plaintext 
highlighter-rouge">ognl.NodeVisitorGuard</code> gives one <code 
class="language-plaintext highlighter-rouge">visit</code> method per node type, 
each allowing the node unless
+overridden:</p>
+
+<div class="language-java highlighter-rouge"><div class="highlight"><pre 
class="highlight"><code><span class="kd">public</span> <span 
class="kd">class</span> <span class="nc">NoArrayCreationGuard</span> <span 
class="kd">extends</span> <span class="nc">NodeVisitorGuard</span> <span 
class="kd">implements</span> <span class="nc">OgnlNodeGuard</span> <span 
class="o">{</span>
+
+    <span class="nd">@Override</span>
+    <span class="kd">public</span> <span class="nc">Boolean</span> <span 
class="nf">visit</span><span class="o">(</span><span class="nc">ASTCtor</span> 
<span class="n">node</span><span class="o">,</span> <span 
class="nc">Void</span> <span class="n">data</span><span class="o">)</span> 
<span class="o">{</span>
+        <span class="k">return</span> <span class="o">!</span><span 
class="n">node</span><span class="o">.</span><span 
class="na">isArray</span><span class="o">();</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</code></pre></div></div>
+
+<p>Set the constant to the class name:</p>
+
+<div class="language-xml highlighter-rouge"><div class="highlight"><pre 
class="highlight"><code><span class="nt">&lt;constant</span> <span 
class="na">name=</span><span class="s">"struts.ognl.nodeGuard"</span> <span 
class="na">value=</span><span 
class="s">"com.example.NoArrayCreationGuard"</span><span class="nt">/&gt;</span>
+</code></pre></div></div>
+
+<p>or declare a bean and refer to it by name:</p>
+
+<div class="language-xml highlighter-rouge"><div class="highlight"><pre 
class="highlight"><code><span class="nt">&lt;bean</span> <span 
class="na">type=</span><span 
class="s">"org.apache.struts2.ognl.OgnlNodeGuard"</span> <span 
class="na">name=</span><span class="s">"noArrayCreation"</span> <span 
class="na">class=</span><span 
class="s">"com.example.NoArrayCreationGuard"</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;constant</span> <span class="na">name=</span><span 
class="s">"struts.ognl.nodeGuard"</span> <span class="na">value=</span><span 
class="s">"noArrayCreation"</span><span class="nt">/&gt;</span>
+</code></pre></div></div>
+
+<p>The two settings add up:</p>
+
+<table>
+  <thead>
+    <tr>
+      <th>Setting</th>
+      <th>What it does</th>
+      <th>Default</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr>
+      <td><code class="language-plaintext 
highlighter-rouge">struts.ognl.excludedNodeTypes</code></td>
+      <td>Refuses every node of a listed type</td>
+      <td>empty, no node type is refused</td>
+    </tr>
+    <tr>
+      <td><code class="language-plaintext 
highlighter-rouge">struts.ognl.nodeGuard</code></td>
+      <td>Selects the <code class="language-plaintext 
highlighter-rouge">OgnlNodeGuard</code> asked about every other node</td>
+      <td><code class="language-plaintext 
highlighter-rouge">StrutsNodeGuard</code>, which allows them</td>
+    </tr>
+  </tbody>
+</table>
+
+<p>A custom guard is applied on top of <code class="language-plaintext 
highlighter-rouge">struts.ognl.excludedNodeTypes</code>, it does not replace 
the list, and it cannot allow
+a node type the list excludes.</p>
+
+<p>A guard is a singleton and is called from many threads. OGNL asks it once 
per parsed expression and remembers the
+answer, so a guard must give the same answer for the same node every time: 
decide from the node, its children and its
+parents only, never from the request, the user or any other state that 
changes.</p>
+
+<p><code class="language-plaintext highlighter-rouge">OgnlNodeGuard</code> is 
the only type an application implements. <code class="language-plaintext 
highlighter-rouge">StrutsNodeGuard</code> is the default implementation, and
+<code class="language-plaintext highlighter-rouge">ContextNodeGuard</code> is 
the internal class that combines the list with the selected guard.</p>
+
+<h5 id="before-struts-760">Before Struts 7.6.0</h5>
+
+<p>The <code class="language-plaintext 
highlighter-rouge">struts.ognlGuard</code> extension point and the <code 
class="language-plaintext highlighter-rouge">OgnlGuard</code> interface let an 
application define its own rules for
+blocking both raw OGNL expressions and parsed syntax trees. They are 
deprecated since Struts 7.6.0 and will be removed
+in Struts 8.0.0; they keep working until then.</p>
 
   </section>
 </article>

Reply via email to