Skip to content

Commit

Permalink
Set FEATURE_SECURE_PROCESSING for DocumentBuilderFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Nov 4, 2024
1 parent d779eec commit 4932ddd
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.w3c.dom.Document;
import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
Expand Down Expand Up @@ -170,6 +171,11 @@ public static boolean isLegalExtension(final List<File> toCheck, final String[]

public static FeatureExtractorConfig mergeEnabledFeaturesFromPolicy(FeatureExtractorConfig currentConfig, InputStream policy) throws ParserConfigurationException, IOException, SAXException, XPathExpressionException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Unable to secure policy processing");
}
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(policy);
Expand Down

0 comments on commit 4932ddd

Please sign in to comment.