def checkfornew(self): db = vulndb.db() count = db.count()[0] if count > 0: alert = vulnalert.alert() # the alert class will decide to alert or not based on the config file alert.popupNotify("New vulnerabilities", "There are " + str(count) + " new vulnerabilities") alert.sendEmail(db.select()) # toggle the alert field for those vulns db.togglealert() # update window with new items self.window.refreshlist() return True
def __init__(self): # database connection self.db = vulndb.db() self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("Vulnerabilities") self.window.set_size_request(800, 600) self.window.set_border_width(10) self.window.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.window.connect("delete-event", self.destroy) self.window.set_icon_from_file("icon.png") # Window Boxes main_vbox = gtk.VBox(False, 3) top_hbox = gtk.HBox() ################################################################ # Top Part of Window ################################################################ # Variable to keep track of the database index for each item self.dbindex = "" link_click = gtk.EventBox() self.lbl_cve = gtk.Label() self.lbl_cve.set_alignment(0,0) self.lbl_date = gtk.Label() self.lbl_date.set_alignment(0,0) self.lbl_desc = gtk.Label() self.lbl_desc.set_line_wrap(True) self.lbl_desc.set_justify(gtk.JUSTIFY_LEFT) self.lbl_desc.set_size_request(500,60) self.lbl_desc.set_alignment(0,0) self.lbl_link = gtk.Label() self.lbl_link.set_alignment(0,0) self.lbl_link.grab_focus() link_click.add(self.lbl_link) link_click.connect("button_press_event", self.openlink) top_halign = gtk.Alignment(1, 0, 0, 0) top_vbox = gtk.VBox() # Link button requires a uri to start with, might as well go with SX self.linkbutton1 = gtk.LinkButton("http://www.soldierx.com") self.linkbutton1.set_alignment(0,0) self.linktt = gtk.Tooltips() btnAck = gtk.Button("Acknowlege") btnRemove = gtk.Button("Remove") tt_btnAck = gtk.Tooltips() tt_btnRemove = gtk.Tooltips() tt_btnAck.set_tip(btnAck, "Don't show vulnerability in list anymore\nStays in database though") tt_btnRemove.set_tip(btnRemove, "Remove vulnerability from database\nYour config file may result in this vulnerability being added again") action_btn_box = gtk.HButtonBox() action_btn_box.set_layout(gtk.BUTTONBOX_SPREAD) action_btn_box.set_spacing(20) action_btn_box.add(btnAck) action_btn_box.add(btnRemove) right_frame = gtk.Frame("Actions") right_frame.set_size_request(250,100) right_frame.add(action_btn_box) top_vbox.pack_start(self.lbl_cve, padding=2) top_vbox.pack_start(self.lbl_date, padding=2) top_vbox.pack_start(self.lbl_desc, padding=2) top_vbox.pack_start(self.linkbutton1, padding=2) top_hbox.pack_start(top_vbox) top_hbox.pack_start(top_halign) top_hbox.pack_start(right_frame, False, False, 20) main_vbox.pack_start(top_hbox, False, False, 10) ################################################################ # Treeview part of window ################################################################ # Make the main window scrollable swindow = gtk.ScrolledWindow() swindow.set_shadow_type(gtk.SHADOW_ETCHED_IN) swindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) # Put scollable window in the VBox main_vbox.pack_start(swindow, True, True, 0) # Create Model for list store self.store = self.list_model() self.treeview = gtk.TreeView(self.store) self.treeview.set_rules_hint(True) # Create the columns self.create_columns(self.treeview) select = self.treeview.get_selection() select.connect("changed", self.row_selected) btnAck.connect("clicked", self.action, self.treeview, "acknowledge") btnRemove.connect("clicked", self.action, self.treeview, "remove") # Add treeview to scrollable window swindow.add(self.treeview) self.window.add(main_vbox) # Show window self.window.show_all() # Select the first item on the list self.treeview.grab_focus() select.select_path(0)
callback(current) current = current.get_next() ######################################################################## # MAIN FUNCTION ######################################################################## if __name__ == "__main__": if len(sys.argv) > 1: search = sys.argv[1] else: search = "CSRF" # Initialize database... db = vulndb.db() # create a list to hold the entire feed Vulns = VulnList() # create a list to hold matched vulnerabilities GOING AWAY???? MatchedVulns = VulnList() # get nist feed and set xml root #feed = getFeed() feed = getFeed() root = ET.fromstring(feed) for i in root: info = [] info.append(i[0].text) # CVE info.append(i[1].text) # Link info.append(i[2].text) # description info.append(i[3].text) # date