mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +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:
|
||||
packet.show(label_lvl=" ")
|
||||
hexdump(packet)
|
||||
except:
|
||||
except Exception:
|
||||
return
|
||||
return
|
||||
|
||||
|
||||
@@ -200,9 +200,9 @@ class Application(BWMainWindow):
|
||||
self.__parser = XMLReader(file)
|
||||
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,
|
||||
primary_text='Error opening file.',
|
||||
|
||||
@@ -648,7 +648,7 @@ class NetworkInventoryTest(unittest.TestCase):
|
||||
inv.add_scan(scan_2)
|
||||
try:
|
||||
inv.remove_scan(scan_3)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self.assertEqual(added_ips, inv.hosts.keys())
|
||||
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
|
||||
os.kill(self.command_process.pid, SIGKILL)
|
||||
self.command_process.wait()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
import ctypes
|
||||
ctypes.windll.kernel32.TerminateProcess(
|
||||
int(self.command_process._handle), -1)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def get_path(self):
|
||||
|
||||
@@ -238,7 +238,7 @@ class Paths(object):
|
||||
|
||||
try:
|
||||
return self.__dict__[name]
|
||||
except:
|
||||
except Exception:
|
||||
raise NameError(name)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
|
||||
@@ -137,7 +137,7 @@ class RecentScans(object):
|
||||
|
||||
try:
|
||||
self.recent_scans_file = Path.recent_scans
|
||||
except:
|
||||
except Exception:
|
||||
self.recent_scans_file = False
|
||||
|
||||
if (self.recent_scans_file and
|
||||
|
||||
@@ -552,7 +552,7 @@ class SearchDir(SearchResult, object):
|
||||
try:
|
||||
parsed = NmapParser()
|
||||
parsed.parse_file(scan_file)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
self.scan_results.append(parsed)
|
||||
|
||||
@@ -137,7 +137,7 @@ class TargetList(object):
|
||||
|
||||
try:
|
||||
self.target_list_file = Path.target_list
|
||||
except:
|
||||
except Exception:
|
||||
self.target_list_file = False
|
||||
|
||||
#import pdb; pdb.set_trace()
|
||||
|
||||
@@ -229,7 +229,7 @@ class SearchConfig(UmitConfigParser, object):
|
||||
def get_converted_save_time(self):
|
||||
try:
|
||||
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
|
||||
return 60 * 60 * 24 * 60
|
||||
|
||||
@@ -307,7 +307,7 @@ class Profile(UmitConfigParser, object):
|
||||
def remove_profile(self, profile_name):
|
||||
try:
|
||||
self.remove_section(profile_name)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self.save_changes()
|
||||
|
||||
@@ -470,7 +470,7 @@ class NmapOutputHighlight(object):
|
||||
return self.sanity_settings([
|
||||
config_parser.get(
|
||||
property_name, prop, True) for prop in self.setts])
|
||||
except:
|
||||
except Exception:
|
||||
settings = []
|
||||
prop_settings = self.default_highlights[p_name]
|
||||
settings.append(prop_settings["bold"])
|
||||
|
||||
@@ -155,7 +155,7 @@ umitdb = ""
|
||||
|
||||
try:
|
||||
umitdb = Path.db
|
||||
except:
|
||||
except Exception:
|
||||
import os.path
|
||||
from BasePaths import base_paths
|
||||
|
||||
@@ -268,7 +268,7 @@ class UmitDB(object):
|
||||
|
||||
try:
|
||||
self.cursor.execute(drop_string)
|
||||
except:
|
||||
except Exception:
|
||||
connection.rollback()
|
||||
else:
|
||||
connection.commit()
|
||||
|
||||
@@ -179,7 +179,7 @@ class UnicodeFileChooserDialog(gtk.FileChooserDialog):
|
||||
encoding = sys.getfilesystemencoding() or "UTF-8"
|
||||
try:
|
||||
filename = filename.decode(encoding)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return filename
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ class ScanWindow(UmitScanWindow):
|
||||
# gtk.STOCK_ABOUT is only available in PyGTK 2.6 and later.
|
||||
try:
|
||||
about_icon = gtk.STOCK_ABOUT
|
||||
except:
|
||||
except AttributeError:
|
||||
about_icon = None
|
||||
|
||||
self.main_actions = [
|
||||
|
||||
@@ -321,7 +321,7 @@ class NmapOutputViewer (gtk.VBox):
|
||||
buf = self.text_view.get_buffer()
|
||||
try:
|
||||
running = (command is not None and command.scan_state() is True)
|
||||
except:
|
||||
except Exception:
|
||||
running = False
|
||||
complete = False
|
||||
else:
|
||||
|
||||
@@ -235,7 +235,7 @@ class ScanHostsView(HIGVBox, object):
|
||||
try:
|
||||
child = self.scrolled.get_child()
|
||||
self.scrolled.remove(child)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _set_scrolled(self):
|
||||
|
||||
@@ -618,8 +618,8 @@ class ScanInterface(HIGVBox):
|
||||
alive = scan.scan_state()
|
||||
if alive:
|
||||
continue
|
||||
except:
|
||||
log.debug("Scan terminated unexpectedly: %s" % scan.command)
|
||||
except Exception as e:
|
||||
log.debug("Scan terminated unexpectedly: %s (%s)" % (scan.command, e))
|
||||
self.scans_store.fail_running_scan(scan)
|
||||
else:
|
||||
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
|
||||
# file. Ignore the exception in this case.
|
||||
st = os.stat(command.get_xml_output_filename())
|
||||
except:
|
||||
except Exception:
|
||||
st = None
|
||||
if st is None or st.st_size > 0:
|
||||
warn_dialog = HIGAlertDialog(
|
||||
|
||||
@@ -313,7 +313,7 @@ class ScriptInterface:
|
||||
def script_list_timer_callback(self, process, callback):
|
||||
try:
|
||||
status = process.scan_state()
|
||||
except:
|
||||
except Exception:
|
||||
status = None
|
||||
log.debug("Script interface: script_list_timer_callback %s" %
|
||||
repr(status))
|
||||
|
||||
@@ -180,7 +180,7 @@ class HIGAlertDialog(gtk.MessageDialog):
|
||||
# GTK up to version 2.4 does not have secondary_text
|
||||
try:
|
||||
self.format_secondary_text(secondary_text)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user