Skip to content

Commit

Permalink
Merge pull request #259 from mybatis/autofix/alert-4-fe4c663044
Browse files Browse the repository at this point in the history
Fix code scanning alert no. 4: Resolving XML external entity in user-controlled data
  • Loading branch information
hazendaz authored Sep 26, 2024
2 parents ba20fd0 + 9e82257 commit e348c4a
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 e348c4a

Please sign in to comment.