def fix_is_applicable_for_product(platform, product): """Based on the platform dict specifier of the remediation script to determine if this remediation script is applicable for this product. Return 'True' if so, 'False' otherwise""" product, product_version = parse_product_name(product) # Define general platforms multi_platforms = ['multi_platform_all', 'multi_platform_' + product] # First test if platform isn't for 'multi_platform_all' or # 'multi_platform_' + product result = False for mp in multi_platforms: if mp in platform and product in multi_product_list: result = True product_name = "" # Get official name for product if product_version is not None: product_name = map_product(product) + ' ' + product_version else: product_name = map_product(product) # Test if this is for the concrete product version for pf in platform.split(','): if product_name == pf.strip(): result = True # Remediation script isn't neither a multi platform one, nor isn't applicable # for this product => return False to indicate that return product_name, result
def fix_is_applicable_for_product(platform, product): """Based on the platform dict specifier of the remediation script to determine if this remediation script is applicable for this product. Return 'True' if so, 'False' otherwise""" product, product_version = parse_product_name(product) # Define general platforms multi_platforms = ['multi_platform_all', 'multi_platform_' + product] # First test if platform isn't for 'multi_platform_all' or # 'multi_platform_' + product result = False for mp in multi_platforms: if mp in platform and product in multi_product_list: result = True product_name = "" # Get official name for product if product_version is not None: product_name = map_product(product) + ' ' + product_version else: product_name = map_product(product) # Test if this is for the concrete product version for pf in platform.split(','): if product_name == pf.strip(): result = True # Remediation script isn't neither a multi platform one, nor isn't # applicable for this product => return False to indicate that return product_name, result
def add_platforms(xml_tree, multi_platform): for affected in xml_tree.findall(".//{%s}affected" % oval_ns): if affected.get("family") != "unix": continue for plat_elem in affected: try: if plat_elem.text == 'multi_platform_oval': for platforms in multi_platform[plat_elem.text]: for plat in multi_platform[platforms]: platform = ElementTree.Element("{%s}platform" % oval_ns) platform.text = map_product(platforms) + ' ' + plat affected.insert(1, platform) else: for platforms in multi_platform[plat_elem.text]: platform = ElementTree.Element("{%s}platform" % oval_ns) platform.text = map_product( plat_elem.text) + ' ' + platforms affected.insert(0, platform) except KeyError: pass # Remove multi_platform element if re.findall('multi_platform', plat_elem.text): affected.remove(plat_elem) return xml_tree
def add_platforms(xml_tree, multi_platform): for affected in xml_tree.findall(".//{%s}affected" % oval_ns): if affected.get("family") != "unix": continue for plat_elem in affected: try: if plat_elem.text == 'multi_platform_oval': for platforms in multi_platform[plat_elem.text]: for plat in multi_platform[platforms]: platform = ElementTree.Element( "{%s}platform" % oval_ns) platform.text = map_product(platforms) + ' ' + plat affected.insert(1, platform) else: for platforms in multi_platform[plat_elem.text]: platform = ElementTree.Element("{%s}platform" % oval_ns) platform.text = map_product(plat_elem.text) + ' ' + platforms affected.insert(0, platform) except KeyError: pass # Remove multi_platform element if re.findall('multi_platform', plat_elem.text): affected.remove(plat_elem) return xml_tree
def add_platforms(xml_tree, multi_platform): for affected in xml_tree.findall('.//*[@family="unix"]'): for plat_elem in affected: try: if plat_elem.text == 'multi_platform_oval': for platforms in multi_platform[plat_elem.text]: for plat in multi_platform[platforms]: platform = ET.Element('platform') platform.text = map_product(platforms) + ' ' + plat affected.insert(1, platform) else: for platforms in multi_platform[plat_elem.text]: platform = ET.Element('platform') platform.text = map_product(plat_elem.text) + ' ' + platforms affected.insert(0, platform) except KeyError: pass # Remove multi_platform element if re.findall('multi_platform', plat_elem.text): affected.remove(plat_elem) return xml_tree
def check_is_applicable_for_product(oval_check_def, product): """Based on the <platform> specifier of the OVAL check determine if this OVAL check is applicable for this product. Return 'True' if so, 'False' otherwise""" product, product_version = parse_product_name(product) # Define general platforms multi_platforms = [ '<platform>multi_platform_all', '<platform>multi_platform_' + product ] # First test if OVAL check isn't for 'multi_platform_all' or # 'multi_platform_' + product for mp in multi_platforms: if mp in oval_check_def and product in [ 'rhel', 'fedora', 'rhel-osp', 'debian', 'wrlinux' ]: return True # Current SSG checks aren't unified which element of '<platform>' # and '<product>' to use as OVAL AffectedType metadata element, # e.g. Chromium content uses both of them across the various checks # Thus for now check both of them when checking concrete platform / product affected_type_elements = ['<platform>', '<product>'] for afftype in affected_type_elements: # Get official name for product (prefixed with content of afftype) product_name = afftype + map_product(product) # Append the product version to the official name if product_version is not None: product_name += ' ' + product_version # Test if this OVAL check is for the concrete product version if product_name in oval_check_def: return True # OVAL check isn't neither a multi platform one, nor isn't applicable # for this product => return False to indicate that return False
def check_is_applicable_for_product(oval_check_def, product): """Based on the <platform> specifier of the OVAL check determine if this OVAL check is applicable for this product. Return 'True' if so, 'False' otherwise""" product, product_version = parse_product_name(product) # Define general platforms multi_platforms = ['<platform>multi_platform_all', '<platform>multi_platform_' + product ] # First test if OVAL check isn't for 'multi_platform_all' or # 'multi_platform_' + product for mp in multi_platforms: if mp in oval_check_def and product in multi_product_list: return True # Current SSG checks aren't unified which element of '<platform>' # and '<product>' to use as OVAL AffectedType metadata element, # e.g. Chromium content uses both of them across the various checks # Thus for now check both of them when checking concrete platform / product affected_type_elements = ['<platform>', '<product>'] for afftype in affected_type_elements: # Get official name for product (prefixed with content of afftype) product_name = afftype + map_product(product) # Append the product version to the official name if product_version is not None: product_name += ' ' + product_version # Test if this OVAL check is for the concrete product version if product_name in oval_check_def: return True # OVAL check isn't neither a multi platform one, nor isn't applicable # for this product => return False to indicate that return False