Skip to content

Commit

Permalink
Merge pull request #258 from mybatis/autofix/alert-3-60a2799539
Browse files Browse the repository at this point in the history
Fix code scanning alert no. 3: Resolving XML external entity in user-controlled data
  • Loading branch information
hazendaz authored Sep 26, 2024
2 parents b80acbe + 849e99d commit ba20fd0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/ibatis/common/xml/NodeletParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ private Document createDocument(Reader reader)
throws ParserConfigurationException, FactoryConfigurationError, SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, 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 ba20fd0

Please sign in to comment.