Example #1
0
 def onCVEAction(self, cve, action, **args):
   try:
     if args["current_user"].is_authenticated():
       query = {'user': args["current_user"].get_id()}
       if action == "see":
         db.p_addToList(self.collectionName, query, "cves", cve)
       elif action == "unsee":
         db.p_removeFromList(self.collectionName, query, "cves", cve)
       elif action == "save_settings":
         mode      = args["fields"]["mode"][0]
         buttons   = args["fields"]["buttons"][0]
         mark      = args["fields"]["mark"][0]
         filters   = args["fields"]["filters"][0]
         markcolor = args["fields"]["markcolor"][0]
         if (mode    in ["auto", "manual"] and buttons in ["show", "hide"] and
             mark    in ["show", "hide"]   and filters in ["show", "hide"] and
              re.match("^#[0-9A-Fa-f]{6}$", markcolor)):
           db.p_writeUserSetting(self.collectionName, args["current_user"].get_id(), "mode", mode)
           db.p_writeUserSetting(self.collectionName, args["current_user"].get_id(), "buttons", buttons)
           db.p_writeUserSetting(self.collectionName, args["current_user"].get_id(), "mark", mark)
           db.p_writeUserSetting(self.collectionName, args["current_user"].get_id(), "filters", filters)
           db.p_writeUserSetting(self.collectionName, args["current_user"].get_id(), "markcolor", markcolor)
         else: return False
       return True
     return False
   except Exception as e:
     print(e)
     return False
Example #2
0
 def onCVEOpen(self, cve, **args):
     if args["current_user"].is_authenticated():
         if db.p_readUserSetting(self.collectionName,
                                 args["current_user"].get_id(),
                                 "mode") == "auto":
             query = {'user': args["current_user"].get_id()}
             db.p_addToList(self.collectionName, query, "cves", cve)
Example #3
0
 def onCVEAction(self, cve, action, **args):
     try:
         query = {'user': args["current_user"].get_id()}
         if action == "bookmark":
             db.p_addToList(self.collectionName, query, "bookmarks", cve)
         elif action == "unbookmark":
             db.p_removeFromList(self.collectionName, query, "bookmarks",
                                 cve)
         return True
     except Exception as e:
         return False
Example #4
0
 def onCVEAction(self, cve, action, **args):
   if args["current_user"].is_authenticated():
     if   action == "save":
       data = db.p_queryOne(self.collectionName, {'cve': cve})
       user = args["current_user"].get_id()
       # Ensure the entry exists
       if not data: db.p_addEntry(self.collectionName, {"cve": cve, "notes": []})
       # Get note if exists:
       self._deleteIfExists(cve, user, int(args["fields"]["id"][0]))
       # Add note
       nid = db.p_readSetting(self.collectionName, "last_note") + 1
       db.p_addToList(self.collectionName, {'cve': cve}, "notes", {'id': nid, 'user': user, 'notes': args["fields"]["text"][0]})
       # Update last note id
       db.p_writeSetting(self.collectionName, "last_note", nid)
       return True
     elif action == "delete":
       user = args["current_user"].get_id()
       self._deleteIfExists(cve, user, int(args["fields"]["id"][0]))
       return True
Example #5
0
 def onCVEAction(self, cve, action, **args):
     try:
         if args["current_user"].is_authenticated():
             query = {'user': args["current_user"].get_id()}
             if action == "see":
                 db.p_addToList(self.collectionName, query, "cves", cve)
             elif action == "unsee":
                 db.p_removeFromList(self.collectionName, query, "cves",
                                     cve)
             elif action == "save_settings":
                 mode = args["fields"]["mode"][0]
                 buttons = args["fields"]["buttons"][0]
                 mark = args["fields"]["mark"][0]
                 filters = args["fields"]["filters"][0]
                 markcolor = args["fields"]["markcolor"][0]
                 if (mode in ["auto", "manual"]
                         and buttons in ["show", "hide"]
                         and mark in ["show", "hide"]
                         and filters in ["show", "hide"]
                         and re.match("^#[0-9A-Fa-f]{6}$", markcolor)):
                     db.p_writeUserSetting(self.collectionName,
                                           args["current_user"].get_id(),
                                           "mode", mode)
                     db.p_writeUserSetting(self.collectionName,
                                           args["current_user"].get_id(),
                                           "buttons", buttons)
                     db.p_writeUserSetting(self.collectionName,
                                           args["current_user"].get_id(),
                                           "mark", mark)
                     db.p_writeUserSetting(self.collectionName,
                                           args["current_user"].get_id(),
                                           "filters", filters)
                     db.p_writeUserSetting(self.collectionName,
                                           args["current_user"].get_id(),
                                           "markcolor", markcolor)
                 else:
                     return False
             return True
         return False
     except Exception as e:
         print(e)
         return False
Example #6
0
 def onCVEOpen(self, cve, **args):
   if args["current_user"].is_authenticated():
     if db.p_readUserSetting(self.collectionName, args["current_user"].get_id(), "mode") == "auto":
       query = {'user': args["current_user"].get_id()}
       db.p_addToList(self.collectionName, query, "cves", cve)
Example #7
0
 def onCVEOpen(self, cve, **args):
   if self._userAlowed(args["current_user"]):
     if db.p_readUserSetting(self.collectionName, args["current_user"].get_id(), "mode") == "auto":
       db.p_addToList(self.collectionName, {}, "cves", cve)
Example #8
0
 def onCVEOpen(self, cve, **args):
     if self._userAlowed(args["current_user"]):
         if db.p_readUserSetting(self.collectionName,
                                 args["current_user"].get_id(),
                                 "mode") == "auto":
             db.p_addToList(self.collectionName, {}, "cves", cve)