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

markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/11.0.x by this push:
     new 0a19a7be0c Deprecate RemoteAddr[Filter|Valve] in favour of 
RemoteCIDR[Filter|Valve]
0a19a7be0c is described below

commit 0a19a7be0c6aaf30ad1a5260abb26f87b56998c4
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Oct 8 10:20:05 2025 +0100

    Deprecate RemoteAddr[Filter|Valve] in favour of RemoteCIDR[Filter|Valve]
---
 RUNNING.txt                                                 |  4 ++--
 java/org/apache/catalina/filters/RemoteAddrFilter.java      |  3 +++
 java/org/apache/catalina/valves/RemoteAddrValve.java        |  3 +++
 test/org/apache/catalina/mapper/TestMapperWebapps.java      |  4 ++--
 test/org/apache/catalina/valves/TestRequestFilterValve.java |  1 +
 webapps/docs/META-INF/context.xml                           |  4 ++--
 webapps/docs/changelog.xml                                  |  5 +++++
 webapps/docs/config/context.xml                             |  4 ++--
 webapps/docs/config/engine.xml                              |  4 ++--
 webapps/docs/config/filter.xml                              |  5 +++++
 webapps/docs/config/host.xml                                |  6 +++---
 webapps/docs/config/valve.xml                               |  5 +++++
 webapps/docs/manager-howto.xml                              | 10 +++++-----
 webapps/docs/security-howto.xml                             |  4 ++--
 webapps/examples/META-INF/context.xml                       |  4 ++--
 webapps/host-manager/META-INF/context.xml                   |  4 ++--
 webapps/host-manager/WEB-INF/manager.xml                    |  4 ++--
 webapps/manager/META-INF/context.xml                        |  4 ++--
 18 files changed, 50 insertions(+), 28 deletions(-)

diff --git a/RUNNING.txt b/RUNNING.txt
index 4a7aee9037..18c2032e67 100644
--- a/RUNNING.txt
+++ b/RUNNING.txt
@@ -305,8 +305,8 @@ The file will look like the following:
   <?xml version="1.0" encoding="UTF-8"?>
   <Context docBase="${catalina.home}/webapps/manager"
     antiResourceLocking="false" privileged="true" >
-    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
-         allow="127\.0\.0\.1" />
+  <Valve className="org.apache.catalina.valves.RemoteCIDRValve"
+         allow="127.0.0.0/8,::1/128" />
     <Manager 
sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
   </Context>
 
diff --git a/java/org/apache/catalina/filters/RemoteAddrFilter.java 
b/java/org/apache/catalina/filters/RemoteAddrFilter.java
index f335795c03..1752132a3d 100644
--- a/java/org/apache/catalina/filters/RemoteAddrFilter.java
+++ b/java/org/apache/catalina/filters/RemoteAddrFilter.java
@@ -29,7 +29,10 @@ import org.apache.juli.logging.LogFactory;
 /**
  * Concrete implementation of <code>RequestFilter</code> that filters based on 
the string representation of the remote
  * client's IP address.
+ *
+ * @deprecated This Filter will be removed in Tomcat 12 onwards. Use {@link 
RemoteCIDRFilter} instead.
  */
+@Deprecated
 public final class RemoteAddrFilter extends RequestFilter {
 
     // Log must be non-static as loggers are created per class-loader and this
diff --git a/java/org/apache/catalina/valves/RemoteAddrValve.java 
b/java/org/apache/catalina/valves/RemoteAddrValve.java
index de34f763e4..bd128c10b1 100644
--- a/java/org/apache/catalina/valves/RemoteAddrValve.java
+++ b/java/org/apache/catalina/valves/RemoteAddrValve.java
@@ -30,7 +30,10 @@ import org.apache.juli.logging.LogFactory;
 /**
  * Concrete implementation of <code>RequestFilterValve</code> that filters 
based on the string representation of the
  * remote client's IP address optionally combined with the server connector 
port number.
+ *
+ * @deprecated This Valve will be removed in Tomcat 12 onwards. Use {@link 
RemoteCIDRValve} instead.
  */
+@Deprecated
 public final class RemoteAddrValve extends RequestFilterValve {
 
     private static final Log log = LogFactory.getLog(RemoteAddrValve.class);
diff --git a/test/org/apache/catalina/mapper/TestMapperWebapps.java 
b/test/org/apache/catalina/mapper/TestMapperWebapps.java
index 39b4b64e1b..52722e605d 100644
--- a/test/org/apache/catalina/mapper/TestMapperWebapps.java
+++ b/test/org/apache/catalina/mapper/TestMapperWebapps.java
@@ -32,7 +32,7 @@ import org.junit.Test;
 import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
-import org.apache.catalina.valves.RemoteAddrValve;
+import org.apache.catalina.valves.RemoteHostValve;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.descriptor.web.SecurityCollection;
 import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
@@ -297,7 +297,7 @@ public class TestMapperWebapps extends TomcatBaseTest {
         org.apache.catalina.Context examples = tomcat.addWebapp(null, 
"/examples", examplesDir.getAbsolutePath());
         examples.setMapperContextRootRedirectEnabled(false);
         // Then block access to the examples to test redirection
-        RemoteAddrValve rav = new RemoteAddrValve();
+        RemoteHostValve rav = new RemoteHostValve();
         rav.setDeny(".*");
         rav.setDenyStatus(404);
         examples.getPipeline().addValve(rav);
diff --git a/test/org/apache/catalina/valves/TestRequestFilterValve.java 
b/test/org/apache/catalina/valves/TestRequestFilterValve.java
index 47ca0fca93..5caeb951c4 100644
--- a/test/org/apache/catalina/valves/TestRequestFilterValve.java
+++ b/test/org/apache/catalina/valves/TestRequestFilterValve.java
@@ -105,6 +105,7 @@ public class TestRequestFilterValve {
         }
     }
 
+    @SuppressWarnings("deprecation")
     private void oneTest(String allow, String deny, boolean denyStatus, 
boolean addConnectorPort,
             boolean usePeerAddress, boolean auth, String property, String 
type, boolean allowed) {
         // PREPARE
diff --git a/webapps/docs/META-INF/context.xml 
b/webapps/docs/META-INF/context.xml
index ce7bd255d6..a5ac67f392 100644
--- a/webapps/docs/META-INF/context.xml
+++ b/webapps/docs/META-INF/context.xml
@@ -16,6 +16,6 @@
   limitations under the License.
 -->
 <Context antiResourceLocking="false" ignoreAnnotations="true">
-  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
-         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
+  <Valve className="org.apache.catalina.valves.RemoteCIDRValve"
+         allow="127.0.0.0/8,::1/128" />
 </Context>
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 0e6e8d2010..d1753c6286 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -117,6 +117,11 @@
         Log warnings when the SSO configuration does not comply with the
         documentation. (remm)
       </fix>
+      <update>
+        Deprecate the <code>RemoteAddrFilter</code> and
+        <code>RemoteAddValve</code> in favour of the
+        <code>RemoteCIDRFilter</code> and <code>RemoteCIDRValve</code>. (markt)
+      </update>
     </changelog>
   </subsection>
   <subsection name="Coyote">
diff --git a/webapps/docs/config/context.xml b/webapps/docs/config/context.xml
index a05d9d0145..73716fe508 100644
--- a/webapps/docs/config/context.xml
+++ b/webapps/docs/config/context.xml
@@ -1269,8 +1269,8 @@
   ...
   <Valve className="org.apache.catalina.valves.RemoteHostValve"
          allow=".*\.mycompany\.com|www\.yourcompany\.com"/>
-  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
-         deny="192\.168\.1\.\d+"/>
+  <Valve className="org.apache.catalina.valves.RemoteCIDRValve"
+         deny="192.168.1.0/24"/>
   ...
 </Context>]]></source>
 
diff --git a/webapps/docs/config/engine.xml b/webapps/docs/config/engine.xml
index 7180e34bc4..44b6f10cc8 100644
--- a/webapps/docs/config/engine.xml
+++ b/webapps/docs/config/engine.xml
@@ -242,8 +242,8 @@
   ...
   <Valve className="org.apache.catalina.valves.RemoteHostValve"
          allow=".*\.mycompany\.com|www\.yourcompany\.com"/>
-  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
-         deny="192\.168\.1\.\d+"/>
+  <Valve className="org.apache.catalina.valves.RemoteCIDRValve"
+         deny="192.168.1.0/24"/>
   ...
 </Engine>]]></source>
 
diff --git a/webapps/docs/config/filter.xml b/webapps/docs/config/filter.xml
index 5bd820db93..a439437635 100644
--- a/webapps/docs/config/filter.xml
+++ b/webapps/docs/config/filter.xml
@@ -1131,6 +1131,11 @@ FINE: Request "/docs/config/manager.html" with response 
status "200"
     <code>::1</code>. Consult your access logs for the actual value.</p>
 
     <p>See also: <a href="#Remote_Host_Filter">Remote Host Filter</a>.</p>
+
+    <p><strong>Note:</strong> This Filter is deprecated and will be removed in
+    Tomcat 12. Use the <a href="#Remote_CIDR_Filter">Remote CIDR Filter</a>
+    instead.</p>
+
   </subsection>
 
   <subsection name="Filter Class Name">
diff --git a/webapps/docs/config/host.xml b/webapps/docs/config/host.xml
index ce4dc50656..204dd6b144 100644
--- a/webapps/docs/config/host.xml
+++ b/webapps/docs/config/host.xml
@@ -275,7 +275,7 @@
         a descriptor is located at <code>/META-INF/context.xml</code> and no
         descriptor is present in <strong>xmlBase</strong> then the context will
         fail to start in case the descriptor contains necessary configuration
-        for secure deployment (such as a RemoteAddrValve) which should not be
+        for secure deployment (such as a RemoteCIDRValve) which should not be
         ignored. The default is <code>true</code>.</p>
       </attribute>
 
@@ -549,8 +549,8 @@
   ...
   <Valve className="org.apache.catalina.valves.RemoteHostValve"
          allow=".*\.mycompany\.com|www\.yourcompany\.com"/>
-  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
-         deny="192\.168\.1\.\d+"/>
+  <Valve className="org.apache.catalina.valves.RemoteCIDRValve"
+         deny="192.168.1.0/24"/>
   ...
 </Host>]]></source>
 
diff --git a/webapps/docs/config/valve.xml b/webapps/docs/config/valve.xml
index 802ed1d5e4..2024463a4d 100644
--- a/webapps/docs/config/valve.xml
+++ b/webapps/docs/config/valve.xml
@@ -667,6 +667,11 @@
     <a href="#Remote_CIDR_Valve">Remote CIDR Valve</a>,
     <a href="#Remote_IP_Valve">Remote IP Valve</a>,
     <a href="http.html">HTTP Connector</a> configuration.</p>
+
+    <p><strong>Note:</strong> This Valve is deprecated and will be removed in
+    Tomcat 12. Use <a href="#Remote_CIDR_Valve">Remote CIDR Valve</a>
+    instead.</p>
+
   </subsection>
 
   <subsection name="Attributes">
diff --git a/webapps/docs/manager-howto.xml b/webapps/docs/manager-howto.xml
index 02e0650422..3bd65b9536 100644
--- a/webapps/docs/manager-howto.xml
+++ b/webapps/docs/manager-howto.xml
@@ -76,8 +76,8 @@ example:</p>
          docBase="${catalina.home}/webapps/manager">
   <CookieProcessor 
className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
                    sameSiteCookies="strict" />
-  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
-         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
+  <Valve className="org.apache.catalina.valves.RemoteCIDRValve"
+         allow="127.0.0.0/8,::1/128" />
   <Manager 
sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
 </Context>]]></source>
 
@@ -204,13 +204,13 @@ the role <strong>manager-script</strong>.</p>
 
 <p>In addition to the password restrictions, access to the Manager web
 application can be restricted by the <strong>remote IP address</strong> or host
-by adding a <code>RemoteAddrValve</code> or <code>RemoteHostValve</code>.
+by adding a <code>RemoteCIDRValve</code> or <code>RemoteHostValve</code>.
 See <a href="config/valve.html#Remote_Address_Filter">valves documentation</a>
 for details. Here is
 an example of restricting access to the localhost by IP address:</p>
 <source><![CDATA[<Context privileged="true">
-         <Valve className="org.apache.catalina.valves.RemoteAddrValve"
-                allow="127\.0\.0\.1"/>
+  <Valve className="org.apache.catalina.valves.RemoteCIDRValve"
+         allow="127.0.0.0/8,::1/128" />
 </Context>]]></source>
 
 </section>
diff --git a/webapps/docs/security-howto.xml b/webapps/docs/security-howto.xml
index 990cf2ae46..acd15059b4 100644
--- a/webapps/docs/security-howto.xml
+++ b/webapps/docs/security-howto.xml
@@ -169,7 +169,7 @@
        <li>Do not remove the use of the <a
            
href="config/realm.html#LockOut_Realm_-_org.apache.catalina.realm.LockOutRealm">LockOutRealm</a>
            which prevents brute force attacks against user passwords.</li>
-       <li>Configure the <a 
href="config/valve.html#Remote_Address_Valve">RemoteAddrValve</a>
+       <li>Configure the <a 
href="config/valve.html#Remote_CIDR_Valve">RemoteCIDRValve</a>
            in the <a href="config/context.html">context.xml</a> file for the
            management application which limits access to localhost by default.
            If remote access is required, limit it to specific IP addresses 
using
@@ -431,7 +431,7 @@
       context as required.</p>
 
       <p>Any administrative application should be protected by a
-      RemoteAddrValve (this Valve is also available as a Filter).
+      RemoteCIDRValve (this Valve is also available as a Filter).
       The <strong>allow</strong> attribute should be used to limit access to a
       set of known trusted hosts.</p>
 
diff --git a/webapps/examples/META-INF/context.xml 
b/webapps/examples/META-INF/context.xml
index 611394516d..46ad272a04 100644
--- a/webapps/examples/META-INF/context.xml
+++ b/webapps/examples/META-INF/context.xml
@@ -18,6 +18,6 @@
 <Context ignoreAnnotations="true">
   <CookieProcessor 
className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
                    sameSiteCookies="strict" />
-  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
-         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
+  <Valve className="org.apache.catalina.valves.RemoteCIDRValve"
+         allow="127.0.0.0/8,::1/128" />
 </Context>
diff --git a/webapps/host-manager/META-INF/context.xml 
b/webapps/host-manager/META-INF/context.xml
index 6074c87a5e..9247872edf 100644
--- a/webapps/host-manager/META-INF/context.xml
+++ b/webapps/host-manager/META-INF/context.xml
@@ -18,7 +18,7 @@
 <Context antiResourceLocking="false" privileged="true" 
ignoreAnnotations="true">
   <CookieProcessor 
className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
                    sameSiteCookies="strict" />
-  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
-         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
+  <Valve className="org.apache.catalina.valves.RemoteCIDRValve"
+         allow="127.0.0.0/8,::1/128" />
   <Manager 
sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
 </Context>
\ No newline at end of file
diff --git a/webapps/host-manager/WEB-INF/manager.xml 
b/webapps/host-manager/WEB-INF/manager.xml
index a26dca6542..25c9b526e5 100644
--- a/webapps/host-manager/WEB-INF/manager.xml
+++ b/webapps/host-manager/WEB-INF/manager.xml
@@ -24,7 +24,7 @@
          privileged="true" antiResourceLocking="false" >
   <CookieProcessor 
className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
                    sameSiteCookies="strict" />
-  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
-         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
+  <Valve className="org.apache.catalina.valves.RemoteCIDRValve"
+         allow="127.0.0.0/8,::1/128" />
   <Manager 
sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
 </Context>
diff --git a/webapps/manager/META-INF/context.xml 
b/webapps/manager/META-INF/context.xml
index e88e00d485..bb968a2115 100644
--- a/webapps/manager/META-INF/context.xml
+++ b/webapps/manager/META-INF/context.xml
@@ -18,7 +18,7 @@
 <Context antiResourceLocking="false" privileged="true" 
ignoreAnnotations="true">
   <CookieProcessor 
className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
                    sameSiteCookies="strict" />
-  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
-         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
+  <Valve className="org.apache.catalina.valves.RemoteCIDRValve"
+         allow="127.0.0.0/8,::1/128" />
   <Manager 
sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
 </Context>


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

Reply via email to