def matches_filter(finding, request):
    """
    Filters:

        * /scans/0/kb/?name= returns only vulnerabilities which contain the
          specified string in the vulnerability name. (contains)

        * /scans/0/kb/?url= returns only vulnerabilities for a specific URL
          (startswith)

    If more than one filter is specified they are combined using AND.

    :param finding: The vulnerability
    :param request: The HTTP request object
    :return: True if the finding (vulnerability) matches the specified filter
    """
    name = request.args.get('name', None)
    url = request.args.get('url', None)

    if name is not None and url is not None:
        return (name.lower() in finding.get_name().lower() and
                finding.get_url() is not None and
                finding.get_url().url_string.startswith(url))

    elif name is not None:
        return name.lower() in finding.get_name().lower()

    elif url is not None:
        return (finding.get_url() is not None and
                finding.get_url().url_string.startswith(url))

    # No filter
    return True