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

   # CAMEL-27773: camel-alibaba-eventbridge - reject CloudEvent extensions that 
reuse reserved attribute names
   
   ## Problem
   
   When the body sent to the `alibaba-eventbridge` producer is a `CloudEvent` 
instance, the producer
   validates the event's `source` and `type` (its dedicated fields) against the 
configured
   `allowedEventSources` / cloud validation and then hands the same object to 
the Alibaba SDK. The SDK
   serializes a request by flattening every entry of the CloudEvent 
`extensions` map up to a top-level
   attribute, overwriting any dedicated attribute of the same name. As a 
result, a `CloudEvent` whose
   `extensions` map contains a key that reuses a reserved CloudEvents core 
attribute name (for example
   `source` or `type`) is published with a `source`/`type` taken from the 
extension rather than from the
   dedicated field the producer validated. The value that is validated and the 
value that is published
   can therefore differ.
   
   Only the `CloudEvent`-object body path is affected. The `Map` and JSON-text 
body paths build a fresh
   event from named keys and are not affected.
   
   ## Change
   
   `MapCloudEventValidator.validateCloudEvent` now rejects, with an 
`IllegalArgumentException`, a
   `CloudEvent` whose `extensions` map contains a key equal to a reserved 
CloudEvents core attribute name
   (`id`, `source`, `specversion`, `type`, `datacontenttype`, `dataschema`, 
`subject`, `time`, `data`).
   These are exactly the names the SDK serializes from the dedicated 
`CloudEvent` fields and would
   otherwise flatten over. The Alibaba-specific `aliyuneventbusname` extension 
(how the bus name is
   carried, and what the validator reads back) and any other non-reserved 
extension keep working. This
   keeps the value that is validated equal to the value that is published.
   
   ## Tests
   
   Added to `MapCloudEventValidationTest`:
   
   - `cloudEventExtensionNamedSourceIsRejected` - a `CloudEvent` carrying a 
`source` extension is rejected.
   - `cloudEventExtensionNamedTypeIsRejected` - a `CloudEvent` carrying a 
`type` extension is rejected.
   - `cloudEventWithNonReservedExtensionIsAccepted` - a `CloudEvent` with a 
non-reserved extension (plus
     the bus-name extension) is still accepted.
   
   The upgrade guide (`camel-4x-upgrade-guide-4_25.adoc`) documents the new 
rejection as a 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