Пример #1
0
 def removeItem(self, toDeleteIid):
     """
     Remove defect from given iid in defect treeview
     Args:
         toDeleteIid: database ID of defect to delete
     """
     item = self.treevw.item(toDeleteIid)
     dialog = ChildDialogQuestion(
         self.parent, "DELETE WARNING",
         "Are you sure you want to delete defect " + str(item["text"]) +
         " ?", ["Delete", "Cancel"])
     self.parent.wait_window(dialog.app)
     if dialog.rvalue != "Delete":
         return
     self.treevw.delete(toDeleteIid)
     defectToDelete = Defect.fetchObject({
         "title": item["text"],
         "ip": "",
         "port": "",
         "proto": ""
     })
     if defectToDelete is not None:
         if defectToDelete.index is not None:
             index = int(defectToDelete.index)
             children = self.treevw.get_children()
             for i in range(index + 1, len(children), 1):
                 d_o = Defect({"_id": children[i]})
                 d_o.update({"index": str(i)})
         defectToDelete.delete()
         self.resizeDefectTreeview()
Пример #2
0
 def addDefect(self, defect_o):
     """
     Add the given defect object in the treeview
     Args:
         defect_o: a Models.Defect object to be inserted in treeview
     """
     if defect_o is None:
         return
     children = self.treevw.get_children()
     if defect_o.index is None or str(defect_o.index) == "":
         indToInsert = self.findInsertIndex(defect_o)
         if str(indToInsert) != "end":
             for i in range(int(indToInsert), len(children), 1):
                 d_o = Defect({"_id": children[i]})
                 d_o.update({"index": str(i + 1)})
     else:
         indToInsert = defect_o.index
     types = defect_o.mtype
     types = ", ".join(defect_o.mtype)
     new_values = (defect_o.ease, defect_o.impact, defect_o.risk, types,
                   defect_o.redactor
                   if defect_o.redactor != "N/A" else self.mainRedac)
     already_inserted = False
     already_inserted_iid = None
     for child in children:
         title = self.treevw.item(child)["text"]
         if title == defect_o.title:
             already_inserted = True
             already_inserted_iid = child
             break
     if not already_inserted:
         try:
             self.treevw.insert('',
                                indToInsert,
                                defect_o.getId(),
                                text=defect_o.title,
                                values=new_values,
                                tags=(defect_o.risk))
             defect_o.update({"index": str(indToInsert)})
         except tk.TclError:
             # The defect already exists
             already_inserted = True
             already_inserted_iid = defect_o.getId()
     if already_inserted:
         existing = self.treevw.item(already_inserted_iid)
         values = existing["values"]
         if values[4].strip() == "N/A":
             values[4] = defect_o.redactor
         elif defect_o.redactor not in values[4].split(", "):
             values[4] += ", " + defect_o.redactor
         self.treevw.item(already_inserted_iid, values=values)
     # mongoInstance.insert("defects_table",{""})
     self.resizeDefectTreeview()
Пример #3
0
 def setMainRedactor(self):
     """Sets a main redactor for a pentest. Each not assigned defect will be assigned to him/her"""
     self.settings.reloadSettings()
     dialog = ChildDialogCombo(self.parent, self.settings.getPentesters()+["N/A"], "Set main redactor", "N/A")
     newVal = self.parent.wait_window(dialog.app)
     if newVal is None:
         return
     if not newVal or newVal.strip() == "":
         return
     columnRedactor = self.treevw['columns'].index("redactor")
     for it in self.treevw.get_children():
         oldValues = self.treevw.item(it)["values"]
         if oldValues[columnRedactor] == "N/A":
             oldValues[columnRedactor] = newVal
             self.treevw.item(it, values=oldValues)
             d_o = Defect({"_id":it})
             d_o.update({"redactor":newVal})
     self.mainRedac = newVal