|
18 | 18 |
|
19 | 19 | package org.apache.hadoop.yarn.server.nodemanager.webapp.dao.gpu; |
20 | 20 |
|
| 21 | +import java.io.StringReader; |
| 22 | +import javax.xml.XMLConstants; |
| 23 | +import javax.xml.bind.JAXBContext; |
| 24 | +import javax.xml.bind.JAXBException; |
| 25 | +import javax.xml.bind.Unmarshaller; |
| 26 | +import javax.xml.parsers.SAXParserFactory; |
| 27 | +import javax.xml.transform.sax.SAXSource; |
| 28 | + |
21 | 29 | import org.apache.hadoop.classification.InterfaceAudience; |
22 | 30 | import org.apache.hadoop.classification.InterfaceStability; |
23 | 31 | import org.apache.hadoop.yarn.exceptions.YarnException; |
| 32 | + |
24 | 33 | import org.slf4j.Logger; |
25 | 34 | import org.slf4j.LoggerFactory; |
26 | 35 | import org.xml.sax.InputSource; |
27 | 36 | import org.xml.sax.XMLReader; |
28 | 37 |
|
29 | | -import javax.xml.bind.JAXBContext; |
30 | | -import javax.xml.bind.JAXBException; |
31 | | -import javax.xml.bind.Unmarshaller; |
32 | | -import javax.xml.parsers.SAXParserFactory; |
33 | | -import javax.xml.transform.sax.SAXSource; |
34 | | -import java.io.StringReader; |
| 38 | +import static org.apache.hadoop.util.XMLUtils.EXTERNAL_GENERAL_ENTITIES; |
| 39 | +import static org.apache.hadoop.util.XMLUtils.EXTERNAL_PARAMETER_ENTITIES; |
| 40 | +import static org.apache.hadoop.util.XMLUtils.LOAD_EXTERNAL_DECL; |
| 41 | +import static org.apache.hadoop.util.XMLUtils.VALIDATION; |
35 | 42 |
|
36 | 43 | /** |
37 | 44 | * Parse XML and get GPU device information |
@@ -68,10 +75,11 @@ public GpuDeviceInformationParser() throws YarnException { |
68 | 75 | */ |
69 | 76 | private SAXParserFactory initSaxParserFactory() throws Exception { |
70 | 77 | SAXParserFactory spf = SAXParserFactory.newInstance(); |
71 | | - spf.setFeature( |
72 | | - "http://apache.org/xml/features/nonvalidating/load-external-dtd", |
73 | | - false); |
74 | | - spf.setFeature("http://xml.org/sax/features/validation", false); |
| 78 | + spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); |
| 79 | + spf.setFeature(LOAD_EXTERNAL_DECL, false); |
| 80 | + spf.setFeature(EXTERNAL_GENERAL_ENTITIES, false); |
| 81 | + spf.setFeature(EXTERNAL_PARAMETER_ENTITIES, false); |
| 82 | + spf.setFeature(VALIDATION, false); |
75 | 83 | return spf; |
76 | 84 | } |
77 | 85 |
|
|
0 commit comments