'Plugin entry point, test existence of HTML forms containing
password-type inputs.
:param request: The HTTP request object.
:param response: The HTTP response object
:return: None, all results are saved in the kb.'

def grep(self, request, response):

    try:
        dp = parser_cache.dpc.get_document_parser_for(response)
    except BaseFrameworkException:
        return
    url = request.get_url()
    proto = url.get_protocol()
    url_string = url.url_string
    for form in dp.get_forms():
        action = form.get_action()
        action_proto = action.get_protocol()
        for p in form.keys():
            input_type = form.get_parameter_type(p)
            if (input_type != INPUT_TYPE_PASSWD):
                continue
            if (action_proto == 'http'):
                desc = 'The    URL:    "%s"    contains    a    <form>    tag    which    submits    credentials    over    HTTP'
                desc %= url_string
                v = Vuln('Insecure    password    submission    over    HTTP', desc, severity.MEDIUM, response.id, self.get_name())
                v.set_url(response.get_url())
                self.kb_append_uniq(self, 'form_cleartext_password', v)
                break
            if (proto == 'http'):
                desc = 'The    URL:    "%s"    was    delivered    over    the    insecure    HTTP    protocol    and    has    <form>    which    contains    a    password    input'
                desc %= url_string
                v = Vuln('Insecure    password    form    access    over    HTTP', desc, severity.MEDIUM, response.id, self.get_name())
                self.kb_append_uniq(self, 'form_cleartext_password', v)
                break
