| @@ 89-113 (lines=25) @@ | ||
| 86 | ssg.utils.write_list_file(fix_file, new_contents) |
|
| 87 | ||
| 88 | ||
| 89 | def replace_platforms(rule_obj, lang, platforms): |
|
| 90 | fix_file, fix_contents = ssg.fixes.get_fix_contents(rule_obj, lang, 'shared') |
|
| 91 | current_platforms = ssg.fixes.applicable_platforms(fix_file) |
|
| 92 | new_platforms = set(current_platforms) |
|
| 93 | ||
| 94 | for platform in platforms: |
|
| 95 | parsed_platform = platform.split('~') |
|
| 96 | if not len(parsed_platform) == 2: |
|
| 97 | print("Invalid platform replacement description: %s" % product, |
|
| 98 | file=sys.stderr) |
|
| 99 | sys.exit(1) |
|
| 100 | ||
| 101 | match = ssg.rule_yaml.parse_prodtype(parsed_platform[0]) |
|
| 102 | replacement = ssg.rule_yaml.parse_prodtype(parsed_platform[1]) |
|
| 103 | ||
| 104 | if match.issubset(current_platforms): |
|
| 105 | new_platforms.difference_update(match) |
|
| 106 | new_platforms.update(replacement) |
|
| 107 | ||
| 108 | print("Current platforms: %s" % ','.join(sorted(current_platforms))) |
|
| 109 | print("New platforms: %s" % ','.join(sorted(new_platforms))) |
|
| 110 | ||
| 111 | new_contents = ssg.fixes.set_applicable_platforms(fix_contents, |
|
| 112 | new_platforms) |
|
| 113 | ssg.utils.write_list_file(fix_file, new_contents) |
|
| 114 | ||
| 115 | ||
| 116 | def delete_fixes(rule_obj, lang, products): |
|
| @@ 87-111 (lines=25) @@ | ||
| 84 | ssg.utils.write_list_file(oval_file, new_contents) |
|
| 85 | ||
| 86 | ||
| 87 | def replace_platforms(rule_obj, platforms): |
|
| 88 | oval_file, oval_contents = ssg.checks.get_oval_contents(rule_obj, 'shared') |
|
| 89 | current_platforms = ssg.oval.applicable_platforms(oval_file) |
|
| 90 | new_platforms = set(current_platforms) |
|
| 91 | ||
| 92 | for platform in platforms: |
|
| 93 | parsed_platform = platform.split('~') |
|
| 94 | if not len(parsed_platform) == 2: |
|
| 95 | print("Invalid platform replacement description: %s" % product, |
|
| 96 | file=sys.stderr) |
|
| 97 | sys.exit(1) |
|
| 98 | ||
| 99 | match = ssg.rule_yaml.parse_prodtype(parsed_platform[0]) |
|
| 100 | replacement = ssg.rule_yaml.parse_prodtype(parsed_platform[1]) |
|
| 101 | ||
| 102 | if match.issubset(current_platforms): |
|
| 103 | new_platforms.difference_update(match) |
|
| 104 | new_platforms.update(replacement) |
|
| 105 | ||
| 106 | print("Current platforms: %s" % ','.join(sorted(current_platforms))) |
|
| 107 | print("New platforms: %s" % ','.join(sorted(new_platforms))) |
|
| 108 | ||
| 109 | new_contents = ssg.checks.set_applicable_platforms(oval_contents, |
|
| 110 | new_platforms) |
|
| 111 | ssg.utils.write_list_file(oval_file, new_contents) |
|
| 112 | ||
| 113 | ||
| 114 | def delete_ovals(rule_obj, products): |
|