def cveItemsProcess(type, url, args): if args.v: print("%s... downloading: %s" % (type, url)) file = Configuration.getFile(url) try: (f, r) = file except: sys.exit( "Cannot open url %s. Bad URL or not connected to the internet?" % _url) # get your parser on !! parser = make_parser() ch = CVEHandler() parser.setContentHandler(ch) parser.parse(f) if args.u: i = db.getInfo("cves") if args.u: last_modified = parse_datetime(r.headers['last-modified'], ignoretz=True) if i is not None: if last_modified == i['last-modified']: print("Not modified") sys.exit(0) db.setColUpdate("cves", last_modified) if args.v: u_counter = 0 n_counter = 0 for item in progressbar(ch.cves): if 'cvss' not in item: item['cvss'] = None else: item['cvss'] = float(item['cvss']) if 'cwe' not in item: item['cwe'] = defaultvalue['cwe'] # check if already exists x = db.getCVE(item['id']) # if so, update the entry. if x: if args.v: u_counter += 1 db.updateCVE(item) else: if args.v: n_counter += 1 db.insertCVE(item) if args.v: print("New: %s Updated: %s" % (n_counter, u_counter)) print("")
db.setColUpdate("cves", last_modified) cvej = json.loads(f.read()) for cveitem in cvej['CVE_Items']: item = process_cve_item(item=cveitem) # check if the CVE already exists. x = db.getCVE(item['id']) # if so, update the entry. if x: if args.v: print('Update: {}'.format(item['id'])) print(item) db.updateCVE(item) else: if args.v: print('Insert: {}'.format(item['id'])) db.insertCVE(item) # get the 'recent' file getfile = file_prefix + file_rec + file_suffix try: (f, r) = Configuration.getFile( Configuration.getFeedURL('cve') + getfile) except: sys.exit( "Cannot open url %s. Bad URL or not connected to the internet?" % (Configuration.getFeedURL("cve") + getfile)) cvej = json.loads(f.read()) for cveitem in cvej['CVE_Items']: item = process_cve_item(item=cveitem) # check if the CVE already exists. x = db.getCVE(item['id']) # if so, update the entry.
parser = make_parser() ch = CVEHandler() parser.setContentHandler(ch) parser.parse(f) for item in ch.cves: # check if the CVE already exists. x = db.getCVE(item['id']) # if so, update the entry. if x: if 'cvss' not in item: item['cvss'] = None if 'cwe' not in item: item['cwe'] = defaultvalue['cwe'] db.updateCVE(item) else: db.insertCVE(item) # get the 'recent' file getfile = file_prefix + file_rec + file_suffix try: (f, r) = Configuration.getFile(Configuration.getCVEDict() + getfile, compressed=True) except: sys.exit( "Cannot open url %s. Bad URL or not connected to the internet?" % (Configuration.getCVEDict() + getfile)) parser = make_parser() ch = CVEHandler() parser.setContentHandler(ch) parser.parse(f) for item in progressbar(ch.cves):
parser = make_parser() ch = CVEHandler() parser.setContentHandler(ch) parser.parse(f) for item in ch.cves: # check if the CVE already exists. x = db.getCVE(item['id']) # if so, update the entry. if x: if 'cvss' not in item: item['cvss'] = None if 'cwe' not in item: item['cwe'] = defaultvalue['cwe'] db.updateCVE(item) else: db.insertCVE(item) # get the 'recent' file getfile = file_prefix + file_rec + file_suffix try: (f, r) = Configuration.getFile(Configuration.getCVEDict() + getfile, compressed = True) except: sys.exit("Cannot open url %s. Bad URL or not connected to the internet?"%(Configuration.getCVEDict() + getfile)) parser = make_parser() ch = CVEHandler() parser.setContentHandler(ch) parser.parse(f) for item in progressbar(ch.cves): # check if the CVE already exists. x = db.getCVE(item['id']) # if so, update the entry. if x:
parser = make_parser() ch = CVEHandler() parser.setContentHandler(ch) parser.parse(f) for item in ch.cves: # check if the CVE already exists. x = dbLayer.getCVE(item['id']) # if so, update the entry. if x: if 'cvss' not in item: item['cvss'] = defaultvalue['cvss'] if 'cwe' not in item: item['cwe'] = defaultvalue['cwe'] dbLayer.updateCVE(item) else: dbLayer.insertCVE(item) # get the 'recent' file getfile = file_prefix + file_rec + file_suffix try: f = Configuration.getFile(Configuration.getCVEDict() + getfile) except: sys.exit("Cannot open url %s. Bad URL or not connected to the internet?"%(Configuration.getCVEDict() + getfile)) parser = make_parser() ch = CVEHandler() parser.setContentHandler(ch) parser.parse(f) for item in progressbar(ch.cves): # check if the CVE already exists. x = dbLayer.getCVE(item['id']) # if so, update the entry. if x: