ssg.oval module
Common functions for processing OVAL in SSG
- ssg.oval.applicable_platforms(oval_file, oval_version_string=None)[source]
Returns the applicable platforms for a given OVAL file.
This function processes an OVAL file to extract the platforms it applies to. It uses a specified OVAL version string or a default version if none is provided. The function constructs an XML tree from the OVAL file and extracts platform information from it.
- Parameters:
oval_file (str) – The path to the OVAL file to be processed.
oval_version_string (str, optional) – The OVAL version string to be used. If not provided, a default version is used.
- Returns:
A list of platforms that the OVAL file applies to.
- Return type:
list
- Raises:
Exception – If there is an error while parsing the OVAL file.
- ssg.oval.parse_affected(oval_contents)[source]
Returns the tuple (start_affected, end_affected, platform_indents) for the passed OVAL file contents.
Args: oval_contents (list of str): The contents of the OVAL file, where each element is a line from
the file.
- Returns:
- A tuple containing:
start_affected (int): The line number of the starting <affected> tag.
end_affected (int): The line number of the closing </affected> tag.
platform_indents (str): The indenting characters before the contents of the <affected> element.
- Return type:
tuple
- Raises:
ValueError – If the OVAL file does not contain a single <affected> element, if the start tag is after the end tag, or if the tags contain other elements.