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.
- oval_groups
A dictionary containing groups of OVAL definitions.
- Type:
dict
- target
The name of the target element to find.
- Type:
str
- attrib
The attribute of the target element to retrieve.
- Type:
str
- result
A set to store the results of the found elements’ attributes.
- Type:
set
- 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.
- Parameters:
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:
- This method does not return a value. The results are stored in the instance
variable self.result.
- Return type:
None
- ssg.parse_oval.find_extending_defs(oval_groups, defn)[source]
Find and return the definitions that extend a given definition.
- Parameters:
oval_groups (dict) – A dictionary containing OVAL groups.
defn (str) – The definition to find extensions for.
- Returns:
A list of definitions that extend the given definition.
- Return type:
list
- ssg.parse_oval.get_container_groups(fname)[source]
Parses an OVAL file and retrieves container groups.
- Parameters:
fname (str) – The path to the OVAL file to be parsed.
- Returns:
A list of container groups extracted from the OVAL file.
- Return type:
list
- 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.
- Parameters:
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.