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

davsclaus pushed a commit to branch camel-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.18.x by this push:
     new 5fa277b8121c [backport camel-4.18.x] CAMEL-27049: camel-main - mask 
the server and vault options flagged secret (#30241)
5fa277b8121c is described below

commit 5fa277b8121cd68b5e97d5dc37208b4874eb9bd8
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Nov 16 23:10:05 2026 +0100

    [backport camel-4.18.x] CAMEL-27049: camel-main - mask the server and vault 
options flagged secret (#30241)
    
    Backport of #30204 to camel-4.18.x. UpdateSensitizeHelper also collects the
    camel-main options flagged secret, as whole keys, into SENSITIVE_WHOLE_KEYS 
in
    SensitiveUtils (and sensitive-whole-keys.json), which containsSensitive 
checks
    first. The server and management JWT keystore passwords and the Azure, GCP 
and
    IBM vault secrets are now masked in the auto-configuration summary. 
Component
    and endpoint options with the same name are not affected.
    
    Adapted: the generator change is ported by hand, the IBM vault options
    eventStreamUsername and eventStreamPassword are flagged secret (as on main),
    and MainSecurityPolicyTest is left out as the security policy is not on this
    branch.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../main/camel-main-configuration-metadata.json    |  4 +-
 .../camel/catalog/main/sensitive-whole-keys.json   | 23 ++++++
 .../catalog/SecretOptionsAreSensitiveKeysTest.java | 71 +++++++++++++++++
 .../vault/IBMSecretsManagerVaultConfiguration.java |  4 +-
 .../camel-main-configuration-metadata.json         |  4 +-
 .../MainAutoConfigurationSummaryMaskingTest.java   | 91 ++++++++++++++++++++++
 .../src/test/resources/summary-masking.properties  | 19 +++++
 .../java/org/apache/camel/util/SensitiveUtils.java | 39 +++++++++-
 .../org/apache/camel/util/SensitiveUtilsTest.java  | 31 ++++++++
 .../maven/packaging/UpdateSensitizeHelper.java     | 73 +++++++++++++----
 10 files changed, 336 insertions(+), 23 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index ee37ed2f9a5f..166aebc6d042 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -440,9 +440,9 @@
     { "name": "camel.vault.ibm.eventStreamBootstrapServers", "required": 
false, "description": "Specify the Bootstrap servers for consuming notification 
on IBM Event Stream. Multiple servers can be separated by comma.", 
"sourceType": "org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", 
"type": "string", "javaType": "java.lang.String", "secret": false },
     { "name": "camel.vault.ibm.eventStreamConsumerPollTimeout", "required": 
false, "description": "Specify the Consumer Poll Timeout while consuming from 
IBM Event Stream Topic", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": 
"integer", "javaType": "long", "defaultValue": 3000, "secret": false },
     { "name": "camel.vault.ibm.eventStreamGroupId", "required": false, 
"description": "Specify the Consumer Group ID to access IBM Event Stream", 
"sourceType": "org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", 
"type": "string", "javaType": "java.lang.String", "secret": false },
-    { "name": "camel.vault.ibm.eventStreamPassword", "required": false, 
"description": "Specify the password to access IBM Event Stream", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": false },
+    { "name": "camel.vault.ibm.eventStreamPassword", "required": false, 
"description": "Specify the password to access IBM Event Stream", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": true },
     { "name": "camel.vault.ibm.eventStreamTopic", "required": false, 
"description": "Specify the topic name for consuming notification on IBM Event 
Stream", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": false },
-    { "name": "camel.vault.ibm.eventStreamUsername", "required": false, 
"description": "Specify the username to access IBM Event Stream", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": false },
+    { "name": "camel.vault.ibm.eventStreamUsername", "required": false, 
"description": "Specify the username to access IBM Event Stream", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": true },
     { "name": "camel.vault.ibm.refreshEnabled", "required": false, 
"description": "Whether to automatically reload Camel upon secrets being 
updated in IBM.", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": 
"boolean", "javaType": "boolean", "defaultValue": false, "secret": false },
     { "name": "camel.vault.ibm.secrets", "required": false, "description": 
"Specify the secret names (or pattern) to check for updates. Multiple secrets 
can be separated by comma.", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": false },
     { "name": "camel.vault.ibm.serviceUrl", "required": false, "description": 
"Service URL to access IBM Secrets Manager vault", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": false },
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/sensitive-whole-keys.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/sensitive-whole-keys.json
new file mode 100644
index 000000000000..4886b3bcb5cd
--- /dev/null
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/sensitive-whole-keys.json
@@ -0,0 +1,23 @@
+[
+  "camel.lra.callbacksecret",
+  "camel.management.jwtkeystorepassword",
+  "camel.server.jwtkeystorepassword",
+  "camel.vault.aws.accesskey",
+  "camel.vault.aws.secretkey",
+  "camel.vault.azure.blobaccesskey",
+  "camel.vault.azure.clientid",
+  "camel.vault.azure.clientsecret",
+  "camel.vault.azure.eventhubconnectionstring",
+  "camel.vault.azure.tenantid",
+  "camel.vault.cyberark.apikey",
+  "camel.vault.cyberark.password",
+  "camel.vault.cyberark.username",
+  "camel.vault.gcp.serviceaccountkey",
+  "camel.vault.hashicorp.token",
+  "camel.vault.ibm.eventstreampassword",
+  "camel.vault.ibm.eventstreamusername",
+  "camel.vault.ibm.token",
+  "camel.vault.springconfig.password",
+  "camel.vault.springconfig.token",
+  "camel.vault.springconfig.username"
+]
diff --git 
a/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/SecretOptionsAreSensitiveKeysTest.java
 
b/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/SecretOptionsAreSensitiveKeysTest.java
new file mode 100644
index 000000000000..4004c1c081c3
--- /dev/null
+++ 
b/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/SecretOptionsAreSensitiveKeysTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.catalog;
+
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.camel.tooling.model.BaseOptionModel;
+import org.apache.camel.util.SensitiveUtils;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Every option flagged secret in the catalog must be a sensitive key, so its 
value is masked wherever Camel masks
+ * sensitive keys (such as the Camel Main auto-configuration summary).
+ */
+class SecretOptionsAreSensitiveKeysTest {
+
+    private static final CamelCatalog CATALOG = new DefaultCamelCatalog();
+
+    @Test
+    void everySecretMainOptionIsASensitiveKey() {
+        Set<String> missing = new TreeSet<>();
+        collectMissing("main", CATALOG.mainModel().getOptions(), missing);
+
+        assertTrue(missing.isEmpty(), "Secret options missing from the 
sensitive keys: " + missing);
+    }
+
+    @Test
+    void everySecretComponentDataFormatLanguageAndBeanOptionIsASensitiveKey() {
+        Set<String> missing = new TreeSet<>();
+        for (String name : CATALOG.findComponentNames()) {
+            collectMissing("component:" + name, 
CATALOG.componentModel(name).getComponentOptions(), missing);
+        }
+        for (String name : CATALOG.findDataFormatNames()) {
+            collectMissing("dataformat:" + name, 
CATALOG.dataFormatModel(name).getOptions(), missing);
+        }
+        for (String name : CATALOG.findLanguageNames()) {
+            collectMissing("language:" + name, 
CATALOG.languageModel(name).getOptions(), missing);
+        }
+        for (String name : CATALOG.findBeansNames()) {
+            collectMissing("bean:" + name, 
CATALOG.pojoBeanModel(name).getOptions(), missing);
+        }
+
+        assertTrue(missing.isEmpty(), "Secret options missing from the 
sensitive keys: " + missing);
+    }
+
+    private static void collectMissing(String owner, List<? extends 
BaseOptionModel> options, Set<String> missing) {
+        for (BaseOptionModel option : options) {
+            if (option.isSecret() && 
!SensitiveUtils.containsSensitive(option.getName())) {
+                missing.add(owner + " " + option.getName());
+            }
+        }
+    }
+}
diff --git 
a/core/camel-api/src/main/java/org/apache/camel/vault/IBMSecretsManagerVaultConfiguration.java
 
b/core/camel-api/src/main/java/org/apache/camel/vault/IBMSecretsManagerVaultConfiguration.java
index 0a8cdcc30af5..37b6de317c05 100644
--- 
a/core/camel-api/src/main/java/org/apache/camel/vault/IBMSecretsManagerVaultConfiguration.java
+++ 
b/core/camel-api/src/main/java/org/apache/camel/vault/IBMSecretsManagerVaultConfiguration.java
@@ -35,9 +35,9 @@ public class IBMSecretsManagerVaultConfiguration extends 
VaultConfiguration {
     private String eventStreamTopic;
     @Metadata
     private String eventStreamBootstrapServers;
-    @Metadata
+    @Metadata(secret = true)
     private String eventStreamUsername;
-    @Metadata
+    @Metadata(secret = true)
     private String eventStreamPassword;
     @Metadata
     private String eventStreamGroupId;
diff --git 
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
 
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index ee37ed2f9a5f..166aebc6d042 100644
--- 
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ 
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -440,9 +440,9 @@
     { "name": "camel.vault.ibm.eventStreamBootstrapServers", "required": 
false, "description": "Specify the Bootstrap servers for consuming notification 
on IBM Event Stream. Multiple servers can be separated by comma.", 
"sourceType": "org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", 
"type": "string", "javaType": "java.lang.String", "secret": false },
     { "name": "camel.vault.ibm.eventStreamConsumerPollTimeout", "required": 
false, "description": "Specify the Consumer Poll Timeout while consuming from 
IBM Event Stream Topic", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": 
"integer", "javaType": "long", "defaultValue": 3000, "secret": false },
     { "name": "camel.vault.ibm.eventStreamGroupId", "required": false, 
"description": "Specify the Consumer Group ID to access IBM Event Stream", 
"sourceType": "org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", 
"type": "string", "javaType": "java.lang.String", "secret": false },
-    { "name": "camel.vault.ibm.eventStreamPassword", "required": false, 
"description": "Specify the password to access IBM Event Stream", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": false },
+    { "name": "camel.vault.ibm.eventStreamPassword", "required": false, 
"description": "Specify the password to access IBM Event Stream", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": true },
     { "name": "camel.vault.ibm.eventStreamTopic", "required": false, 
"description": "Specify the topic name for consuming notification on IBM Event 
Stream", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": false },
-    { "name": "camel.vault.ibm.eventStreamUsername", "required": false, 
"description": "Specify the username to access IBM Event Stream", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": false },
+    { "name": "camel.vault.ibm.eventStreamUsername", "required": false, 
"description": "Specify the username to access IBM Event Stream", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": true },
     { "name": "camel.vault.ibm.refreshEnabled", "required": false, 
"description": "Whether to automatically reload Camel upon secrets being 
updated in IBM.", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": 
"boolean", "javaType": "boolean", "defaultValue": false, "secret": false },
     { "name": "camel.vault.ibm.secrets", "required": false, "description": 
"Specify the secret names (or pattern) to check for updates. Multiple secrets 
can be separated by comma.", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": false },
     { "name": "camel.vault.ibm.serviceUrl", "required": false, "description": 
"Service URL to access IBM Secrets Manager vault", "sourceType": 
"org.apache.camel.vault.IBMSecretsManagerVaultConfiguration", "type": "string", 
"javaType": "java.lang.String", "secret": false },
diff --git 
a/core/camel-main/src/test/java/org/apache/camel/main/MainAutoConfigurationSummaryMaskingTest.java
 
b/core/camel-main/src/test/java/org/apache/camel/main/MainAutoConfigurationSummaryMaskingTest.java
new file mode 100644
index 000000000000..969fd4c30a31
--- /dev/null
+++ 
b/core/camel-main/src/test/java/org/apache/camel/main/MainAutoConfigurationSummaryMaskingTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.main;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.LoggerConfig;
+import org.apache.logging.log4j.core.config.Property;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.parallel.Isolated;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@Isolated
+class MainAutoConfigurationSummaryMaskingTest {
+
+    private static final String LOGGER = BaseMainSupport.class.getName();
+
+    private final List<String> messages = new CopyOnWriteArrayList<>();
+    private AbstractAppender appender;
+
+    @BeforeEach
+    void addAppender() {
+        appender = new 
AbstractAppender("MainAutoConfigurationSummaryMaskingTest", null, null, true, 
Property.EMPTY_ARRAY) {
+            @Override
+            public void append(LogEvent event) {
+                messages.add(event.getMessage().getFormattedMessage());
+            }
+        };
+        appender.start();
+        LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+        Configuration config = ctx.getConfiguration();
+        LoggerConfig loggerConfig = new LoggerConfig(LOGGER, Level.INFO, true);
+        loggerConfig.addAppender(appender, Level.INFO, null);
+        config.addLogger(LOGGER, loggerConfig);
+        ctx.updateLoggers();
+    }
+
+    @AfterEach
+    void removeAppender() {
+        LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+        ctx.getConfiguration().removeLogger(LOGGER);
+        ctx.updateLoggers();
+        appender.stop();
+    }
+
+    @Test
+    void serverJwtKeystorePasswordIsMaskedInSummary() {
+        assertMaskedInSummary("camel.server.jwtKeystorePassword", 
"Keyst0reS3cr3t");
+    }
+
+    @Test
+    void vaultEventhubConnectionStringIsMaskedInSummary() {
+        assertMaskedInSummary("camel.vault.azure.eventhubConnectionString", 
"C0nnS3cr3t");
+    }
+
+    private void assertMaskedInSummary(String key, String value) {
+        Main main = new Main();
+        
main.setPropertyPlaceholderLocations("classpath:summary-masking.properties");
+        main.start();
+        try {
+            assertTrue(messages.stream().anyMatch(m -> m.contains(key + " = 
xxxxxx")), messages.toString());
+            assertTrue(messages.stream().noneMatch(m -> m.contains(value)), 
messages.toString());
+        } finally {
+            main.stop();
+        }
+    }
+}
diff --git a/core/camel-main/src/test/resources/summary-masking.properties 
b/core/camel-main/src/test/resources/summary-masking.properties
new file mode 100644
index 000000000000..0e4ad64be212
--- /dev/null
+++ b/core/camel-main/src/test/resources/summary-masking.properties
@@ -0,0 +1,19 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+camel.server.jwtKeystorePassword=Keyst0reS3cr3t
+camel.vault.azure.eventhubConnectionString=Endpoint=sb://myhub/;Key=C0nnS3cr3t
diff --git 
a/core/camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java 
b/core/camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java
index 425d2d39dc5f..29897fcc60cf 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java
@@ -117,6 +117,35 @@ public final class SensitiveUtils {
             // SENSITIVE-KEYS: END
             )));
 
+    // the camel-main options flagged secret, matched by their whole key in 
lower case without dashes, as a component can
+    // have an option with the same name that is not secret (such as tenantId)
+    private static final Set<String> SENSITIVE_WHOLE_KEYS = Set.of(
+            // Generated by camel build tools - do NOT edit this list!
+            // SENSITIVE-WHOLE-KEYS: START
+            "camel.lra.callbacksecret",
+            "camel.management.jwtkeystorepassword",
+            "camel.server.jwtkeystorepassword",
+            "camel.vault.aws.accesskey",
+            "camel.vault.aws.secretkey",
+            "camel.vault.azure.blobaccesskey",
+            "camel.vault.azure.clientid",
+            "camel.vault.azure.clientsecret",
+            "camel.vault.azure.eventhubconnectionstring",
+            "camel.vault.azure.tenantid",
+            "camel.vault.cyberark.apikey",
+            "camel.vault.cyberark.password",
+            "camel.vault.cyberark.username",
+            "camel.vault.gcp.serviceaccountkey",
+            "camel.vault.hashicorp.token",
+            "camel.vault.ibm.eventstreampassword",
+            "camel.vault.ibm.eventstreamusername",
+            "camel.vault.ibm.token",
+            "camel.vault.springconfig.password",
+            "camel.vault.springconfig.token",
+            "camel.vault.springconfig.username"
+    // SENSITIVE-WHOLE-KEYS: END
+    );
+
     private static final String SENSITIVE_PATTERN = ""
                                                     // Generated by camel 
build tools - do NOT edit this list!
                                                     // SENSITIVE-PATTERN: START
@@ -228,17 +257,23 @@ public final class SensitiveUtils {
 
     /**
      * Whether the given configuration property contains a sensitive key (such 
as password, accesstoken, etc.)
+     * <p>
+     * The camel-main options flagged secret (such as {@code 
camel.vault.azure.tenantId}) are matched by their whole
+     * key. Any other key is matched by its last part (the option name). The 
match ignores case and dashes.
      *
      * @param  text the configuration property
      * @return      true if sensitive, false otherwise
      */
     public static boolean containsSensitive(String text) {
+        text = text.toLowerCase(Locale.ENGLISH);
+        text = text.replace("-", "");
+        if (SENSITIVE_WHOLE_KEYS.contains(text)) {
+            return true;
+        }
         int lastPeriod = text.lastIndexOf('.');
         if (lastPeriod >= 0) {
             text = text.substring(lastPeriod + 1);
         }
-        text = text.toLowerCase(Locale.ENGLISH);
-        text = text.replace("-", "");
         return SENSITIVE_KEYS.contains(text);
     }
 
diff --git 
a/core/camel-util/src/test/java/org/apache/camel/util/SensitiveUtilsTest.java 
b/core/camel-util/src/test/java/org/apache/camel/util/SensitiveUtilsTest.java
index ec8cad0894c6..c9e17a9d7122 100644
--- 
a/core/camel-util/src/test/java/org/apache/camel/util/SensitiveUtilsTest.java
+++ 
b/core/camel-util/src/test/java/org/apache/camel/util/SensitiveUtilsTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.util;
 
 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;
 
@@ -55,4 +56,34 @@ class SensitiveUtilsTest {
         assertFalse(SensitiveUtils.containsSensitive("bar"));
     }
 
+    @Test
+    void serverAndVaultSecretOptionsAreSensitive() {
+        
assertTrue(SensitiveUtils.containsSensitive("camel.server.jwtKeystorePassword"));
+        
assertTrue(SensitiveUtils.containsSensitive("camel.management.jwtKeystorePassword"));
+        
assertTrue(SensitiveUtils.containsSensitive("camel.vault.azure.eventhubConnectionString"));
+        
assertTrue(SensitiveUtils.containsSensitive("camel.vault.azure.tenantId"));
+        
assertTrue(SensitiveUtils.containsSensitive("camel.vault.gcp.serviceAccountKey"));
+        
assertTrue(SensitiveUtils.containsSensitive("camel.vault.ibm.eventStreamUsername"));
+        
assertTrue(SensitiveUtils.containsSensitive("camel.vault.ibm.eventStreamPassword"));
+        // dash case
+        
assertTrue(SensitiveUtils.containsSensitive("camel.vault.azure.tenant-id"));
+        
assertTrue(SensitiveUtils.containsSensitive("camel.server.jwt-keystore-password"));
+        // as loaded from the environment variable 
CAMEL_VAULT_GCP_SERVICEACCOUNTKEY
+        
assertTrue(SensitiveUtils.containsSensitive("camel.vault.gcp.serviceaccountkey"));
+    }
+
+    @Test
+    void componentOptionsWithTheNameOfASecretMainOptionAreNotSensitive() {
+        // serviceAccountKey and tenantId are secret as camel.vault options 
only, and not as component options
+        
assertFalse(SensitiveUtils.containsSensitive("camel.component.google-pubsub.serviceAccountKey"));
+        
assertFalse(SensitiveUtils.containsSensitive("camel.component.azure-storage-datalake.tenantId"));
+        assertFalse(SensitiveUtils.containsSensitive("serviceAccountKey"));
+        assertFalse(SensitiveUtils.containsSensitive("tenantId"));
+        assertFalse(SensitiveUtils.containsSensitive("jwtKeystorePassword"));
+        
assertFalse(SensitiveUtils.containsSensitive("camel.vault.azure.tenantId.foo"));
+        // and an endpoint uri parameter with such a name is not masked
+        
assertEquals("azure-storage-datalake:myaccount?tenantId=mytenant&accountKey=xxxxxx",
+                
URISupport.sanitizeUri("azure-storage-datalake:myaccount?tenantId=mytenant&accountKey=mykey"));
+    }
+
 }
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSensitizeHelper.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSensitizeHelper.java
index 48a239825316..a4c91f27b7d2 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSensitizeHelper.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSensitizeHelper.java
@@ -19,8 +19,10 @@ package org.apache.camel.maven.packaging;
 import java.io.File;
 import java.nio.file.Path;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 import java.util.Set;
 import java.util.StringJoiner;
 import java.util.TreeSet;
@@ -32,6 +34,7 @@ import org.apache.camel.tooling.model.ComponentModel;
 import org.apache.camel.tooling.model.DataFormatModel;
 import org.apache.camel.tooling.model.JsonMapper;
 import org.apache.camel.tooling.model.LanguageModel;
+import org.apache.camel.tooling.model.PojoBeanModel;
 import org.apache.camel.tooling.util.PackageHelper;
 import org.apache.camel.tooling.util.Strings;
 import org.apache.camel.util.json.JsonArray;
@@ -53,6 +56,8 @@ public class UpdateSensitizeHelper extends 
AbstractGeneratorMojo {
 
     private static final String KEYS_START_TOKEN = "// SENSITIVE-KEYS: START";
     private static final String KEYS_END_TOKEN = "// SENSITIVE-KEYS: END";
+    private static final String WHOLE_KEYS_START_TOKEN = "// 
SENSITIVE-WHOLE-KEYS: START";
+    private static final String WHOLE_KEYS_END_TOKEN = "// 
SENSITIVE-WHOLE-KEYS: END";
     private static final String PATTERN_START_TOKEN = "// SENSITIVE-PATTERN: 
START";
     private static final String PATTERN_END_TOKEN = "// SENSITIVE-PATTERN: 
END";
 
@@ -63,6 +68,10 @@ public class UpdateSensitizeHelper extends 
AbstractGeneratorMojo {
                     "apipassword", "apiuser", "apiusername", "api_key", 
"api_secret", "callbacksecret", "secret",
                     "keystorePassword" };
 
+    // the camel-main configuration options (camel.server, camel.vault and 
others), whose secret options are matched by
+    // their whole key, as a component can have an option with the same name 
that is not secret (such as tenantId)
+    private static final String MAIN_METADATA = 
"camel-main-configuration-metadata.json";
+
     @Parameter(defaultValue = 
"${project.basedir}/src/generated/resources/org/apache/camel/catalog/")
     protected File jsonDir;
 
@@ -91,6 +100,8 @@ public class UpdateSensitizeHelper extends 
AbstractGeneratorMojo {
             jsonFiles = stream.toList();
         }
         Set<String> secrets = new TreeSet<>();
+        // the whole keys of the camel-main options flagged secret (such as 
camel.vault.azure.tenantid)
+        Set<String> wholeKeys = new TreeSet<>();
 
         for (Path file : jsonFiles) {
             final String name = PackageHelper.asName(file);
@@ -108,13 +119,39 @@ public class UpdateSensitizeHelper extends 
AbstractGeneratorMojo {
                 boolean isComponent = obj.getMap("component") != null;
                 boolean isDataFormat = !isComponent && 
obj.getMap("dataformat") != null;
                 boolean isLanguage = !isComponent && !isDataFormat && 
obj.getMap("language") != null;
+                boolean isBean = !isComponent && !isDataFormat && !isLanguage 
&& obj.getMap("bean") != null;
+                boolean isMain = 
MAIN_METADATA.equals(file.getFileName().toString());
 
                 // only check these kind
-                if (!isComponent && !isDataFormat && !isLanguage) {
+                if (!isComponent && !isDataFormat && !isLanguage && !isBean && 
!isMain) {
                     continue;
                 }
 
-                if (isComponent) {
+                if (isMain) {
+                    // the option names are whole keys (such as 
camel.server.jwtKeystorePassword)
+                    Collection<?> properties = obj.getCollection("properties");
+                    if (properties != null) {
+                        for (Object o : properties) {
+                            Map<?, ?> option = (Map<?, ?>) o;
+                            if (Boolean.TRUE.equals(option.get("secret"))) {
+                                // key should be lower and without dashes
+                                String key = 
option.get("name").toString().toLowerCase(Locale.ENGLISH);
+                                key = key.replace("-", "");
+                                wholeKeys.add(key);
+                            }
+                        }
+                    }
+                } else if (isBean) {
+                    PojoBeanModel pm = JsonMapper.generatePojoBeanModel(obj);
+                    pm.getOptions().forEach(o -> {
+                        if (o.isSecret()) {
+                            // key should be lower and without dashes
+                            String key = 
o.getName().toLowerCase(Locale.ENGLISH);
+                            key = key.replace("-", "");
+                            secrets.add(key);
+                        }
+                    });
+                } else if (isComponent) {
                     ComponentModel cm = 
JsonMapper.generateComponentModel(json);
                     cm.getComponentOptions().forEach(o -> {
                         if (o.isSecret()) {
@@ -154,10 +191,14 @@ public class UpdateSensitizeHelper extends 
AbstractGeneratorMojo {
         secrets.addAll(Arrays.asList(EXTRA_KEYS));
 
         getLog().info("There are " + secrets.size()
-                      + " distinct secret options across all the Camel 
components/dataformats/languages");
+                      + " distinct secret options across all the Camel 
components/dataformats/languages/beans, and "
+                      + wholeKeys.size() + " secret camel-main options");
 
         try {
-            boolean updated = updateSensitiveHelperKeys(camelDir, secrets);
+            boolean updated = updateSensitiveHelperKeys(camelDir, 
KEYS_START_TOKEN, KEYS_END_TOKEN, secrets,
+                    "                    ");
+            updated |= updateSensitiveHelperKeys(camelDir, 
WHOLE_KEYS_START_TOKEN, WHOLE_KEYS_END_TOKEN, wholeKeys,
+                    "            ");
             updated |= updateSensitiveHelperPatterns(camelDir, secrets);
             if (updated) {
                 getLog().info("Updated 
camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java file");
@@ -169,26 +210,28 @@ public class UpdateSensitizeHelper extends 
AbstractGeneratorMojo {
         }
 
         try {
-            updateSensitiveJsonSchema(baseDir, secrets);
+            updateSensitiveJsonSchema(baseDir, "sensitive-keys.json", secrets);
+            updateSensitiveJsonSchema(baseDir, "sensitive-whole-keys.json", 
wholeKeys);
         } catch (Exception e) {
-            throw new MojoExecutionException("Error updating 
sensitive-keys.json", e);
+            throw new MojoExecutionException("Error updating 
sensitive-keys.json or sensitive-whole-keys.json", e);
         }
     }
 
-    private boolean updateSensitiveHelperKeys(File camelDir, Set<String> 
secrets) throws Exception {
+    private boolean updateSensitiveHelperKeys(
+            File camelDir, String startToken, String endToken, Set<String> 
secrets, String indent)
+            throws Exception {
         // load source code and update
         File java = new File(camelDir, 
"src/main/java/org/apache/camel/util/SensitiveUtils.java");
         String text = PackageHelper.loadText(java);
-        String spaces20 = "                    ";
         String spaces12 = "            ";
 
         StringJoiner sb = new StringJoiner(",\n");
         for (String name : secrets) {
-            sb.add(spaces20 + "\"" + name + "\"");
+            sb.add(indent + "\"" + name + "\"");
         }
         String changed = sb.toString();
 
-        String existing = Strings.between(text, KEYS_START_TOKEN, 
KEYS_END_TOKEN);
+        String existing = Strings.between(text, startToken, endToken);
         if (existing != null) {
             // remove leading line breaks etc
             existing = existing.trim();
@@ -196,9 +239,9 @@ public class UpdateSensitizeHelper extends 
AbstractGeneratorMojo {
             if (existing.equals(changed)) {
                 return false;
             } else {
-                String before = Strings.before(text, KEYS_START_TOKEN);
-                String after = Strings.after(text, KEYS_END_TOKEN);
-                text = before + KEYS_START_TOKEN + "\n" + spaces20 + changed + 
"\n" + spaces12 + KEYS_END_TOKEN + after;
+                String before = Strings.before(text, startToken);
+                String after = Strings.after(text, endToken);
+                text = before + startToken + "\n" + indent + changed + "\n" + 
spaces12 + endToken + after;
                 PackageHelper.writeText(java, text);
                 return true;
             }
@@ -249,8 +292,8 @@ public class UpdateSensitizeHelper extends 
AbstractGeneratorMojo {
         return false;
     }
 
-    private void updateSensitiveJsonSchema(File camelDir, Set<String> secrets) 
throws Exception {
-        File target = new File(camelDir, 
"src/generated/resources/org/apache/camel/catalog/main/sensitive-keys.json");
+    private void updateSensitiveJsonSchema(File camelDir, String fileName, 
Set<String> secrets) throws Exception {
+        File target = new File(camelDir, 
"src/generated/resources/org/apache/camel/catalog/main/" + fileName);
         JsonArray arr = new JsonArray();
         arr.addAll(secrets);
         String json = JsonMapper.serialize(arr);

Reply via email to