[Secure-testing-commits] r14057 - bin lib/python

Michael Gilbert gilbert-guest at alioth.debian.org
Sun Feb 7 22:10:49 UTC 2010


Author: gilbert-guest
Date: 2010-02-07 22:10:48 +0000 (Sun, 07 Feb 2010)
New Revision: 14057

Modified:
   bin/tracker_service.py
   lib/python/bugs.py
   lib/python/security_db.py
Log:
per-release page refactoring

Modified: bin/tracker_service.py
===================================================================
--- bin/tracker_service.py	2010-02-07 21:34:34 UTC (rev 14056)
+++ bin/tracker_service.py	2010-02-07 22:10:48 UTC (rev 14057)
@@ -24,8 +24,10 @@
     webservice_base_class = WebServiceHTTP
 
 class BugFilter:
-    default_action_list = [("hide_medium_urgency", "lower urgencies"),
-                           ("hide_non_remote", "local vulnerabilities")]
+    default_action_list = [("show_high_urgency", "only high urgencies"),
+                           ("show_medium_urgency", "only medium and high urgencies"),
+                           ("show_remote_only", "only remote vulnerabilities"),
+                           ("show_undetermined_urgency", "undetermined and unimportant urgencies")]
     def __init__(self, params, action_list=None):
         if action_list is None:
             self.action_list = self.default_action_list
@@ -41,35 +43,42 @@
         l = []
         for (prop, desc) in self.action_list:
             if self.params[prop]:
-                a = A(url.updateParamsDict({prop : None}),
-                      'Show ' + desc)
+                if self.params['show_medium_urgency'] and prop == 'show_medium_urgency':
+                    note = 'Restore lower than medium urgencies'
+                elif self.params['show_high_urgency'] and prop == 'show_high_urgency':
+                    note = 'Restore lower than high urgencies'
+                else:
+                    note = 'Hide ' + desc
+                l.append(TR(TD(A(url.updateParamsDict({prop : None}), note))))
             else:
-                a = A(url.updateParamsDict({prop : '1'}),
-                      'Hide ' + desc)
-            l.append(a)
-            l.append(' ')
+                note = 'Show ' + desc
+                l.append(TR(TD(A(url.updateParamsDict({prop : '1'}), note))))
 
-        return apply(P, l[:-1])
+        return TABLE(l)
 
-    def urgencyFiltered(self, urg):
-        """Returns True if the urgency urg is filtered."""
-        return self.params['hide_medium_urgency'] \
-               and urg not in ("high", "unknown", "")
+    def urgencyFiltered(self, urg, vuln):
+        """Returns True for urgencies that should be filtered."""
+        filterlow = self.params['show_medium_urgency'] and \
+                    urg in ('low', 'unimportant', 'undetermined')
+        filtermed = self.params['show_high_urgency'] and \
+                    urg in ('medium', 'low', 'unimportant', 'undetermined')
+        filteruni = not self.params['show_undetermined_urgency'] \
+                    and vuln == 2 or urg == 'unimportant'
+        return filterlow or filtermed or filteruni
 
     def remoteFiltered(self, remote):
-        """Returns True if the attack range is filtered."""
-        return remote is not None and self.params['hide_non_remote'] \
+        """Returns True for only remote flaws if filtered."""
+        return remote is not None and not self.params['show_remote_only'] \
                and not remote
 
 class BugFilterNoDSA(BugFilter):
     def __init__(self, params):
         BugFilter.__init__(self, params, self.default_action_list
-            + [('hide_nodsa', 'non-DSA vulnerabilities')])
-        self.hide_nodsa = int(params.get('hide_nodsa',(0,))[0])
+            + [('show_nodsa', 'non-DSA vulnerabilities')])
 
     def nodsaFiltered(self, nodsa):
-        """Returns True if no DSA will be issued for the bug."""
-        return nodsa and self.params['hide_nodsa']
+        """Returns True for no DSA issues if filtered."""
+        return nodsa and not self.params['show_nodsa']
 
 class TrackerService(webservice_base_class):
     head_contents = compose(STYLE(
@@ -624,17 +633,17 @@
         
         def gen():
             old_pkg_name = ''
-            for (pkg_name, bug_name, archive, urgency, remote, no_dsa) in \
+            for (pkg_name, bug_name, archive, urgency, vulnerable, remote, no_dsa) in \
                     self.db.cursor().execute(
-                """SELECT package, bug, section, urgency, remote, no_dsa
+                """SELECT package, bug, section, urgency, vulnerable, remote, no_dsa
                 FROM %s_status""" % release):
-                if bf.urgencyFiltered(urgency):
+                if bf.urgencyFiltered(urgency, vulnerable):
                     continue
                 if bf.remoteFiltered(remote):
                     continue
                 if bf.nodsaFiltered(no_dsa):
                     continue
-                
+
                 if pkg_name == old_pkg_name:
                     pkg_name = ''
                 else:
@@ -649,15 +658,11 @@
                 else:
                     remote = 'no'
 
-                if urgency == 'unknown':
-                    if no_dsa:
-                        urgency = 'no DSA'
-                    else:
-                        urgency = ''
-                elif urgency == 'high':
+                if vulnerable == 2:
+                    urgency = self.make_purple(urgency)
+
+                if urgency == 'high':
                     urgency = self.make_red(urgency)
-                elif urgency == 'undetermined':
-                    urgency = self.make_purple(urgency)
                 else:
                     if no_dsa:
                         urgency = urgency + '*'
@@ -666,7 +671,7 @@
 
         return self.create_page(
             url, 'Vulnerable source packages in the %s suite' % release,
-            [bf.actions(url),
+            [bf.actions(url), BR(),
              make_table(gen(), caption=("Package", "Bug", "Urgency",
                                         "Remote")),
              P('''(If a "*" is included in the urgency field, no DSA is planned
@@ -683,13 +688,13 @@
 
         def gen():
             old_pkg_name = ''
-            for (pkg_name, bug_name, archive, urgency,
+            for (pkg_name, bug_name, archive, urgency, vulnerable,
                  sid_vulnerable, ts_fixed, remote, no_dsa) \
                  in self.db.cursor().execute(
-                """SELECT package, bug, section, urgency, unstable_vulnerable,
-                testing_security_fixed, remote, no_dsa
+                """SELECT package, bug, section, urgency, vulnerable,
+                unstable_vulnerable, testing_security_fixed, remote, no_dsa
                 FROM testing_status"""):
-                if bf.urgencyFiltered(urgency):
+                if bf.urgencyFiltered(urgency, vulnerable):
                     continue
                 if bf.remoteFiltered(remote):
                     continue
@@ -710,6 +715,9 @@
                 else:
                     remote = 'no'
 
+                if sid_vulnerable == 2:
+                    urgency = self.make_purple(urgency)
+
                 if ts_fixed:
                     status = 'fixed in testing-security'
                 else:
@@ -718,9 +726,6 @@
                     else:
                         status = self.make_dangerous('fixed in unstable')
 
-                if urgency == 'unknown':
-                    urgency = ''
-
                 yield (pkg_name, self.make_xref(url, bug_name),
                        urgency, remote, status)
 
@@ -728,7 +733,7 @@
             url, 'Vulnerable source packages in the testing suite',
             [make_menu(url.scriptRelative,
                        ("status/dtsa-candidates", "Candidates for DTSAs")),
-             bf.actions(url),
+             bf.actions(url), BR(),
              make_table(gen(), caption=("Package", "Bug", "Urgency",
                                         "Remote"))])
 
@@ -738,18 +743,17 @@
 
         def gen():
             old_pkg_name = ''
-            for (pkg_name, bug_name, section, urgency, remote) \
+            for (pkg_name, bug_name, section, urgency, vulnerable, remote) \
                     in self.db.cursor().execute(
                 """SELECT DISTINCT sp.name, st.bug_name,
-                sp.archive, st.urgency,
+                sp.archive, st.urgency, st.vulnerable,
                 (SELECT range_remote FROM nvd_data
                  WHERE cve_name = st.bug_name)
                 FROM source_package_status AS st, source_packages AS sp
-                WHERE st.vulnerable AND st.urgency <> 'unimportant'
-                AND sp.rowid = st.package AND sp.release = ?
-                AND sp.subrelease = ''
+                WHERE st.vulnerable AND sp.rowid = st.package
+                AND sp.release = ?  AND sp.subrelease = ''
                 ORDER BY sp.name, st.bug_name""", (rel,)):
-                if bf.urgencyFiltered(urgency):
+                if bf.urgencyFiltered(urgency, vulnerable):
                     continue
                 if bf.remoteFiltered(remote):
                     continue
@@ -770,14 +774,13 @@
                 else:
                     remote = 'no'
 
-                if urgency == 'unknown':
-                    urgency = ''
-                elif urgency == 'high':
+                if urgency == 'high':
                     urgency = self.make_red(urgency)
-                elif urgency == 'undetermined':
+                elif vulnerable == 2:
                     urgency = self.make_purple(urgency)
 
                 yield pkg_name, self.make_xref(url, bug_name), urgency, remote
+
         return self.create_page(
             url, title,
             [P("""Note that the list below is based on source packages.
@@ -785,7 +788,7 @@
             fixed source version has been uploaded to the archive, even
             if there are still some vulnerably binary packages present
             in the archive."""),
-             bf.actions(url),
+             bf.actions(url), BR(),
              make_table(gen(), caption=('Package', 'Bug', 'Urgency',
                                         'Remote'))])
 
@@ -812,10 +815,10 @@
 
         def gen():
             old_pkg_name = ''
-            for (pkg_name, bug_name, archive, urgency, stable_later,
-                 remote) \
+            for (pkg_name, bug_name, archive, urgency, vulnerable,
+                 stable_later, remote) \
                     in self.db.cursor().execute(
-                """SELECT package, bug, section, urgency,
+                """SELECT package, bug, section, urgency, vulnerable,
                 (SELECT testing.version_id < stable.version_id
                  FROM source_packages AS testing, source_packages AS stable
                  WHERE testing.name = testing_status.package
@@ -831,7 +834,7 @@
                 FROM testing_status
                 WHERE (NOT unstable_vulnerable)
                 AND (NOT testing_security_fixed)"""):
-                if bf.urgencyFiltered(urgency):
+                if bf.urgencyFiltered(urgency, vulnerable):
                     continue
                 if bf.remoteFiltered(remote):
                     continue
@@ -855,9 +858,7 @@
                 else:
                     remote = 'no'
 
-                if urgency == 'unknown':
-                    urgency = ''
-                elif urgency == 'high':
+                if urgency == 'high':
                     urgency = self.make_red(urgency)
 
                 if stable_later:
@@ -876,7 +877,7 @@
              make_menu(url.scriptRelative,
                        ("status/release/testing",
                         "List of vulnerable packages in testing")),
-             bf.actions(url),
+             bf.actions(url), BR(),
              make_table(gen(),
                         caption=("Package", "Migration", "Bug", "Urgency",
                                  "Remote"))])

Modified: lib/python/bugs.py
===================================================================
--- lib/python/bugs.py	2010-02-07 21:34:34 UTC (rev 14056)
+++ lib/python/bugs.py	2010-02-07 22:10:48 UTC (rev 14057)
@@ -23,7 +23,7 @@
 
 def listUrgencies():
     urgencies = {}
-    urgs = ("high", "medium", "low", "unimportant", "unknown", "undetermined")
+    urgs = ("high", "medium", "low", "unimportant", "undetermined")
     for u in range(len(urgs)):
         urgencies[urgs[u]] = Urgency(urgs[u], -u)
     Urgency.urgencies = urgencies
@@ -140,7 +140,10 @@
 
     def __init__(self, package, version, notes, release=None):
         bugs = []
-        urgency = "unknown"
+        if version == 'undetermined':
+            urgency = 'undetermined'
+        else:
+            urgency = 'low'
         if notes is not None:
             for n in self.re_notes_split.split(notes):
                 u = internUrgency(n)
@@ -611,11 +614,8 @@
                                              (p, None, d, release=release))
                             self.removed_packages[p] = True
                         elif v == 'undetermined':
-                            if not d:
-                                d = 'undetermined'
                             pkg_notes.append(PackageNoteParsed
-                                             (p, 'undetermined', 'undetermined', 
-                                              release=release))
+                                             (p, 'undetermined', d, release=release))
                         else:
                             self.raiseSyntaxError(
                                 "invalid special version %s in package entry"

Modified: lib/python/security_db.py
===================================================================
--- lib/python/security_db.py	2010-02-07 21:34:34 UTC (rev 14056)
+++ lib/python/security_db.py	2010-02-07 22:10:48 UTC (rev 14057)
@@ -362,6 +362,7 @@
             """CREATE VIEW testing_status AS
             SELECT DISTINCT sp.name AS package, st.bug_name AS bug,
             sp.archive AS section, st.urgency AS urgency,
+            st.vulnerable AS vulnerable,
             (SELECT vulnerable
             FROM source_packages AS sidp, source_package_status AS sidst
             WHERE sidp.name = sp.name
@@ -383,9 +384,8 @@
             AND pnd.package = sp.name
             AND pnd.release = 'squeeze')) AS no_dsa
             FROM source_package_status AS st, source_packages AS sp
-            WHERE st.vulnerable AND st.urgency <> 'unimportant'
-            AND sp.rowid = st.package AND sp.release = 'squeeze'
-            AND sp.subrelease = ''
+            WHERE st.vulnerable > 0 AND sp.rowid = st.package
+            AND sp.release = 'squeeze' AND sp.subrelease = ''
             ORDER BY sp.name, st.urgency, st.bug_name""")
 
         for (name, nickname) in (('stable', 'lenny'), ('oldstable', 'etch'),):
@@ -393,6 +393,7 @@
                 """CREATE VIEW %s_status AS
                 SELECT DISTINCT sp.name AS package, st.bug_name AS bug,
                 sp.archive AS section, st.urgency AS urgency,
+                st.vulnerable AS vulnerable,
                 (SELECT range_remote FROM nvd_data
                  WHERE cve_name = st.bug_name) AS remote,
                 (EXISTS (SELECT * FROM package_notes_nodsa AS pnd
@@ -400,9 +401,8 @@
                  AND pnd.package = sp.name
                  AND pnd.release = '%s')) AS no_dsa
                 FROM source_package_status AS st, source_packages AS sp
-                WHERE st.vulnerable AND st.urgency <> 'unimportant'
-                AND sp.rowid = st.package AND sp.release = '%s'
-                AND sp.subrelease = ''
+                WHERE st.vulnerable > 0 AND sp.rowid = st.package
+                AND sp.release = '%s' AND sp.subrelease = ''
                 AND NOT COALESCE((SELECT NOT vulnerable
                 FROM source_packages AS secp, source_package_status AS secst
                 WHERE secp.name = sp.name
@@ -413,8 +413,6 @@
                 ORDER BY sp.name, urgency_to_number(urgency), st.bug_name"""
                 % (name, nickname, nickname, nickname))
 
-        
-
     def _initFunctions(self):
         """Registers user-defined SQLite functions."""
 




More information about the Secure-testing-commits mailing list