You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/08/28 17:43:42 UTC
(commons-xml) 03/09: Rename HardeningExpatXMLReader to SecureExpatXMLReader.
This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/commons-xml.git
commit 7c83633867edef016bd7ad5117f5f79e516df931
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Aug 28 13:36:05 2026 -0400
Rename HardeningExpatXMLReader to SecureExpatXMLReader.
Local build OK.
---
.../java/org/apache/commons/xml/SecureSAXParserFactory.java | 10 +++++-----
src/main/java/org/apache/commons/xml/SecureXMLReader.java | 2 +-
src/test/java/org/apache/commons/xml/AttackTestSupport.java | 4 ++--
src/test/java/org/apache/commons/xml/ShadingFootprintTest.java | 8 ++++----
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/main/java/org/apache/commons/xml/SecureSAXParserFactory.java b/src/main/java/org/apache/commons/xml/SecureSAXParserFactory.java
index 7d99fa6..58489ba 100644
--- a/src/main/java/org/apache/commons/xml/SecureSAXParserFactory.java
+++ b/src/main/java/org/apache/commons/xml/SecureSAXParserFactory.java
@@ -85,7 +85,7 @@ public final class SecureSAXParserFactory {
* <li><strong>Android</strong> (Harmony / Expat): {@link XMLConstants#FEATURE_SECURE_PROCESSING FSP} and the JAXP 1.5 {@code ACCESS_EXTERNAL_*} properties
* are not recognized, and libexpat enforces its own Billion Laughs check, so neither is applied. Two fixups are still needed: an ignore-all resolver
* (Expat ignores external fetches silently when no resolver is set; the floor keeps that behavior non-bypassable, resolving anything unresolved to
- * empty), and a {@link HardeningExpatXMLReader} so the unsupported {@code namespace-prefixes} feature is rejected at
+ * empty), and a {@link SecureExpatXMLReader} so the unsupported {@code namespace-prefixes} feature is rejected at
* configuration time rather than mid-parse.</li>
* <li><strong>FSP</strong>: required on every other reader. It switches on the implementation's built-in security manager, which is what carries the
* processing limits.</li>
@@ -143,9 +143,9 @@ static XMLReader secure(final XMLReader reader) {
}
if (ANDROID_EXPAT_READER.equals(reader.getClass().getName())) {
// Expat ignores external fetches when no resolver is set; the ignore-all floor keeps that behavior non-bypassable (routing a caller-set resolver,
- // including SAXParser.parse's handler, through it and resolving anything unresolved to empty) and, via HardeningExpatXMLReader, rejects the
+ // including SAXParser.parse's handler, through it and resolving anything unresolved to empty) and, via SecureExpatXMLReader, rejects the
// unsupported namespace-prefixes feature eagerly rather than mid-parse.
- return new HardeningExpatXMLReader(reader);
+ return new SecureExpatXMLReader(reader);
}
// Required: enables the JDK XMLSecurityManager / Xerces SecurityManager limits.
setFeature(reader, XMLConstants.FEATURE_SECURE_PROCESSING, true);
@@ -325,11 +325,11 @@ private SecureSAXParserFactory() {
* {@code parse}, with a {@link SAXNotSupportedException}. Reporting the rejection eagerly from {@link #setFeature(String, boolean)} lets consumers that probe
* the feature, such as Xalan's identity transformer, catch the exception and fall back instead of failing the whole parse.</p>
*/
- static final class HardeningExpatXMLReader extends SecureXMLReader {
+ static final class SecureExpatXMLReader extends SecureXMLReader {
private static final String NAMESPACE_PREFIXES_FEATURE = "http://xml.org/sax/features/namespace-prefixes";
- HardeningExpatXMLReader(final XMLReader delegate) {
+ SecureExpatXMLReader(final XMLReader delegate) {
super(delegate);
}
diff --git a/src/main/java/org/apache/commons/xml/SecureXMLReader.java b/src/main/java/org/apache/commons/xml/SecureXMLReader.java
index 1dff366..25d9408 100644
--- a/src/main/java/org/apache/commons/xml/SecureXMLReader.java
+++ b/src/main/java/org/apache/commons/xml/SecureXMLReader.java
@@ -38,7 +38,7 @@
* {@link javax.xml.parsers.SAXParser#parse(org.xml.sax.InputSource, org.xml.sax.helpers.DefaultHandler) SAXParser.parse(source, handler)} installs as the
* reader's entity resolver, which would otherwise silently replace the floor. {@link #getEntityResolver()} reports the caller's resolver unwrapped.</p>
*
- * <p>Every other method forwards to the wrapped delegate; subclasses (e.g. {@code HardeningExpatXMLReader}) add per-implementation fixups on top of the floor.</p>
+ * <p>Every other method forwards to the wrapped delegate; subclasses (e.g. {@code SecureExpatXMLReader}) add per-implementation fixups on top of the floor.</p>
*/
class SecureXMLReader implements XMLReader {
diff --git a/src/test/java/org/apache/commons/xml/AttackTestSupport.java b/src/test/java/org/apache/commons/xml/AttackTestSupport.java
index 4c7a622..e79ca36 100644
--- a/src/test/java/org/apache/commons/xml/AttackTestSupport.java
+++ b/src/test/java/org/apache/commons/xml/AttackTestSupport.java
@@ -91,7 +91,7 @@
final class AttackTestSupport {
/**
- * Test-only permissive counterpart of {@code SecureSAXParserFactory.HardeningExpatXMLReader}: a pass-through Expat wrapper that rejects the
+ * Test-only permissive counterpart of {@code SecureSAXParserFactory.SecureExpatXMLReader}: a pass-through Expat wrapper that rejects the
* {@code namespace-prefixes} feature eagerly (so a probing TrAX identity transformer falls back instead of failing the whole parse) but installs no ignore-all
* resolver floor, so the unconfigured/positive controls stay permissive.
*/
@@ -888,7 +888,7 @@ private static void liftEntityLimits(final XMLReader reader) {
*
* <p>On Android the reader is Expat, which accepts {@code namespace-prefixes} at {@code setFeature} time but fails mid-parse; a probing TrAX path (an
* identity transform, or Xalan's {@code TrAXFilter} self-provisioning) enables that feature, so wrap it to reject the feature eagerly (matching the
- * production {@code HardeningExpatXMLReader}) while keeping the control permissive (no floor).</p>
+ * production {@code SecureExpatXMLReader}) while keeping the control permissive (no floor).</p>
*
* @return A permissive reader, wrapped on Android to reject {@code namespace-prefixes} eagerly.
*/
diff --git a/src/test/java/org/apache/commons/xml/ShadingFootprintTest.java b/src/test/java/org/apache/commons/xml/ShadingFootprintTest.java
index dd09608..a1d581b 100644
--- a/src/test/java/org/apache/commons/xml/ShadingFootprintTest.java
+++ b/src/test/java/org/apache/commons/xml/ShadingFootprintTest.java
@@ -73,7 +73,7 @@ class ShadingFootprintTest {
"SecureSAXParser",
"SecureSAXParserFactory",
"SecureSAXParserFactory$1",
- "SecureSAXParserFactory$HardeningExpatXMLReader",
+ "SecureSAXParserFactory$SecureExpatXMLReader",
"SecureSAXParserFactory$Wrapper",
"SecureXMLReader",
"MethodHandleFactory");
@@ -106,7 +106,7 @@ class ShadingFootprintTest {
"SecureSAXParser",
"SecureSAXParserFactory",
"SecureSAXParserFactory$1",
- "SecureSAXParserFactory$HardeningExpatXMLReader",
+ "SecureSAXParserFactory$SecureExpatXMLReader",
"SecureSAXParserFactory$Wrapper",
"SecureTemplates",
"SecureTemplatesHandler",
@@ -136,7 +136,7 @@ class ShadingFootprintTest {
"SecureSAXParser",
"SecureSAXParserFactory",
"SecureSAXParserFactory$1",
- "SecureSAXParserFactory$HardeningExpatXMLReader",
+ "SecureSAXParserFactory$SecureExpatXMLReader",
"SecureSAXParserFactory$Wrapper",
"SecureXMLReader",
"SecureXPath",
@@ -158,7 +158,7 @@ class ShadingFootprintTest {
"SecureSAXParser",
"SecureSAXParserFactory",
"SecureSAXParserFactory$1",
- "SecureSAXParserFactory$HardeningExpatXMLReader",
+ "SecureSAXParserFactory$SecureExpatXMLReader",
"SecureSAXParserFactory$Wrapper",
"SecureSchema",
"SecureSchemaFactory",