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.
- Parameters:
fix_path (str) – The file path to the fix configuration file.
- Returns:
A list of platforms that the fix applies to.
- Return type:
list
- 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(…).
- Parameters:
fix_contents (list of str) – The contents of the configuration file as a list of strings.
- Returns:
The line number of the platform configuration option, or None if not found.
- Return type:
int or None
- ssg.fixes.get_fix_contents(rule_obj, lang, fix_id)[source]
Retrieve the path and contents of a specific fix.
- Parameters:
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:
A tuple containing the path to the fix and the contents of the fix.
- Return type:
tuple
- 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.
- Parameters:
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:
The full path to the fix file.
- Return type:
str
- 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.
- Parameters:
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:
The modified contents with the updated platforms.
- Return type:
list of str
- Raises:
ValueError – If the platform line cannot be found in the fix contents.