@@ -125,14 +125,13 @@ class OvalDocument(object):
125125 NS_OVAL = {"oval" : "http://oval.mitre.org/XMLSchema/oval-common-5" }
126126 NS_XSI = {"xsi" : "http://www.w3.org/2001/XMLSchema-instance" }
127127
128- # xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5"
129- # xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5"
128+ # xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5"# xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5"
130129 # xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
131130 # xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd
132131 # http://oval.mitre.org/XMLSchema/oval-definitions-5#independent independent-definitions-schema.xsd
133132 # http://oval.mitre.org/XMLSchema/oval-definitions-5#solaris solaris-definitions-schema.xsd
134133 # http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd
135- # http://oval.mitre.org/XMLSchema/oval-definitions-5#unix unix-definitions-schema.xsd">^M
134+ # http://oval.mitre.org/XMLSchema/oval-definitions-5#unix unix-definitions-schema.xsd">
136135
137136 @staticmethod
138137 def indent (elem , level = 0 ):
@@ -172,7 +171,7 @@ def __init__(self, tree):
172171 # if not tree or not isinstance(tree, ElementTree):
173172 if not tree :
174173 root = Element ("oval_definitions" )
175- self .tree = ElementTree .ElementTree (root )
174+ self .tree = defusedxml . ElementTree .ElementTree (root )
176175 element = Element ("{" + OvalDocument .NS_DEFAULT .get ("def" ) + "}generator" )
177176 gen = OvalGenerator (element )
178177 gen .setProduct ("The CIS OVAL Repository" )
@@ -209,7 +208,7 @@ def parseFromFile(self, filename):
209208 self .tree = None
210209 return False
211210 else :
212- self .tree = ElementTree .parse (filename )
211+ self .tree = defusedxml . ElementTree .parse (filename )
213212 return True
214213 except Exception :
215214 return False
@@ -226,8 +225,8 @@ def parseFromText(self, xmltext):
226225 if not xmltext :
227226 return False
228227 else :
229- root = ElementTree .fromstring (xmltext )
230- self .tree = ElementTree (root )
228+ root = defusedxml . ElementTree .fromstring (xmltext )
229+ self .tree = defusedxml . ElementTree . ElementTree (root )
231230 return True
232231 except Exception :
233232 return False
@@ -261,7 +260,7 @@ def to_string(self):
261260 if root is None :
262261 return ""
263262 OvalDocument .indent (root )
264- return ElementTree .tostring (root , "UTF-8" , "xml" ).decode ("utf-8" )
263+ return defusedxml . ElementTree .tostring (root , "UTF-8" , "xml" ).decode ("utf-8" )
265264
266265 def getDocumentRoot (self ):
267266 """
@@ -326,8 +325,7 @@ def getDefinitions(self):
326325 if defroot is None :
327326 return None
328327
329- element_list = list (defroot )
330- if not element_list :
328+ element_list = list (defroot ) if not element_list :
331329 return None
332330
333331 return [OvalDefinition (element ) for element in element_list ]
0 commit comments