ssg.parse_oval module
Common functions for OVAL parsing in SSG
- class ssg.parse_oval.ElementFinder(oval_groups)[source]
Bases:
objectA class to find specific elements within an XML structure based on given criteria.
- Attributes:
oval_groups (dict): A dictionary containing groups of OVAL definitions. target (str): The name of the target element to find. attrib (str): The attribute of the target element to retrieve. result (set): A set to store the results of the found elements’ attributes.
- find_element(start_element, target_element_name, sought_attrib)[source]
Find elements in an XML tree that match the target element name and sought attribute.
- Args:
start_element (Element): The starting element to begin the search from. target_element_name (str): The name of the target element to find. sought_attrib (str): The attribute to look for in the target elements.
- Returns:
- None: This method does not return a value. The results are stored in the instance
variable self.result.
- ssg.parse_oval.find_extending_defs(oval_groups, defn)[source]
Find and return the definitions that extend a given definition.
- Args:
oval_groups (dict): A dictionary containing OVAL groups. defn (str): The definition to find extensions for.
- Returns:
list: A list of definitions that extend the given definition.
- ssg.parse_oval.get_container_groups(fname)[source]
Parses an OVAL file and retrieves container groups.
- Args:
fname (str): The path to the OVAL file to be parsed.
- Returns:
list: A list of container groups extracted from the OVAL file.
- ssg.parse_oval.resolve_definition(oval_groups, defn)[source]
Resolves a definition by finding the attribute ‘external_variable’ with the specified ‘id’ in the given OVAL groups.
- Args:
oval_groups (dict): A dictionary containing OVAL groups. defn (str): The definition to resolve.
- Returns:
The value of the ‘external_variable’ attribute with the specified ‘id’ if found, otherwise None.