Changeset 828

Show
Ignore:
Timestamp:
06/17/07 18:54:44 (6 years ago)
Author:
ggpolo
Message:

added more methods for store and retrieve, it should be "complete" for now. updated viewer a bit, and more one test and other minor changes in umitIventory

Location:
branch/ggpolo
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • branch/ggpolo/umitDB/retrieve.py

    r789 r828  
    349349        return address[0] 
    350350     
    351      
     351         
    352352    def get_finish_timestamp_for_scan_from_db(self, scan): 
    353353        """ 
     
    362362     
    363363     
    364     """ 
    365     Missing (c1) for port data retrieve: ostype in service_info. 
     364    def get_scan_details_for_scan_from_db(self, scan): 
     365        """ 
     366        Get scan details for a scan. 
     367        """ 
     368        debug("Getting scan details for scan id %d.." % scan) 
     369         
     370        details = self.cursor.execute("SELECT args, xmloutputversion, verbose, \ 
     371                  debugging, scanner.name, scanner.version FROM scan \ 
     372                  JOIN scanner ON (scan.fk_scanner = scanner.pk) \ 
     373                  WHERE scan.pk = ?", (scan, )).fetchone() 
     374         
     375        return details 
     376 
     377     
     378    """ 
     379    (c1) Missing for port data retrieve: ostype in service_info. 
    366380    Reason: NmapParser doesn't handle this yet. 
    367381    """ 
     
    419433                            (host_id, )).fetchall()[0] 
    420434        return epdata 
    421  
     435     
     436    def get_fingerprint_info_for_host_from_db(self, host_id): 
     437        """ 
     438        Get fingerprinto info for a host id. 
     439        """ 
     440        debug("Getting fingerprinto info for host id %d" % host_id) 
     441         
     442        # Warning: current finger_print table is deprecated, change this to  
     443        #          use the new one in umitdb branch. (update table name and new 
     444        #          field) 
     445         
     446        fpinfo = self.cursor.execute("SELECT uptime, lastboot, \ 
     447                 tcp_sequence_class, tcp_sequence_index, tcp_sequence_value, \ 
     448                 tcp_sequence_difficulty, tcp_ts_sequence_class, \ 
     449                 tcp_ts_sequence_value, ip_id_sequence_class, \ 
     450                 ip_id_sequence_value FROM finger_print_info \ 
     451                 WHERE fk_host = ?", (host_id, )).fetchone() 
     452         
     453        return fpinfo 
     454     
     455 
     456    def get_osmatch_for_host_from_db(self, host_id): 
     457        """ 
     458        Get osmatch data for a host id. 
     459        """ 
     460        debug("Getting osmatch for host id %d" % host_id) 
     461         
     462        match = self.cursor.execute("SELECT name, accuracy, line FROM osmatch \ 
     463                WHERE fk_host = ?", (host_id, )).fetchone() 
     464         
     465        return match 
     466     
     467    def get_osclasses_for_host_from_db(self, host_id): 
     468        """ 
     469        Get osclasses for a host id. 
     470        """ 
     471        debug("Getting osclasses for host id %d" % host_id) 
     472         
     473        classes = self.cursor.execute("SELECT osclass.accuracy, osgen.gen, \ 
     474                  osfamily.family, osvendor.vendor, ostype.type FROM osclass \ 
     475                  JOIN osgen ON (osclass.fk_osgen = osgen.pk) \ 
     476                  JOIN osfamily ON (osclass.fk_osfamily = osfamily.pk) \ 
     477                  JOIN osvendor ON (osclass.fk_osvendor = osvendor.pk) \ 
     478                  JOIN ostype ON (osclass.fk_ostype = ostype.pk) \ 
     479                  WHERE osclass.fk_host = ?", (host_id, )).fetchall() 
     480         
     481        return classes 
     482     
    422483 
    423484class InventoryRetrieve(ConnectDB, CompositeRetrieve): 
  • branch/ggpolo/umitInventory/new-sample/tldetailgraph.py

    r816 r828  
    253253        cr.clip() 
    254254         
     255        cr.set_line_join(cairo.LINE_JOIN_ROUND) 
    255256        # good points 
    256257        cr.move_to(self.x, self.y) 
     
    502503        cr.rectangle(*event.area) 
    503504        cr.clip() 
     505        cr.set_line_join(cairo.LINE_JOIN_ROUND) 
    504506         
    505507        self._draw_base(cr) 
  • branch/ggpolo/umitInventory/viewer.py

    r822 r828  
    2424import gtk 
    2525import gobject 
     26import pango 
    2627import time 
     28import cairo 
     29from gtk import gdk 
     30 
    2731from os.path import join, split 
    2832from higwidgets.higwindows import HIGMainWindow 
     
    5559 
    5660 
     61class beautydate(gtk.Widget): 
     62    __gsignals__ = { 'clicked': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, 
     63                               ()) 
     64                   } 
     65 
     66    def __init__(self, title): 
     67        gtk.Widget.__init__(self) 
     68        self.title = self.create_pango_layout("%s" % title) 
     69        self.title_font_size = 10 
     70        self.bhover = False 
     71        self.bshow = True 
     72        self.bclicked = False 
     73        self.gradlevel = 1 
     74        self.graddec = True 
     75        self.timer = -1 
     76        self.incl = 1.6 
     77        self.temptext = None # temp text (used in ni viewer) 
     78 
     79        self.title.set_font_description(pango.FontDescription("Serif Bold %s" % self.title_font_size)) 
     80     
     81    def _get_title_font_size(self): 
     82        """ 
     83        Get title font size. 
     84        """ 
     85        return self.__tsfont 
     86 
     87    def _set_title_font_size(self, size): 
     88        """ 
     89        Set title font size. 
     90        """ 
     91        self.__tsfont = size 
     92 
     93    def do_realize(self): 
     94        self.set_flags(self.flags() | gtk.REALIZED) 
     95 
     96        self.window = gdk.Window(self.get_parent_window(), 
     97                                 width=self.allocation.width, 
     98                                 height=self.allocation.height, 
     99                                 window_type=gdk.WINDOW_CHILD, 
     100                                 wclass=gdk.INPUT_OUTPUT, 
     101                                 event_mask=self.get_events() | 
     102                                             gdk.EXPOSURE_MASK |  
     103                                             gdk.POINTER_MOTION_MASK | 
     104                                             gdk.BUTTON_PRESS_MASK | 
     105                                             gdk.BUTTON_RELEASE_MASK | 
     106                                             gdk.ENTER_NOTIFY_MASK | 
     107                                             gdk.LEAVE_NOTIFY_MASK)  
     108        self.window.set_user_data(self) 
     109        self.style.attach(self.window) 
     110        self.style.set_background(self.window, gtk.STATE_NORMAL) 
     111        self.window.move_resize(*self.allocation) 
     112 
     113        self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2)) 
     114 
     115 
     116    def do_unrealize(self): 
     117        self.window.set_user_data(None) 
     118 
     119    def do_size_request(self, requisition): 
     120        width, height = self.title.get_size() 
     121        width = width / pango.SCALE 
     122        height = (height / pango.SCALE) + 6 
     123 
     124        if width < 430: 
     125            width = 430 
     126 
     127        requisition.width = width 
     128        requisition.height = height 
     129 
     130    def do_size_allocate(self, allocation): 
     131        self.allocation = allocation 
     132 
     133        if self.flags() & gtk.REALIZED: 
     134            self.window.move_resize(*allocation) 
     135             
     136    def do_enter_notify_event(self, event): 
     137        self.bhover = True 
     138        self.queue_draw() 
     139 
     140    def do_leave_notify_event(self, event): 
     141        self.bhover = False 
     142        self.queue_draw() 
     143 
     144    def do_button_press_event(self, event): 
     145        if self.bhover: 
     146            if self.timer != -1: 
     147                return 
     148            self.bshow = not self.bshow 
     149            self.bclicked = True 
     150            self.graddec = True 
     151            self.emit('clicked') 
     152            self.queue_draw() 
     153 
     154    def timeout(self): 
     155        if self.graddec: 
     156            self.gradlevel -= 0.1 
     157        else: 
     158            self.gradlevel += 0.1 
     159 
     160        if self.bshow: 
     161            self.incl += 0.1 
     162        else: 
     163            self.incl -= 0.1 
     164        if self.incl < 1.0: 
     165            self.incl = 1.0 
     166        if self.incl > 1.6: 
     167            self.incl = 1.6 
     168 
     169        if self.gradlevel >= 1: 
     170            if self.bshow: 
     171                self.incl = 1.6 
     172            else: 
     173                self.incl = 1.0 
     174            self.bclicked = False # animation end 
     175            self.timer = -1 
     176            return False 
     177 
     178        self.queue_draw() 
     179 
     180    def do_expose_event(self, event): 
     181        border = 4 
     182        cr = self.window.cairo_create() 
     183        cr.rectangle(*event.area) 
     184        cr.clip() 
     185 
     186        # white background 
     187        cr.save() 
     188        cr.rectangle(*event.area) 
     189        cr.set_source_rgb(1, 1, 1) 
     190        cr.fill() 
     191        cr.restore() 
     192         
     193        # shadow 
     194        cr.save() 
     195        cr.rectangle(4, self.allocation[3] - border,  
     196                     self.allocation[2] - 4 - 1, border) 
     197        pat = cairo.LinearGradient(0, 0, 0, self.allocation[3]) 
     198        pat.add_color_stop_rgb(0.7, 0, 0, 0) 
     199        pat.add_color_stop_rgb(1, 1, 1, 1) 
     200        cr.set_source(pat) 
     201        cr.fill() 
     202        cr.restore() 
     203 
     204        # contour 
     205        cr.save() 
     206        cr.rectangle(self.allocation[2] - border, border, border - 1,  
     207                     self.allocation[3] - 2 * border) 
     208        cr.set_source_rgba(0, 0, 0, 0.4) 
     209        cr.fill() 
     210        cr.restore() 
     211 
     212        # rectangle and gradient 
     213        cr.save() 
     214 
     215        cr.rectangle(0, 0, self.allocation[2] - 4,  
     216                     self.allocation[3] - border) 
     217        pat = cairo.LinearGradient(0, 0, self.allocation[2] - border, 0) 
     218        if self.bshow: # anim transitions 
     219            if not self.bclicked: 
     220                pat.add_color_stop_rgba(1, 0.729, 0.851, 1, 1) 
     221                pat.add_color_stop_rgba(0, 0.918, 0.957, 1, 1) 
     222            else: 
     223                if self.gradlevel < 0.6: 
     224                    self.graddec = False 
     225                
     226                if self.graddec: 
     227                    pat.add_color_stop_rgba(1, 0.7, 0.7, 0.7, self.gradlevel) 
     228                    pat.add_color_stop_rgba(0, 0.8, 0.8, 0.8, self.gradlevel) 
     229                else: 
     230                    pat.add_color_stop_rgba(1, 0.729, 0.851, 1, self.gradlevel) 
     231                    pat.add_color_stop_rgba(0, 0.918, 0.957, 1, self.gradlevel) 
     232 
     233                if self.timer != -1: 
     234                    gobject.source_remove(self.timer) 
     235 
     236                gobject.timeout_add(25, self.timeout) 
     237        else:  
     238            if not self.bclicked: 
     239                pat.add_color_stop_rgba(1, 0.75, 0.75, 0.75, 1) 
     240                pat.add_color_stop_rgba(0, 0.9, 0.9, 0.9, 1) 
     241            else: 
     242                if self.gradlevel < 0.4: 
     243                    self.graddec = False 
     244                 
     245                if self.graddec: 
     246                    pat.add_color_stop_rgba(1, 0.729, 0.851, 1, self.gradlevel) 
     247                    pat.add_color_stop_rgba(0, 0.918, 0.957, 1, self.gradlevel) 
     248                else: 
     249                    pat.add_color_stop_rgba(1, 0.75, 0.75, 0.75, self.gradlevel) 
     250                    pat.add_color_stop_rgba(0, 0.9, 0.9, 0.9, self.gradlevel) 
     251                 
     252                if self.timer != -1: 
     253                    gobject.source_remove(self.timer) 
     254                 
     255                self.timer = gobject.timeout_add(25, self.timeout) 
     256 
     257        cr.set_source(pat) 
     258        cr.fill() 
     259        cr.restore() 
     260 
     261        # \/ or > 
     262        cr.move_to(4, border) 
     263        if self.bshow: # \/ # anim transitions 
     264            if not self.bclicked: 
     265                cr.rel_line_to(10/1.6, 10) 
     266                cr.rel_line_to(10/1.6, -10) 
     267            else: 
     268                cr.rel_line_to(10/self.incl, 10/((1.6 - self.incl) + 1)) 
     269                cr.rel_line_to(10/self.incl, -10/((1.6 - self.incl) + 1)) 
     270        else: # > 
     271            if not self.bclicked: 
     272                cr.rel_line_to(10, 10/1.6) 
     273                cr.rel_line_to(-10, 10/1.6) 
     274            else: 
     275                cr.rel_line_to(10/self.incl, 10/((1.6 - self.incl) + 1)) 
     276                cr.rel_line_to(-10/self.incl, 10/((1.6 - self.incl) + 1)) 
     277 
     278        if self.bhover: 
     279            alpha = 1 
     280        else: 
     281            alpha = 0.6 
     282        cr.set_source_rgba(0, 0, 0, alpha) 
     283        cr.fill() 
     284 
     285        # write date title 
     286        if self.bhover: 
     287            cr.set_source_rgb(0, 0, 0) 
     288        else: 
     289            cr.set_source_rgba(0, 0, 0, 0.6) 
     290        _, fonth = self.title.get_pixel_size() 
     291        cr.move_to(20, 1) 
     292        cr.update_layout(self.title) 
     293        cr.show_layout(self.title) 
     294 
     295    # Properties 
     296    title_font_size = property(_get_title_font_size, _set_title_font_size) 
     297 
     298 
     299gobject.type_register(beautydate) 
     300 
     301 
    57302class LegendDlg(gtk.Dialog): 
    58303    """ 
     
    164409        self.pages = [ ] 
    165410         
    166         if inv_activated: 
    167             self.append_inv() 
     411        #if inv_activated: 
     412        #    self.append_inv() 
    168413         
    169414        self.__layout() 
    170415 
    171416 
    172     def append_inv(self, title="Info"): 
     417    def append_inv(self, title="Info", box=None): 
    173418        """ 
    174419        Add info page. 
    175420        """ 
    176         if not title in self.pages: 
    177             scroll = HIGScrolledWindow() 
    178             custom_title = self.__create_custom_title(title, scroll) 
    179             self.append_page(scroll, custom_title) 
    180             self.pages.append(title) 
    181              
    182             self.__layout() 
    183  
    184             return 0 
    185          
    186         return 1 
    187          
    188          
    189     def append_host(self, host_addr): 
     421        if self.page_exists(title): 
     422            return 
     423         
     424        custom_title = self.__create_custom_title(title, box) 
     425        self.append_page(box, custom_title) 
     426        self.pages.append(title) 
     427             
     428        self.__layout() 
     429         
     430         
     431    def append_host(self, host_addr, box): 
    190432        """ 
    191433        Add host page. 
    192434        """ 
    193         if not host_addr in self.pages: 
    194             scroll = HIGScrolledWindow() 
    195             custom_title = self.__create_custom_title(host_addr, scroll) 
    196             self.append_page(scroll, custom_title) 
    197             self.pages.append(host_addr) 
    198              
    199             self.__layout() 
    200              
    201             return 0 
    202          
    203         return 1 
     435        if self.page_exists(host_addr): 
     436            return 
     437         
     438        custom_title = self.__create_custom_title(host_addr, box) 
     439        self.append_page(box, custom_title) 
     440        self.pages.append(host_addr) 
     441             
     442        self.__layout() 
     443 
     444     
     445    def page_exists(self, pagetitle): 
     446        """ 
     447        Check if there is a page with pagetitle in this notebook. 
     448        """ 
     449        if pagetitle in self.pages: 
     450            return True 
     451         
     452        return False 
    204453 
    205454 
     
    208457        Remove a page from notebook and from self.pages 
    209458        """ 
     459        print button, page 
     460         
    210461        del self.pages[self.pages.index(text)] 
    211462        self.remove(page) 
     
    504755        # check if activated inventory isnt open already 
    505756        if not title in self.invnbpages_titles: 
    506             newinvnb = InventoryNB(self, title, not data["host_addr"]) 
     757            newinvnb = InventoryNB(self, title)#, not data["host_addr"]) 
    507758            self.invnb.append_page(newinvnb, gtk.Label(_("%s" % title))) 
    508759                 
     
    512763            # check if a host was activated 
    513764            if data["host_addr"]:  
    514                 newinvnb.append_host(data["host_addr"]) 
    515                  
    516             err = 0 
     765                box = self._load_inventory_host_data(title, data["host_addr"]) 
     766                newinvnb.append_host(data["host_addr"], box) 
     767            else: 
     768                box = self._load_inventory_data(title) 
     769                newinvnb.append_inv(box=box) 
     770                 
    517771        else: 
    518772            p = self.invnbpages_objects[self.invnbpages_titles.index(title)] 
    519773            # check if a host was activated 
    520             if data["host_addr"]:  
    521                 err = p.append_host(data["host_addr"]) 
     774            if data["host_addr"] and not p.page_exists(data["host_addr"]):  
     775                box = self._load_inventory_host_data(title, data["host_addr"]) 
     776                p.append_host(data["host_addr"], box) 
     777                 
    522778            # if it is not a host, it was inventory 
    523             else:  
    524                 err = p.append_inv() 
    525              
     779            else: 
     780                box = self._load_inventory_data(title) 
     781                p.append_inv(box=box) 
     782         
     783        """ 
    526784        if not err: # tab wasn't in inventory tab 
    527785            if data["host_addr"]: 
     
    529787                 
    530788            else: 
    531                 print "load inv info" 
    532                  
     789                pass 
     790                #self._load_inventory_data(title) 
     791        """ 
     792                 
     793                 
     794     
     795    def _load_inventory_data(self, inventory_name): 
     796        fk_inventory = self.invdb.get_inventory_id_for_name(inventory_name) 
     797        scans = self.invdb.get_scans_id_for_inventory(fk_inventory) 
     798        last_scan_id = scans[len(scans)-1][0] 
     799        hosts = self.addresses[inventory_name] 
     800         
     801        box = gtk.VBox() 
     802         
     803        # scan info 
     804        hb = gtk.HBox() 
     805        hb.pack_start(gtk.Label(_("Scan count: %d" % len(scans))), False, False, 0) 
     806        box.pack_start(hb, False, False, 0) 
     807         
     808        hb = gtk.HBox() 
     809        last_scan_date = self.invdb.get_finish_timestamp_for_scan_from_db(last_scan_id) 
     810        hb.pack_start(gtk.Label(_("Last scan date: %s" % last_scan_date)), False, False, 0) 
     811        box.pack_start(hb, False, False, 0) 
     812         
     813        details = self.invdb.get_scan_details_for_scan_from_db(scans[0][0]) 
     814        detc = [ _("Scan args"), _("XML output version"), _("Verbose"),  
     815                 _("Debugging"), _("Scanner name"), _("Scanner version") ] 
     816        for indx, item in enumerate(details): 
     817            hb = gtk.HBox() 
     818            hb.pack_start(gtk.Label("%s: %s" % (detc[indx], item)), False, False, 0) 
     819            box.pack_start(hb, False, False, 0) 
     820         
     821        # "separator" 
     822        hb = gtk.HBox() 
     823        hb.pack_start(gtk.Label("\n"), False, False, 0) 
     824        box.pack_start(hb, False, False, 0) 
     825         
     826        # hosts info 
     827        hb = gtk.HBox() 
     828        hb.pack_start(gtk.Label(_("Hosts: %s" % ', '.join(host for host in hosts))), False, False, 0) 
     829        box.pack_start(hb, False, False, 0) 
     830         
     831        hb = gtk.HBox() 
     832        hb.pack_start(gtk.Label(_("Host count: %s" % len(hosts))), False, False, 0) 
     833        box.pack_start(hb, False, False, 0) 
     834         
     835        sw = gtk.ScrolledWindow() 
     836        sw.add_with_viewport(box) 
     837        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 
     838        sw.show_all() 
     839         
     840        return sw 
     841            
     842 
     843    def create_tags(self, buffer): 
     844        buffer.create_tag("heading_center", weight=pango.WEIGHT_BOLD, 
     845                          size=15 * pango.SCALE, 
     846                          justification=gtk.JUSTIFY_CENTER) 
     847 
     848        buffer.create_tag("whitefg", foreground="white") 
     849                         #invisible=True) 
     850 
     851        buffer.create_tag("p", left_margin=30) 
     852 
     853    def insert_text(self, buffer, text): 
     854        iter = buffer.get_iter_at_offset(0) 
     855        buffer.insert(iter, ' ') 
     856        anchor = buffer.create_child_anchor(iter) 
     857        buffer.insert(iter, "\n") 
     858        for i in text: 
     859            buffer.insert_with_tags_by_name(iter, i, "p") 
     860 
     861    def attach_widgets(self, text_view, date): 
     862        buffer = text_view.get_buffer() 
     863        iter = buffer.get_start_iter() 
     864 
     865        while self.find_anchor(iter): 
     866            anchor = iter.get_child_anchor() 
     867            text = beautydate(date) 
     868            text.connect('clicked', self.tclick, text, buffer) 
     869 
     870            text_view.add_child_at_anchor(text, anchor) 
     871            text.show_all() 
     872 
     873        return 
     874     
     875    def find_anchor(self, iter): 
     876        while iter.forward_char(): 
     877            if iter.get_child_anchor(): 
     878                return True 
     879     
     880    def tclick(self, event, widget, textbuffer): 
     881        if widget.bshow: 
     882            iter = textbuffer.get_iter_at_line(1) 
     883            textbuffer.insert_with_tags_by_name(iter, widget.temptext, "p") 
     884        else: 
     885            start, end = textbuffer.get_bounds() 
     886            start = textbuffer.get_iter_at_line(1) 
     887            if not widget.temptext: 
     888                text = textbuffer.get_text(start, end) 
     889                widget.temptext = text 
     890                 
     891            textbuffer.delete(start, end) 
    533892 
    534893    def _load_inventory_host_data(self, inventory_name, host_addr): 
     
    541900        finish_data = self.invdb.get_finish_data_for_inventory_from_db(fk_inventory) 
    542901                 
    543         # get last created page 
    544         p = self.invnbpages_objects[self.invnbpages_titles.index(inventory_name)] 
    545         content = p.get_nth_page(p.get_n_pages() - 1) 
    546              
    547         lstore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, 
    548                                gobject.TYPE_STRING, gobject.TYPE_STRING) 
    549              
    550         # fill liststore 
     902        box = gtk.VBox() 
    551903        host_count = 0 
     904         
    552905        for item in finish_data: 
    553             iter = lstore.append() 
    554             lstore.set(iter, 0, item[1]) 
    555                  
     906            #if host_count == 10: 
     907            #    break # forcing last 10 results 
     908             
     909            # textview 
     910            tview = gtk.TextView() 
     911            tview.set_editable(False) 
     912            text_buffer = tview.get_buffer() 
     913            self.create_tags(text_buffer) 
     914         
     915            text = [ ] 
     916             
    556917            try:  
    557918                base_hosts_data[host_count][0] 
    558919            except:  
    559                 lstore.set(iter, 1, "down") 
     920                text.append("Host down") # host state 
     921                self.insert_text(text_buffer, text) 
     922                self.attach_widgets(tview, item[1]) 
     923                box.pack_start(tview) 
     924                 
    560925                continue 
    561926             
    562927            if base_hosts_data[host_count][0] == item[0]: 
    563                 lstore.set(iter, 1, "up") 
    564                 # get port data for this host 
     928               # get port data for this host 
    565929                pdata = self.invdb.get_portid_and_fks_for_host_from_db(base_hosts_data[host_count][1]) 
    566930                temp = "" 
    567931                for pd in pdata: 
    568                     fpd = self.invdb.get_port_data_for_pdata_from_db(pd[2],  
    569                                                                      pd[3],  
     932                    fpd = self.invdb.get_port_data_for_pdata_from_db(pd[2], pd[3],  
    570933                                                                     pd[1]) 
    571934                    if len(pdata) > 1: 
    572                         temp += "Port No: %s, Data: %s\n" % (pd[0], fpd) 
     935                        el = '\n\n' 
    573936                    else: 
    574                         temp += "Port No: %s, Data: %s" % (pd[0], fpd) 
    575                      
    576                 lstore.set(iter, 2, temp) 
     937                        el = '\n' 
     938                         
     939                    temp += "Port No: %s, Protocol: %s, Port state: %s, \n\ 
     940Service product: %s, Service version: %s, Service extrainfo: %s, \n\ 
     941Service name: %s%s" % (pd[0], fpd[0], fpd[1], fpd[2], fpd[3], fpd[4], fpd[7], el) 
     942                 
     943                text.append(temp) # port data 
    577944                 
    578945                # get extraports data for this host 
    579946                epdata = self.invdb.get_extraports_data_for_host_from_db(base_hosts_data[host_count][1]) 
    580                 lstore.set(iter, 3, "Count: %d, State: %s" % (epdata[0], epdata[1])) 
     947                text.append("Extraports\n") 
     948                text.append("Count: %d, State: %s" % (epdata[0], epdata[1])) 
     949                 
     950                # get fingerprint info for host 
     951                fpinfo = self.invdb.get_fingerprint_info_for_host_from_db(base_hosts_data[host_count][1]) 
     952                if fpinfo: 
     953                    text.append("Uptime: %s, Last boot:%s\netc: %s" % (fpinfo[0], 
     954                                                                       fpinfo[1], 
     955                                                                       fpinfo[2:])) 
    581956                     
     957                # get osmatch info for host 
     958                match = self.invdb.get_osmatch_for_host_from_db(base_hosts_data[host_count][1]) 
     959                if match: 
     960                    text.append("Name: %s, Accuracy: %s, Line: %s" % (match[0], 
     961                                                                      match[1], 
     962                                                                      match[2])) 
     963                     
     964                # get osclasses for host 
     965                classes = self.invdb.get_osclasses_for_host_from_db(base_hosts_data[host_count][1]) 
     966                if classes: 
     967                    text.append(classes) 
     968                     
     969                print text, text_buffer 
     970                self.insert_text(text_buffer, text) 
     971                self.attach_widgets(tview, item[1]) 
     972                box.pack_start(tview) 
     973                 
    582974                host_count += 1 
    583975            else: 
    584                 lstore.set(iter, 1, "down") 
    585                      
    586         treeview = gtk.TreeView(lstore) 
    587         content.add(treeview) 
    588                  
    589         # column for scan finish timestamp 
    590         column = gtk.TreeViewColumn(_("Scan finish date"),  
    591                                     gtk.CellRendererText(), text=0) 
    592         column.set_sort_column_id(0) 
    593         treeview.append_column(column) 
    594                  
    595         # column for host status 
    596         column = gtk.TreeViewColumn(_("Host status"),  
    597                                     gtk.CellRendererText(), text=1) 
    598         treeview.append_column(column) 
    599          
    600         # column for host ports (this will be broken in several parts) 
    601         column = gtk.TreeViewColumn(_("Host ports"), 
    602                                     gtk.CellRendererText(), text=2) 
    603         treeview.append_column(column) 
    604          
    605         # column for host extraports (" ") 
    606         column = gtk.TreeViewColumn(_("Host extraports"), 
    607                                     gtk.CellRendererText(), text=3) 
    608         treeview.append_column(column) 
    609                  
    610         treeview.show() 
    611              
     976                text.append("down") 
     977                self.insert_text(text_buffer, text) 
     978                self.attach_widgets(tview, item[1]) 
     979                box.pack_start(tview) 
     980                 
     981        sw = gtk.ScrolledWindow() 
     982        sw.add_with_viewport(box) 
     983        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 
     984        sw.show_all() 
     985     
     986        return sw 
     987         
    612988 
    613989    def _fill_tree(self):