| 1 |
fw |
1994 |
#!/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 bugs |
| 22 |
|
|
import debian_support |
| 23 |
|
|
import security_db |
| 24 |
|
|
|
| 25 |
|
|
db_file = 'data/security.db' |
| 26 |
|
|
try: |
| 27 |
|
|
db = security_db.DB(db_file, verbose=True) |
| 28 |
fw |
2000 |
new_file = False |
| 29 |
fw |
1994 |
except security_db.SchemaMismatch: |
| 30 |
|
|
os.unlink(db_file) |
| 31 |
|
|
db = security_db.DB(db_file, verbose=True) |
| 32 |
fw |
2000 |
new_file = True |
| 33 |
fw |
1994 |
|
| 34 |
|
|
cursor = db.writeTxn() |
| 35 |
|
|
|
| 36 |
|
|
# Bug lists (CAN/CVE/DSA/DTSA) |
| 37 |
|
|
|
| 38 |
|
|
try: |
| 39 |
|
|
warnings = db.readBugs(cursor, 'data') |
| 40 |
|
|
except debian_support.ParseError, e: |
| 41 |
|
|
e.printOut(sys.stderr) |
| 42 |
|
|
sys.exit(1) |
| 43 |
|
|
except security_db.InsertError, e: |
| 44 |
|
|
for err in e.errors: |
| 45 |
|
|
print err |
| 46 |
|
|
sys.exit(1) |
| 47 |
|
|
if warnings: |
| 48 |
|
|
for x in warnings: |
| 49 |
|
|
print x |
| 50 |
|
|
sys.exit(1) |
| 51 |
|
|
|
| 52 |
|
|
# Packages |
| 53 |
|
|
|
| 54 |
|
|
db.readPackages(cursor, 'data/packages') |
| 55 |
|
|
|
| 56 |
fw |
2000 |
if new_file: |
| 57 |
|
|
db.commit(cursor) |
| 58 |
|
|
cursor = db.writeTxn() |
| 59 |
|
|
|
| 60 |
fw |
2088 |
# Removed packages |
| 61 |
|
|
|
| 62 |
|
|
db.readRemovedPackages(cursor, 'data/packages/removed-packages') |
| 63 |
|
|
|
| 64 |
fw |
1994 |
# Calculate vulnerability information. |
| 65 |
|
|
|
| 66 |
|
|
warnings = db.calculateVulnerabilities(cursor) |
| 67 |
|
|
if warnings: |
| 68 |
|
|
for x in warnings: |
| 69 |
|
|
print x |
| 70 |
|
|
sys.exit(1) |
| 71 |
|
|
|
| 72 |
|
|
# Everything worked well. |
| 73 |
|
|
|
| 74 |
|
|
db.commit(cursor) |