import re


def filter_search(rules, query):
    """
    Filter the rules object for rules that have a certain string in them
    :param rules: YARA rules JSON object
    :param query: string to search in rule name and description
    :return: list of filtered rules
    """
    filtered_rules = []
    # Process the rules
    for rule in rules:
        if re.search(r'%s' % query, rule['description'], re.IGNORECASE) or \
                re.search(r'%s' % query, rule['name'], re.IGNORECASE):
            filtered_rules.append(rule)
    return filtered_rules