def match_rules(rules, app, action):
    """
    This will match rules found in Policy.
    """
    for rule in rules.split(','):
        try:
            rule_app, rule_action = rule.split(':')
            rule_app = rule_app.replace(' ', '')
            rule_action = rule_action.replace(' ', '')
            if rule_app == '*' or rule_app == app:
                if (rule_action == '*' or rule_action == action or action ==
                    '%'):
                    return True
        except Exception as ex:
            continue
    return False
