Author: fw
Date: 2010-05-04 15:05:57 +0000 (Tue, 04 May 2010)
New Revision: 14600
Modified:
lib/python/security_db.py
Log:
lib/python/security_db.py: remove binary_package_status table
We no longer track binary packages.
Modified: lib/python/security_db.py
==================================================================---
lib/python/security_db.py 2010-05-04 09:15:11 UTC (rev 14599)
+++ lib/python/security_db.py 2010-05-04 15:05:57 UTC (rev 14600)
@@ -291,17 +291,7 @@
"""CREATE INDEX source_package_status_package
ON source_package_status(package)""")
- cursor.execute("""CREATE TABLE binary_package_status
- (bug_name TEXT NOT NULL,
- package INTEGER NOT NULL,
- vulnerable INTEGER NOT NULL,
- urgency TEXT NOT NULL,
- PRIMARY KEY (bug_name, package))""")
cursor.execute(
- """CREATE INDEX binary_package_status_package
- ON binary_package_status(package)""")
-
- cursor.execute(
"CREATE TABLE removed_packages (name TEXT NOT NULL PRIMARY
KEY)")
cursor.execute(
@@ -1025,7 +1015,6 @@
if self.verbose:
print " remove old status"
cursor.execute("DELETE FROM source_package_status")
- cursor.execute("DELETE FROM binary_package_status")
cursor.execute("DELETE FROM bug_status")
if self.verbose:
@@ -1060,86 +1049,6 @@
WHERE p.name = n.package
AND p.release = n.release""")
- if self.verbose:
- print " binary packages (from source packages)"
- cursor.execute(
- """INSERT INTO binary_package_status
- SELECT n.bug_name, p.rowid,
- CASE WHEN n.fixed_version == ''undetermined'' THEN
2
- ELSE CASE WHEN n.fixed_version IS NULL THEN 1
- ELSE CASE WHEN p.version_id < n.fixed_version_id THEN 1
- ELSE 0 END END END,
- n.urgency
- FROM package_notes AS n, binary_packages AS p
- WHERE n.release = '''' AND p.source =
n.package""")
-
- cursor.execute(
- """INSERT OR REPLACE INTO binary_package_status
- SELECT n.bug_name, p.rowid,
- CASE WHEN n.fixed_version == ''undetermined'' THEN
2
- ELSE CASE WHEN n.fixed_version IS NULL THEN 1
- ELSE CASE WHEN p.version_id < n.fixed_version_id THEN 1
- ELSE 0 END END END,
- n.urgency
- FROM package_notes AS n, binary_packages AS p
- WHERE p.source = n.package AND p.release =
n.release""")
-
- # Almost the same for binary packages. We prefer interpreting
- # package names as source packages, so we only process the
- # notes which refer to binary packages. (Of course, we do not
- # have to add status information for binary package
- # separately.)
-
- if self.verbose:
- print " binary packages (unqualified)"
- cursor.execute(
- """INSERT INTO binary_package_status
- SELECT n.bug_name, p.rowid,
- CASE WHEN n.fixed_version == ''undetermined'' THEN
2
- ELSE CASE WHEN n.fixed_version IS NULL THEN 1
- ELSE CASE WHEN p.version_id < n.fixed_version_id THEN 1
- ELSE 0 END END END,
- n.urgency
- FROM package_notes AS n, binary_packages AS p
- WHERE n.release = '''' AND p.name = n.package
- AND n.package_kind = ''binary''""")
-
- if self.verbose:
- print " binary packages (qualified)"
- cursor.execute(
- """INSERT OR REPLACE INTO binary_package_status
- SELECT n.bug_name, p.rowid,
- CASE WHEN n.fixed_version == ''undetermined'' THEN
2
- ELSE CASE WHEN n.fixed_version IS NULL THEN 1
- ELSE CASE WHEN p.version_id < n.fixed_version_id THEN 1
- ELSE 0 END END END,
- n.urgency
- FROM package_notes AS n, binary_packages AS p
- WHERE p.name = n.package AND p.release = n.release
- AND n.package_kind = ''binary''""")
-
- if self.verbose:
- print " source packages (from binary packages)"
- cursor.execute(
- """INSERT INTO source_package_status
- SELECT n.bug_name, s.rowid,
- MAX( CASE WHEN n.fixed_version == ''undetermined''
THEN 2
- ELSE CASE WHEN n.fixed_version IS NULL THEN 1
- ELSE CASE WHEN b.version_id < n.fixed_version_id THEN 1
- ELSE 0 END END END ),
- MAX(n.urgency)
- FROM package_notes AS n, binary_packages AS b,
- source_packages AS s
- WHERE n.package_kind = ''binary'' AND b.name =
n.package
- AND s.name = b.source
- AND s.release = b.release AND s.subrelease = b.subrelease
- AND s.archive = b.archive
- GROUP BY n.bug_name, s.rowid, s.release""")
- # The "GROUP BY" is needed because we we might have multiple
- # rows in the binary_packages table for different
- # architectures.
- # FIXME: MAX(n.urgency) is wrong.
-
# assign nvd urgencies to those that have not yet been assigned
if self.verbose:
print " insert nvd urgencies"
@@ -1154,16 +1063,6 @@
WHERE s.bug_name == n.cve_name
AND s.urgency == ''not yet
assigned''""")
cursor.execute(
- """REPLACE INTO binary_package_status
- SELECT b.bug_name, b.package, b.vulnerable,
- CASE WHEN n.severity == ''Medium'' THEN
''medium**''
- ELSE CASE WHEN n.severity == ''High'' THEN
''high**''
- ELSE CASE WHEN n.severity == ''Low'' THEN
''low**''
- ELSE ''not yet assigned'' END END END
- FROM nvd_data AS n, binary_package_status AS b
- WHERE b.bug_name == n.cve_name
- AND b.urgency == ''not yet
assigned''""")
- cursor.execute(
"""REPLACE INTO package_notes
SELECT p.id, p.bug_name, p.package, p.fixed_version,
p.fixed_version_id, p.release, p.package_kind,
@@ -1406,15 +1305,6 @@
AND st.bug_name = ?
AND st.package = p.rowid
ORDER BY p.version COLLATE version DESC"""
- elif kind == ''binary'':
- fix_available_sql = """SELECT st.vulnerable
- FROM binary_packages AS p, binary_package_status AS st
- WHERE p.name = ?
- AND p.release = ?
- AND p.subrelease IN ('''',
''security'')
- AND st.bug_name = ?
- AND st.package = p.rowid
- ORDER BY p.version COLLATE version DESC"""
else:
fix_available_sql = ''''
@@ -1766,33 +1656,6 @@
(bug,)):
yield package, releases.split('', ''), version,
vulnerable
- def getBinaryPackages(self, cursor, bug):
- """A generator which returns tuples
(BINARY-PACKAGE-LIST,
- RELEASE-LIST, VERSION, ARCH-LIST, VULNERABLE-FLAG) of binary
- packages which are related to the given bug."""
-
- for (packages, releases, version, archs, vulnerable) in cursor.execute(
- """SELECT string_list(package) AS packages,
releases,
- version, archs, vulnerable
- FROM (SELECT package, string_set(release) AS releases,
- version, archs, vulnerable
- FROM (SELECT p.name AS package,
- release_name(p.release, p.subrelease, p.archive) AS release,
- p.version AS version, string_set(archs) AS archs,
- s.vulnerable AS vulnerable
- FROM binary_package_status AS s, binary_packages AS p
- WHERE s.bug_name = ? AND p.rowid = s.package
- GROUP BY p.name, p.release, p.subrelease, p.archive,
- p.version, vulnerable
- ORDER BY release_to_number(p.release), p.subrelease)
- GROUP BY package, version, vulnerable, archs
- ORDER BY package)
- GROUP BY releases, version, vulnerable, archs
- ORDER BY packages, version COLLATE version""",
- (bug,)):
- yield (packages.split('', ''),
releases.split('',''), version,
- archs.split('',''), vulnerable)
-
def getBugsFromDebianBug(self, cursor, number):
"""A generator which returns a list of tuples
(BUG-NAME, URGENCY, DESCRIPTION)."""
@@ -1843,35 +1706,6 @@
WHERE vulnerable = ?
ORDER BY name""", (pkg, vulnerable))
- def getBugsForBinaryPackage(self, cursor, pkg, vulnerable):
- """Returns a generator for a list of (BUG, DESCRIPTION)
pairs
- which have the requested status."""
- return cursor.execute(
- """SELECT name, description
- FROM (SELECT bugs.name AS name, bugs.description AS description,
- MAX(st.vulnerable) AS vulnerable
- FROM binary_packages AS bp, binary_package_status AS st, bugs
- WHERE bp.name = ?
- AND bp.release <> ''woody''
- AND st.package = bp.rowid
- AND st.urgency <> ''unimportant''
- AND bugs.name = st.bug_name
- GROUP BY bugs.name, bugs.description)
- WHERE vulnerable = ?
- ORDER BY name""", (pkg, vulnerable))
-
- def getNonBugsForBinaryPackage(self, cursor, pkg):
- """Returns a generator for a list of (BUG, DESCRIPTION)
pairs
- which have the requested status."""
-
- return cursor.execute(
- """SELECT DISTINCT bugs.name, bugs.description
- FROM binary_packages AS bp, binary_package_status AS st, bugs
- WHERE bp.name = ? AND st.package = bp.rowid
- AND st.urgency = ''unimportant''
- AND bugs.name = st.bug_name
- ORDER BY bugs.name""", (pkg,))
-
def getTODOs(self, cursor=None, hide_check=False):
"""Returns a list of pairs (BUG-NAME,
DESCRIPTION)."""
if cursor is None: