This is an automated email from the ASF dual-hosted git repository.
cshannon pushed a commit to branch activemq-5.19.x
in repository https://gitbox.apache.org/repos/asf/activemq.git
The following commit(s) were added to refs/heads/activemq-5.19.x by this push:
new 0a15814b36 Minor bug fix for BrokerView#validateAllowedUri (#1900)
(#1903)
0a15814b36 is described below
commit 0a15814b3627e346d126a473ae1117805c2cb336
Author: Christopher L. Shannon <[email protected]>
AuthorDate: Sat Apr 11 09:31:12 2026 -0400
Minor bug fix for BrokerView#validateAllowedUri (#1900) (#1903)
The wrong variable is being referenced in the nested loop. This does not
cause the validation to actually break due to other checks done during
the recursive call, but is incorrect either way. With this fix the
counter needed tweaking for limiting the number of nested components as
well.
Follow on to #1847
(cherry picked from commit b787b0ed11cf1b7444b0a3904398fea5dc16179b)
---
.../src/main/java/org/apache/activemq/broker/jmx/BrokerView.java | 7 ++++---
.../src/test/java/org/apache/activemq/jmx/JmxCreateNCTest.java | 9 +++++++--
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
index 0416333547..b4b3d28003 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
@@ -570,7 +570,8 @@ public class BrokerView implements BrokerViewMBean {
// Validate the URI does not contain VM transport
private static void validateAllowedUri(URI uri, int depth) throws
URISyntaxException {
// Don't allow more than 5 nested URIs to prevent blowing the stack
- if (depth > 5) {
+ // If we are greater than 4 then this is the 5th level of composite
+ if (depth > 4) {
throw new IllegalArgumentException("URI can't contain more than 5
nested composite URIs");
}
@@ -585,10 +586,10 @@ public class BrokerView implements BrokerViewMBean {
// Each URI could be a nested composite URI so call
validateAllowedUri()
// to validate it. This check if composite first so we don't
add to
// the recursive stack depth if there's a lot of URIs that are
not composite
- if (URISupport.isCompositeURI(uri)) {
+ if (URISupport.isCompositeURI(component)) {
validateAllowedUri(component, depth);
} else {
- validateAllowedScheme(uri.getScheme());
+ validateAllowedScheme(component.getScheme());
}
}
}
diff --git
a/activemq-unit-tests/src/test/java/org/apache/activemq/jmx/JmxCreateNCTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/jmx/JmxCreateNCTest.java
index 141e5c0ee8..1b3548432b 100644
---
a/activemq-unit-tests/src/test/java/org/apache/activemq/jmx/JmxCreateNCTest.java
+++
b/activemq-unit-tests/src/test/java/org/apache/activemq/jmx/JmxCreateNCTest.java
@@ -116,11 +116,16 @@ public class JmxCreateNCTest {
@Test
public void testAddNetworkConnectorMaxComposite() throws Exception {
+ // Should allow 5 nested (excludes first wrapper) so no exception
thrown
+ assertNotNull(proxy.addNetworkConnector(
+
"static:(static:(static:(static:(static:(bad://localhost)))))"));
+
try {
- // verify nested composite URI with more than 5 levels is blocked
+ // verify nested composite URI with more than 5 levels is blocked.
This has 6 nested
+ // (not including first wrapper url
proxy.addNetworkConnector(
"static:(failover:(failover:(failover:(failover:(failover:(tcp://localhost:0))))))");
- fail("Should have failed trying to add vm connector bridge");
+ fail("Should have failed trying to add more than 5 connector
bridges");
} catch (IllegalArgumentException e) {
assertEquals("URI can't contain more than 5 nested composite
URIs", e.getMessage());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact