def remove_tag_feed(request):
    """
    It allows to modify the feed by removing a certain tag and loading the new feed configuration
    """
    backup_data = file.read_xml_file(file_path=custom_canonical_oval_feed_path,
                                     namespaces=vd.XML_FEED_NAMESPACES)

    data_removed_tag = replace_regex(request.param['pattern'], '',
                                     str(backup_data))

    file.write_file(file_path=custom_canonical_oval_feed_path,
                    data=data_removed_tag)

    vd.clean_vuln_and_sys_programs_tables()

    control_service('restart', daemon='wazuh-modulesd')

    vd.set_system(system='BIONIC')

    yield request.param

    file.write_file(file_path=custom_canonical_oval_feed_path,
                    data=backup_data)

    vd.clean_vuln_and_sys_programs_tables()

    file.truncate_file(LOG_FILE_PATH)
Пример #2
0
def modify_feed(test_data, request):
    """
    Modify the redhat OVAL feed, setting a test field value
    """
    backup_data = file.read_xml_file(file_path=custom_redhat_oval_feed_path,
                                     namespaces=vd.XML_FEED_NAMESPACES,
                                     xml_header=True)

    modified_data = replace_regex(pattern=test_data['pattern'],
                                  new_value=test_data['update'],
                                  data=str(backup_data),
                                  replace_group=True)

    file.write_file(file_path=custom_redhat_oval_feed_path, data=modified_data)

    vd.clean_vuln_and_sys_programs_tables()

    control_service('restart', daemon='wazuh-modulesd')

    vd.set_system(system='RHEL8')

    yield

    file.write_file(file_path=custom_redhat_oval_feed_path, data=backup_data)

    vd.clean_vuln_and_sys_programs_tables()

    file.truncate_file(LOG_FILE_PATH)
def modify_feed(test_data, request):
    """Modify the Arch Linux feed by setting a test field value."""
    backup_data = read_json_file(custom_archlinux_json_feed_path)
    modified_data = json.dumps(dict(backup_data[0]), indent=4)

    for item in backup_data[1:]:
        modified_data += ",\n" + json.dumps(dict(item), indent=4)

    modified_string_data = replace_regex(pattern=test_data['pattern'], new_value=test_data['update'],
                                         data=modified_data, replace_group=True)
    modified_string_data = f"[\n{modified_string_data}\n]"

    write_file(custom_archlinux_json_feed_path, modified_string_data)

    vd.clean_vuln_and_sys_programs_tables()
    control_service('restart', daemon='wazuh-modulesd')
    vd.set_system(system='Windows10')

    yield

    write_json_file(custom_archlinux_json_feed_path, backup_data)
    vd.clean_vuln_and_sys_programs_tables()
    truncate_file(LOG_FILE_PATH)