This is an automated email from the ASF dual-hosted git repository.

ppkarwasz pushed a commit to branch ci/zulu-8u152
in repository https://gitbox.apache.org/repos/asf/commons-secure-xml.git

commit 414da2f31af7753ed3917565e22ff7e3deb1d51d
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Tue Sep 1 12:14:19 2026 +0200

    Pin the CI Zulu job to JDK 8u152
    
    The Zulu job exists to cover the oldest JDK 8 behavior the securing has
    to work against, but 8u201 already carries the 8u162 backport wave. Pin
    it to 8u152, the last release before XSLTC's getAssociatedStylesheet
    began honoring the XMLReader carried by a SAXSource: through 8u152 it
    self-provisions a parser instead, which the newer job cannot exercise.
    
    jdk.xml.overrideDefaultParser arrived in the same wave, so
    OverrideDefaultParserTest now skips where the runtime does not
    recognize the feature rather than failing on it.
    
    Assisted-By: Claude Fable 5 <[email protected]>
    Claude-Session: https://claude.ai/code/session_01CLnTBsvmYtxzNTWVGNyz33
---
 .github/workflows/maven.yml                        |  7 ++++---
 .../xml/secure/OverrideDefaultParserTest.java      | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index f231076..83b3c05 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -42,8 +42,9 @@ jobs:
     # - Distribution variance, one job each:
     #     * Semeru 8 and 21     OpenJ9's class library is the most divergent 
runtime setup-java offers,
     #                           and the most plausible source of surprises in 
factory lookup and class loading.
-    #     * Zulu                Pinned to an old 8 patch level.
-    #                           Verifies the securing degrades gracefully on a 
runtime predating the later jdk.xml.* backports.
+    #     * Zulu                Pinned to 8u152, the last release before 
XSLTC's getAssociatedStylesheet started honoring the XMLReader
+    #                           carried by a SAXSource (it self-provisioned 
one through 8u152, and honors it from 8u162 on).
+    #                           Also predates the later jdk.xml.* backports, 
so it covers the oldest behavior the securing has to degrade against.
     #     * GraalVM             Runs the suite as a native image via the 
`native-xalan` profile:
     #                           the JAXP providers resolve at build time under 
the closed-world assumption, a different code path from
     #                           the JVM's run-time ServiceLoader lookup. 25 is 
the latest GraalVM release.
@@ -75,7 +76,7 @@ jobs:
             java-version: 21
             distribution: semeru
           - os: ubuntu-latest
-            java-version: 8.0.201
+            java-version: 8.0.152
             distribution: zulu
           # native-image resolves the JAXP providers at build time under the 
closed-world assumption, a different
           # code path from the JVM's run-time ServiceLoader lookup. 25 is the 
latest GraalVM release.
diff --git 
a/src/test/java/org/apache/commons/xml/secure/OverrideDefaultParserTest.java 
b/src/test/java/org/apache/commons/xml/secure/OverrideDefaultParserTest.java
index 1ada79b..d5b640e 100644
--- a/src/test/java/org/apache/commons/xml/secure/OverrideDefaultParserTest.java
+++ b/src/test/java/org/apache/commons/xml/secure/OverrideDefaultParserTest.java
@@ -22,6 +22,7 @@
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assumptions.assumeFalse;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 import java.io.StringWriter;
 
@@ -54,6 +55,23 @@ class OverrideDefaultParserTest {
     /** Package prefix of the JDK's built-in parsers, the family a {@code 
false} feature value pins. */
     private static final String JDK_INTERNAL_PREFIX = 
"com.sun.org.apache.xerces.internal.";
 
+    /** {@code true} where the runtime's factories know {@value 
SecureSAXParserFactory#OVERRIDE_DEFAULT_PARSER}; JDK 8 gained it in 8u162. */
+    private static final boolean SUPPORTS_FEATURE = probeFeature();
+
+    private static boolean probeFeature() {
+        try {
+            TransformerFactory.newInstance().setFeature(FEATURE, true);
+            return true;
+        } catch (final Exception e) {
+            return false;
+        }
+    }
+
+    /** Skips a test on a runtime whose factories do not recognize the 
feature, where there is no selection to observe. */
+    private static void assumeFeatureSupported() {
+        assumeTrue(SUPPORTS_FEATURE, "runtime does not recognize " + FEATURE);
+    }
+
     private static String transform(final TransformerFactory factory, final 
String text) throws Exception {
         final Transformer transformer = 
factory.newTransformer(AttackTestSupport.streamSource(AttackTestSupport.xsltBody(text)));
         final StringWriter out = new StringWriter();
@@ -73,6 +91,7 @@ private static boolean xercesOnClasspath() {
     @Test
     void schemaFactoryReadsFeatureAtCreation() throws Exception {
         assumeFalse(AttackTestSupport.IS_ANDROID);
+        assumeFeatureSupported();
         final SchemaFactory factory = SecureSchemaFactory.newDefaultInstance();
         assertFalse(factory.getFeature(FEATURE));
         assertFalse(((SecureSchema) 
factory.newSchema(AttackTestSupport.streamSource(AttackTestSupport.BENIGN_SCHEMA))).overrideDefaultParser);
@@ -97,6 +116,7 @@ void secureReaderFollowsFlag() throws Exception {
     @Test
     void transformerFactoryReadsFeatureAtCreation() throws Exception {
         assumeFalse(AttackTestSupport.IS_ANDROID);
+        assumeFeatureSupported();
         final TransformerFactory factory = 
SecureTransformerFactory.newDefaultInstance();
         assertFalse(factory.getFeature(FEATURE));
         assertFalse(((SecureTemplates) 
factory.newTemplates(AttackTestSupport.streamSource(AttackTestSupport.xsltBody("probe")))).overrideDefaultParser);
@@ -110,6 +130,7 @@ void transformerFactoryReadsFeatureAtCreation() throws 
Exception {
     @DisabledInNativeImage
     void transformSucceedsUnderBothParserFamilies() throws Exception {
         assumeFalse(AttackTestSupport.IS_ANDROID);
+        assumeFeatureSupported();
         final TransformerFactory factory = 
SecureTransformerFactory.newDefaultInstance();
         // Feature false (the JDK's default): stylesheet and source parse 
through the pinned platform parser.
         assertTrue(transform(factory, "pinned").contains("pinned"));
@@ -121,6 +142,7 @@ void transformSucceedsUnderBothParserFamilies() throws 
Exception {
     @Test
     void xPathFactoryReadsFeatureAtCreation() throws Exception {
         assumeFalse(AttackTestSupport.IS_ANDROID);
+        assumeFeatureSupported();
         final XPathFactory factory = SecureXPathFactory.newDefaultInstance();
         assertFalse(factory.getFeature(FEATURE));
         assertFalse(((SecureXPath) factory.newXPath()).overrideDefaultParser);

Reply via email to