MCPcopy Index your code
hub / github.com/aboutcode-org/vulnerablecode / getGenerator

Method getGenerator

vulnerabilities/lib_oval.py:278–309  ·  view source on GitHub ↗

Gets the generator for this OVAL document as an OvalGenerator object. If the generator element does not exist, the default behavior is to return none. However, setting the optional parameter to True will cause a default generate element to be created, added to the d

(self, create=False)

Source from the content-addressed store, hash-verified

276 return self.tree.getroot()
277
278 def getGenerator(self, create=False):
279 """
280 Gets the generator for this OVAL document as an OvalGenerator object.
281 If the generator element does not exist, the default behavior is to
282 return none. However, setting the optional parameter to True will cause
283 a default generate element to be created, added to the document, and that will be returned.
284 A value of None may also be returned if this OvalDocument is empty
285
286 @rtype: OvalGenerator
287 @return: An OvalGenerator object, or None if it does not exist and create was not set to True
288 """
289 if not self.tree:
290 return None
291
292 root = self.getDocumentRoot()
293 if not root:
294 return None
295
296 gen_element = root.find("def:generator", OvalDocument.NS_DEFAULT)
297
298 if gen_element is not None:
299 return OvalGenerator(gen_element)
300
301 if not create:
302 return None
303 else:
304 element = Element("{" + OvalDocument.NS_DEFAULT.get("def") + "}generator")
305 gen = OvalGenerator(element)
306 gen.setProduct("The CIS OVAL Repository")
307 gen.setTimestamp(None)
308 gen.setSchemaVersion("5.10.1")
309 return gen
310
311 def getDefinitions(self):
312 """

Callers 1

get_data_from_xml_docMethod · 0.80

Calls 6

getDocumentRootMethod · 0.95
setProductMethod · 0.95
setTimestampMethod · 0.95
setSchemaVersionMethod · 0.95
OvalGeneratorClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected