'Note that this method only makes sense if called in a loop with the
other check_* methods.
:param web_socket_url: The URL of the web socket
:param web_socket_version: The protocol version
:return: True if the web socket checks the origin for connections:
* Only the same origin can connect
* Send any cookie/basic auth known to the scanner'

def check_is_restricted_by_origin(self, web_socket_url, web_socket_version):

    origin_domain = web_socket_url.get_domain()
    for scheme in {'http', 'https'}:
        origin = ('%s://%s' % (scheme, origin_domain))
        upgrade_request = build_ws_upgrade_request(web_socket_url, web_socket_version=web_socket_version, origin=origin)
        upgrade_response = self._uri_opener.send_mutant(upgrade_request, cookies=False, use_basic_auth=False)
        if (not is_successful_upgrade(upgrade_response)):
            continue
        msg = 'An    HTML5    WebSocket    which    allows    connections    only    when    the    origin    is    set    to    "%s"    was    found    at    "%s"'
        msg %= (origin_domain, web_socket_url)
        v = Vuln.from_fr('Origin    restricted    WebSocket', msg, severity.LOW, upgrade_response.id, self.get_name(), upgrade_request)
        self.kb_append_uniq(self, 'websocket_hijacking', v)
        return True
    return False
