2
# Copyright 2008-2009 Canonical, Ltd.
3
# Author: Jamie Strandboge <jamie@canonical.com>
7
import sys, os, os.path, re, urllib, tempfile
11
from launchpadlib.launchpad import Launchpad, EDGE_SERVICE_ROOT
12
from launchpadlib.credentials import Credentials
13
from launchpadlib.errors import HTTPError
15
print "DEPRECATED: please use:"
16
print "$ report-todo-sponsoring --status 'In Progress' --team ubuntu-security --has-patch"
19
# Stolen from lpl_common.py from ubuntu-qa-tools
21
cachedir = os.path.expanduser('~/.launchpadlib/cache')
22
if not os.path.exists(cachedir):
23
os.makedirs(cachedir,0700)
25
credfile = os.path.expanduser('~/.launchpadlib/credentials')
27
credentials = Credentials()
28
credentials.load(open(credfile))
29
launchpad = Launchpad(credentials, EDGE_SERVICE_ROOT, cachedir)
31
launchpad = Launchpad.get_token_and_login(sys.argv[0], EDGE_SERVICE_ROOT, cachedir)
32
credfd = tempfile.NamedTemporaryFile(dir=os.path.dirname(credfile))
33
launchpad.credentials.save(credfd)
34
os.link(credfd.name, credfile)
40
parser = optparse.OptionParser()
41
parser.add_option("-u", "--update", dest="update", help="Update CVEs with released package versions", action='store_true')
42
parser.add_option("-v", "--verbose", dest="verbose", help="Report logic while processing USNs", action='store_true')
43
parser.add_option("-a", "--any", dest="any", help="Show any bugs with status NEW, CONFIRMED, TRIAGED, INPROGRESS, FIXCOMMITTED with a patch attached", action='store_true')
44
(opt, args) = parser.parse_args()
50
cves.append("CVE-" + c.sequence)
55
# This should be api-ified
56
# Need to figure out a way to get a list of bugs via an API query
58
from launchpadbugs.connector import ConnectBugList
59
BugList = ConnectBugList()
61
BugList.authentication = cve_lib.config["plb_authentication"]
63
url="https://bugs.launchpad.net/~ubuntu-security/+bugs?field.searchtext=&orderby=-importance&field.status%3Alist=INPROGRESS&assignee_option=any&field.assignee=&field.bug_reporter=&field.bug_supervisor=&field.bug_commenter=&field.subscriber=&field.status_upstream-empty-marker=1&field.omit_dupes.used=&field.has_patch.used=&field.has_patch=on&field.has_cve.used=&field.tag=&field.tags_combinator=ANY&search=Search"
65
url="https://bugs.launchpad.net/~ubuntu-security/+bugs?field.searchtext=&orderby=-importance&field.status%3Alist=NEW&field.status%3Alist=CONFIRMED&field.status%3Alist=TRIAGED&field.status%3Alist=INPROGRESS&field.status%3Alist=FIXCOMMITTED&assignee_option=any&field.assignee=&field.bug_reporter=&field.bug_supervisor=&field.bug_commenter=&field.subscriber=ubuntu-security&field.status_upstream-empty-marker=1&field.omit_dupes.used=&field.omit_dupes=on&field.has_patch.used=&field.has_patch=on&field.has_cve.used=&field.tag=&field.tags_combinator=ANY&search=Search"
67
# end should be api-ified section
70
for info in BugList(url):
74
bug_url = "http://launchpad.net/bugs/%s" % (num)
75
bug_cves = get_cves(bug)
77
#print "Checking: %s" % (num)
78
for task in bug.bug_tasks:
79
#if task.status != "In Progress":
82
if not ' (' in task.bug_target_name:
83
#print "Skipping target name=%s" % (task.bug_target_name)
85
pkg, target = task.bug_target_name.split(' (',1)
86
target = target.split(')')[0]
88
target, targeted_to = target.split(' ',1)
90
if target and target.lower() != 'ubuntu':
91
#print 'skipping target "%s" (%s)' % (target, pkg)
93
if task.status in ['Fix Released', 'Invalid', "Won't Fix"]:
94
#print 'skipping (pkg:%s status:%s)' % (pkg, task.status)
97
if not re.match(r'^[a-z0-9][a-z0-9+\.\-]+$', pkg):
98
print >>sys.stderr, "Bad package name '%s'" % (pkg)
102
for a in bug.attachments:
103
if a.type.lower() == "patch":
108
print "%s:\n %s" % (pkg, bug_url)
110
print " %s" % (bug.title)
112
if len(bug_cves) > 0:
116
filename = "%s/%s" % (cve_lib.active_dir, c)
117
if opt.update and os.path.exists(filename):
118
cve_lib.add_patch(filename, pkg, bug_url, type)