Croway commented on code in PR #30204:
URL: https://github.com/apache/camel/pull/30204#discussion_r4586814458


##########
tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSensitizeHelper.java:
##########
@@ -154,13 +157,23 @@ public void execute() throws MojoExecutionException {
                 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) {

Review Comment:
   **Same root cause on the insecure side: four camel-main `insecure:dev` 
options are still never reported**
   
   This branch collects only the secret options from the camel-main metadata. 
Four options flagged `security=insecure:dev` there are not in `SecurityUtils`, 
so the security policy never reports them:
   
   - `camel.management.mcpEnabled`
   - `camel.management.openapiUiEnabled`
   - `camel.server.jwtAllowMissingIssuerAndAudience`
   - `camel.management.jwtAllowMissingIssuerAndAudience`
   
   The camel-main options that are reported (`devConsoleEnabled`, 
`uploadEnabled`, `downloadEnabled`, `sendEnabled`) come from the 
hand-maintained `EXTRA_SECURITY_OPTIONS`.
   
   Same camel-main run, with `camel.main.profile=prod`:
   
   | plus | bd3f02f (PR) and 90293a9 (base) |
   |---|---|
   | `camel.management.devConsoleEnabled=true` (control) | fails: 
`[insecure:dev] Insecure configuration detected ... 
[camel.management.devConsoleEnabled]` |
   | `camel.management.mcpEnabled=true` | starts |
   | `camel.management.openapiUiEnabled=true` | starts |
   | `camel.server.jwtAllowMissingIssuerAndAudience=true` | starts |
   | `camel.management.jwtAllowMissingIssuerAndAudience=true` | starts |
   
   This is not a regression from this PR. It is the CAMEL-27049 root cause in 
the other half of the generator: the main metadata is now read, but only for 
secrets. Collecting the main options that have a `security` category here too 
would pick up these four, and new ones, without adding them to 
`EXTRA_SECURITY_OPTIONS` by hand. A follow-up is fine if you prefer to keep 
this PR to secrets.
   
   _Claude Code on behalf of Croway_



##########
tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSensitizeHelper.java:
##########
@@ -154,13 +157,23 @@ public void execute() throws MojoExecutionException {
                 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 full keys (such as 
camel.server.jwtKeystorePassword)
+                    MainModel mm = JsonMapper.generateMainModel(obj);
+                    mm.getOptions().forEach(
+                            o -> collectSecretOption(o, 
o.getName().substring(o.getName().lastIndexOf('.') + 1), secrets));

Review Comment:
   **`serviceaccountkey` and `tenantid` become sensitive for every component 
option with that name, and a prod app using a Google or Azure component no 
longer starts**
   
   `SensitiveUtils.containsSensitive` matches only the last part of the key, 
against one list shared by everything. So a name that is secret only under 
`camel.vault.*` now also matches component options that are not secret:
   
   - `serviceAccountKey`: 18 Google components declare it (11 of them as a 
component option), all with `secret=false`. On these components it is a 
resource location: "It can be loaded by default from classpath, but you can 
prefix with classpath:, file:, or http:".
   - `tenantId`: `azure-functions` and `azure-storage-datalake` declare it as a 
component option with `secret=false`. Only the `azure-key-vault` endpoint flags 
it secret.
   
   `camel.main.profile=prod` sets the security policy to `fail`, so such an app 
now fails at startup. I ran camel-main with two stub components bound as 
`google-pubsub` and `azure-storage-datalake`, which have the same option names:
   
   | `camel.main.profile=prod` plus | bd3f02f (PR) | 90293a9 (base) |
   |---|---|---|
   | nothing (control) | starts | starts |
   | `camel.component.google-pubsub.serviceAccountKey=classpath:sa.json` | 
fails: `[secret] Secret property is configured with plain-text value ... 
[camel.component.google-pubsub.serviceAccountKey]` | starts |
   | 
`camel.component.azure-storage-datalake.tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47`
 | fails: `[secret] ... [camel.component.azure-storage-datalake.tenantId]` | 
starts |
   | `camel.vault.gcp.serviceAccountKey=file:/etc/gcp/sa.json` | fails: 
`[secret] ... [camel.vault.gcp.serviceAccountKey]` | starts |
   
   Without the prod profile, each of these logs a `SECURITY WARNING` at 
startup. The summary also shows `xxxxxx` instead of the file path.
   
   The last row is in the scope of this PR, but 
`camel.vault.gcp.serviceAccountKey` is documented as "The Service Account Key 
location". A file path is not a plain-text secret, and the policy cannot tell 
the two apart.
   
   The insecure options already avoid this kind of spill. 
`SECURITY_OPTION_OWNERS` limits a name to the components that declare it (see 
`MainSecurityPolicyTest.testOptionWithSameNameAsInsecureOptionOfAnotherComponent`
 for `tls`), and `SECURITY_KEYS` matches `camel.chaos.rules` by its whole key. 
A suggestion: generate the camel-main secret options as a set of whole keys 
(for example `camel.vault.azure.tenantid`) and check that set in 
`SensitiveUtils.containsSensitive` before the last-part match. That masks 
`camel.vault.azure.tenantId` without touching `camel.component.*.tenantId`. It 
may also be worth checking whether `camel.vault.gcp.serviceAccountKey` should 
be `secret=true` at all, since it holds a location.
   
   _Claude Code on behalf of Croway_



##########
docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc:
##########
@@ -46,6 +46,18 @@ the route is not yet stopped when the control bus step 
returns.
 The webhook consumer still logs the body it validates at `DEBUG`, but no 
longer the signature from the `X-Signature` header, nor the signature it 
calculates.
 The `InvalidMessageSignatureException` of a failed check no longer carries the 
calculated signature: `getCalculatedSignature()` returns `null` and is 
deprecated, as is the constructor that takes it.
 
+=== camel-main - the server and vault options flagged secret are sensitive keys
+
+The options `camel.server.jwtKeystorePassword`, 
`camel.management.jwtKeystorePassword`,
+`camel.vault.azure.eventhubConnectionString`, `camel.vault.azure.tenantId`, 
`camel.vault.gcp.serviceAccountKey`,
+`camel.vault.ibm.eventStreamUsername` and 
`camel.vault.ibm.eventStreamPassword` are flagged secret, and are now also
+sensitive keys, like the other secret options. The Camel Main 
auto-configuration summary shows their value as `xxxxxx`,
+and an endpoint URI parameter with one of these names, such as `tenantId`, is 
masked in sanitized URIs.
+
+The `camel.security.secretPolicy` check now also reports these options when 
they are configured as plain text,
+including a value set through an environment variable: a warning by default, 
and the startup fails with
+`camel.main.profile=prod`. Configure them with a property placeholder or a 
vault reference instead.

Review Comment:
   **The guide lists only the seven camel-main options, but the change reaches 
every component option with the same name**
   
   Because the keys match on the last part of the name (see the comment on 
`UpdateSensitizeHelper`), the users most affected are not those who set these 
seven options. They are the users of the Google components 
(`camel.component.google-*.serviceAccountKey`) and of `azure-functions` / 
`azure-storage-datalake` (`camel.component.*.tenantId`). With 
`camel.main.profile=prod`, their app no longer starts, and the upgrade guide 
does not mention them.
   
   If the matching stays as it is, could this section name those component 
options too? It should also give the ways out: a `{{...}}` placeholder, or 
adding the key to `camel.security.allowedProperties`. A file location such as 
`classpath:sa.json` is not something users expect to have to move behind a 
placeholder.
   
   _Claude Code on behalf of Croway_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to