summaryrefslogtreecommitdiffstats
path: root/bin/update-nvd
blob: 88fe39450b05fc8a22f149e43b08735c1bd3cb17 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/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 = file(name)
    data += nvd.parse(f)
    f.close()

cursor = db.writeTxn()
if incremental:
    db.updateNVD(cursor, data)
else:
    db.replaceNVD(cursor, data)
db.commit(cursor)

© 2014-2024 Faster IT GmbH | imprint | privacy policy