Merge lp:~pkern/ubuntu-cve-tracker/master into lp:~ubuntu-security/ubuntu-cve-tracker/master

Proposed by Philipp Kern
Status: Rejected
Rejected by: Jamie Strandboge
Proposed branch: lp:~pkern/ubuntu-cve-tracker/master
Merge into: lp:~ubuntu-security/ubuntu-cve-tracker/master
Diff against target: 41 lines (+13/-2)
1 file modified
scripts/convert-pickle.py (+13/-2)
To merge this branch: bzr merge lp:~pkern/ubuntu-cve-tracker/master
Reviewer Review Type Date Requested Status
Marc Deslauriers Pending
Review via email: mp+233670@code.launchpad.net

Description of the change

The JSON USN database is huge and can benefit a lot from compression. It does not look like it already serves a compressed copy. Furthermore the cron parts are missing in the source, hence I simply patched the pickle to JSON converter.

To post a comment you must log in.
Revision history for this message
Philipp Kern (pkern) wrote :

FWIW, for instance Cloud services like AppEngine can only download 32 MiB per chunk over HTTP, hence this proposal.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

We already offer compressed (bz2) alongside the uncompressed files.

From IRC:
07:37 < jdstrand> mdeslaur, and pkern: so, there are already bz2 files created:
                  cd $UCT/scripts/fetch-db database.pickle.bz2
07:37 < jdstrand> ...
07:38 < jdstrand> = Fetching database.pickle.bz2 =
07:38 < jdstrand> --2014-09-10 07:37:36--
                  https://usn.ubuntu.com/usn-db/database.pickle.bz2
07:38 < jdstrand> ...
07:38 < jdstrand> = Fetching database.pickle.bz2.sha256 =
07:38 < jdstrand> --2014-09-10 07:37:49--
                  https://usn.ubuntu.com/usn-db/database.pickle.bz2.sha256
07:38 < jdstrand> ...
07:38 < jdstrand> = Verifiying database.pickle.bz2.sha256 =
07:38 < jdstrand> ./database.pickle.bz2: OK
07:38 < jdstrand> = Uncompressing database.pickle.bz2 =
07:38 < jdstrand> Download complete. File saved to 'database.pickle'
07:38 < jdstrand> so that is the pickle file
07:38 < jdstrand> but the json is there too
07:38 < jdstrand> $ $UCT/scripts/fetch-db database.json.bz2
07:38 < jdstrand> = Fetching database.json.bz2 =
07:38 < jdstrand> --2014-09-10 07:38:47--
                  https://usn.ubuntu.com/usn-db/database.json.bz2
07:38 < jdstrand> ...
07:39 < jdstrand> = Fetching database.json.bz2.sha256 =
07:39 < jdstrand> --2014-09-10 07:38:55--
                  https://usn.ubuntu.com/usn-db/database.json.bz2.sha256
07:39 < jdstrand> ...
07:39 < jdstrand> = Verifiying database.json.bz2.sha256 =
07:39 < jdstrand> ./database.json.bz2: OK
07:39 < jdstrand> = Uncompressing database.json.bz2 =
07:39 < jdstrand> Download complete. File saved to 'database.json'

Unmerged revisions

8455. By pkern <pkern@localhost>

Save the JSON database gzip'ed as well, which makes for much smaller files.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'scripts/convert-pickle.py'
--- scripts/convert-pickle.py 2012-04-26 21:27:31 +0000
+++ scripts/convert-pickle.py 2014-09-08 07:37:44 +0000
@@ -9,16 +9,28 @@
99
10import codecs10import codecs
11import cPickle11import cPickle
12import cStringIO
13import gzip
12import json14import json
13import optparse15import optparse
14import os16import os
17import shutil
15import sys18import sys
1619
17# TODO: move these to usn_lib.py20# TODO: move these to usn_lib.py
18def save_database_json(database, db_filename):21def save_database_json(database, db_filename):
19 '''Save usn database'''22 '''Save usn database'''
20 filename = os.path.expanduser(db_filename)23 filename = os.path.expanduser(db_filename)
21 json.dump(database, open(filename, 'w'), -1, encoding="utf-8")24 buf = cStringIO.StringIO()
25 json.dump(database, buf, -1, encoding="utf-8")
26 buf.seek(0)
27 print >>sys.stderr, "INFO: Saving %s..." % (filename)
28 with open(filename, 'w') as outf:
29 shutil.copyfileobj(buf, outf)
30 buf.seek(0)
31 print >>sys.stderr, "INFO: Saving %s..." % (filename + '.gz')
32 with gzip.GzipFile(filename + '.gz', 'w') as outf:
33 shutil.copyfileobj(buf, outf)
2234
23def convert_pickle_to_json(indb, outdb):35def convert_pickle_to_json(indb, outdb):
24 '''Convert a pickle database into a json'''36 '''Convert a pickle database into a json'''
@@ -47,7 +59,6 @@
47 if count > 0:59 if count > 0:
48 print >>sys.stderr, "WARN: performed %d pickle decode conversions" % count60 print >>sys.stderr, "WARN: performed %d pickle decode conversions" % count
4961
50 print >>sys.stderr, "INFO: Saving %s..." % (outdb)
51 save_database_json(new_db, outdb)62 save_database_json(new_db, outdb)
5263
53#64#