gnodet-bot commented on PR #31193:
URL: https://github.com/apache/camel/pull/31193#issuecomment-7348253016

   Supplementary note on the `tryAddEntityResolver` implementation:
   
   **`SAXParserFactory` per call (medium):** `SAXParserFactory.newInstance()` 
performs service-loader classpath scanning and `newSAXParser()` allocates a new 
parser on every invocation of `tryAddEntityResolver`. On a high-throughput 
route with reader-less `SAXSource` bodies, this executes on every exchange. The 
Saxon side of the codebase solves this with a static `SecureReaderPoolHolder` — 
`SAXParserFactory` is thread-safe after configuration; only the `XMLReader` 
must be new per call. Consider caching the factory as a `private static final` 
field.
   
   **XMLReader hardening (supporting davsclaus's point 2):** With only 
`FEATURE_SECURE_PROCESSING`, the JDK parser doesn't block external entity 
fetching for entities the resolver returns `null` for. Saxon's secure reader 
pool also disables `external-general-entities`, `external-parameter-entities`, 
and `LOAD_EXTERNAL_DTD`. Defence-in-depth, since the user has opted in to 
entity resolution via their resolver.
   
   _This note was generated by an AI agent, Hermès on behalf of @gnodet._
   
   <!-- reviewer: gnodet-bot -->


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