Exemplo n.º 1
0
 def getcpe(self, cpeid=None):
     if not(self.namelookup):
         return cpeid
     e = db.getCPE(cpeid)
     if e is None:
         e = db.getAlternativeCPE(cpeid)
         if e is None:
             return cpeid
     if 'id' in e:
         return e['title']
Exemplo n.º 2
0
 def getcpe(self, cpeid=None):
     if not (self.namelookup):
         return cpeid
     e = db.getCPE(cpeid)
     if e is None:
         e = db.getAlternativeCPE(cpeid)
         if e is None:
             return cpeid
     if 'id' in e:
         return e['title']
if date:
    collections = db.getCVEsNewerThan(icve)
else:
    collections = db.getCVEs()
# 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 progressbar(col):
    for cpeentry in item['vulnerable_configuration']:
        checkdup = db.getAlternativeCPE(cpeentry)
        if checkdup and len(checkdup) <= 0:
            entry = db.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:
    db.cpeotherBulkInsert(batch)
if date:
    collections = db.getCVEsNewerThan(icve)
else:
    collections = db.getCVEs()
# 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 progressbar(col):
    for cpeentry in item['vulnerable_configuration']:
        checkdup = db.getAlternativeCPE(cpeentry)
        if checkdup and len(checkdup) <= 0:
            entry = db.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:
    db.cpeotherBulkInsert(batch)