[Secure-testing-commits] r34474 - bin lib/python
Florian Weimer
fw at moszumanska.debian.org
Sun May 24 19:36:20 UTC 2015
Author: fw
Date: 2015-05-24 19:36:19 +0000 (Sun, 24 May 2015)
New Revision: 34474
Modified:
bin/tracker_service.py
lib/python/security_db.py
Log:
Introduce named tuples BugsForSourcePackage, DSAsForSourcePackage
Modified: bin/tracker_service.py
===================================================================
--- bin/tracker_service.py 2015-05-24 17:30:17 UTC (rev 34473)
+++ bin/tracker_service.py 2015-05-24 19:36:19 UTC (rev 34474)
@@ -587,8 +587,8 @@
self.db.cursor(), pkg):
yield release, version
def gen_bug_list(lst):
- for (bug, description) in lst:
- yield self.make_xref(url, bug), description
+ for bug in lst:
+ yield self.make_xref(url, bug.bug), bug.description
suites = ()
for (release, version) in self.db.getSourcePackageVersions(
@@ -597,10 +597,10 @@
suites = suites + (release,)
def gen_summary(bugs):
- for (bug, description) in bugs:
+ for bug in bugs:
status = {}
for (package, releases, version, vulnerable) \
- in self.db.getSourcePackages(self.db.cursor(), bug):
+ in self.db.getSourcePackages(self.db.cursor(), bug.bug):
for release in releases:
if package == pkg:
if vulnerable == 1:
@@ -615,7 +615,8 @@
status_row = status_row + (status[release],)
else:
status_row = status_row + (self.make_purple('unknown'),)
- yield (self.make_xref(url, bug),) + status_row + (description,)
+ yield (self.make_xref(url, bug.bug),) + status_row \
+ + (bug.description,)
return self.create_page(
url, 'Information on source package ' + pkg,
Modified: lib/python/security_db.py
===================================================================
--- lib/python/security_db.py 2015-05-24 17:30:17 UTC (rev 34473)
+++ lib/python/security_db.py 2015-05-24 19:36:19 UTC (rev 34474)
@@ -39,6 +39,8 @@
import types
import zlib
+from collections import namedtuple
+
import debian_support
import dist_config
@@ -98,6 +100,21 @@
The caller is expected to remove and regenerate the database."""
+ def getBugsForSourcePackage(self, cursor, pkg, vulnerable, unimportant):
+ """Returns a generator for a list of (BUG, DESCRIPTION) pairs
+ which have the requested status. Only bugs affecting supported
+ releases are returned."""
+
+# Returned by DB.getBugsForSourcePackage().
+BugsForSourcePackage = namedtuple(
+ "BugsForSourcePackage",
+ "bug description")
+
+# Returned by DB.getDSAsForSourcePackage().
+DSAsForSourcePackage = namedtuple(
+ "DSAsForSourcePackage",
+ "bug description")
+
class DB:
"""Access to the security database.
@@ -1719,10 +1736,11 @@
return flag
def getBugsForSourcePackage(self, cursor, pkg, vulnerable, unimportant):
- """Returns a generator for a list of (BUG, DESCRIPTION) pairs
- which have the requested status. Only bugs affecting supported
- releases are returned."""
- return cursor.execute(
+ """Returns a generator for BugsForSourcePackage named tuples which
+ have the requested status. Only bugs affecting supported
+ releases are returned.
+ """
+ for row in cursor.execute(
"""SELECT DISTINCT name, description
FROM (SELECT bugs.name AS name, bugs.description AS description,
MAX(st.vulnerable
@@ -1742,16 +1760,18 @@
AND (bugs.name LIKE 'CVE-%' OR bugs.name LIKE 'TEMP-%')
GROUP BY bugs.name, bugs.description, sp.name)
WHERE vulnerable = ? AND unimportant = ?
- ORDER BY name DESC""", (pkg, vulnerable, unimportant))
+ ORDER BY name DESC""", (pkg, vulnerable, unimportant)):
+ yield BugsForSourcePackage(*row)
def getDSAsForSourcePackage(self, cursor, package):
- return cursor.execute(
+ for row in cursor.execute(
"""SELECT bugs.name, bugs.description
FROM bugs, package_notes as p
WHERE p.bug_name = bugs.name
AND ( bugs.name LIKE 'DSA-%' OR bugs.name LIKE 'DLA-%')
AND p.package = ?
- ORDER BY bugs.release_date DESC""", (package,))
+ ORDER BY bugs.release_date DESC""", (package,)):
+ yield DSAsForSourcePackage(*row)
def getTODOs(self, cursor=None, hide_check=False):
More information about the Secure-testing-commits
mailing list