Skip to content

Commit

Permalink
Fix code scanning alert no. 4: Resolving XML external entity in user-…
Browse files Browse the repository at this point in the history
…controlled data

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
hazendaz and github-advanced-security[bot] authored Sep 26, 2024
1 parent ba20fd0 commit 9e82257
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/ibatis/common/xml/NodeletParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ private Document createDocument(InputStream inputStream)
throws ParserConfigurationException, FactoryConfigurationError, SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
factory.setValidating(validation);
Expand Down

0 comments on commit 9e82257

Please sign in to comment.