You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/07/28 17:31:31 UTC

[camel] branch main updated: CAMEL-19676: camel-core: Do not log sensitive endpoint uri, if route … (#10889)

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

davsclaus 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 283c82add0a CAMEL-19676: camel-core: Do not log sensitive endpoint uri, if route … (#10889)
283c82add0a is described below

commit 283c82add0a1a1bd60455579055bd16f88dcdac3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 28 19:31:24 2023 +0200

    CAMEL-19676: camel-core: Do not log sensitive endpoint uri, if route … (#10889)
    
    CAMEL-19676: camel-core: Do not log sensitive endpoint uri, if route failed to be created.
---
 .../java/org/apache/camel/model/SendDefinition.java     | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/SendDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/SendDefinition.java
index 36f765ac64a..21392205b79 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/SendDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/SendDefinition.java
@@ -24,6 +24,7 @@ import jakarta.xml.bind.annotation.XmlTransient;
 import org.apache.camel.Endpoint;
 import org.apache.camel.builder.EndpointProducerBuilder;
 import org.apache.camel.spi.Metadata;
+import org.apache.camel.util.URISupport;
 
 /**
  * Sends the message to an endpoint
@@ -32,6 +33,8 @@ import org.apache.camel.spi.Metadata;
 public abstract class SendDefinition<Type extends ProcessorDefinition<Type>> extends NoOutputDefinition<Type>
         implements EndpointRequiredDefinition {
 
+    @XmlTransient
+    private String endpointUriToString;
     @XmlTransient
     protected Endpoint endpoint;
     @XmlTransient
@@ -106,11 +109,23 @@ public abstract class SendDefinition<Type extends ProcessorDefinition<Type>> ext
 
     @Override
     public String getLabel() {
-        String uri = getEndpointUri();
+        if (endpointUriToString == null) {
+            String value = null;
+            try {
+                value = getEndpointUri();
+            } catch (RuntimeException e) {
+                // ignore any exception and use null for building the string value
+            }
+            // ensure to sanitize uri so we do not show sensitive information such as passwords
+            endpointUriToString = URISupport.sanitizeUri(value);
+        }
+
+        String uri = endpointUriToString;
         return uri != null ? uri : "no uri supplied";
     }
 
     protected void clear() {
+        this.endpointUriToString = null;
         this.endpointProducerBuilder = null;
         this.endpoint = null;
         this.uri = null;