#!/usr/bin/python import os import os.path import string import sys def setup_paths(): check_file = 'lib/python/debian_support.py' path = os.getcwd() while 1: if os.path.exists("%s/%s" % (path, check_file)): sys.path = [path + '/lib/python'] + sys.path return path idx = string.rfind(path, '/') if idx == -1: raise ImportError("could not setup paths") path = path[0:idx] os.chdir(setup_paths()) import nvd import security_db db_file = 'data/security.db' db = security_db.DB(db_file) incremental = False data = [] for name in sys.argv[1:]: if name == '-i': incremental = True continue f = open(name) data += nvd.parse(f) f.close() # For some reason, NVD adds duplicates, so we need to get rid of them. # Sort afterwords to increase locality in the insert process. deduplicate = {} for x in data: deduplicate[x[0]] = x data = deduplicate.values() data.sort() cursor = db.writeTxn() db.updateNVD(cursor, data, incremental) db.commit(cursor)