You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by br...@apache.org on 2023/12/25 07:42:03 UTC

(ambari) branch branch-2.7 updated: Validate xml file to remediate vulnerablity. Contributed by Bhavya Hoda

This is an automated email from the ASF dual-hosted git repository.

brahma pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
     new d9652e4611 Validate xml file to remediate vulnerablity. Contributed by Bhavya Hoda <bh...@microsoft.com>
d9652e4611 is described below

commit d9652e4611ea36208d5f748028b3a9cd980e6edb
Author: Brahma Reddy Battula <br...@apache.org>
AuthorDate: Mon Dec 25 13:11:46 2023 +0530

    Validate xml file to remediate vulnerablity. Contributed by Bhavya Hoda <bh...@microsoft.com>
---
 .../src/main/java/org/apache/oozie/ambari/view/Utils.java     | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/Utils.java b/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/Utils.java
index c0459c6a7d..89ea8d3c11 100644
--- a/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/Utils.java
+++ b/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/Utils.java
@@ -58,9 +58,20 @@ import org.xml.sax.SAXException;
 public class Utils {
 	private static final String XML_INDENT_SPACES = "4";
 	private static final String XML_INDENT_AMT_PROP_NAME = "{http://xml.apache.org/xslt}indent-amount";
+	private final String FEATURES_DISALLOW_DOCTYPE = "http://apache.org/xml/features/disallow-doctype-decl";
 	private final static Logger LOGGER = LoggerFactory
 			.getLogger(Utils.class);
 	private final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+	Utils() {
+		// Refer to https://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html#setFeature-java.lang.String-boolean-
+		try{
+			dbf.setFeature(FEATURES_DISALLOW_DOCTYPE, true);
+			LOGGER.info("Setting feature disallow doctype to true");
+		} catch (ParserConfigurationException | TransformerFactoryConfigurationError e) {
+			LOGGER.error("Error in formatting xml", e);
+			throw new RuntimeException(e);
+		}
+	}
 	public String formatXml(String xml) {
 
 		try {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ambari.apache.org
For additional commands, e-mail: commits-help@ambari.apache.org