davsclaus commented on code in PR #30555:
URL: https://github.com/apache/camel/pull/30555#discussion_r4652580509
##########
catalog/camel-catalog-cve/src/main/java/org/apache/camel/catalog/cve/DependencyChains.java:
##########
@@ -171,13 +171,37 @@ private static Path siblingPom(Path jarPath) {
return Files.isRegularFile(pom) ? pom : null;
}
+ // a POM is read with secure processing and without external entities
+ private static DocumentBuilderFactory createDocumentBuilderFactory() {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ factory.setIgnoringElementContentWhitespace(true);
+ factory.setIgnoringComments(true);
+ try {
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
Boolean.TRUE);
+ } catch (ParserConfigurationException e) {
+ // not supported by this parser
+ }
+ try {
+
factory.setFeature("http://xml.org/sax/features/external-general-entities",
false);
+ } catch (ParserConfigurationException e) {
+ // not supported by this parser
+ }
+ try {
+
factory.setFeature("http://xml.org/sax/features/external-parameter-entities",
false);
+ } catch (ParserConfigurationException e) {
+ // not supported by this parser
+ }
+ return factory;
+ }
Review Comment:
Good catch: restored in 8c8a7cb4d87a, with `Class.forName` instead of
`ObjectHelper.loadClass` (the module has no camel-util dependency), so the
factory now sets the same features and the Xerces `SecurityManager` as
`XmlHelper`.
_Claude Code on behalf of Claus Ibsen (davsclaus)_
--
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]