This is an automated email from the ASF dual-hosted git repository.
Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 7abf13b2b314 CAMEL-24455: camel-platform-http - select proxy mode by
the exact path, not by prefix (#25833)
7abf13b2b314 is described below
commit 7abf13b2b314f40b8e76af3ba655266b57ff5e20
Author: Andrea Cosentino <[email protected]>
AuthorDate: Fri Aug 28 11:13:51 2026 +0200
CAMEL-24455: camel-platform-http - select proxy mode by the exact path, not
by prefix (#25833)
isHttpProxy() tested path.startsWith(PROXY_PATH), so any endpoint whose
path merely began
with "proxy" - proxyStats, proxy-health, proxying - was treated as the
documented
platform-http:proxy endpoint. That is not only a naming curiosity:
getPath() returns "/"
for such an endpoint, making it a catch-all, and
VertxPlatformHttpConsumer.handleProxy()
sets Exchange.HTTP_HOST from the request's own Host header so a bridging
producer
forwards there. A route author naming an endpoint proxyStats got a
catch-all whose
forward target came from the caller.
Compare for equality. The check is deliberately strict rather than
tolerating a leading
slash: platform-http:/proxy did not select proxy mode before and still does
not, so
tightening this can never turn an endpoint into a proxy that was not
already one. The
test asserts that, so the check is not loosened later by mistake.
Every platform-http:proxy usage in the tree - the component docs,
PlatformHttpProxyTest,
VertxPlatformHttpProxyTest, VertxPlatformHttpsProxyTest - already uses the
exact path.
Signed-off-by: Andrea Cosentino <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Federico Mariani <[email protected]>
---
.../platform/http/PlatformHttpEndpoint.java | 10 +++-
.../http/PlatformHttpEndpointProxyPathTest.java | 65 ++++++++++++++++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_23.adoc | 16 ++++++
3 files changed, 90 insertions(+), 1 deletion(-)
diff --git
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java
index 61e8af2103de..01a57379a351 100644
---
a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java
+++
b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java
@@ -327,8 +327,16 @@ public class PlatformHttpEndpoint extends DefaultEndpoint
: getComponent().getOrCreateEngine();
}
+ /**
+ * Whether this endpoint is the documented {@code platform-http:proxy}
endpoint.
+ * <p>
+ * Compared for equality rather than as a prefix. Proxy mode makes {@link
#getPath()} return {@code "/"}, turning
+ * the endpoint into a catch-all, and the consumer then takes the forward
target from the request's own {@code Host}
+ * header - so a path that merely begins with "proxy", such as {@code
proxyStats}, would become a forwarding proxy
+ * its author never asked for.
+ */
public boolean isHttpProxy() {
- return this.path.startsWith(PROXY_PATH);
+ return PROXY_PATH.equals(this.path);
}
public boolean isReturnHttpRequestHeaders() {
diff --git
a/components/camel-platform-http/src/test/java/org/apache/camel/component/platform/http/PlatformHttpEndpointProxyPathTest.java
b/components/camel-platform-http/src/test/java/org/apache/camel/component/platform/http/PlatformHttpEndpointProxyPathTest.java
new file mode 100644
index 000000000000..5d2e4b39d526
--- /dev/null
+++
b/components/camel-platform-http/src/test/java/org/apache/camel/component/platform/http/PlatformHttpEndpointProxyPathTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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 org.apache.camel.component.platform.http;
+
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Proxy mode makes the endpoint a catch-all whose forward target comes from
the request's own Host header. Selecting it
+ * by prefix meant any path merely beginning with "proxy" became a forwarding
proxy its author never asked for.
+ */
+class PlatformHttpEndpointProxyPathTest {
+
+ @Test
+ void onlyTheProxyPathSelectsProxyMode() throws Exception {
+ assertTrue(isProxy("platform-http:proxy"));
+
+ // a leading slash did not select proxy mode before the check was
tightened, and still does not:
+ // narrowing the check must never turn an endpoint into a proxy that
was not already one
+ assertFalse(isProxy("platform-http:/proxy"));
+
+ assertFalse(isProxy("platform-http:proxyStats"));
+ assertFalse(isProxy("platform-http:proxy-health"));
+ assertFalse(isProxy("platform-http:proxying"));
+ assertFalse(isProxy("platform-http:/orders"));
+ }
+
+ @Test
+ void aNonProxyPathIsNotTurnedIntoACatchAll() throws Exception {
+ try (DefaultCamelContext context = new DefaultCamelContext()) {
+ context.start();
+ PlatformHttpComponent component = new
PlatformHttpComponent(context);
+ PlatformHttpEndpoint endpoint
+ = (PlatformHttpEndpoint)
component.createEndpoint("platform-http:proxyStats");
+
+ assertEquals("proxyStats", endpoint.getPath());
+ }
+ }
+
+ private static boolean isProxy(String uri) throws Exception {
+ try (DefaultCamelContext context = new DefaultCamelContext()) {
+ context.start();
+ PlatformHttpComponent component = new
PlatformHttpComponent(context);
+ return ((PlatformHttpEndpoint)
component.createEndpoint(uri)).isHttpProxy();
+ }
+ }
+}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
index ed3c9483a505..8cfe4267a2f3 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
@@ -544,6 +544,22 @@ is truncated rather than recreated and would otherwise
keep its original permiss
Deployments where another account legitimately reads these files — a sidecar
or a backup agent running as
a different user — need to run as the owner, or use a group-aware key store
instead.
+=== camel-platform-http
+
+`PlatformHttpEndpoint.isHttpProxy()` selected proxy mode with
`path.startsWith("proxy")` rather than an
+equality check, so any endpoint whose path merely began with those five
characters — `proxyStats`,
+`proxy-health`, `proxying` — was treated as the documented
`platform-http:proxy` endpoint. That has
+consequences beyond the name: `getPath()` returns `/` for such an endpoint,
making it a catch-all, and
+`VertxPlatformHttpConsumer.handleProxy()` sets `Exchange.HTTP_HOST` from the
request's own `Host` header
+so a bridging producer forwards there. A route author naming an endpoint
`proxyStats` therefore got a
+catch-all whose forward target came from the caller.
+
+Proxy mode is now selected only by the exact path `proxy`. The check is
deliberately strict:
+`platform-http:/proxy`, with a leading slash, did not select proxy mode before
and still does not, so
+this can never turn an endpoint into a proxy that was not already one.
+
+Routes relying on the prefix match must be renamed to the exact path `proxy`.
+
=== camel-grpc
The gRPC consumer no longer returns the route exception's message to the
client.