Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,8 @@ private static void validateAllowedUrl(String uriString) throws URISyntaxExcepti
// 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");
}

Expand All @@ -625,10 +626,10 @@ private static void validateAllowedUri(URI uri, int depth) throws URISyntaxExcep
// 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());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,16 @@ public void testVmBridgeBlocked() throws Exception {

@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());
}
Expand Down