1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 14:11:29 +00:00

Deduplicate scan names in the diff window.

This is based on an idea from jah in
http://seclists.org/nmap-dev/2012/q1/655. Make ScanChooser and
DiffWindow take a flat list of scans, not a dict of names → scans, and
centralize the deduplication in ScanChooser.add_scan.
This commit is contained in:
david
2012-03-30 06:54:17 +00:00
parent b2f3139284
commit ce11ecb708
3 changed files with 18 additions and 35 deletions

View File

@@ -1,5 +1,8 @@
# Nmap Changelog ($Id$); -*-text-*- # Nmap Changelog ($Id$); -*-text-*-
o [Zenmap] It is now possible to compare scans having the same name or
command line. [Jah, David Fifield]
o [NSE] Added rdp-vuln-ms12-020.nse by Aleksandar Nikolic. This tests o [NSE] Added rdp-vuln-ms12-020.nse by Aleksandar Nikolic. This tests
for two Remote Desktop vulnerabilities, including one allowing for two Remote Desktop vulnerabilities, including one allowing
remote code execution, that were fixed in the MS12-020 advisory. remote code execution, that were fixed in the MS12-020 advisory.

View File

@@ -122,10 +122,10 @@ class ScanChooser(HIGVBox):
"changed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()) "changed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
} }
def __init__(self, scan_dict, title): def __init__(self, scans, title):
self.__gobject_init__() self.__gobject_init__()
self.title = title self.title = title
self.scan_dict = scan_dict self.scan_dict = {}
# Setting HIGVBox # Setting HIGVBox
self.set_border_width(5) self.set_border_width(5)
@@ -138,8 +138,8 @@ class ScanChooser(HIGVBox):
self._set_text_view() self._set_text_view()
self._set_open_button() self._set_open_button()
for scan in scan_dict: for scan in scans:
self.list_scan.append([scan]) self.add_scan(scan.scan_name or scan.get_nmap_command(), scan)
self.combo_scan.connect('changed', self.show_scan) self.combo_scan.connect('changed', self.show_scan)
self.combo_scan.connect('changed', lambda x: self.emit('changed')) self.combo_scan.connect('changed', lambda x: self.emit('changed'))
@@ -272,11 +272,8 @@ The parsing error that occurred was\n%s") % str(e))
class DiffWindow(gtk.Window): class DiffWindow(gtk.Window):
def __init__(self, scans): def __init__(self, scans):
"""scans in the format: {"scan_title":parsed_scan}
"""
gtk.Window.__init__(self) gtk.Window.__init__(self)
self.set_title(_("Compare Results")) self.set_title(_("Compare Results"))
self.scans = scans
self.ndiff_process = None self.ndiff_process = None
# We allow the user to start a new diff before the old one has finished. # We allow the user to start a new diff before the old one has finished.
# We have to keep references to old processes until they finish to avoid # We have to keep references to old processes until they finish to avoid
@@ -284,16 +281,6 @@ class DiffWindow(gtk.Window):
self.old_processes = [] self.old_processes = []
self.timer_id = None self.timer_id = None
self._create_widgets()
self._pack_widgets()
self._connect_widgets()
self.set_default_size(-1, 500)
# Initial Size Request
self.initial_size = self.get_size()
def _create_widgets(self):
self.main_vbox = HIGVBox() self.main_vbox = HIGVBox()
self.diff_view = DiffView() self.diff_view = DiffView()
self.diff_view.set_size_request(-1, 100) self.diff_view.set_size_request(-1, 100)
@@ -301,8 +288,16 @@ class DiffWindow(gtk.Window):
self.progress = gtk.ProgressBar() self.progress = gtk.ProgressBar()
self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE) self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
self.hbox_selection = HIGHBox() self.hbox_selection = HIGHBox()
self.scan_chooser_a = ScanChooser(self.scans, _(u"A Scan")) self.scan_chooser_a = ScanChooser(scans, _(u"A Scan"))
self.scan_chooser_b = ScanChooser(self.scans, _(u"B Scan")) self.scan_chooser_b = ScanChooser(scans, _(u"B Scan"))
self._pack_widgets()
self._connect_widgets()
self.set_default_size(-1, 500)
# Initial Size Request
self.initial_size = self.get_size()
def _pack_widgets(self): def _pack_widgets(self):
self.main_vbox.set_border_width(6) self.main_vbox.set_border_width(6)

View File

@@ -840,22 +840,7 @@ running at the background.\nWhat do you want to do?'))
def _load_diff_compare_cb (self, widget=None, extra=None): def _load_diff_compare_cb (self, widget=None, extra=None):
"""Loads all active scans into a dictionary, passes it to the DiffWindow """Loads all active scans into a dictionary, passes it to the DiffWindow
constructor, and then displays the 'Compare Results' window.""" constructor, and then displays the 'Compare Results' window."""
# We must change this test dict self.diff_window = DiffWindow(self.scan_interface.inventory.get_scans())
# This dict has the following syntax:
# key = Scan name
# value = nmap output in string format
dic = {}
for parsed in self.scan_interface.inventory.get_scans():
if parsed.scan_name:
scan_name = parsed.scan_name
else:
scan_name = parsed.get_nmap_command()
dic[scan_name] = parsed
self.diff_window = DiffWindow(dic)
self.diff_window.show_all() self.diff_window.show_all()
def show_help(): def show_help():