class ScanResultNotebook(HIGNotebook): """This is the right side of a ScanResult, the notebook with the tabs such as "Nmap Output".""" def __init__(self, inventory, scans_store): HIGNotebook.__init__(self) self.set_border_width(5) self.__create_widgets(inventory, scans_store) self.scans_list.scans_list.connect( "row-activated", self._scan_row_activated) self.append_page(self.nmap_output_page, gtk.Label(_('Nmap Output'))) self.append_page(self.open_ports_page, gtk.Label(_('Ports / Hosts'))) self.append_page(self.topology_page, gtk.Label(_('Topology'))) self.append_page(self.host_details_page, gtk.Label(_('Host Details'))) self.append_page(self.scans_list_page, gtk.Label(_('Scans'))) def host_mode(self): self.open_ports.host.host_mode() def port_mode(self): self.open_ports.host.port_mode() def __create_widgets(self, inventory, scans_store): self.open_ports_page = HIGVBox() self.nmap_output_page = HIGVBox() self.topology_page = HIGVBox() self.host_details_page = HIGScrolledWindow() self.host_details_vbox = HIGVBox() self.scans_list_page = HIGVBox() self.open_ports = ScanOpenPortsPage() self.nmap_output = ScanNmapOutputPage(scans_store) self.topology = TopologyPage(inventory) self.scans_list = ScanScanListPage(scans_store) self.no_selected = gtk.Label(_('No host selected.')) self.host_details = self.no_selected self.open_ports_page.add(self.open_ports) self.nmap_output_page.add(self.nmap_output) self.topology_page.add(self.topology) self.scans_list_page.add(self.scans_list) self.host_details_page.add_with_viewport(self.host_details_vbox) self.host_details_vbox._pack_expand_fill(self.host_details) def _scan_row_activated(self, treeview, path, view_column): """Switch back to the Nmap Output view when a scan is activated (double-clicked) on the scans list.""" self.nmap_output.set_active_iter(treeview.get_model().get_iter(path)) self.set_current_page(0)
class ScanResultNotebook(HIGNotebook): """ ScanResultNotebook Creates a new Scan Results notebook page, which includes the sections Ports/Hosts, Nmap Output, Host Details, and Scan Details. Organizes the way the results for scan is displayed in its new tab. """ def __init__(self, inventory, scans_store): HIGNotebook.__init__(self) self.set_border_width(5) self.__create_widgets(inventory, scans_store) self.__nmap_output_refreshing() self.scans_list.scans_list.connect("row-activated", self._scan_row_activated) self.append_page(self.nmap_output_page, gtk.Label(_('Nmap Output'))) self.append_page(self.open_ports_page, gtk.Label(_('Ports / Hosts'))) self.append_page(self.topology_page, gtk.Label(_('Topology'))) self.append_page(self.host_details_page, gtk.Label(_('Host Details'))) self.append_page(self.scans_list_page, gtk.Label(_('Scans'))) def host_mode(self): self.open_ports.host.host_mode() def port_mode(self): self.open_ports.host.port_mode() def __create_widgets(self, inventory, scans_store): self.open_ports_page = HIGVBox() self.nmap_output_page = HIGVBox() self.topology_page = HIGVBox() self.host_details_page = HIGScrolledWindow() self.host_details_vbox = HIGVBox() self.scans_list_page = HIGVBox() self.open_ports = ScanOpenPortsPage() self.nmap_output = ScanNmapOutputPage(scans_store) self.topology = TopologyPage(inventory) self.scans_list = ScanScanListPage(scans_store) self.no_selected = gtk.Label(_('No host selected.')) self.host_details = self.no_selected self.open_ports_page.add(self.open_ports) self.nmap_output_page.add(self.nmap_output) self.topology_page.add(self.topology) self.scans_list_page.add(self.scans_list) self.host_details_page.add_with_viewport(self.host_details_vbox) self.host_details_vbox._pack_expand_fill(self.host_details) def __nmap_output_refreshing(self): self.connect('switch-page', self.refresh_cb) def _scan_row_activated(self, treeview, path, view_column): """Switch back to the Nmap Output view when a scan is activated (double-clicked) on the scans list.""" self.nmap_output.set_active_iter(treeview.get_model().get_iter(path)) self.set_current_page(0) def refresh_cb(self, widget, page=None, page_num=None): if self.nmap_output.nmap_output.thread.isAlive(): if page_num == 2: self.nmap_output.nmap_output.refresh_output()