ssg.checks module
Common functions for processing Checks in SSG
- ssg.checks.get_content_ref_if_exists_and_not_remote(check)[source]
Given an OVAL check element, examine the
xccdf_ns:check-content-ref.If the check-content-ref element exists and it isn’t remote, return it.
- Args:
check (Element): An OVAL check element to be examined.
- Returns:
Element or None: The check-content-ref element if it exists and is not remote, otherwise None.
- See Also:
is_content_href_remote: Function to determine if the content reference is remote.
- ssg.checks.get_oval_contents(rule_obj, oval_id)[source]
Returns the tuple (path, contents) of the check described by the given oval_id or product.
- Parameters:
rule_obj (object): The rule object containing the OVAL definitions. oval_id (str): The identifier of the OVAL check.
- Returns:
tuple: A tuple containing the path to the OVAL file and its contents.
- ssg.checks.get_oval_path(rule_obj, oval_id)[source]
Returns the full path to the OVAL check file for the given rule object and OVAL ID.
- Args:
- rule_obj (dict): A dictionary containing rule information.
It must include the keys ‘dir’, ‘id’, and ‘ovals’.
- oval_id (str): A string representing the ID of the OVAL check file.
If it does not end with “.xml”, the extension will be appended.
- Returns:
str: The full path to the OVAL check file.
- Raises:
ValueError: If the rule_obj is malformed or if the oval_id is unknown for the given rule.
- ssg.checks.is_content_href_remote(check_content_ref)[source]
Given an OVAL check-content-ref element, examine the ‘href’ attribute.
- ssg.checks.set_applicable_platforms(oval_contents, new_platforms)[source]
Modifies the given OVAL contents to update the platforms to the new platforms.
- Args:
oval_contents (list of str): The original OVAL content lines. new_platforms (list of str): The new platforms to be set in the OVAL content.
- Returns:
list of str: The modified OVAL content lines with updated platforms.