mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Avoid handling BaseException, so SysExit and KeyboardInterrupt are propagated. #1834
This commit is contained in:
@@ -252,7 +252,7 @@ def print_received_packet(packet):
|
|||||||
try:
|
try:
|
||||||
packet.show(label_lvl=" ")
|
packet.show(label_lvl=" ")
|
||||||
hexdump(packet)
|
hexdump(packet)
|
||||||
except:
|
except Exception:
|
||||||
return
|
return
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -200,9 +200,9 @@ class Application(BWMainWindow):
|
|||||||
self.__parser = XMLReader(file)
|
self.__parser = XMLReader(file)
|
||||||
self.__parser.parse()
|
self.__parser.parse()
|
||||||
|
|
||||||
except:
|
except Exception as e:
|
||||||
|
|
||||||
text = 'It is not possible open file: %s.' % file
|
text = 'It is not possible open file %s: %s' % (file, e)
|
||||||
|
|
||||||
alert = BWAlertDialog(self,
|
alert = BWAlertDialog(self,
|
||||||
primary_text='Error opening file.',
|
primary_text='Error opening file.',
|
||||||
|
|||||||
@@ -648,7 +648,7 @@ class NetworkInventoryTest(unittest.TestCase):
|
|||||||
inv.add_scan(scan_2)
|
inv.add_scan(scan_2)
|
||||||
try:
|
try:
|
||||||
inv.remove_scan(scan_3)
|
inv.remove_scan(scan_3)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self.assertEqual(added_ips, inv.hosts.keys())
|
self.assertEqual(added_ips, inv.hosts.keys())
|
||||||
self.assertEqual(host_a.hostnames, ["a"])
|
self.assertEqual(host_a.hostnames, ["a"])
|
||||||
|
|||||||
@@ -274,14 +274,14 @@ class NmapCommand(object):
|
|||||||
log.debug(">>> SIGTERM has not worked even after waiting for 5 seconds. Using SIGKILL.") # noqa
|
log.debug(">>> SIGTERM has not worked even after waiting for 5 seconds. Using SIGKILL.") # noqa
|
||||||
os.kill(self.command_process.pid, SIGKILL)
|
os.kill(self.command_process.pid, SIGKILL)
|
||||||
self.command_process.wait()
|
self.command_process.wait()
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
import ctypes
|
import ctypes
|
||||||
ctypes.windll.kernel32.TerminateProcess(
|
ctypes.windll.kernel32.TerminateProcess(
|
||||||
int(self.command_process._handle), -1)
|
int(self.command_process._handle), -1)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_path(self):
|
def get_path(self):
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ class Paths(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
return self.__dict__[name]
|
return self.__dict__[name]
|
||||||
except:
|
except Exception:
|
||||||
raise NameError(name)
|
raise NameError(name)
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
def __setattr__(self, name, value):
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class RecentScans(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.recent_scans_file = Path.recent_scans
|
self.recent_scans_file = Path.recent_scans
|
||||||
except:
|
except Exception:
|
||||||
self.recent_scans_file = False
|
self.recent_scans_file = False
|
||||||
|
|
||||||
if (self.recent_scans_file and
|
if (self.recent_scans_file and
|
||||||
|
|||||||
@@ -552,7 +552,7 @@ class SearchDir(SearchResult, object):
|
|||||||
try:
|
try:
|
||||||
parsed = NmapParser()
|
parsed = NmapParser()
|
||||||
parsed.parse_file(scan_file)
|
parsed.parse_file(scan_file)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.scan_results.append(parsed)
|
self.scan_results.append(parsed)
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class TargetList(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.target_list_file = Path.target_list
|
self.target_list_file = Path.target_list
|
||||||
except:
|
except Exception:
|
||||||
self.target_list_file = False
|
self.target_list_file = False
|
||||||
|
|
||||||
#import pdb; pdb.set_trace()
|
#import pdb; pdb.set_trace()
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ class SearchConfig(UmitConfigParser, object):
|
|||||||
def get_converted_save_time(self):
|
def get_converted_save_time(self):
|
||||||
try:
|
try:
|
||||||
return int(self.save_time[0]) * self.time_list[self.save_time[1]]
|
return int(self.save_time[0]) * self.time_list[self.save_time[1]]
|
||||||
except:
|
except Exception:
|
||||||
# If something goes wrong, return a save time of 60 days
|
# If something goes wrong, return a save time of 60 days
|
||||||
return 60 * 60 * 24 * 60
|
return 60 * 60 * 24 * 60
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ class Profile(UmitConfigParser, object):
|
|||||||
def remove_profile(self, profile_name):
|
def remove_profile(self, profile_name):
|
||||||
try:
|
try:
|
||||||
self.remove_section(profile_name)
|
self.remove_section(profile_name)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self.save_changes()
|
self.save_changes()
|
||||||
|
|
||||||
@@ -470,7 +470,7 @@ class NmapOutputHighlight(object):
|
|||||||
return self.sanity_settings([
|
return self.sanity_settings([
|
||||||
config_parser.get(
|
config_parser.get(
|
||||||
property_name, prop, True) for prop in self.setts])
|
property_name, prop, True) for prop in self.setts])
|
||||||
except:
|
except Exception:
|
||||||
settings = []
|
settings = []
|
||||||
prop_settings = self.default_highlights[p_name]
|
prop_settings = self.default_highlights[p_name]
|
||||||
settings.append(prop_settings["bold"])
|
settings.append(prop_settings["bold"])
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ umitdb = ""
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
umitdb = Path.db
|
umitdb = Path.db
|
||||||
except:
|
except Exception:
|
||||||
import os.path
|
import os.path
|
||||||
from BasePaths import base_paths
|
from BasePaths import base_paths
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ class UmitDB(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.cursor.execute(drop_string)
|
self.cursor.execute(drop_string)
|
||||||
except:
|
except Exception:
|
||||||
connection.rollback()
|
connection.rollback()
|
||||||
else:
|
else:
|
||||||
connection.commit()
|
connection.commit()
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ class UnicodeFileChooserDialog(gtk.FileChooserDialog):
|
|||||||
encoding = sys.getfilesystemencoding() or "UTF-8"
|
encoding = sys.getfilesystemencoding() or "UTF-8"
|
||||||
try:
|
try:
|
||||||
filename = filename.decode(encoding)
|
filename = filename.decode(encoding)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ class ScanWindow(UmitScanWindow):
|
|||||||
# gtk.STOCK_ABOUT is only available in PyGTK 2.6 and later.
|
# gtk.STOCK_ABOUT is only available in PyGTK 2.6 and later.
|
||||||
try:
|
try:
|
||||||
about_icon = gtk.STOCK_ABOUT
|
about_icon = gtk.STOCK_ABOUT
|
||||||
except:
|
except AttributeError:
|
||||||
about_icon = None
|
about_icon = None
|
||||||
|
|
||||||
self.main_actions = [
|
self.main_actions = [
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ class NmapOutputViewer (gtk.VBox):
|
|||||||
buf = self.text_view.get_buffer()
|
buf = self.text_view.get_buffer()
|
||||||
try:
|
try:
|
||||||
running = (command is not None and command.scan_state() is True)
|
running = (command is not None and command.scan_state() is True)
|
||||||
except:
|
except Exception:
|
||||||
running = False
|
running = False
|
||||||
complete = False
|
complete = False
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ class ScanHostsView(HIGVBox, object):
|
|||||||
try:
|
try:
|
||||||
child = self.scrolled.get_child()
|
child = self.scrolled.get_child()
|
||||||
self.scrolled.remove(child)
|
self.scrolled.remove(child)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _set_scrolled(self):
|
def _set_scrolled(self):
|
||||||
|
|||||||
@@ -618,8 +618,8 @@ class ScanInterface(HIGVBox):
|
|||||||
alive = scan.scan_state()
|
alive = scan.scan_state()
|
||||||
if alive:
|
if alive:
|
||||||
continue
|
continue
|
||||||
except:
|
except Exception as e:
|
||||||
log.debug("Scan terminated unexpectedly: %s" % scan.command)
|
log.debug("Scan terminated unexpectedly: %s (%s)" % (scan.command, e))
|
||||||
self.scans_store.fail_running_scan(scan)
|
self.scans_store.fail_running_scan(scan)
|
||||||
else:
|
else:
|
||||||
log.debug("Scan finished: %s" % scan.command)
|
log.debug("Scan finished: %s" % scan.command)
|
||||||
@@ -650,7 +650,7 @@ class ScanInterface(HIGVBox):
|
|||||||
# Some options like --iflist cause Nmap to emit an empty XML
|
# Some options like --iflist cause Nmap to emit an empty XML
|
||||||
# file. Ignore the exception in this case.
|
# file. Ignore the exception in this case.
|
||||||
st = os.stat(command.get_xml_output_filename())
|
st = os.stat(command.get_xml_output_filename())
|
||||||
except:
|
except Exception:
|
||||||
st = None
|
st = None
|
||||||
if st is None or st.st_size > 0:
|
if st is None or st.st_size > 0:
|
||||||
warn_dialog = HIGAlertDialog(
|
warn_dialog = HIGAlertDialog(
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ class ScriptInterface:
|
|||||||
def script_list_timer_callback(self, process, callback):
|
def script_list_timer_callback(self, process, callback):
|
||||||
try:
|
try:
|
||||||
status = process.scan_state()
|
status = process.scan_state()
|
||||||
except:
|
except Exception:
|
||||||
status = None
|
status = None
|
||||||
log.debug("Script interface: script_list_timer_callback %s" %
|
log.debug("Script interface: script_list_timer_callback %s" %
|
||||||
repr(status))
|
repr(status))
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ class HIGAlertDialog(gtk.MessageDialog):
|
|||||||
# GTK up to version 2.4 does not have secondary_text
|
# GTK up to version 2.4 does not have secondary_text
|
||||||
try:
|
try:
|
||||||
self.format_secondary_text(secondary_text)
|
self.format_secondary_text(secondary_text)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user