Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.w3c.dom.NodeList;
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 @@ -422,7 +423,18 @@ public static void updateConfigBackUpFile() {
private static void updateConfigFile(String filePath, Document newFile) throws Exception {
try {
LoggingService.logInfo(MODULE_NAME, "Start updating configuration data to config.xml");
Transformer transformer = TransformerFactory.newInstance().newTransformer();
TransformerFactory secureFactory = TransformerFactory.newInstance();

try {
secureFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
secureFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
secureFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
} catch (Exception e) {
throw new RuntimeException(e);
}

Transformer transformer = secureFactory.newTransformer();

transformer.setOutputProperty(OutputKeys.INDENT, "yes");
StreamResult result = new StreamResult(new File(filePath));
DOMSource source = new DOMSource(newFile);
Expand Down Expand Up @@ -1092,6 +1104,15 @@ private static void createConfigProperty(CommandLineConfigParam cmdParam) throws

DOMSource source = new DOMSource(configFile);
TransformerFactory transformerFactory = TransformerFactory.newInstance();

try {
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
} catch (Exception e) {
throw new RuntimeException(e);
}

Transformer transformer = transformerFactory.newTransformer();
StreamResult result = new StreamResult(getCurrentConfigPath());
transformer.transform(source, result);
Expand Down