Esempio n. 1
0
 def getcpe(self, cpeid=None):
     if not self.namelookup:
         return cpeid
     e = getCPE(cpeid)
     if e is None:
         e = getAlternativeCPE(cpeid)
         if e is None:
             return cpeid
     if "id" in e:
         return e["title"]
Esempio n. 2
0
def lookupcpe(cpeid=None):
    e = getCPE(cpeid)
    if e is None:
        return cpeid
    if "id" in e:
        return e["title"]
else:
    collections = getCVEs()["results"]
# check cpes for cves and parse and store missing cpes in cpeother
batch = []

# skip on empty collections
col = list(collections)
if not col:
    print("Empty collections, import skipped")
    sys.exit(2)

for item in tqdm(col):
    for cpeentry in item["vulnerable_configuration"]:
        checkdup = getAlternativeCPE(cpeentry)
        if checkdup and len(checkdup) <= 0:
            entry = getCPE(cpeentry)
            if entry and len(entry.count) <= 0:
                title = cpeentry
                title = title[10:]
                title = title.replace(":-:", " ", 10)
                title = title.replace(":", " ", 10)
                title = title.replace("_", " ", 10)
                title = urllib.parse.unquote_plus(title)

                title = title.title()
                batch.append({"id": cpeentry, "title": title})
if len(batch) != 0:
    cpeotherBulkInsert(batch)

# update database info after successful program-run
setColUpdate("cpeother", icve)