Example #1
0
    def notify(self, db, collection, iid, action, _parent):
        """
        Callback for the observer implemented in mongo.py.
        Each time an object is inserted, updated or deleted the standard way, this function will be called.

        Args:
            collection: the collection that has been modified
            iid: the mongo ObjectId _id that was modified/inserted/deleted
            action: string "update" or "insert" or "delete". It was the action performed on the iid
            _parent: Not used. the mongo ObjectId of the parent. Only if action in an insert. Not used anymore
        """
        apiclient = APIClient.getInstance()
        if not apiclient.getCurrentPentest() != "":
            return
        if apiclient.getCurrentPentest() != db:
            return
        if action == "update":
            if collection == "defects":
                defect_m = Defect.fetchObject({"_id": ObjectId(iid)})
                self.updateDefectInTreevw(defect_m, )
        elif action == "insert":
            view = None
            res = Defect.fetchObject({"_id": ObjectId(iid)})
            # Defect insertion takes place in calendarTreeview,
            # Remarks don't appear in the treeview, only in this module, so must notify here
            if collection == "remarks":
                self.addRemark(Remark.fetchObject({"_id": ObjectId(iid)}))
Example #2
0
 def removeItem(self, toDeleteIid):
     """
     Remove defect from given iid in defect treeview
     Args:
         toDeleteIid: database ID of defect to delete
     """
     try:
         item = self.treevw.item(toDeleteIid)
     except tk.TclError:
         return
     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:
         defectToDelete.delete()
         self.resizeDefectTreeview()
Example #3
0
 def OnDoubleClick(self, event):
     """
     Callback for double click on treeview.
     Opens a window to update the double clicked defect view.
     Args:
         event: automatically created with the event catch. stores data about line in treeview that was double clicked.
     """
     item = self.treevw.identify("item", event.x, event.y)
     if item is None or item == '':
         return
     defect_m = Defect.fetchObject({"_id": ObjectId(item)})
     dialog = ChildDialogDefectView(self.tkApp, self.settings, defect_m)
     self.parent.wait_window(dialog.app)
     self.updateDefectInTreevw(defect_m)