oscerd opened a new pull request, #30332:
URL: https://github.com/apache/camel/pull/30332

   ## Summary
   
   [CAMEL-27161](https://issues.apache.org/jira/browse/CAMEL-27161)
   
   The security policy (`camel.security.*`, which fails startup with 
`camel.main.profile=prod`) checked the `camel.*` configuration properties only. 
The beans that a YAML or XML route file defines in its `beans` section were not 
checked: with the prod profile, `camel.beans.opaPolicy.failOpen=true` in 
`application.properties` fails startup, while the same `failOpen: true` on a 
YAML bean started, and the bean had `failOpen=true` (checked with `camel run` 
on 4.23.0).
   
   The YAML and XML DSL (and the Spring XML and Blueprint XML handlers of 
camel-kamelet-main) register the beans of a route file as a 
`BeanFactoryDefinition` in the model (`Model.addCustomBean`). Once the routes 
are loaded, camel-main now checks the properties of these beans with 
`SecurityUtils.detectViolations`, under the key of a bean configured from 
properties, `camel.beans.<name>.<property>`:
   
   - the option matching is the one of `camel.beans.*` properties, and 
`camel.security.allowedProperties` takes the same key
   - nested properties are checked as `camel.beans.<name>.<key>.<nestedKey>`
   - the violations are added to `SecurityPolicyResult`, so the security policy 
health check reports them with those of the configuration properties
   - `enforceSecurityPolicies` is split into `detectSecurityViolations` and 
`applySecurityPolicies`, which the bean check reuses; nothing changes for the 
configuration properties
   
   The YAML and XML beans are already created when the configuration properties 
are checked (the route files are pre-parsed during the auto-configuration), but 
the beans of a Java `RouteBuilder` only reach the model when the routes are 
configured, so one check after `configureRoutes()` covers both.
   
   Not covered here:
   
   - the options set in the endpoint URIs of routes (such as 
`opa:authz/allow?failOpen=true`) are still not checked. The security policy 
page now says so, and route-level URI scanning is in the Future Work of 
`design/security.adoc`
   - camel-spring-boot has its own check 
(`CamelSecurityPolicyAutoConfiguration`), which reads the `camel.*` properties 
of the Spring environment, so the beans of route files are not checked there 
either
   
   ## Behaviour change
   
   A bean in a route file that sets an insecure option or a plain-text secret 
is now reported: a warning by default, and the startup fails with 
`camel.main.profile=prod`. The 4.24 upgrade guide has an entry.
   
   ## Tests
   
   - `MainSecurityPolicyBeansTest` (camel-main): an insecure option and a 
plain-text secret on a bean of a route fail the startup, with the policy set to 
`fail` and with the prod profile; a secure value, a secret from a placeholder 
and an allowed key start; a nested property is checked; a warned bean property 
is reported in `SecurityPolicyResult` after the configuration property
   - `MainSecurityPolicyBeansTest` (camel-yaml-dsl) and 
`XmlMainSecurityPolicyBeansTest` (camel-xml-io-dsl): a YAML and an XML route 
file with a bean that sets `trustAllCertificates=true`, with 
`camel.main.profile=prod`: the startup fails, and starts when the key is in 
`camel.security.allowedProperties`
   - camel-main (366 tests) and camel-xml-io-dsl (74 tests) pass; in 
camel-yaml-dsl the new tests, `MainTest` and `CallNestedKameletTest` pass; the 
full reactor install (`-DskipTests`) passes
   - revert check: without the new check, 5 of the 8 camel-main tests and the 
prod-profile test of the YAML and XML modules fail, as the startup no longer 
fails and only the configuration property is reported
   
   ## Docs
   
   - `security-policy.adoc`: the properties of the beans of route files are 
checked, with the key to allow one, and the endpoint URI options are not
   - `design/security.adoc`: the runtime detection step
   - `camel-4x-upgrade-guide-4_24.adoc`: the behaviour change
   
   _Claude Code on behalf of oscerd_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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