[Secure-testing-commits] r2034 - lib/python
Florian Weimer
fw at costa.debian.org
Sat Sep 17 22:38:41 UTC 2005
Author: fw
Date: 2005-09-17 22:38:40 +0000 (Sat, 17 Sep 2005)
New Revision: 2034
Modified:
lib/python/bugs.py
Log:
data/security.db (BugFromDB):
Load the bug even when an alias name is used (CAN vs. CVE, DSA
without revision number).
Modified: lib/python/bugs.py
===================================================================
--- lib/python/bugs.py 2005-09-17 16:44:12 UTC (rev 2033)
+++ lib/python/bugs.py 2005-09-17 22:38:40 UTC (rev 2034)
@@ -319,42 +319,70 @@
class BugFromDB(Bug):
def __init__(self, cursor, name):
assert type(name) == types.StringType
- for r in cursor.execute('SELECT * FROM bugs WHERE name = ?', (name,)):
- rdesc = cursor.getdescription()
- data = {}
- for j in range(len(rdesc)):
- data[rdesc[j][0]] = r[j]
- # FIXME: load date
- Bug.__init__(self, data['source_file'], data['source_line'],
- data['release_date'], name,
- data['description'], comments=[],
- notes=[], xref=[],
- not_for_us=not not data['not_for_us'])
- for (x,) in cursor.execute\
- ('SELECT target FROM bugs_xref WHERE source = ?', (name,)):
- self.xref.append(x)
- for (t, c) in cursor.execute\
- ("""SELECT typ, comment FROM bugs_notes
- WHERE bug_name = ?
- ORDER BY rowid""",
- (name,)):
- self.comments.append((t, c))
- # temporary list required because loadBugs needs the cursor
- for nid, package, fixed_version, release, urgency, package_kind \
- in list(cursor.execute
- ("""SELECT id, package, fixed_version, release, urgency,
- package_kind
- FROM package_notes WHERE bug_name = ?""", (name,))):
- n = PackageNote(package, fixed_version, release, urgency)
- n.id = nid
- n.bug_name = name
- n.package_kind = package_kind
- n.loadBugs(cursor)
- self.notes.append(n)
- return
- raise ValueError, "unknown bug " + `name`
+ def lookup(bug):
+ for r in cursor.execute('SELECT * FROM bugs WHERE name = ?',
+ (bug,)):
+ return r
+ else:
+ return None
+ def lookup_dsa(bug):
+ for r in cursor.execute(
+ """SELECT * FROM bugs
+ WHERE name = ? OR name LIKE (? || '-%')
+ ORDER BY release_date DESC
+ LIMIT 1""", (bug, bug,)):
+ return r
+ else:
+ return bug
+
+ r = lookup(name)
+ if r is None:
+ name_components = name.split('-')
+ name_source = name_components[0]
+ if name_source == 'CAN':
+ r = lookup('-'.join(['CVE'] + name_components[1:]))
+ elif name_source == 'CVE':
+ r = lookup('-'.join(['CAN'] + name_components[1:]))
+ elif name_source == 'DSA' and 2 <= len(name_components) <= 3:
+ r = lookup_dsa('DSA-' + name_components[1])
+ if r is None:
+ raise ValueError, "unknown bug " + `name`
+
+ rdesc = cursor.getdescription()
+ data = {}
+ for j in range(len(rdesc)):
+ data[rdesc[j][0]] = r[j]
+ name = data['name']
+ Bug.__init__(self, data['source_file'], data['source_line'],
+ data['release_date'], name,
+ data['description'], comments=[],
+ notes=[], xref=[],
+ not_for_us=not not data['not_for_us'])
+ for (x,) in cursor.execute\
+ ('SELECT target FROM bugs_xref WHERE source = ?', (name,)):
+ self.xref.append(x)
+ for (t, c) in cursor.execute\
+ ("""SELECT typ, comment FROM bugs_notes
+ WHERE bug_name = ?
+ ORDER BY rowid""",
+ (name,)):
+ self.comments.append((t, c))
+
+ # temporary list required because loadBugs needs the cursor
+ for nid, package, fixed_version, release, urgency, package_kind \
+ in list(cursor.execute
+ ("""SELECT id, package, fixed_version, release, urgency,
+ package_kind
+ FROM package_notes WHERE bug_name = ?""", (name,))):
+ n = PackageNote(package, fixed_version, release, urgency)
+ n.id = nid
+ n.bug_name = name
+ n.package_kind = package_kind
+ n.loadBugs(cursor)
+ self.notes.append(n)
+
def getDebianBugs(self, cursor):
"""Returns a list of Debian bugs to which the bug report refers."""
return map(lambda (x,): x, cursor.execute(
More information about the Secure-testing-commits
mailing list