CAMEL-24419: camel-mail - filter the mail session property namespace on MimeMultipart unmarshal - #25568
Conversation
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 11 tested, 28 compile-only — current: 10 all testedMaveniverse Scalpel detected 39 affected modules (current approach: 10).
|
gnodet
left a comment
There was a problem hiding this comment.
LGTM — clean, minimal security fix.
This correctly aligns MimeMultipartDataFormat's header filtering with the mail consumer's filtering from CAMEL-23522. Key observations:
- Strategy swap is correct:
MailHeaderFilterStrategy.initialize()only callssetInFilterStartsWith()for the inbound direction, so the marshal/outbound path is unaffected headerFilterStrategyusage is safe: the field is used solely incopyNonStandardHeaders()→applyFilterToExternalHeaders()(inbound direction)- Case handling:
DefaultHeaderFilterStrategyhaslowerCase=trueby default, so the uppercaseMAIL.SMTP.PORTtest case works correctly via lowercase comparison - Test follows conventions: uses AssertJ, package-private visibility per project standards
- Upgrade guide entry: well-written with clear migration advice in
camel-4x-upgrade-guide-4_23.adoc
All CI checks pass. ✅
AI-generated review — Claude Code on behalf of @gnodet
This review does not replace specialized AI review tools or static analysis.
b58ca3a to
7aecf94
Compare
…on MimeMultipart unmarshal CAMEL-23522 extended MailHeaderFilterStrategy so the inbound path also filters the mail.smtp. and mail.smtps. prefixes, not just Camel*/camel*, so an external mail message cannot inject JavaMail session properties onto the exchange. MimeMultipartDataFormat, which CAMEL-23891 gave a header filter for the Camel* namespace, still held a plain DefaultHeaderFilterStrategy. That strategy only knows Camel*/camel*, so the namespace CAMEL-23522 deliberately filters on the consumer path was not filtered by the headersInline unmarshal path. Switches the data format to MailHeaderFilterStrategy so both entry points agree on the filtered namespace. The swap is confined to the inbound direction: MailHeaderFilterStrategy.initialize() only calls setInFilterStartsWith(), so the out filter keeps the DefaultHeaderFilterStrategy default, and the strategy is used at exactly one site in the data format (copyNonStandardHeaders, which calls applyFilterToExternalHeaders). Marshal behaviour is unchanged. Adds a test next to the existing CAMEL-23891 one, and a 4.23 upgrade-guide entry. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
7aecf94 to
67ee2c8
Compare
Fixes CAMEL-24419.
Problem
CAMEL-23522 extended
MailHeaderFilterStrategyso the inbound path also filters themail.smtp.andmail.smtps.prefixes, not justCamel*/camel*:MimeMultipartDataFormat— which CAMEL-23891 gave a header filter for theCamel*namespace — still held a plainDefaultHeaderFilterStrategy, which only knowsCamel*/camel*. So the namespace CAMEL-23522 deliberately filters on the consumer path was not filtered by theheadersInlineunmarshal path. Two entry points into the same component disagreed about the filtered namespace.Change
One-line swap to
MailHeaderFilterStrategy. I checked two things first to keep the blast radius honest:MailHeaderFilterStrategy.initialize()only callssetInFilterStartsWith(...)— it never touches the out filter, which keepsDefaultHeaderFilterStrategy's field default. Marshal behaviour is unchanged.copyNonStandardHeaders()→applyFilterToExternalHeaders(), which is the inbound direction.So the change does precisely one thing: unmarshal now filters the same namespace as the consumer.
Testing
New test sits next to the existing CAMEL-23891
unmarshalInlineHeadersFiltersCamelInternalHeaders. Verified it catches the regression: it fails against the pre-fix code and passes after.Backport
Intended for camel-4.22.x, camel-4.18.x and camel-4.14.x, matching the CAMEL-23891 backports. The upgrade-guide entry stays on
mainper the project's guide policy._Claude Code on behalf of