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

Holger Levsen holger at moszumanska.debian.org
Thu Feb 26 15:49:43 UTC 2015


Author: holger
Date: 2015-02-26 15:49:43 +0000 (Thu, 26 Feb 2015)
New Revision: 32509

Modified:
   bin/tracker_service.py
   lib/python/security_db.py
Log:
Dump data as .yaml via /tracker/data/yaml (Closes: #761859)

Modified: bin/tracker_service.py
===================================================================
--- bin/tracker_service.py	2015-02-26 15:41:14 UTC (rev 32508)
+++ bin/tracker_service.py	2015-02-26 15:49:43 UTC (rev 32509)
@@ -138,6 +138,7 @@
         self.register('data/funny-versions', self.page_data_funny_versions)
         self.register('data/fake-names', self.page_data_fake_names)
         self.register('data/pts/1', self.page_data_pts)
+        self.register('data/yaml', self.page_yaml)
         self.register('debsecan/**', self.page_debsecan)
         self.register('data/report', self.page_report)
         self.register('style.css', self.page_style_css)
@@ -1226,6 +1227,63 @@
             data.append('\n')
         return BinaryResult(''.join(data),'application/octet-stream')
 
+    def page_yaml(self, path, params, url):
+        data = []
+        old_pkg = ''
+        releases = ('sid', 'jessie', 'wheezy', 'squeeze')
+        for (pkg, bug, desc, debianbug, release, subrelease, version, status, urgency, remote, nodsa) in self.db.cursor().execute(
+                """SELECT sp.name, st.bug_name, bugs.description,
+                (SELECT debian_cve.bug FROM debian_cve
+                WHERE debian_cve.bug_name = st.bug_name
+                ORDER BY debian_cve.bug),
+                sp.release, sp.subrelease, sp.version, st.vulnerable, st.urgency,
+                (SELECT range_remote FROM nvd_data
+                WHERE cve_name = st.bug_name),
+                (SELECT comment FROM package_notes_nodsa AS nd
+                WHERE nd.package = sp.name AND nd.release = sp.release
+                AND nd.bug_name = st.bug_name) AS nodsa
+                FROM source_package_status AS st, source_packages AS sp, bugs
+                WHERE sp.rowid = st.package AND st.bug_name = bugs.name
+                AND ( sp.release = ? OR sp.release = ? OR sp.release = ?
+                OR sp.release = ? )
+                ORDER BY sp.name, st.bug_name, sp.release, sp.subrelease""" , releases):
+
+            if old_pkg != pkg:
+                old_pkg = pkg
+                old_bug = ''
+                data.append(pkg+':\n')
+            if old_bug != bug:
+                old_bug = bug
+                data.append('  '+bug+':\n')
+                data.append('    description: '+desc+'\n')
+                if str(debianbug) != 'None':
+                    data.append('    bug: '+str(debianbug)+'\n')
+                data.append('    releases: \n')
+
+            if subrelease == '':
+                my_release = release
+            else:
+                my_release = release+'-'+subrelease
+
+            data.append('      '+my_release+':\n')
+            data.append('        version: '+version+'\n')
+            if status > 0:
+                # 1 = vulnerable, 2 = undetermined
+                data.append('        status: open\n')
+            else:
+                data.append('        status: resolved\n')
+            data.append('        urgency: '+urgency+'\n')
+            if str(remote) == 'None':
+                data.append('        range: no data\n')
+            elif remote == 1:
+                data.append('        range: remote\n')
+            else:
+                data.append('        range: local\n')
+            if str(nodsa) != 'None':
+                data.append('        nodsa: '+nodsa+'\n')
+
+        return BinaryResult(''.join(data),'application/octet-stream')
+
     def page_debsecan(self, path, params, url):
         obj = '/'.join(path)
         data = self.db.getDebsecan(obj)

Modified: lib/python/security_db.py
===================================================================
--- lib/python/security_db.py	2015-02-26 15:41:14 UTC (rev 32508)
+++ lib/python/security_db.py	2015-02-26 15:49:43 UTC (rev 32509)
@@ -392,6 +392,14 @@
                 ORDER BY sp.name, urgency_to_number(urgency), st.bug_name"""
                 % (name, nickname, nickname, nickname))
 
+        cursor.execute(
+            """CREATE TEMPORARY VIEW debian_cve AS
+            SELECT DISTINCT debian_bugs.bug, st.bug_name
+            FROM package_notes, debian_bugs, source_package_status AS st
+            WHERE package_notes.bug_name = st.bug_name
+            AND debian_bugs.note = package_notes.id
+            ORDER BY debian_bugs.bug""")
+
     def _initFunctions(self):
         """Registers user-defined SQLite functions."""
 




More information about the Secure-testing-commits mailing list