Skip to content

Commit 801fde2

Browse files
committed
fix(ogcxmlutil): replace unsupported XML properties with feature-based security settings
1 parent 8658509 commit 801fde2

File tree

1 file changed

+4
-8
lines changed
  • shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/util

1 file changed

+4
-8
lines changed

shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/util/OgcXmlUtil.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,10 @@ public static Document getDocumentFromString(String xml) throws IOException {
8585
InputSource source = new InputSource(new StringReader(xml));
8686
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
8787

88-
try {
89-
// limit resolution of external entities, see https://rules.sonarsource.com/c/type/Vulnerability/RSPEC-2755
90-
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
91-
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
92-
} catch (IllegalArgumentException e) {
93-
log.error("External DTD/Schema access properties not supported:"
94-
+ e.getMessage());
95-
}
88+
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
89+
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
90+
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
91+
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
9692

9793
DocumentBuilder builder = factory.newDocumentBuilder();
9894
document = builder.parse(source);

0 commit comments

Comments
 (0)