Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve last requests mistakes #17593

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
1ac7a24
resolve python error 'tuple parameter unpacking is not supported in p…
hougomartim Dec 31, 2018
d25c744
Forget 'as' in Exception Syntax ./
hougomartim Dec 31, 2018
39e7f8d
Forget multiple file 'as' in Exception syntax ./
hougomartim Dec 31, 2018
78d89ee
Fix all of Exception syntax ./
hougomartim Dec 31, 2018
772ff24
Fix another Exceptions Syntax ./
hougomartim Dec 31, 2018
a807ee6
Update test_base_consumer.py
hougomartim Feb 2, 2019
f247652
resolve Exception bug ./
hougomartim Feb 2, 2019
a629add
resolve mistakes ./
hougomartim Feb 2, 2019
c438fe5
Merge branch 'master' into master
hougomartim Feb 2, 2019
a74049a
Update test_base_consumer.py
hougomartim Feb 8, 2019
4a83a57
Update exception_handler.py
hougomartim Feb 8, 2019
e9bccd1
Update test_exceptions.py
hougomartim Feb 8, 2019
6c5d3b9
Update wordlist.py
hougomartim Feb 8, 2019
eff7aaf
Update phpinfo-5.1.3-rc4dev.html
hougomartim Feb 8, 2019
96bbfb8
Update phpinfo-5.1.6.html
hougomartim Feb 8, 2019
e5bd25f
Merge branch 'master' into master
hougomartim Oct 22, 2019
c28a8d0
Update regressiontest.py
hougomartim Oct 30, 2019
d22e5aa
Update regressiontest.py
hougomartim Oct 30, 2019
b10910a
Update sqlharvest.py
hougomartim Oct 30, 2019
f26e1d5
Update action.py
hougomartim Oct 30, 2019
2449742
Update action.py
hougomartim Oct 30, 2019
bd43749
Update checks.py
hougomartim Oct 30, 2019
f793b36
Update controller.py
hougomartim Oct 30, 2019
302dd75
Update bigarray.py
hougomartim Oct 30, 2019
0fa10bd
Update bigarray.py
hougomartim Oct 30, 2019
30a6d28
Update common.py
hougomartim Oct 30, 2019
c92c538
Update dump.py
hougomartim Oct 30, 2019
78b2186
Update option.py
hougomartim Oct 30, 2019
8ad3ad2
Update replication.py
hougomartim Oct 30, 2019
fed740c
Update testing.py
hougomartim Oct 30, 2019
9403c19
Update threads.py
hougomartim Oct 30, 2019
43ad005
Update wordlist.py
hougomartim Oct 30, 2019
b9c9fc6
Update configfile.py
hougomartim Oct 30, 2019
e237ba5
Update payloads.py
hougomartim Oct 30, 2019
5e0727c
Update sitemap.py
hougomartim Oct 30, 2019
2bbbef3
Update connect.py
hougomartim Oct 30, 2019
1d27c3f
Update api.py
hougomartim Oct 30, 2019
cd0e5fb
Update crawler.py
hougomartim Oct 30, 2019
9fa5343
Update hash.py
hougomartim Oct 30, 2019
f528ca5
Update hashdb.py
hougomartim Oct 30, 2019
cad9229
Update pivotdumptable.py
hougomartim Oct 30, 2019
13b996b
Update search.py
hougomartim Oct 30, 2019
c67f88c
Update connector.py
hougomartim Oct 30, 2019
e010cd6
Update connector.py
hougomartim Oct 30, 2019
26e6cf5
Update connector.py
hougomartim Oct 30, 2019
3d8bc4d
Update custom.py
hougomartim Oct 30, 2019
92d1b58
Update entries.py
hougomartim Oct 30, 2019
5cb2688
Update beautifulsoup.py
hougomartim Oct 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion w3af/core/controllers/auto_update/git_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def pull(self):
# or which exception would be raised. So I'm catching all and
# verifying if there are conflicts in an exception and in the
# case were no exceptions were raised
except Exception, e:
except Exception as e:
self.handle_conflicts(latest_before_pull)
msg = self.UPD_ERROR_MSG + ' The original exception was: "%s"'
raise GitClientError(msg % e)
Expand Down
2 changes: 1 addition & 1 deletion w3af/core/controllers/auto_update/ui_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def update(self):
self._handle_update_output(resp)
except KeyboardInterrupt:
pass
except Exception, ex:
except Exception as ex:
self._logger('An error occurred while updating: "%s"' % ex)

# TODO: Please read https://github.com/andresriancho/w3af/issues/6
Expand Down
8 changes: 5 additions & 3 deletions w3af/core/controllers/core_helpers/consumers/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _teardown(self):
' scan must stop exception was raised')
self._log_end_took(msg_fmt, start_time, plugin)

except Exception, e:
except Exception as e:
msg_fmt = ('Spent %.2f seconds running %s.end() until an'
' unhandled exception was found')
self._log_end_took(msg_fmt, start_time, plugin)
Expand Down Expand Up @@ -110,7 +110,7 @@ def _consume(self, fuzzable_request):
"""
try:
orig_resp = self.get_original_response(fuzzable_request)
except Exception, e:
except Exception as e:
self.handle_exception('audit',
'audit.get_original_response()',
'audit.get_original_response()', e)
Expand Down Expand Up @@ -147,7 +147,7 @@ def _run_observers(self, fuzzable_request):
try:
for observer in self._observers:
observer.audit(self, fuzzable_request)
except Exception, e:
except Exception as e:
self.handle_exception('audit',
'audit._run_observers()',
'audit._run_observers()', e)
Expand Down Expand Up @@ -175,10 +175,12 @@ def _audit(self, function_id, plugin, fuzzable_request, orig_resp, debugging_id)

try:
plugin.audit_with_copy(fuzzable_request, orig_resp, debugging_id)

except Exception, e:
self.handle_exception('audit',
plugin.get_name(),
fuzzable_request,
e)


took_line.send()
2 changes: 1 addition & 1 deletion w3af/core/controllers/core_helpers/consumers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _login(self, function_id):
try:
if not plugin.has_active_session():
plugin.login()
except Exception, e:
except Exception as e:
self.handle_exception('auth', plugin.get_name(), None, e)

took_line.send()
Expand Down
6 changes: 3 additions & 3 deletions w3af/core/controllers/core_helpers/consumers/bruteforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _teardown(self):
' scan must stop exception was raised')
self._log_end_took(msg_fmt, start_time, plugin)

except Exception, e:
except Exception as e:
msg_fmt = ('Spent %.2f seconds running %s.end() until an'
' unhandled exception was found')
self._log_end_took(msg_fmt, start_time, plugin)
Expand All @@ -92,7 +92,7 @@ def _run_observers(self, fuzzable_request):
try:
for observer in self._observers:
observer.bruteforce(self, fuzzable_request)
except Exception, e:
except Exception as e:
self.handle_exception('bruteforce',
'bruteforce._run_observers()',
'bruteforce._run_observers()', e)
Expand Down Expand Up @@ -146,7 +146,7 @@ def _bruteforce(self, function_id, plugin, fuzzable_request):
# TODO: Report progress to the core.
try:
new_frs = plugin.bruteforce_wrapper(fuzzable_request)
except Exception, e:
except Exception as e:
self.handle_exception('bruteforce', plugin.get_name(),
fuzzable_request, e)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def _teardown(self, plugin=None):
' scan must stop exception was raised')
self._log_end_took(msg_fmt, start_time, plugin)

except Exception, e:
except Exception as e:
msg_fmt = ('Spent %.2f seconds running %s.end() until an'
' unhandled exception was found')
self._log_end_took(msg_fmt, start_time, plugin)
Expand Down Expand Up @@ -212,7 +212,7 @@ def _run_observers(self, fuzzable_request):
try:
for observer in self._observers:
observer.crawl(self, fuzzable_request)
except Exception, e:
except Exception as e:
self.handle_exception('CrawlInfrastructure',
'CrawlInfrastructure._run_observers()',
'CrawlInfrastructure._run_observers()', e)
Expand Down Expand Up @@ -534,11 +534,19 @@ def _discover_worker(self, function_id, plugin, fuzzable_request):
# that is implemented by raising a RunOnce
# exception
self._remove_discovery_plugin(plugin)

except Exception, e:
self.handle_exception(plugin.get_type(),
plugin.get_name(),
fuzzable_request,
e)

except Exception, e:
self.handle_exception(plugin.get_type(),
plugin.get_name(),
fuzzable_request,
e)

else:
# The plugin output is retrieved and analyzed by the
# _route_plugin_results method, here we just verify that the plugin
Expand Down
4 changes: 4 additions & 0 deletions w3af/core/controllers/core_helpers/consumers/grep.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ def _teardown(self):

try:
plugin.end()

except Exception as exception:

msg = 'An exception was found while running %s.end(): "%s"'
args = (plugin.get_name(), exception)
om.out.debug(msg % args)
Expand Down Expand Up @@ -290,6 +292,7 @@ def _run_all_plugins(self, http_response_id):
def _get_plugin_from_name(self, plugin_name):
plugin = self._consumer_plugin_dict.get(plugin_name, None)


if plugin is None:
msg = ('Internal error in grep consumer: plugin with name %s'
' does not exist in dict.')
Expand All @@ -298,6 +301,7 @@ def _get_plugin_from_name(self, plugin_name):

return plugin


def _run_one_plugin(self, plugin_name, http_response_id):
"""
:param plugin_name: Grep plugin name to run
Expand Down
2 changes: 1 addition & 1 deletion w3af/core/controllers/core_helpers/consumers/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def seed_output_queue(self, target_urls):
except HTTPRequestException, hre:
msg = 'The target URL: "%s" is unreachable. Exception: "%s".'
om.out.error(msg % (url, hre))
except Exception, e:
except Exception as e:
msg = ('The target URL: "%s" is unreachable because of an'
' unhandled exception. Error description: "%s". See'
' debug output for more information.\n'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_handle_exception(self):
fr = FuzzableRequest(url)
try:
raise Exception()
except Exception, e:
except Exception as e:
self.bc.handle_exception('audit', 'sqli', fr, e)

exception_data = self.bc.out_queue.get()
Expand Down
4 changes: 2 additions & 2 deletions w3af/core/controllers/core_helpers/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def use_profile(self, profile_name, workdir=None):
# Set the misc and http settings
try:
profile_misc_settings = profile_inst.get_misc_settings()
except BaseFrameworkException, e:
except BaseFrameworkException as e:
msg = ('Setting the framework misc-settings raised an exception'
' due to unknown or invalid configuration parameters. %s')
error_messages.append(msg % e)
Expand All @@ -161,7 +161,7 @@ def use_profile(self, profile_name, workdir=None):

try:
http_settings = profile_inst.get_http_settings()
except BaseFrameworkException, e:
except BaseFrameworkException as e:
msg = ('Setting the framework http-settings raised an exception'
' due to unknown or invalid configuration parameters. %s')
error_messages.append(msg % e)
Expand Down
14 changes: 9 additions & 5 deletions w3af/core/controllers/core_helpers/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ def start(self):

self._fuzzable_request_router()

except Exception, e:
except Exception as e:

om.out.debug('strategy.start() found exception "%s"' % e)
exc_info = sys.exc_info()

try:
# Terminate the consumers, exceptions at this level stop the scan
self.terminate()
except Exception, e:
except Exception as e:
msg = 'strategy.start() found exception while terminating workers "%s"'
om.out.debug(msg % e)
finally:
Expand Down Expand Up @@ -191,6 +191,7 @@ def terminate(self):
om.out.debug('Calling terminate() on %s consumer' % consumer)
start = time.time()


# Set it immediately to None to avoid any race conditions where
# the terminate() method is called twice (from different
# threads) and before the first call finishes
Expand All @@ -211,6 +212,7 @@ def terminate(self):
args = (consumer, spent)
om.out.debug('terminate() on %s consumer took %.2f seconds' % args)


self.set_consumers_to_none()

def join_all_consumers(self):
Expand Down Expand Up @@ -491,7 +493,7 @@ def verify_target_server_up(self):
except ScanMustStopByUserRequest:
# Not a real error, the user stopped the scan
raise
except Exception, e:
except Exception as e:
dbg = 'Exception found during verify_target_server_up: "%s"'
om.out.debug(dbg % e)

Expand Down Expand Up @@ -582,10 +584,12 @@ def alert_if_target_is_301_all(self):
except ScanMustStopByUserRequest:
# Not a real error, the user stopped the scan
raise

except Exception, e:
msg = 'Exception found during alert_if_target_is_301_all(): "%s"'
om.out.debug(msg % e)
raise ScanMustStopException(msg % e)

else:
if http_response.does_redirect_outside_target():
site_does_redirect = True
Expand Down Expand Up @@ -617,7 +621,7 @@ def _setup_404_detection(self):
response = self._w3af_core.uri_opener.GET(url, cache=True)
except ScanMustStopByUserRequest:
raise
except Exception, e:
except Exception as e:
msg = ('Failed to send HTTP request to the configured target'
' URL "%s", the original exception was: "%s" (%s).')
args = (url, e, e.__class__.__name__)
Expand All @@ -627,7 +631,7 @@ def _setup_404_detection(self):
current_target_is_404 = is_404(response)
except ScanMustStopByUserRequest:
raise
except Exception, e:
except Exception as e:
msg = ('Failed to initialize the 404 detection using HTTP'
' response from "%s", the original exception was: "%s"'
' (%s).')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_handle_one(self):

try:
raise Exception('unittest')
except Exception, e:
except Exception as e:
exec_info = sys.exc_info()
enabled_plugins = ''
self.exception_handler.handle(self.status,
Expand Down Expand Up @@ -89,7 +89,7 @@ def test_handle_multiple(self):
for _ in xrange(10):
try:
raise Exception('unittest')
except Exception, e:
except Exception as e:
exec_info = sys.exc_info()
enabled_plugins = ''
self.exception_handler.handle(self.status, e, exec_info,
Expand All @@ -115,7 +115,7 @@ def test_get_unique_exceptions(self):
for _ in xrange(10):
try:
raise Exception('unittest')
except Exception, e:
except Exception as e:
exec_info = sys.exc_info()
enabled_plugins = ''
self.exception_handler.handle(self.status, e, exec_info,
Expand Down Expand Up @@ -145,7 +145,7 @@ def test2():
def test(ehandler):
try:
test2()
except Exception, e:
except Exception as e:
exec_info = sys.exc_info()
enabled_plugins = ''
ehandler.handle(self.status, e, exec_info, enabled_plugins)
Expand Down Expand Up @@ -181,7 +181,7 @@ def test2():
def test(ehandler):
try:
test2()
except Exception, e:
except Exception as e:
exec_info = sys.exc_info()
enabled_plugins = ''
ehandler.handle(self.status, e, exec_info, enabled_plugins)
Expand Down
2 changes: 1 addition & 1 deletion w3af/core/controllers/daemons/proxy/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def handle_request_in_thread(self, flow):
try:
# Send the request to the remote webserver
http_response = self._send_http_request(http_request)
except Exception, e:
except Exception as e:
trace = str(traceback.format_exc())
http_response = self._create_error_response(http_request, None, e,
trace=trace)
Expand Down
4 changes: 2 additions & 2 deletions w3af/core/controllers/daemons/proxy/intercept_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def handle_request_in_thread(self, flow):
else:
# Send the request to the remote webserver
http_response = self._send_http_request(http_request)
except Exception, e:
except Exception as e:
trace = str(traceback.format_exc())
http_response = self._create_error_response(http_request, None, e,
trace=trace)
Expand Down Expand Up @@ -95,7 +95,7 @@ def on_request_edit_finished(self, orig_http_request, head, post_data):
try:
http_request = http_request_parser(head, post_data)
http_response = self._send_http_request(http_request)
except Exception, e:
except Exception as e:
trace = str(traceback.format_exc())
http_response = self._create_error_response(orig_http_request,
None, e, trace=trace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def send_request(_id, proxy_opener, results, exceptions):
results.put(he)
except KeyboardInterrupt, k:
exceptions.put(k)
except Exception, e:
except Exception as e:
exceptions.put(e)
else:
results.put(response)
Expand Down
4 changes: 2 additions & 2 deletions w3af/core/controllers/daemons/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def do_GET(self):
except IOError:
try:
self.send_error(404, 'File Not Found: %s' % self.path)
except Exception, e:
except Exception as e:
om.out.debug('[webserver] Exception: ' + str(e))
else:
try:
Expand All @@ -144,7 +144,7 @@ def do_GET(self):
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(f.read())
except Exception, e:
except Exception as e:
om.out.debug('[webserver] Exception: ' + str(e))

f.close()
Expand Down
2 changes: 1 addition & 1 deletion w3af/core/controllers/easy_contribution/github_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, user_or_token, password=None):
def login(self):
try:
self.gh = Github(self._user_or_token, self._password)
except GithubException, ex:
except GithubException as ex:
# Not sure when we get here, but just in case...
raise LoginFailed(str(ex))
else:
Expand Down
2 changes: 1 addition & 1 deletion w3af/core/controllers/misc/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def f_retry(*args, **kwargs):
while mtries >= 0:
try:
rv = f(*args, **kwargs)
except Exception, ex:
except Exception as ex:
# Ok, fail!
if mtries == 0:
if exc_class:
Expand Down
Loading