| 1 |
#!/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 |
root_path = setup_paths()
|
| 20 |
|
| 21 |
import bugs
|
| 22 |
import debian_support
|
| 23 |
import security_db
|
| 24 |
|
| 25 |
db_file = root_path + '/data/security.db'
|
| 26 |
new_file = not os.path.exists(db_file)
|
| 27 |
db = security_db.DB(db_file)
|
| 28 |
if new_file:
|
| 29 |
db.initSchema()
|
| 30 |
cursor = db.writeTxn()
|
| 31 |
db.deleteBugs(cursor)
|
| 32 |
try:
|
| 33 |
db.insertBugs(cursor, bugs.CVEFile(root_path + '/data/CAN/list'))
|
| 34 |
db.insertBugs(cursor, bugs.CVEFile(root_path + '/data/CVE/list',
|
| 35 |
no_version_needs_note=False))
|
| 36 |
db.insertBugs(cursor, bugs.DSAFile(root_path + '/data/DSA/list'))
|
| 37 |
db.insertBugs(cursor, bugs.DTSAFile(root_path + '/data/DTSA/list'))
|
| 38 |
except debian_support.ParseError, e:
|
| 39 |
db.rollback(cursor)
|
| 40 |
e.printOut(sys.stderr)
|
| 41 |
sys.exit(1)
|
| 42 |
except security_db.InsertError, e:
|
| 43 |
db.rollback(cursor)
|
| 44 |
for err in e.errors:
|
| 45 |
print err
|
| 46 |
sys.exit(1)
|
| 47 |
|
| 48 |
warnings = db.finishBugs(cursor)
|
| 49 |
if warnings:
|
| 50 |
db.rollback(cursor)
|
| 51 |
for x in warnings:
|
| 52 |
print x
|
| 53 |
sys.exit(1)
|
| 54 |
else:
|
| 55 |
db.commit(cursor)
|