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