2
# Author: Kees Cook <kees@ubuntu.com>
3
# Copyright (C) 2011 Canonical Ltd.
5
# Reports the version of the given package in the most recent USN for it
7
# Fetch the USN database first. Override location with --database
8
# wget http://people.canonical.com/~ubuntu-security/usn/database.pickle
10
from __future__ import print_function
16
from source_map import version_compare
17
from lp_lib import UCTLaunchpad
19
parser = optparse.OptionParser()
20
parser.add_option("-D", "--database", help="Specify location of USN data (default 'database.pickle')", default="database.pickle")
21
parser.add_option("-r", "--release", help="Specify comma-separated list of which release to limit the search to (default is all)")
22
parser.add_option("-d", "--debug", dest="debug", help="Report additional debugging while processing", action='store_true')
23
parser.add_option("-g", "--use-glitchdb", dest="use_glitches", help="use kernel version glitchdb as fallback for last USN", action='store_true', default=False)
24
(opt, args) = parser.parse_args()
26
uctlp = UCTLaunchpad(opt)
30
releases = opt.release.split(',')
32
releases = [r for r in cve_lib.releases if cve_lib.is_active_release(r)]
34
usndb = usn_lib.USNdb(args, opt.database, releases, opt)
37
usns = usndb.get_usns(pkg, rel)
38
# if there are no usns reported for this package, then report
39
# the earliest version in this release. Usually this script is
40
# used to report pending cves between the last USN and what was
44
print('Could not find published USN, reporting earliest publication for %s/%s' % (pkg, rel), file=sys.stderr)
47
print('Looking up glitch version for %s/%s' % (pkg, rel), file=sys.stderr)
48
version = cve_lib.lookup_glitch_version(pkg, rel, '~')
52
print(uctlp.get_earliest_version(rel, pkg))
54
print(uctlp.get_earliest_version(rel, pkg))