def _send_404(self, url404): """ Sends a GET request to url404. :return: The HTTP response body. """ # I don't use the cache, because the URLs are random and the only thing # that cache does is to fill up disk space try: response = self._uri_opener.GET(url404, cache=False, grep=False) except HTTPRequestException, hre: message = 'Exception found while detecting 404: "%s"' raise FourOhFourDetectionException(message % hre)
def send_404(uri_opener, url404, debugging_id=None): """ Sends a GET request to url404. :return: The HTTP response body. """ # I don't use the cache, because the URLs are random and the only thing # that cache does is to fill up disk space try: response = uri_opener.GET(url404, cache=False, grep=False, debugging_id=debugging_id) except HTTPRequestException, hre: message = 'Exception found while detecting 404: "%s" (did:%s)' args = (hre, debugging_id) om.out.debug(message % args) raise FourOhFourDetectionException(message % args)
def send_404(uri_opener, url_404, debugging_id=None): """ Sends a GET request to url404. :return: The HTTP response body. """ try: # Note that the cache is used for this request because url_404 was # generated using a predictable algorithm, by caching the 404 responses # we might be speeding up other calls to is_404 response = uri_opener.GET(url_404, cache=True, grep=False, debugging_id=debugging_id) except HTTPRequestException, hre: message = 'Exception found while detecting 404: "%s" (did:%s)' args = (hre, debugging_id) om.out.debug(message % args) raise FourOhFourDetectionException(message % args)
def test_handles_404_exception(self): body = '<meta test="user/pass"></script>' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html')]) request = FuzzableRequest(url, method='GET') resp = HTTPResponse(200, body, headers, url, url, _id=1) with patch('w3af.plugins.grep.meta_tags.is_404') as is_404_mock,\ patch('w3af.core.controllers.plugins.grep_plugin.om.out') as om_mock: msg = 'Exception found while detecting 404: "UnitTest"' is_404_mock.side_effect = FourOhFourDetectionException(msg) self.plugin.grep_wrapper(request, resp) ecall = call.debug(msg) vulns = kb.kb.get('meta_tags', 'meta_tags') self.assertIn(ecall, om_mock.mock_calls) self.assertEqual(vulns, [])