garydgregory commented on code in PR #766:
URL: https://github.com/apache/commons-text/pull/766#discussion_r3960866655
##########
src/test/java/org/apache/commons/text/lookup/StringLookupFactoryTest.java:
##########
@@ -293,12 +293,13 @@ void testXmlStringLookup() {
@Test
void testXmlStringLookupExternalEntityOff() {
- assertThrows(IllegalArgumentException.class,
- () ->
StringLookupFactory.INSTANCE.xmlStringLookup().apply(XmlStringLookupTest.DOC_DIR
+ "document-entity-ref.xml:/document/content"));
+ XmlStringLookupTest.assertDoesNotLeak(
+ () ->
StringLookupFactory.INSTANCE.xmlStringLookup().apply(XmlStringLookupTest.DOC_DIR
+ "document-entity-ref.xml:/document/content"),
+ XmlStringLookupTest.DATA);
}
@Test
- @SetSystemProperty(key = "XmlStringLookup.secure", value = "false")
+ @Disabled("External entities are blocked by Commons Secure XML through an
entity resolver and can no longer be re-enabled.")
Review Comment:
Hi @ppkarwasz
I think you mean [this specific XML
method](https://javadoc.io/doc/org.apache.commons/commons-text/latest/org/apache/commons/text/lookup/StringLookupFactory.html#xmlStringLookup(java.util.Map,java.nio.file.Path...))
in `StringLookupFactory` which already accepts a `Path[]` for fences, so that
would map nicely for the resolver to only accept external entities in those
paths. WDYT?
Otherwise, we could introduce a system property to bypass Commons Secure XML
which would still let some people complain that we are insecure in some cases.
Well, we would reintroduce it since we had it in the Javadoc before but it was
never implemented.
So I am favoring reusing the path fence to also fence external entities.
--
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]