summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFlorian Weimer <fw@deneb.enyo.de>2015-05-24 19:36:19 +0000
committerFlorian Weimer <fw@deneb.enyo.de>2015-05-24 19:36:19 +0000
commit8810a354aea0e2fc3c2a41a795090ce8aca8c1ea (patch)
treef168b5b558299ee4713f456ddf41e17c4b0221dc /lib
parentabca42fc23d307e6c9fff9b55c0afe4d4df28c24 (diff)
Introduce named tuples BugsForSourcePackage, DSAsForSourcePackage
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@34474 e39458fd-73e7-0310-bf30-c45bca0a0e42
Diffstat (limited to 'lib')
-rw-r--r--lib/python/security_db.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/python/security_db.py b/lib/python/security_db.py
index a09ef3f486..2844b2809f 100644
--- a/lib/python/security_db.py
+++ b/lib/python/security_db.py
@@ -39,6 +39,8 @@ import sys
import types
import zlib
+from collections import namedtuple
+
import debian_support
import dist_config
@@ -98,6 +100,21 @@ class SchemaMismatch(Exception):
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 @@ class DB:
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 @@ class DB:
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):

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