/[secure-testing]/bin/update-nvd
ViewVC logotype

Contents of /bin/update-nvd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10437 - (hide annotations) (download)
Thu Nov 20 15:15:24 2008 UTC (4 years, 6 months ago) by fw
File MIME type: text/script
File size: 1106 byte(s)
bin/update-nvd: Remove duplicates before loading NVD data
1 fw 2488 #!/usr/bin/python
2    
3     import os
4     import os.path
5     import string
6     import sys
7    
8     def setup_paths():
9     check_file = 'lib/python/debian_support.py'
10     path = os.getcwd()
11     while 1:
12     if os.path.exists("%s/%s" % (path, check_file)):
13     sys.path = [path + '/lib/python'] + sys.path
14     return path
15     idx = string.rfind(path, '/')
16     if idx == -1:
17     raise ImportError, "could not setup paths"
18     path = path[0:idx]
19     os.chdir(setup_paths())
20    
21     import nvd
22     import security_db
23    
24     db_file = 'data/security.db'
25     db = security_db.DB(db_file)
26    
27 fw 3078 incremental = False
28 fw 2488 data = []
29     for name in sys.argv[1:]:
30 fw 3078 if name == '-i':
31     incremental = True
32     continue
33 fw 2488 f = file(name)
34     data += nvd.parse(f)
35     f.close()
36    
37 fw 10437 # For some reason, NVD adds duplicates, so we need to get rid of them.
38     # Sort afterwords to increase locality in the insert process.
39     deduplicate = {}
40     for x in data:
41     deduplicate[x[0]] = x
42     data = deduplicate.values()
43     data.sort()
44    
45 fw 2488 cursor = db.writeTxn()
46 fw 3078 if incremental:
47     db.updateNVD(cursor, data)
48     else:
49     db.replaceNVD(cursor, data)
50 fw 2488 db.commit(cursor)

Properties

Name Value
svn:mime-type text/script

  ViewVC Help
Powered by ViewVC 1.1.5