ssg.fixes module
Common functions for processing Fixes in SSG
- ssg.fixes.applicable_platforms(fix_path)[source]
Determines the applicable platforms for a given fix.
- Args:
fix_path (str): The file path to the fix configuration file.
- Returns:
list: A list of platforms that the fix applies to.
- Raises:
ValueError: If the fix configuration is malformed or missing the ‘platform’ key.
- ssg.fixes.find_platform_line(fix_contents)[source]
Parses the fix content to determine the line number that the platforms configuration option is on.
- Note:
If the configuration specification changes, please update the corresponding parsing in ssg.build_remediations.parse_from_file_with_jinja(…).
- Args:
fix_contents (list of str): The contents of the configuration file as a list of strings.
- Returns:
int or None: The line number of the platform configuration option, or None if not found.
- ssg.fixes.get_fix_contents(rule_obj, lang, fix_id)[source]
Retrieve the path and contents of a specific fix.
- Args:
rule_obj (object): The rule object containing the fix information. lang (str): The language of the fix. fix_id (str): The identifier of the fix.
- Returns:
tuple: A tuple containing the path to the fix and the contents of the fix.
- ssg.fixes.get_fix_path(rule_obj, lang, fix_id)[source]
Return the full path to the fix for the given language and fix_id in the rule described by rule_obj.
- Args:
- rule_obj (dict): A dictionary containing information about the rule, including dir’, ‘id’,
and ‘remediations’.
lang (str): The language for which the fix is required. fix_id (str): The identifier for the specific fix.
- Returns:
str: The full path to the fix file.
- Raises:
- ValueError: If the rule_obj is malformed or if the fix_id is unknown for the given rule_id
and language.
- ssg.fixes.set_applicable_platforms(fix_contents, new_platforms)[source]
Modifies the given fix contents to update the platforms to the new platforms.
- Args:
fix_contents (list of str): The contents of the fix file as a list of strings. new_platforms (list of str): A list of new platforms to set in the fix file.
- Returns:
list of str: The modified contents with the updated platforms.
- Raises:
ValueError: If the platform line cannot be found in the fix contents.