This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch jbang-trace in repository https://gitbox.apache.org/repos/asf/camel.git
commit b1d6ce1e6d897e0d12edc278ac87359db21387d1 Author: Claus Ibsen <[email protected]> AuthorDate: Sat Jul 29 17:29:49 2023 +0200 CAMEL-19369: camel-jbang - Trace command to show endpoint uri --- .../dsl/jbang/core/commands/action/CamelTraceAction.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelTraceAction.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelTraceAction.java index 9c1799584a6..e9269b91ca5 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelTraceAction.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelTraceAction.java @@ -42,6 +42,7 @@ import org.apache.camel.util.IOHelper; import org.apache.camel.util.StopWatch; import org.apache.camel.util.StringHelper; import org.apache.camel.util.TimeUtils; +import org.apache.camel.util.URISupport; import org.apache.camel.util.json.JsonArray; import org.apache.camel.util.json.JsonObject; import org.apache.camel.util.json.Jsoner; @@ -137,6 +138,10 @@ public class CamelTraceAction extends ActionBaseCommand { description = "Only output traces from the latest (follow if necessary until complete and exit)") boolean latest; + @CommandLine.Option(names = { "--mask" }, + description = "Whether to mask endpoint URIs to avoid printing sensitive information such as password or access keys") + boolean mask; + @CommandLine.Option(names = { "--pretty" }, description = "Pretty print message body when using JSon or XML format") boolean pretty; @@ -421,6 +426,14 @@ public class CamelTraceAction extends ActionBaseCommand { row.location = jo.getString("location"); row.routeId = jo.getString("routeId"); row.nodeId = jo.getString("nodeId"); + String uri = jo.getString("endpointUri"); + if (uri != null) { + row.endpoint = new JsonObject(); + if (mask) { + uri = URISupport.sanitizeUri(uri); + } + row.endpoint.put("endpoint", uri); + } Long ts = jo.getLong("timestamp"); if (ts != null) { row.timestamp = ts; @@ -696,7 +709,7 @@ public class CamelTraceAction extends ActionBaseCommand { } private String getDataAsTable(Row r) { - return tableHelper.getDataAsTable(r.exchangeId, r.exchangePattern, null, r.message, r.exception); + return tableHelper.getDataAsTable(r.exchangeId, r.exchangePattern, r.endpoint, r.message, r.exception); } private String getElapsed(Row r) { @@ -780,6 +793,7 @@ public class CamelTraceAction extends ActionBaseCommand { long elapsed; boolean done; boolean failed; + JsonObject endpoint; JsonObject message; JsonObject exception;
