Exemplo n.º 1
0
 def getSearchResults(self, text, **args):
     result = {"data": []}
     results = []
     # Get all data
     for plugin in self.plugins.values():
         data = plugin.search(text, **args)
         # Validate format
         if type(data) == dict:
             data = [data]
         if type(data) == list and all(
             [(type(x) == dict and "n" in x and "d" in x) for x in data]):
             results.extend(data)
     # Sort through data
     for collection in results:
         for item in collection["d"]:
             # Check if already in result data
             try:
                 if not any(item == entry["id"]
                            for entry in result["data"]):
                     entry = getCVE(item)
                     entry["reason"] = collection["n"]
                     result["data"].append(entry)
             except:
                 pass
     return result
Exemplo n.º 2
0
    def getcve(self, cveid=None):
        if cveid is not None:
            e = getCVE(cveid, collection=self.collection)
            if e is None:
                return None
            if "cwe" in e and self.capeclookup:
                if e["cwe"].lower() != "unknown":
                    e["capec"] = self.getcapec(cweid=(e["cwe"].split("-")[1]))
            if "vulnerable_configuration" in e:
                vulconf = []
                ranking = []
                for conf in e["vulnerable_configuration"]:
                    vulconf.append({"id": conf, "title": self.getcpe(cpeid=conf)})
                    if self.rankinglookup:
                        rank = self.getranking(cpeid=conf)
                        if rank and rank not in ranking:
                            ranking.append(rank)
                e["vulnerable_configuration"] = vulconf
            if self.rankinglookup and len(ranking) > 0:
                e["ranking"] = ranking
            if self.via4lookup:
                f = self.getVIA4(cveid)
                if isinstance(f, dict):
                    e = dict(itertools.chain(e.items(), f.items()))
        else:
            e = None

        return e
Exemplo n.º 3
0
def getcve(cveid=None):
    if cveid is None:
        return False
    return getCVE(cveid)